mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-21 19:07:46 +01:00
17 lines
591 B
TypeScript
17 lines
591 B
TypeScript
|
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());
|
||
|
};
|