blakeblackshear.frigate/web/src/utils/dateUtil.ts

17 lines
591 B
TypeScript
Raw Normal View History

2022-02-27 15:04:12 +01:00
export const longToDate = (long: number): Date => new Date(long * 1000);
export const epochToLong = (date: number): number => date / 1000;
export const dateToLong = (date: Date): number => epochToLong(date.getTime());
const getDateTimeYesterday = (dateTime: Date): Date => {
const twentyFourHoursInMilliseconds = 24 * 60 * 60 * 1000;
return new Date(dateTime.getTime() - twentyFourHoursInMilliseconds);
}
const getNowYesterday = (): Date => {
return getDateTimeYesterday(new Date());
}
export const getNowYesterdayInLong = (): number => {
return dateToLong(getNowYesterday());
};