Closed presentoccupant closed 1 month ago
Expr
should just have a key/value store with things like TimeZone
. Then Expr.get
and Expr.set
could access them.
It looks like time zones are pretty much impossible to deal with is standard JS. There are libraries that purport to Do The Right Thing, but I don't know if we can use them in GAS.
This was rather scary, but it looks like GAS is now JS compliant (instead of Excel compliant, which is what that 1899 business is all about...)
Maybe the best we can do here is make_timestamp
and make_timestamptz
The former would use UTC and the latter would use a specific time zone setting by default.
One way to skin this would be to use Date
string parser and feed it ISO times with offsets:
const actual = new Date('2022-08-31 08:59:51 -0700');
const expected = new Date(Date.UTC(2022, 7, 31, 15, 59, 51));
expect(actual).to.deep.equal(expected);
Unfortunately, this relies on Date.parse
, which is known to be inconsistent across browsers.
Wow Apps Script support for dates is so bad people suggest writing your own parser! Easy enough with a RegExp
but DST is still an issue without a library.
(in my case, Pacific)