luxon
luxon copied to clipboard
DateTime.now() with timezone parameter
Is your feature request related to a problem? Please describe.
We often work with specific timezones, and need to create DateTime instances in a specific timezone.
As far as I understand, the only way to currently do that would be something like: DateTime.now().setZone(zone)
However, this is inefficient as it always requires an extra call to setZone()
and always causes a redundant instance of DateTime to be created in local time only to be thrown away right after.
Describe the solution you'd like
Ideally, I'd like to see something like DateTime.now(zone)
, e.g. allowing you to pass in a zone parameter into the now()
method.
Describe alternatives you've considered
AFAIK the only current alternative is simply DateTime.now().setZone(zone)
If it's a perf thing, this does it in one go:
const zone = "Europe/London"
DateTime.fromObject({zone})
Since that's not a very obvious API, I think we can consider adding this option to now
into 2.0, which reconsiders how to use options like zone
(I don't want to add it now and then just have to change it in 2.0).
Happy for it to go into 2.0. What's the current timeline on that, or is that still far off?
@icambron Is there any information (milestones, blog posts, etc) about 2.0? I'm curious what the major changes will be.