hawkfish / olapscript

An OLAP engine for Google App Script
MIT License
3 stars 1 forks source link

please provide a way to configure up front so timezone defaults to <desired time zone> #63

Closed presentoccupant closed 1 month ago

presentoccupant commented 2 years ago

(in my case, Pacific)

hawkfish commented 2 years ago

Expr should just have a key/value store with things like TimeZone. Then Expr.get and Expr.set could access them.

hawkfish commented 2 years ago

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.

hawkfish commented 2 years ago

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...)

hawkfish commented 2 years ago

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.

hawkfish commented 2 years ago

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.

hawkfish commented 2 years ago

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.