-
Notifications
You must be signed in to change notification settings - Fork 359
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Date missing UTC getters #486
Comments
Is this maybe addressed by some functionality in http://package.elm-lang.org/packages/rluiten/elm-date-extra/latest/? Even if not, it probably makes more sense to target that package with a feature request than |
It looks like elm-date-extra can format a date in UTC by hacking the date based on timezone, but still doesn't handle the case I'm describing. The functionality could go there first, but it seems like a definite hole in the API that it is impossible to know what |
See https://github.com/jweir/elm-iso8601 for a date library that is working to solve this problem. This branch is probably the next release https://github.com/jweir/elm-iso8601/tree/dev/return-Result |
FWIW the function here needs to be native. It probably needs to be getTimezoneOffset. This is a function that shouldn't/can't be recreated in Elm, as it is a wrapper around an OS's time functions. See here for more reading. |
Thank you for bringing this up, IMHO the core Date module is in dire need of this expansion. That by no way means the need for adding expansive timezone support (that would probably be a huge timesink -hehe, I would leave that to 3rd party libs for now). Just some functions for dealing with UTC timestamps (UNIX/ISO8601) would certainly be a nice addition to the core lib as e.g. most backends you'll be getting data from will be using UTC timestamps. |
Getting UTC times was first mentioned in elm/compiler#705 and is tracked in #322. Let's track there. |
There is currently no way to reliably display a given date rather than a localized datetime. For example if I want to say an event is on 1/1/2016, I can use
Date.fromString "2016-01-01
which will parse to the datetime"Fri, 01 Jan 2016 00:00:00 GMT"
. But the only way to get the details out of it (Date.year/month/day
) return in the user's locale. Depending on the user's locale this date could be "2016-01-01" or "2015-12-31".The text was updated successfully, but these errors were encountered: