mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-10-11 15:23:17 +01:00
34 lines
833 B
TypeScript
34 lines
833 B
TypeScript
export function getWeekStart() {
|
|
const weekStart = window?.getWeekStartSetting() as string;
|
|
|
|
if (!weekStart) {
|
|
throw new Error(
|
|
'Please make sure to provide the current user week start setting as a vue inject (week_start)'
|
|
);
|
|
}
|
|
return weekStart;
|
|
}
|
|
|
|
const weekStartMap: Record<string, number> = {
|
|
sunday: 0,
|
|
monday: 1,
|
|
tuesday: 2,
|
|
wednesday: 3,
|
|
thursday: 4,
|
|
friday: 5,
|
|
saturday: 6,
|
|
};
|
|
|
|
export function getWeekStartDayNumber(): number {
|
|
return weekStartMap[getWeekStart()] ?? 1;
|
|
}
|
|
export function getUserTimezone() {
|
|
const timezone = window?.getTimezoneSetting() as string;
|
|
if (!timezone) {
|
|
throw new Error(
|
|
'Please make sure to provide the current user timezone as a vue inject (timezone)'
|
|
);
|
|
}
|
|
return timezone;
|
|
}
|