If an application needs time, the startup is not easy, because Tasks are used, there is no time and time zone available. I think starting with defaults like time 0 and utc is not correct, because it is not true. Having these values typed as Maybe will lead to complexity when handling with time other parts of the code, but should be the solution, that is necessary. There is also a workaround, to use Javascript and pass those values as flags.
I noticed the guide is starting with Model Time.utc (Time.millisToPosix 0). One could argument it’s to keep things simple.
To make this even worse, it is impossible to get current timezone in JavaScript (see note at Time.here).
But if I were to ignore that, and wanted to use the incorrect timezone returned by Time.here, then I think I’d do something like:
type Model
= Uninitialized
| Initialized InitializedModel
type alias InitializedModel =
{ time: Time.Posix
, timezone: Time.Zone
, ...
}
This way there are no Maybe:s, and only few top level functions needs to pattern match on Model, and will then pass inner InitializedModel to those lower level functions which are only used after initialization has been done.