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

Closed
robertjlooby opened this Issue Jan 17, 2016 · 6 comments

Comments

Projects
None yet
6 participants
@robertjlooby
Contributor

robertjlooby commented Jan 17, 2016

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

@jvoigtlaender

This comment has been minimized.

Show comment
Hide comment
@jvoigtlaender

jvoigtlaender Jan 19, 2016

Contributor

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 core here (in light of this: https://github.com/elm-lang/core/blob/master/CONTRIBUTING.md#adding-new-functions).

Contributor

jvoigtlaender commented Jan 19, 2016

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 core here (in light of this: https://github.com/elm-lang/core/blob/master/CONTRIBUTING.md#adding-new-functions).

@robertjlooby

This comment has been minimized.

Show comment
Hide comment
@robertjlooby

robertjlooby Jan 19, 2016

Contributor

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 Date.day will return for a given Date.Date. Seems like something that is necessary in the Date package, not just a convenience.

Contributor

robertjlooby commented Jan 19, 2016

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 Date.day will return for a given Date.Date. Seems like something that is necessary in the Date package, not just a convenience.

@jweir

This comment has been minimized.

Show comment
Hide comment
@jweir

jweir Apr 9, 2016

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

jweir commented Apr 9, 2016

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

@eeue56

This comment has been minimized.

Show comment
Hide comment
@eeue56

eeue56 Jul 20, 2016

Contributor

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.

Contributor

eeue56 commented Jul 20, 2016

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.

@zweizeichen

This comment has been minimized.

Show comment
Hide comment
@zweizeichen

zweizeichen Jul 30, 2016

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.

zweizeichen commented Jul 30, 2016

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.

@evancz

This comment has been minimized.

Show comment
Hide comment
@evancz

evancz Sep 22, 2016

Member

Getting UTC times was first mentioned in elm/compiler#705 and is tracked in #322. Let's track there.

Member

evancz commented Sep 22, 2016

Getting UTC times was first mentioned in elm/compiler#705 and is tracked in #322. Let's track there.

@evancz evancz closed this Sep 22, 2016

@evancz evancz referenced this issue Sep 22, 2016

Open

API Ideas #322

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment