-
Notifications
You must be signed in to change notification settings - Fork 17
Open
Description
I'm writing a library based on this new time api: https://github.com/AdrianRibao/elm-derberos-date
So far it's ok and all tests pass (101 at the moment) but I still haven't introduced the zones in the functions. To do that, I need to adjust the posix time. I was going to copy the code from this library:
-- HELPERS FROM elm/time
-- Some of these functions are useful for this library, but are not exposed in elm/time
-- so they have been copied here.
-- Original code: https://github.com/elm/time/blob/1.0.0/src/Time.elm
-- Copyright (c) 2018-present, Evan Czaplicki
toAdjustedMinutes : Zone -> Posix -> Int
toAdjustedMinutes (Zone defaultOffset eras) time =
toAdjustedMinutesHelp defaultOffset (flooredDiv (posixToMillis time) 60000) eras
toAdjustedMinutesHelp : Int -> Int -> List Era -> Int
toAdjustedMinutesHelp defaultOffset posixMinutes eras =
case eras of
[] ->
posixMinutes + defaultOffset
era :: olderEras ->
if era.start < posixMinutes then
posixMinutes + era.offset
else
toAdjustedMinutesHelp defaultOffset posixMinutes olderEras
flooredDiv : Int -> Float -> Int
flooredDiv numerator denominator =
floor (toFloat numerator / denominator)
but I have two problems:
Erais not exposed in the module- I can't pattern match
toAdjustedMinutes (Zone defaultOffset eras) time =because I don't have aZoneconstructor
Is it possible to expose Era and a Zone so I don't have to copy them in the library?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels