MCPcopy Create free account
hub / github.com/dailydotdev/apps / getIsoWeekNumber

Function getIsoWeekNumber

packages/shared/src/lib/picks.ts:7–15  ·  view source on GitHub ↗
(date: string)

Source from the content-addressed store, hash-verified

5 * never shifts with the viewer's timezone.
6 */
7export const getIsoWeekNumber = (date: string): number => {
8 const [year, month, day] = date.split('-').map(Number);
9 const target = new Date(Date.UTC(year, month - 1, day));
10 // The week belongs to the year of its Thursday.
11 target.setUTCDate(target.getUTCDate() + 4 - (target.getUTCDay() || 7));
12 const yearStart = Date.UTC(target.getUTCFullYear(), 0, 1);
13
14 return Math.ceil(((target.getTime() - yearStart) / DAY_MS + 1) / 7);
15};
16
17/** This ISO week's Monday as YYYY-MM-DD in UTC, the way the API keys picks. */
18export const getCurrentWeekStart = (now: Date = new Date()): string => {

Callers 3

picks.spec.tsFile · 0.90
getServerSidePropsFunction · 0.90
PicksPageFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected