Start to build relay dialog

This commit is contained in:
2024-07-29 22:11:13 +02:00
parent 73163e6e69
commit 8a65687970
11 changed files with 518 additions and 48 deletions

View File

@ -1,6 +1,29 @@
import dayjs, { Dayjs } from "dayjs";
/**
* Get current UNIX time, in seconds
*/
export function time(): number {
return Math.floor(new Date().getTime() / 1000);
}
/**
* Get dayjs representation of given time of day
*/
export function timeOfDay(time: number): Dayjs {
const hours = Math.floor(time / 3600);
const minutes = Math.floor(time / 60) - hours * 60;
return dayjs(
`2022-04-17T${hours.toString().padStart(2, "0")}:${minutes
.toString()
.padStart(2, "0")}`
);
}
/**
* Get time of day (in secs) from a given dayjs representation
*/
export function dayjsToTimeOfDay(d: Dayjs): number {
return d.hour() * 3600 + d.minute() * 60 + d.second();
}