Preserve historical publication days across build timezones
Build and deploy / deploy (push) Successful in 5m24s

This commit is contained in:
huncode committed 2026-10-26 20:09:03 +03:00
1 parent 2d5a687fda
commit 0cb1ce1f15
6 files changed
+37 -5

No files matched your search

+25
View File
@@ -0,0 +1,25 @@
import assert from 'node:assert/strict';
import {execFileSync} from 'node:child_process';
import {fileURLToPath} from 'node:url';
import {formatDate} from '../lib/dates.mjs';
// Source <time> text, datetime and dated permalinks agree on these calendar days.
// These near-midnight UTC instants exposed the old host-timezone-dependent day shift.
const fixtures = [
{instant:'2019-01-12T21:54:18+00:00', long:'12 января 2019 г.', short:'12 янв. 2019 г.'},
{instant:'2017-08-25T21:37:08+00:00', long:'25 августа 2017 г.', short:'25 авг. 2017 г.'},
{instant:'2017-07-12T23:20:53+00:00', long:'12 июля 2017 г.', short:'12 июл. 2017 г.'},
];
if (process.argv.includes('--probe')) {
console.log(JSON.stringify({hostTimezone:new Intl.DateTimeFormat().resolvedOptions().timeZone,
dates:fixtures.map(({instant})=>({instant,long:formatDate(instant),short:formatDate(instant,{month:'short',day:'numeric'})}))}));
} else {
const expected=fixtures.map(({instant,long,short})=>({instant,long,short}));
const results=['UTC','Europe/Moscow'].map(TZ=>{
const result=JSON.parse(execFileSync(process.execPath,[fileURLToPath(import.meta.url),'--probe'],{env:{...process.env,TZ},encoding:'utf8'}));
assert.equal(result.hostTimezone,TZ,'Probe must actually use the requested host timezone');
assert.deepEqual(result.dates,expected,'Historical publication day must not shift with host/browser timezone');
return result;
});
console.log(JSON.stringify({historicalCalendar:'UTC',fixtures:fixtures.length,hostTimezones:results.map(r=>r.hostTimezone),passed:true}));
}