APITime.Instant
Time.Instant
A moment on the Unix time line without a timezone: floor seconds and a nanosecond fraction. Supported moments run from 0001-01-02T00:00:00Z through 9999-12-30T23:59:59.999999999Z, one day inside the calendar at each end so that interpreting any instant in any zone yields a local date within years 1 through 9999. Use Time.DateTime to view an instant in a zone.
import Time.Instant as Instant
import Time.Duration as Duration
import Fail
import Result exposing (Result(..))
result = Fail.attempt {
start = Instant.fromUnix 1700000000 0
finish = Instant.add (Duration.milliseconds 1500) start
(Instant.toIso finish, Duration.toSeconds (Instant.between start finish))
}
result == Ok ("2023-11-14T22:13:21.5Z", 1)
Instant
type InstantSource
Re-exported from Time.Internal.
A moment on the Unix time line. Ordering compares the moment.
Instances:
Eq Instant
Ord Instant
Show Instant
add
add : Duration -> Instant ->{Fail Error} InstantSource
Moves by exact elapsed time, failing with OutOfRange.
between
between : Instant -> Instant -> DurationSource
Signed elapsed duration from the first moment to the second.
fromUnix
fromUnix : Int -> Int ->{Fail Error} InstantSource
Constructs from Unix seconds and a signed nanosecond adjustment, which is carried into the seconds. Fails with OutOfRange outside the supported moments.
toIso
toIso : Instant -> StringSource
Canonical UTC ISO timestamp with Z, trimming trailing fractional zeros.
toUnix
toUnix : Instant -> (Int, Int)Source
Unix floor seconds and the nonnegative nanosecond fraction.
