Files
final-wishes/src/version.js
Eric Bell 14a46abc63 Stop showing the word "null" above the menu (Fixes #26)
render() passed null to root.append(), which prints it as text. Only append
the reset banner when there is one.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-24 14:20:18 -05:00

26 lines
1.1 KiB
JavaScript

// The version of the app code, shown at the top of the page: "Ver YYMMDDX".
// YYMMDD is the date, X the iteration that day (A first, B second, ...).
// Bump with `npm run bump` (see bump-version.js). build.js strips `export`.
export const APP_VERSION = '261124G';
const VERSION_RE = /^(\d{6})([A-Z])$/;
export const isVersion = (v) => typeof v === 'string' && VERSION_RE.test(v);
// YYMMDD for a Date, in local time.
export function versionDate(date) {
const p = (n) => String(n).padStart(2, '0');
return p(date.getFullYear() % 100) + p(date.getMonth() + 1) + p(date.getDate());
}
// The version that follows `current` when released on `date`: the next letter
// on the same day, or A on a new day.
export function nextVersion(current, date) {
if (!isVersion(current)) throw new Error('Not a version: ' + current);
const day = versionDate(date);
if (!current.startsWith(day)) return day + 'A';
const letter = current[6];
if (letter === 'Z') throw new Error('Already 26 versions on ' + day + '; wait until tomorrow.');
return day + String.fromCharCode(letter.charCodeAt(0) + 1);
}