rtfeldman / elm-spa-example

A Single Page Application written in Elm
https://dev.to/rtfeldman/tour-of-an-open-source-elm-spa
MIT License
3.28k stars 530 forks source link

Timezone is set to UTC #60

Open andys8 opened 5 years ago

andys8 commented 5 years ago

Issue

The time zone is not read from the browser, but instead set to utc (edit: in the initializing phase).

https://github.com/rtfeldman/elm-spa-example/blob/b5064c6ef0fde3395a7299f238acf68f93e71d03/src/Page/Home.elm#L71

https://github.com/rtfeldman/elm-spa-example/blob/b5064c6ef0fde3395a7299f238acf68f93e71d03/src/Page/Profile.elm#L65

https://github.com/rtfeldman/elm-spa-example/blob/b5064c6ef0fde3395a7299f238acf68f93e71d03/src/Page/Article.elm#L68

See

https://package.elm-lang.org/packages/elm/time/latest/Time#here https://guide.elm-lang.org/effects/time.html

catz commented 5 years ago

Hello @andys8,

I guess it's totally ok because we run Task.perform GotTimeZone Time.here in init function and setup correct timezone then.

andys8 commented 5 years ago

I wouldn't go with "totally okay". If it is implemented in this way, then it's not that bad in practice, but there is one point in time where the state is not right.

"Making impossible states impossible" 😉 I know the checks are cumbersome, but we should go with Maybe a here.

Edit: I updated the initial issue text