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