// 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 = '261121A'; 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); }