moment / luxon

⏱ A library for working with dates and times in JS
https://moment.github.io/luxon
MIT License
15.23k stars 730 forks source link

DateTime.local().offset command returning Eastern Daylight Savings. How to fetch EST instead? #1461

Closed calicoder77 closed 1 year ago

calicoder77 commented 1 year ago

Good day,

First off incredible work on the project so far. I have a command like this:

DateTime.local().offset

and it returns the daylight savings time I'm in currently. I would like to use Zulu time (UTC) but don't see any docs on how to actually do that. My ultimate goal is to be able to get the proper UTC + or - for my area without the DST. Is this possible? How exactly would I go about doing this?

Thanks

diesieben07 commented 1 year ago

Unfortunately there is no straightforward way to do this, because the Intl API does not expose this information. However you can get close by "probing". Use a resource like this table to find a suitable date and then move your local date to a position on the timeline that would be outside DST in all zones (or all zones you care about). Then use that DateTime's offset.

calicoder77 commented 1 year ago

Hi @diesieben07,

Thanks for the quick reply. Guess I can live with the DST being on every so often.