mirror of
https://github.com/bknd-io/bknd/
synced 2026-08-02 08:06:00 +00:00
4e718a063d
Removed various commented-out code and replaced direct `console.log` and `console.warn` usage across the codebase with `$console` from "core" for standardized logging. Also adjusted linting rules in biome.json to enable warnings for `console.log` usage.
31 lines
808 B
TypeScript
31 lines
808 B
TypeScript
import dayjs from "dayjs";
|
|
import weekOfYear from "dayjs/plugin/weekOfYear.js";
|
|
|
|
declare module "dayjs" {
|
|
interface Dayjs {
|
|
week(): number;
|
|
week(value: number): dayjs.Dayjs;
|
|
}
|
|
}
|
|
|
|
dayjs.extend(weekOfYear);
|
|
|
|
export function datetimeStringLocal(dateOrString?: string | Date | undefined): string {
|
|
return dayjs(dateOrString).format("YYYY-MM-DD HH:mm:ss");
|
|
}
|
|
|
|
export function datetimeStringUTC(dateOrString?: string | Date | undefined): string {
|
|
const date = dateOrString ? new Date(dateOrString) : new Date();
|
|
return date.toISOString().replace("T", " ").split(".")[0]!;
|
|
}
|
|
|
|
export function getTimezoneOffset(): number {
|
|
return new Date().getTimezoneOffset();
|
|
}
|
|
|
|
export function getTimezone(): string {
|
|
return Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
}
|
|
|
|
export { dayjs };
|