Copyright | (C) 2016 Jason Johnson |
---|---|
License | BSD-style (see the file LICENSE) |
Maintainer | Jason Johnson <jason.johnson.081@gmail.com> |
Stability | experimental |
Portability | TBD |
Safe Haskell | Safe |
Language | Haskell2010 |
An Instant
is universal fixed moment in time.
Types
Represents a point on a global time line. An Instant has no concept of time zone or calendar. It is nothing more than the number of nanoseconds since epoch (1.March.2000)
Constructors
Math
minus :: Instant -> Duration -> Instant Source #
}
-- | Create an OffsetDateTime
from this Instant and an Offset
withOffset :: Instant -> Offset -> Calendar -> OffsetDateTime
withOffset instant offset calendar = OffsetDateTime (LocalDateTime date time) offset -- TODO: I'm not sure I like applying the offset on construction. See if we can defer it
where
instant' = instant add
(D.fromSeconds . fromIntegral . offsetSeconds $ offset)
time = LTI.fromInstant instant'
date
| calendar == Gregorian || calendar == Iso = GI.fromInstantInCalendar instant' calendar
| otherwise = undefined -- TODO: Why does compiler think this isn't total without the otherwise?
- - | Convert
Instant
Into aZonedDateTime
based on the suppliedTimeZone
andCalendar
inZone :: Instant -> TimeZone -> Calendar -> ZonedDateTime inZone instant UTCzone calendar = ZonedDateTime odt UTCzone where odt = withOffset instant Offset.empty calendar inZone instant tzi@TimeZone { } calendar = ZonedDateTime odt tzi where odt = withOffset instant offset calendar offset | otherwise = undefined -- TODO: When TimeZone module is implemented we can finish this (look at the olson time zone series from hackage, but we can't use it all)
Subtract a Duration
from an Instant
to get an Instant
in the past. NOTE: does not handle negative durations, use add
Conversion
inUtc :: Instant -> ZonedDateTime Source #
Convert Instant
to a ZonedDateTime
in the UTC time zone, ISO calendar
Debug - to be removed
fromInstant :: Instant -> LocalTime Source #