Re:Dates and Times in JavaScript – A New API for Dates from ...
by himinlomax on Thursday July 09, 2020 @03:42PM
(#23784217)
Will it allow for using TAI?
[ Parent
| on HN ]
Re:Dates and Times in JavaScript – A New API for Dates from ...
by ryzokuken on Thursday July 09, 2020 @04:54PM
(#23785083)
Not the core API, but a simple custom timezone can be used to implement TAI. I worked on a POC for it, but you can totally test this with the polyfill right now.
Re:Dates and Times in JavaScript – A New API for Dates from ...
by deathanatos on Thursday July 09, 2020 @07:14PM
(#23786372)
Kind of, but not really? The proposal's Absolute represents time in the POSIX timescale, so it is inherently incapable of representing all of TAI, the same as it is inherently incapable of representing UTC.
I attempted to test your library's behavior in this regard, but I do not think you are correctly implementing the proposal's TimeZone. TimeZone.getDateTimeFor() is supposed to take an Absolute and return, in your case, the time that absolute represents in TAI (that time, in the TimeZone). But this:
var one_before = new Temporal.Absolute(915148799n * 1000000000n);
console.log(one_before.toString());
console.log((new Temporal.TimeZone('UTC')).getDateTimeFor(one_before).toString());
console.log((new TAI()).getDateTimeFor(one_before).toString());
emits, 1998-12-31T23:59:59Z
1998-12-31T23:59:59
1970-01-01T00:15:15.148768
That last timestamp being the output supposedly in TAI; but that POSIX timestamp, 915148799 represents 1999-01-01T00:00:30 in TAI. That is, the second line, 1998-12-31T23:59:59 in UTC == 1999-01-01T00:00:30 TAI.The other direction (getPossibleAbsolutes) is similarly effected.