MCPcopy Create free account
hub / github.com/ZenNotes/zennotes / isoWeekParts

Function isoWeekParts

packages/app-core/src/lib/template-render.ts:112–120  ·  view source on GitHub ↗
(date: Date)

Source from the content-addressed store, hash-verified

110}
111
112function isoWeekParts(date: Date): { week: number; year: number } {
113 // Shift to the Thursday of the current ISO week, working in UTC to avoid DST.
114 const d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()))
115 const dayNum = d.getUTCDay() || 7 // Sunday -> 7
116 d.setUTCDate(d.getUTCDate() + 4 - dayNum)
117 const yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1))
118 const week = Math.ceil(((d.getTime() - yearStart.getTime()) / 86_400_000 + 1) / 7)
119 return { week, year: d.getUTCFullYear() }
120}
121
122/** ISO 8601 week number (1-53) for the given date. */
123export function getISOWeek(date: Date): number {

Callers 2

getISOWeekFunction · 0.85
getISOWeekYearFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected