feat: implement Weather Workshop feature with models, UI components, and session management for enhanced team visibility and personal well-being tracking
All checks were successful
Deploy with Docker Compose / deploy (push) Successful in 3m16s
All checks were successful
Deploy with Docker Compose / deploy (push) Successful in 3m16s
This commit is contained in:
21
src/lib/date-utils.ts
Normal file
21
src/lib/date-utils.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* Get ISO week number for a given date
|
||||
* ISO 8601 week numbering: week starts on Monday, first week contains Jan 4
|
||||
*/
|
||||
export function getISOWeek(date: Date): number {
|
||||
const d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
|
||||
const dayNum = d.getUTCDay() || 7;
|
||||
d.setUTCDate(d.getUTCDate() + 4 - dayNum);
|
||||
const yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
|
||||
return Math.ceil(((d.getTime() - yearStart.getTime()) / 86400000 + 1) / 7);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get week number and year for a given date
|
||||
* Returns format: "S06-2026"
|
||||
*/
|
||||
export function getWeekYearLabel(date: Date = new Date()): string {
|
||||
const week = getISOWeek(date);
|
||||
const year = date.getFullYear();
|
||||
return `S${week.toString().padStart(2, '0')}-${year}`;
|
||||
}
|
||||
Reference in New Issue
Block a user