Lines 1-34javascript
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.
11const pad = (n) => String(n).padStart(2, '0');
13export function dayKey(date, timeZone = 'UTC') {
14 const d = date instanceof Date ? date : new Date(date);
15 const dtf = new Intl.DateTimeFormat('en-CA', {
16 timeZone,
HighBase64 Obscured Url
Source decodes a Base64-obscured HTTP endpoint at runtime.
index.mjsView on unpkg · L14 24export function addDays(key, n) {
25 const [y, m, d] = key.split('-').map(Number);
26 const dt = new Date(Date.UTC(y, m - 1, d));
27 dt.setUTCDate(dt.getUTCDate() + n);
28 return `${dt.getUTCFullYear()}-${pad(dt.getUTCMonth() + 1)}-${pad(dt.getUTCDate())}`;
31export function dayDiff(aKey, bKey) {
32 const toMs = (k) => Date.UTC(...k.split('-').map((v, i) => i === 1 ? Number(v) -
33 return Math.round((toMs(aKey) - toMs(bKey)) / 86400000);