Files
bknd/app/src/core/utils/dates.ts
T
dswbx 4e718a063d cleanup: replace console.log/warn with $console, remove commented-out code
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.
2025-04-10 14:18:48 +02:00

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 };