Skip to content

Commit

Permalink
reduce lines of code
Browse files Browse the repository at this point in the history
  • Loading branch information
imclerran committed Feb 1, 2024
1 parent e006bd5 commit 7ccd445
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions package/IsoToUtc.roc
Original file line number Diff line number Diff line change
Expand Up @@ -213,28 +213,23 @@ parseFractionalTime = \wholeBytes, fractionalBytes ->
when wholeBytes is
[_,_] -> # hh
when parseLocalTimeHour wholeBytes is
Ok time ->
frac * nanosPerHour |> Num.round |> fromNanosSinceMidnight |> addTimes time |> Ok
Ok time -> frac * nanosPerHour |> Num.round |> fromNanosSinceMidnight |> addTimes time |> Ok
Err InvalidTimeFormat -> Err InvalidTimeFormat
[_,_,_,_] -> # hhmm
when parseLocalTimeMinuteBasic wholeBytes is
Ok time ->
frac * nanosPerMinute |> Num.round |> fromNanosSinceMidnight |> addTimes time |> Ok
Ok time -> frac * nanosPerMinute |> Num.round |> fromNanosSinceMidnight |> addTimes time |> Ok
Err InvalidTimeFormat -> Err InvalidTimeFormat
[_,_,':',_,_] -> # hh:mm
when parseLocalTimeMinuteExtended wholeBytes is
Ok time ->
frac * nanosPerMinute |> Num.round |> fromNanosSinceMidnight |> addTimes time |> Ok
Ok time -> frac * nanosPerMinute |> Num.round |> fromNanosSinceMidnight |> addTimes time |> Ok
Err InvalidTimeFormat -> Err InvalidTimeFormat
[_,_,_,_,_,_] -> # hhmmss
when parseLocalTimeBasic wholeBytes is
Ok time ->
frac * nanosPerSecond |> Num.round |> fromNanosSinceMidnight |> addTimes time |> Ok
Ok time -> frac * nanosPerSecond |> Num.round |> fromNanosSinceMidnight |> addTimes time |> Ok
Err InvalidTimeFormat -> Err InvalidTimeFormat
[_,_,':',_,_,':',_,_] -> # hh:mm:ss
when parseLocalTimeExtended wholeBytes is
Ok time ->
frac * nanosPerSecond |> Num.round |> fromNanosSinceMidnight |> addTimes time |> Ok
Ok time -> frac * nanosPerSecond |> Num.round |> fromNanosSinceMidnight |> addTimes time |> Ok
Err InvalidTimeFormat -> Err InvalidTimeFormat
_ -> Err InvalidTimeFormat
Err InvalidBytes -> Err InvalidTimeFormat
Expand Down

0 comments on commit 7ccd445

Please sign in to comment.