mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-08-18 00:58:08 +00:00
fix(web): compare zones on fields Intl has always had
dateStyle/timeStyle are late additions to Intl -- Firefox shipped them in 91 -- and an implementation that does not know them ignores them and formats the date alone. The comparison would then read New York, Chicago and Madrid as the same zone and tick the step for a timezone that is plainly wrong, which is the failure the check exists to catch. Silent, and only on older browsers. Explicit numeric fields (year/month/day/hour/minute) have been in Intl since ECMA-402 v1, so there is nothing left to degrade to. The options look like a stylistic choice, so a test pins them: it reads the comparison with comments stripped -- the comment names dateStyle to explain why it is not used -- and fails if either style option comes back or a time field is dropped. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01STMbQE4YctTacQXfbYqKuW
This commit is contained in:
co-authored by
Claude Opus 5
parent
2f64dbc48c
commit
dcba6120f9
@@ -191,8 +191,18 @@
|
||||
try {
|
||||
var now = new Date();
|
||||
var stamp = function (tz) {
|
||||
// Explicit numeric fields rather than dateStyle/timeStyle:
|
||||
// those are late additions to Intl (Firefox shipped them in
|
||||
// 91), and an implementation that does not know them ignores
|
||||
// them and formats the date alone. That would compare
|
||||
// New York, Chicago and Madrid as equal and tick the step for
|
||||
// a timezone that is plainly wrong -- the exact failure this
|
||||
// check exists to catch. These options have been in Intl
|
||||
// since ECMA-402 v1.
|
||||
return new Intl.DateTimeFormat('en-US', {
|
||||
timeZone: tz, dateStyle: 'short', timeStyle: 'short'
|
||||
timeZone: tz, year: 'numeric', month: '2-digit',
|
||||
day: '2-digit', hour: '2-digit', minute: '2-digit',
|
||||
hour12: false
|
||||
}).format(now);
|
||||
};
|
||||
return stamp(a) === stamp(b);
|
||||
|
||||
Reference in New Issue
Block a user