Module

JS.Temporal.Instant

Package
purescript-js-temporal
Repository
pete-murphy/purescript-js-temporal

A point in time with nanosecond precision, represented as nanoseconds since the Unix epoch (1970-01-01T00:00:00Z). No time zone or calendar. Use toZonedDateTimeISO to interpret in a time zone.

See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Temporal/Instant

#new Source

new :: BigInt -> Effect Instant

Creates an Instant from epoch nanoseconds. Corresponds to Temporal.Instant().

#from Source

from :: String -> Effect Instant

Parses an ISO 8601 instant string (e.g. "2024-01-15T12:00:00Z"). Throws on invalid input.

#fromEpochMilliseconds Source

fromEpochMilliseconds :: Number -> Effect Instant

Creates an Instant from epoch milliseconds.

#fromEpochNanoseconds Source

fromEpochNanoseconds :: BigInt -> Effect Instant

Creates an Instant from epoch nanoseconds.

#epochMilliseconds Source

#epochNanoseconds Source

#add Source

add :: Duration -> Instant -> Effect Instant

Adds a duration to an instant. Throws for calendar durations.

#subtract Source

subtract :: Duration -> Instant -> Effect Instant

Subtracts a duration from an instant. Throws for calendar durations.

#until Source

until :: forall provided. ConvertOptionsWithDefaults ToDifferenceOptions (Record DifferenceOptions) (Record provided) (Record DifferenceOptions) => Record provided -> Instant -> Instant -> Effect Duration

Returns the duration from this instant until the other. Options: largestUnit, smallestUnit, roundingIncrement, roundingMode.

#until_ Source

until_ :: Instant -> Instant -> Effect Duration

Same as until with default options.

#since Source

since :: forall provided. ConvertOptionsWithDefaults ToDifferenceOptions (Record DifferenceOptions) (Record provided) (Record DifferenceOptions) => Record provided -> Instant -> Instant -> Effect Duration

Returns the duration from the other instant to this one (inverse of until).

#since_ Source

since_ :: Instant -> Instant -> Effect Duration

Same as since with default options.

#round Source

round :: forall provided. ConvertOptionsWithDefaults ToRoundOptions (Record RoundOptions) (Record provided) (Record RoundOptions) => Record provided -> Instant -> Effect Instant

Rounds the instant to the given smallest unit. Options: smallestUnit, roundingIncrement, roundingMode.

#fromDateTimeInstant Source

fromDateTimeInstant :: Instant -> Effect Instant

Converts a purescript-datetime Instant to a Temporal Instant. See docs/purescript-datetime-interop.md.

#toDateTimeInstant Source

toDateTimeInstant :: Instant -> Maybe Instant

Converts a Temporal Instant to a purescript-datetime Instant. Returns Nothing if the value is outside the datetime Instant range. See docs/purescript-datetime-interop.md.

#toZonedDateTimeISO Source

toZonedDateTimeISO :: String -> Instant -> ZonedDateTime

Converts the instant to a ZonedDateTime in the given time zone (e.g. "America/New_York").

#toString Source

toString :: forall provided. ConvertOptionsWithDefaults ToToStringOptions (Record ToStringOptions) (Record provided) (Record ToStringOptions) => Record provided -> Instant -> String

Serializes the instant to ISO 8601 format. Options: fractionalSecondDigits, smallestUnit, roundingMode, timeZone.

#toString_ Source

toString_ :: Instant -> String

Default ISO 8601 serialization (no options). Prefer over toString {}.

Re-exports from JS.Temporal.Instant.Internal

#Instant Source

data Instant

A point in time (opaque type).

Instances