Files
huncode 12562baeb5
Build and deploy / deploy (push) Successful in 2m39s
Implement ProgCode identity and real shared reading UI kit
2026-10-27 15:19:49 +03:00

26 lines
1.6 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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}));
}