add timesheets page

This commit is contained in:
Gregor Vostrak
2026-04-30 02:50:02 +02:00
parent 1cc000a584
commit 09af0f775f
28 changed files with 2424 additions and 147 deletions

View File

@@ -8,6 +8,20 @@ export function getWeekStart() {
}
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) {

View File

@@ -188,6 +188,15 @@ export function getLocalizedDateFromTimestamp(timestamp: string) {
return getLocalizedDayJs(timestamp).format('YYYY-MM-DD');
}
/**
* Converts a local Date to a UTC-formatted ISO string.
* Treats the Date as being in the user's timezone and converts to UTC.
* This is the inverse of getLocalizedDayJs (which goes UTC → local).
*/
export function localDateToUtc(date: dayjs.Dayjs): string {
return date.tz(getUserTimezone(), true).utc().format();
}
/*
* Returns a formatted date.
* @param date - date in the format of 'YYYY-MM-DD'