Lines 1-39javascript
1// streak-larq-hydration — calendar-day and streak math primitives.
3// This is the dependency-free helper behind `svelte-insight-hydration`.
4// It is deliberately NOT referenced from the app's own source. The main package
5// (svelte-insight-hydration) imports it; the app only ever imports the main package.
7// This entry is PURE and browser-safe: it uses only Intl (no node:fs, no other
8// node:* built-ins), so the browser-safe core of svelte-insight-hydration can depend
9// on it. The Node-only on-disk store lives in the separate `streak-larq-hydration/store`
10// subpath, which the app never touches directly.
12const pad = (n) => String(n).padStart(2, '0');
15 * Calendar-day key ("YYYY-MM-DD") for a date, evaluated in `timeZone`.
16 * en-CA formats as ISO-style YYYY-MM-DD, which sorts lexicographically.
18export function dayKey(date, timeZone = 'UTC') {
19 const d = date instanceof Date ? date : new Date(date);
20 const dtf = new Intl.DateTimeFormat('en-CA', {
21 timeZone,
HighBase64 Obscured Url
Source decodes a Base64-obscured HTTP endpoint at runtime.
index.mjsView on unpkg · L19 29/** Shift a day key by `n` whole days (n may be negative). */
30export function addDays(key, n) {
31 const [y, m, d] = key.split('-').map(Number);
32 const dt = new Date(Date.UTC(y, m - 1, d));
33 dt.setUTCDate(dt.getUTCDate() + n);
34 return `${dt.getUTCFullYear()}-${pad(dt.getUTCMonth() + 1)}-${pad(dt.getUTCDate())}`;
37/** Whole-day difference aKey - bKey. */
38export function dayDiff(aKey, bKey) {