HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Modulehourglass-0.2.12Haskell2010

Time.Compat

Basic Time conversion compatibility.

This module aims to help conversion between the types from the package time to the package hourglass.

Example of use (extracted from file ExampleTimeCompat.hs):

import Data.Hourglass        as H
import Data.Hourglass.Compat as C
import Data.Time             as T

transpose :: T.ZonedTime
          -> H.LocalTime H.DateTime
transpose oldTime =
    H.localTime
        offsetTime
        (H.DateTime newDate timeofday)
  where
    newDate :: H.Date
    newDate = C.dateFromTAIEpoch $ T.toModifiedJulianDay $ T.localDay $ T.zonedTimeToLocalTime oldTime

    timeofday :: H.TimeOfDay
    timeofday = C.diffTimeToTimeOfDay $ T.timeOfDayToTime $ T.localTimeOfDay $ T.zonedTimeToLocalTime oldTime

    offsetTime = H.TimezoneOffset $ fromIntegral $ T.timeZoneMinutes $ T.zonedTimeZone oldTime
  • 3 values
  • Packagehourglass-0.2.12
  • Exports3
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceCompat.hs
valuedateFromPOSIXEpoch
  1. :: Integer

    number of days since POSIX Epoch

  2. -> Date
#

Convert an integer which represent the Number of days (To/From) POSIX Epoch to a Date (POSIX Epoch is 1970-01-01).

valuedateFromTAIEpoch
  1. :: Integer

    number of days since TAI Epoch

  2. -> Date
#

Convert an integer which represents the Number of days (To/From) TAI Epoch This function allows use of the package time to easily convert the Day into the Hourglass Date representation (TAI Epoch is 1858-11-17).

This function allows user to easily convert a Data.Time.Calendar.Day into Date

import qualified Data.Time.Calendar as T

timeDay :: T.Day

dateFromTAIEpoch $ T.toModifiedJulianDay timeDay
valuediffTimeToTimeOfDay
  1. :: Real t
  2. => t

    number of seconds of the time of the day

  3. -> TimeOfDay
#

Convert of differential of time of a day. (it convers a Data.Time.Clock.DiffTime into a TimeOfDay)

Example with DiffTime type from time:

import qualified Data.Time.Clock as T

difftime :: T.DiffTime

diffTimeToTimeOfDay difftime

Example with the TimeOfDay type from time:

import qualified Data.Time.Clock as T

timeofday :: T.TimeOfDay

diffTimeToTimeOfDay $ T.timeOfDayToTime timeofday