mirror of
https://github.com/fergalmoran/radio-otherway.git
synced 2026-01-03 07:36:10 +00:00
21 lines
750 B
TypeScript
21 lines
750 B
TypeScript
const getMonthName = (date: Date) => {
|
|
return date.toLocaleString("default", { month: "short" });
|
|
};
|
|
const getTime = (date: Date) =>
|
|
date.toLocaleTimeString("en-IE", { timeStyle: "short" });
|
|
|
|
const getStartOfToday = (admin: any) => {
|
|
const now = new Date();
|
|
now.setHours(5, 0, 0, 0); // +5 hours for Eastern Time
|
|
const timestamp = admin.firestore.Timestamp.fromDate(now);
|
|
return timestamp; // ex. 1631246400
|
|
};
|
|
const dateDifferenceInSeconds = (date1: Date, date2: Date) =>
|
|
Math.abs((date1.getTime() - date2.getTime())) / 1000;
|
|
|
|
const addSeconds = (date: Date, seconds: number) => {
|
|
date.setSeconds(date.getSeconds() + seconds);
|
|
return date;
|
|
};
|
|
export { getMonthName, getTime, getStartOfToday, dateDifferenceInSeconds, addSeconds };
|