Implement ProgCode identity and real shared reading UI kit
Build and deploy / deploy (push) Successful in 2m39s
Build and deploy / deploy (push) Successful in 2m39s
This commit is contained in:
1 parent
99c848189e
commit
12562baeb5
2040 files changed
+184656
-181
No files matched your search
@@ -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}));
|
||||
}
|
||||
Reference in new issue
Block a user