Closed McBen closed 3 years ago
Related: #458.
It makes sense to replace all our custom time/date routines with standard Intl.DateTimeFormat
.
E.g. see:
var options = {
hour: 'numeric', minute: 'numeric', second: 'numeric',
timeZone: 'Europe/London',
timeZoneName: 'short'
};
var o = Intl.DateTimeFormat('en-GB', options);
var before = new Date('March 28, 21 1:59:59 GMT+01:00');
var after = new Date(before.getTime()+1000); // 1 second later
console.log(o.format(before)); // 0:59:59 GMT
console.log(o.format(after)); // 2:00:00 BST
Or
console.log(before.toLocaleTimeString('en-GB', options)); // 0:59:59 GMT
console.log(after.toLocaleTimeString('en-GB', options)); // 2:00:00 BST
Wait a minute.. All can be even simpler:
var before = new Date('March 28, 21 1:59:59 GMT+01:00');
var after = new Date(before.getTime()+1000); // 1 second later
console.log(before.getHours());
console.log(after.getHours());
@johnd0e that us wrong. in europe we change on last sunday in March, while the US changes on second sunday in March. and back on last sunday in October (US first sunday in November Yes, that means we have several weeks of mix.
@MysticJay Does not matter, as browser will make the job according to your tz/locale
https://github.com/IITC-CE/ingress-intel-total-conversion/blob/3f4867a4a4ab5dd86d093fcaa9829f3267f70e9b/core/code/region_scoreboard.js#L124-L128
Here we skip daylight saving.
In a cycle which includes a clock-change the CP times (after clock-change) will be wrong.