MCPcopy Create free account
hub / github.com/codemix/graph / week

Method week

packages/graph/src/TemporalTypes.ts:98–108  ·  view source on GitHub ↗

* Get the ISO week number (1-53). * Uses the ISO 8601 definition where week 1 is the week containing January 4th.

()

Source from the content-addressed store, hash-verified

96 * Uses the ISO 8601 definition where week 1 is the week containing January 4th.
97 */
98 public get week(): number {
99 const date = new Date(Date.UTC(this.#year, this.#month - 1, this.#day));
100 // Set to nearest Thursday: current date + 4 - current day number (making Sunday=7)
101 const dayNum = date.getUTCDay() || 7;
102 date.setUTCDate(date.getUTCDate() + 4 - dayNum);
103 // Get first day of year
104 const yearStart = new Date(Date.UTC(date.getUTCFullYear(), 0, 1));
105 // Calculate full weeks between
106 const weekNo = Math.ceil(((date.getTime() - yearStart.getTime()) / 86400000 + 1) / 7);
107 return weekNo;
108 }
109
110 /**
111 * Get the day of week (1=Monday, 7=Sunday).

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected