APITime.TimeOfDay

Time.TimeOfDay

A nanosecond-precise clock reading without a date or timezone. Midnight belongs to the start of a day; 24:00 and leap seconds are not accepted.

import Time.TimeOfDay as TOD
import Fail
import Result exposing (Result(..))

Fail.attempt { TOD.parse "09:30:00.120000000" |> TOD.toIso } == Ok "09:30:00.12"

TimeOfDay

type TimeOfDaySource

Re-exported from Time.Internal.

A clock reading. Ordering runs from midnight to the final nanosecond.

Instances:

Eq TimeOfDay
Ord TimeOfDay
Show TimeOfDay

format

format : String -> TimeOfDay -> StringSource

Output formatting with %H, %M, %S, %N (nine digits), %T, and %%. Other tokens are copied verbatim.

fromNanoseconds

fromNanoseconds : Int ->{Fail Error} TimeOfDaySource

Validates nanoseconds since midnight, in [0, 86400000000000), failing with InvalidComponent “time of day”.

hour

hour : TimeOfDay -> IntSource

Hour, 0 through 23.

make

make : Int -> Int -> Int -> Int ->{Fail Error} TimeOfDaySource

Validates hour (0–23), minute and second (0–59), and nanosecond (0–999999999), failing with InvalidComponent naming the offending field.

midnight

midnight : TimeOfDaySource

00:00:00, with no fractional seconds.

minute

minute : TimeOfDay -> IntSource

Minute within the hour, 0 through 59.

nanosecond

nanosecond : TimeOfDay -> IntSource

Nanosecond fraction, 0 through 999999999.

parse

parse : String ->{Fail Error} TimeOfDaySource

Strict HH:MM:SS with an optional decimal fraction of 1 through 9 digits. Fails with InvalidText, including for out-of-range fields.

second

second : TimeOfDay -> IntSource

Second within the minute, 0 through 59.

toIso

toIso : TimeOfDay -> StringSource

Canonical HH:MM:SS with a fraction only when nonzero, without trailing zeros.

toNanoseconds

toNanoseconds : TimeOfDay -> IntSource

Nanoseconds since midnight.