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.fromString is NOT a pure function, result depends on local env #855

Closed
witoldsz opened this Issue Apr 22, 2017 · 3 comments

Comments

Projects
None yet
3 participants
@witoldsz

witoldsz commented Apr 22, 2017

The result below depends on your local time zone.

"2017-07-25T20:31:23.647Z"
    |> Date.fromString
    |> Result.map (Date.hour >> toString >> (++) "The hour is: ")
    |> Result.withDefault ""

What I see is:

The hour is: 22

Run this: https://runelm.io/c/2su

Functions in Elm are supposed to be pure, this one is not, because it calls new Date(…) which produces a date with a time zone of the local environment (system).

P.S.
Just to be clear: this is not about the ambiguous input. The Z stands for UTC (ISO8601).

@process-bot

This comment has been minimized.

Show comment
Hide comment
@process-bot

process-bot Apr 22, 2017

Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it!

Here is what to expect next, and if anyone wants to comment, keep these things in mind.

process-bot commented Apr 22, 2017

Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it!

Here is what to expect next, and if anyone wants to comment, keep these things in mind.

@witoldsz

This comment has been minimized.

Show comment
Hide comment
@witoldsz

witoldsz Apr 22, 2017

I can see the #816 does not address this particular issue.

witoldsz commented Apr 22, 2017

I can see the #816 does not address this particular issue.

@lukewestby lukewestby referenced this issue May 17, 2017

Closed

Date #816

2 of 7 tasks complete
@lukewestby

This comment has been minimized.

Show comment
Hide comment
@lukewestby

lukewestby May 17, 2017

Member

Added to #816, thank you!

Member

lukewestby commented May 17, 2017

Added to #816, thank you!

@lukewestby lukewestby closed this May 17, 2017

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