chronos 1.0.6 → 1.0.7
raw patch · 3 files changed
+84/−48 lines, 3 filesdep +Win32dep ~hashablePVP ok
version bump matches the API change (PVP)
Dependencies added: Win32
Dependency ranges changed: hashable
API changes (from Hackage documentation)
Files
- chronos.cabal +4/−2
- src/Chronos.hs +71/−44
- src/Chronos/Internal/CTimespec.hs +9/−2
chronos.cabal view
@@ -2,7 +2,7 @@ name: chronos version:- 1.0.6+ 1.0.7 synopsis: A performant time library description:@@ -63,11 +63,13 @@ , bytestring >= 0.10 && < 0.11 , clock >= 0.7 && < 0.9 , hashable >= 1.2 && < 1.3- , primitive >= 0.7 && < 0.8+ , primitive >= 0.6.4 && < 0.8 , semigroups >= 0.16 && < 0.19 , text >= 1.2 && < 1.3 , torsor >= 0.1 && < 0.2 , vector >= 0.11 && < 0.13+ if os(windows)+ build-depends: Win32 >= 2.2 && < 2.9 default-language: Haskell2010 c-sources:
src/Chronos.hs view
@@ -6,6 +6,7 @@ , MagicHash , MultiParamTypeClasses , OverloadedStrings+ , RecordWildCards , ScopedTypeVariables , TypeFamilies , TypeInType@@ -248,7 +249,6 @@ import Data.Char (isDigit) import Data.ByteString (ByteString) import Torsor (add,difference,scale,plus)-import Chronos.Internal.CTimespec (getPosixNanoseconds) import Data.Word (Word64, Word8) import Torsor import GHC.Generics (Generic)@@ -279,6 +279,13 @@ import qualified Data.Vector.Unboxed as UVector import qualified System.Clock as CLK +#ifdef mingw32_HOST_OS+import System.Win32.Time (SYSTEMTIME(..))+import qualified System.Win32.Time as W32+#else+import Chronos.Internal.CTimespec (getPosixNanoseconds)+#endif+ #if !MIN_VERSION_base(4,11,0) import Data.Semigroup (Semigroup, (<>)) #endif@@ -454,7 +461,27 @@ -- | Get the current time from the system clock. now :: IO Time+#ifdef mingw32_HOST_OS+now = do+ SYSTEMTIME{..} <- W32.getSystemTime+ let date = Date+ { dateYear = Year (fromIntegral wYear)+ , dateMonth = Month (fromIntegral wMonth)+ , dateDay = DayOfMonth (fromIntegral wDay)+ }+ let secNano = (fromIntegral wSecond :: Int64) * 1000000000+ msNano = (fromIntegral wMilliseconds :: Int64) * 1000000+ nano = secNano + msNano+ let time = TimeOfDay+ { timeOfDayHour = fromIntegral wHour+ , timeOfDayMinute = fromIntegral wMinute+ , timeOfDayNanoseconds = fromIntegral nano+ }+ let dt = Datetime date time+ pure $ datetimeToTime dt+#else now = fmap Time getPosixNanoseconds+#endif -- | The Unix epoch, that is 1970-01-01 00:00:00. epoch :: Time@@ -837,7 +864,7 @@ caseDayOfWeek :: DayOfWeekMatch a -> DayOfWeek -> a caseDayOfWeek (DayOfWeekMatch v) (DayOfWeek ix) = Vector.unsafeIndex v ix -- | Given a 'Date' and a separator, construct a 'Text' 'TB.Builder'--- corresponding to Year/Month/Day encoding.+-- corresponding to Year\/Month\/Day encoding. builder_Ymd :: Maybe Char -> Date -> TB.Builder builder_Ymd msep (Date (Year y) m d) = case msep of Nothing ->@@ -852,7 +879,7 @@ <> zeroPadDayOfMonth d -- | Given a 'Date' and a separator, construct a 'Text' 'TB.Builder'--- corresponding to a Day/Month/Year encoding.+-- corresponding to a Day\/Month\/Year encoding. builder_Dmy :: Maybe Char -> Date -> TB.Builder builder_Dmy msep (Date (Year y) m d) = case msep of Nothing ->@@ -866,7 +893,7 @@ <> sepBuilder <> TB.decimal y --- | Parse a Year/Month/Day-encoded 'Date' that uses the+-- | Parse a Year\/Month\/Day-encoded 'Date' that uses the -- given separator. parser_Ymd :: Maybe Char -> Parser Date parser_Ymd msep = do@@ -879,7 +906,7 @@ when (d < 1 || d > 31) (fail "day must be between 1 and 31") pure (Date (Year y) (Month $ m - 1) (DayOfMonth d)) --- | Parse a Month/Day/Year-encoded 'Date' that uses the+-- | Parse a Month\/Day\/Year-encoded 'Date' that uses the -- given separator. parser_Mdy :: Maybe Char -> Parser Date parser_Mdy msep = do@@ -892,7 +919,7 @@ y <- parseFixedDigits 4 pure (Date (Year y) (Month $ m - 1) (DayOfMonth d)) --- | Parse a Day/Month/Year-encoded 'Date' that uses the+-- | Parse a Day\/Month\/Year-encoded 'Date' that uses the -- given separator. parser_Dmy :: Maybe Char -> Parser Date parser_Dmy msep = do@@ -906,7 +933,7 @@ pure (Date (Year y) (Month $ m - 1) (DayOfMonth d)) -- | Given a 'Date' and a separator, construct a 'ByteString' 'BB.Builder'--- corresponding to a Day/Month/Year encoding.+-- corresponding to a Day\/Month\/Year encoding. builderUtf8_Ymd :: Maybe Char -> Date -> BB.Builder builderUtf8_Ymd msep (Date (Year y) m d) = case msep of Nothing ->@@ -920,7 +947,7 @@ <> sepBuilder <> zeroPadDayOfMonthBS d --- | Parse a Year/Month/Day-encoded 'Date' that uses the+-- | Parse a Year\/Month\/Day-encoded 'Date' that uses the -- given separator. parserUtf8_Ymd :: Maybe Char -> AB.Parser Date parserUtf8_Ymd msep = do@@ -934,7 +961,7 @@ pure (Date (Year y) (Month $ m - 1) (DayOfMonth d)) -- | Given a 'SubsecondPrecision' and a separator, construct a--- 'Text' 'TB.Builder' corresponding to a Hour/Minute/Second+-- 'Text' 'TB.Builder' corresponding to an Hour\/Minute\/Second -- encoding. builder_HMS :: SubsecondPrecision -> Maybe Char -> TimeOfDay -> TB.Builder builder_HMS sp msep (TimeOfDay h m ns) =@@ -974,7 +1001,7 @@ then TB.fromText pm else TB.fromText am --- | Parse an Hour/Minute/Second-encoded 'TimeOfDay' that uses+-- | Parse an Hour\/Minute\/Second-encoded 'TimeOfDay' that uses -- the given separator. parser_HMS :: Maybe Char -> Parser TimeOfDay parser_HMS msep = do@@ -1128,7 +1155,7 @@ -- | Given a 'SubsecondPrecision' and a 'DatetimeFormat', construct a -- 'Text' 'TB.Builder' corresponding to a--- Day/Month/Year,Hour/Minute/Second encoding of the given 'Datetime'.+-- Day\/Month\/Year,Hour\/Minute\/Second encoding of the given 'Datetime'. builder_DmyHMS :: SubsecondPrecision -> DatetimeFormat -> Datetime -> TB.Builder builder_DmyHMS sp (DatetimeFormat mdateSep msep mtimeSep) (Datetime date time) = case msep of@@ -1140,7 +1167,7 @@ -- | Given a 'MeridiemLocale', a 'SubsecondPrecision', -- and a 'DatetimeFormat', construct a 'Text' 'TB.Builder'--- corresponding to a Day/Month/Year,IMS encoding of the given+-- corresponding to a Day\/Month\/Year,IMS encoding of the given -- 'Datetime'. This differs from 'builder_DmyIMSp' in that -- it adds a space between the locale and seconds. builder_DmyIMS_p :: MeridiemLocale Text -> SubsecondPrecision -> DatetimeFormat -> Datetime -> TB.Builder@@ -1151,7 +1178,7 @@ -- | Given a 'MeridiemLocale', a 'SubsecondPrecision', -- and a 'DatetimeFormat', construct a 'Text' 'TB.Builder'--- corresponding to a Day/Month/Year,IMS encoding of the given+-- corresponding to a Day\/Month\/Year,IMS encoding of the given -- 'Datetime'. builder_DmyIMSp :: MeridiemLocale Text -> SubsecondPrecision -> DatetimeFormat -> Datetime -> TB.Builder builder_DmyIMSp locale sp (DatetimeFormat mdateSep msep mtimeSep) (Datetime date time) =@@ -1160,7 +1187,7 @@ <> builder_IMS_p locale sp mtimeSep time -- | Given a 'SubsecondPrecision' and 'DatetimeFormat', construct--- 'Text' that corresponds to a Day/Month/Year,Hour/Minute/Second+-- 'Text' that corresponds to a Day\/Month\/Year,Hour\/Minute\/Second -- encoding of the given 'Datetime'. encode_DmyHMS :: SubsecondPrecision -> DatetimeFormat -> Datetime -> Text encode_DmyHMS sp format =@@ -1168,13 +1195,13 @@ -- | Given a 'MeridiemLocale', a 'SubsecondPrecision', and a -- 'DatetimeFormat', construct 'Text' that corresponds to a--- Day/Month/Year,IMS encoding of the given 'Datetime'. This+-- Day\/Month\/Year,IMS encoding of the given 'Datetime'. This -- inserts a space between the locale and seconds. encode_DmyIMS_p :: MeridiemLocale Text -> SubsecondPrecision -> DatetimeFormat -> Datetime -> Text encode_DmyIMS_p a sp b = LT.toStrict . TB.toLazyText . builder_DmyIMS_p a sp b -- | Given a 'SubsecondPrecision' and 'DatetimeFormat', construct--- 'Text' that corresponds to a Year/Month/Day,Hour/Minute/Second+-- 'Text' that corresponds to a Year\/Month\/Day,Hour\/Minute\/Second -- encoding of the given 'Datetime'. encode_YmdHMS :: SubsecondPrecision -> DatetimeFormat -> Datetime -> Text encode_YmdHMS sp format =@@ -1182,14 +1209,14 @@ -- | Given a 'MeridiemLocale', a 'SubsecondPrecision', and a -- 'DatetimeFormat', construct 'Text' that corresponds to a--- Year/Month/Day,IMS encoding of the given 'Datetime'. This+-- Year\/Month\/Day,IMS encoding of the given 'Datetime'. This -- inserts a space between the locale and seconds. encode_YmdIMS_p :: MeridiemLocale Text -> SubsecondPrecision -> DatetimeFormat -> Datetime -> Text encode_YmdIMS_p a sp b = LT.toStrict . TB.toLazyText . builder_YmdIMS_p a sp b -- | Given a 'SubsecondPrecision' and a 'DatetimeFormat', construct -- a 'Text' 'TB.Builder' corresponding to a--- Year/Month/Day,Hour/Minute/Second encoding of the given 'Datetime'.+-- Year\/Month\/Day,Hour\/Minute\/Second encoding of the given 'Datetime'. builder_YmdHMS :: SubsecondPrecision -> DatetimeFormat -> Datetime -> TB.Builder builder_YmdHMS sp (DatetimeFormat mdateSep msep mtimeSep) (Datetime date time) = case msep of@@ -1201,7 +1228,7 @@ -- | Given a 'MeridiemLocale', a 'SubsecondPrecision', and a -- 'DatetimeFormat', construct a 'Text' 'TB.Builder' that--- corresponds to a Year/Month/Day,IMS encoding of the+-- corresponds to a Year\/Month\/Day,IMS encoding of the -- given 'Datetime'. This inserts a space between the locale -- and seconds. builder_YmdIMS_p :: MeridiemLocale Text -> SubsecondPrecision -> DatetimeFormat -> Datetime -> TB.Builder@@ -1212,7 +1239,7 @@ -- | Given a 'MeridiemLocale', a 'SubsecondPrecision', and a -- 'DatetimeFormat', construct a 'Text' 'TB.Builder' that--- corresponds to a Year/Month/Day,IMS encoding of the+-- corresponds to a Year\/Month\/Day,IMS encoding of the -- given 'Datetime'. builder_YmdIMSp :: MeridiemLocale Text -> SubsecondPrecision -> DatetimeFormat -> Datetime -> TB.Builder builder_YmdIMSp locale sp (DatetimeFormat mdateSep msep mtimeSep) (Datetime date time) =@@ -1225,13 +1252,13 @@ builderW3C :: Datetime -> TB.Builder builderW3C = builder_YmdHMS SubsecondPrecisionAuto w3c --- | Decode a Year/Month/Day,Hour/Minute/Second-encoded 'Datetime'+-- | Decode a Year\/Month\/Day,Hour\/Minute\/Second-encoded 'Datetime' -- from 'Text' that was encoded with the given 'DatetimeFormat'. decode_YmdHMS :: DatetimeFormat -> Text -> Maybe Datetime decode_YmdHMS format = either (const Nothing) Just . AT.parseOnly (parser_YmdHMS format) --- | Parse a Day/Month/Year,Hour/Minute/Second-encoded 'Datetime'+-- | Parse a Day\/Month\/Year,Hour\/Minute\/Second-encoded 'Datetime' -- that was encoded with the given 'DatetimeFormat'. parser_DmyHMS :: DatetimeFormat -> Parser Datetime parser_DmyHMS (DatetimeFormat mdateSep msep mtimeSep) = do@@ -1255,7 +1282,7 @@ time <- parser_HMS_opt_S mtimeSep pure (Datetime date time) --- | Decode a Day/Month/Year,Hour/Minute/Second-encoded 'Datetime'+-- | Decode a Day\/Month\/Year,Hour\/Minute\/Second-encoded 'Datetime' -- from 'Text' that was encoded with the given 'DatetimeFormat'. decode_DmyHMS :: DatetimeFormat -> Text -> Maybe Datetime decode_DmyHMS format =@@ -1272,7 +1299,7 @@ decode_DmyHMS_opt_S :: DatetimeFormat -> Text -> Maybe Datetime decode_DmyHMS_opt_S format = either (const Nothing) Just . AT.parseOnly (parser_DmyHMS_opt_S format)--- | Parses a Year/Month/Day,Hour/Minute/Second-encoded 'Datetime'+-- | Parses a Year\/Month\/Day,Hour\/Minute\/Second-encoded 'Datetime' -- that was encoded using the given 'DatetimeFormat'. parser_YmdHMS :: DatetimeFormat -> Parser Datetime parser_YmdHMS (DatetimeFormat mdateSep msep mtimeSep) = do@@ -1311,7 +1338,7 @@ -- ByteString stuff --------------- --- | Given a 'SubsecondPrecision' and a separator, construct a 'ByteString' 'BB.Builder' corresponding to an Hour/Month/Second encoding of the given 'TimeOfDay'.+-- | Given a 'SubsecondPrecision' and a separator, construct a 'ByteString' 'BB.Builder' corresponding to an Hour\/Month\/Second encoding of the given 'TimeOfDay'. builderUtf8_HMS :: SubsecondPrecision -> Maybe Char -> TimeOfDay -> BB.Builder builderUtf8_HMS sp msep (TimeOfDay h m ns) = indexTwoDigitByteStringBuilder h@@ -1346,7 +1373,7 @@ <> internalBuilderUtf8_NS sp msep m ns <> internalBuilderUtf8_p meridiemLocale h --- | Parse an Hour/Minute/Second-encoded 'TimeOfDay' that uses+-- | Parse an Hour\/Minute\/Second-encoded 'TimeOfDay' that uses -- the given separator. parserUtf8_HMS :: Maybe Char -> AB.Parser TimeOfDay parserUtf8_HMS msep = do@@ -1503,14 +1530,14 @@ !s = fromIntegral sInt64 -- | Given a 'SubsecondPrecision' and a 'DatetimeFormat', construct--- a 'ByteString' corresponding to a Year/Month/Day,Hour/Minute/Second+-- a 'ByteString' corresponding to a Year\/Month\/Day,Hour\/Minute\/Second -- encoding of the given 'Datetime'. encodeUtf8_YmdHMS :: SubsecondPrecision -> DatetimeFormat -> Datetime -> ByteString encodeUtf8_YmdHMS sp format = LB.toStrict . BB.toLazyByteString . builderUtf8_YmdHMS sp format -- | Given a 'MeridiemLocale', a 'SubsecondPrecision', and a 'DatetimeFormat',--- construct a 'ByteString' corresponding to a Year/Month/Day,IMS encoding+-- construct a 'ByteString' corresponding to a Year\/Month\/Day,IMS encoding -- of the given 'Datetime'. This inserts a space between the locale and -- seconds. encodeUtf8_YmdIMS_p :: MeridiemLocale ByteString -> SubsecondPrecision -> DatetimeFormat -> Datetime -> ByteString@@ -1518,7 +1545,7 @@ -- | Given a 'SubsecondPrecision' and a 'DatetimeFormat', construct -- a 'ByteString' 'BB.Builder' corresponding to a--- Year/Month/Day,Hour/Minute/Second encoding of the+-- Year\/Month\/Day,Hour\/Minute\/Second encoding of the -- given 'Datetime'. builderUtf8_YmdHMS :: SubsecondPrecision -> DatetimeFormat -> Datetime -> BB.Builder builderUtf8_YmdHMS sp (DatetimeFormat mdateSep msep mtimeSep) (Datetime date time) =@@ -1531,7 +1558,7 @@ -- | Given a 'SubsecondPrecision' and a 'DatetimeFormat', construct -- a 'ByteString' 'BB.Builder' corresponding to a--- Year/Month/Day,IMS encoding of the given 'Datetime'. This inserts+-- Year\/Month\/Day,IMS encoding of the given 'Datetime'. This inserts -- a space between the locale and seconds. builderUtf8_YmdIMS_p :: MeridiemLocale ByteString -> SubsecondPrecision -> DatetimeFormat -> Datetime -> BB.Builder builderUtf8_YmdIMS_p locale sp (DatetimeFormat mdateSep msep mtimeSep) (Datetime date time) =@@ -1541,7 +1568,7 @@ -- | Given a 'SubsecondPrecision' and a 'DatetimeFormat', construct -- a 'ByteString' 'BB.Builder' corresponding to a--- Year/Month/Day,IMS encoding of the given 'Datetime'.+-- Year\/Month\/Day,IMS encoding of the given 'Datetime'. builderUtf8_YmdIMSp :: MeridiemLocale ByteString -> SubsecondPrecision -> DatetimeFormat -> Datetime -> BB.Builder builderUtf8_YmdIMSp locale sp (DatetimeFormat mdateSep msep mtimeSep) (Datetime date time) = builderUtf8_Ymd mdateSep date@@ -1553,13 +1580,13 @@ builderUtf8W3C :: Datetime -> BB.Builder builderUtf8W3C = builderUtf8_YmdHMS SubsecondPrecisionAuto (DatetimeFormat (Just '-') (Just 'T') (Just ':')) --- | Decode a Year/Month/Day,Hour/Minute/Second-encoded 'Datetime' from+-- | Decode a Year\/Month\/Day,Hour\/Minute\/Second-encoded 'Datetime' from -- a 'ByteString'. decodeUtf8_YmdHMS :: DatetimeFormat -> ByteString -> Maybe Datetime decodeUtf8_YmdHMS format = either (const Nothing) Just . AB.parseOnly (parserUtf8_YmdHMS format) --- | Parse a Year/Month/Day,Hour/Minute/Second-encoded 'Datetime' that was+-- | Parse a Year\/Month\/Day,Hour\/Minute\/Second-encoded 'Datetime' that was -- encoded using the given 'DatetimeFormat'. parserUtf8_YmdHMS :: DatetimeFormat -> AB.Parser Datetime parserUtf8_YmdHMS (DatetimeFormat mdateSep msep mtimeSep) = do@@ -1597,14 +1624,14 @@ -- | Given an 'OffsetFormat', a 'SubsecondPrecision', and -- a 'DatetimeFormat', construct a 'Text' 'TB.Builder'--- corresponding to a Year/Month/Day,Hour/Minute/Second encoding+-- corresponding to a Year\/Month\/Day,Hour\/Minute\/Second encoding -- of the given 'OffsetDatetime'. builder_YmdHMSz :: OffsetFormat -> SubsecondPrecision -> DatetimeFormat -> OffsetDatetime -> TB.Builder builder_YmdHMSz offsetFormat sp datetimeFormat (OffsetDatetime datetime offset) = builder_YmdHMS sp datetimeFormat datetime <> builderOffset offsetFormat offset --- | Parse a Year/Month/Day,Hour/Minute/Second-encoded 'OffsetDatetime'+-- | Parse a Year\/Month\/Day,Hour\/Minute\/Second-encoded 'OffsetDatetime' -- that was encoded using the given 'OffsetFormat' -- and 'DatetimeFormat'. parser_YmdHMSz :: OffsetFormat -> DatetimeFormat -> Parser OffsetDatetime@@ -1614,7 +1641,7 @@ -- | Given an 'OffsetFormat', a 'MeridiemLocale', a -- 'SubsecondPrecision', and 'DatetimeFormat', construct a--- 'Text' 'TB.Builder' corresponding to a Year/Month/Day,IMS-encoding+-- 'Text' 'TB.Builder' corresponding to a Year\/Month\/Day,IMS-encoding -- of the given 'OffsetDatetime'. builder_YmdIMS_p_z :: OffsetFormat -> MeridiemLocale Text -> SubsecondPrecision -> DatetimeFormat -> OffsetDatetime -> TB.Builder builder_YmdIMS_p_z offsetFormat meridiemLocale sp datetimeFormat (OffsetDatetime datetime offset) =@@ -1624,7 +1651,7 @@ -- | Given an 'OffsetFormat', a 'SubsecondPrecision', -- and a 'DatetimeFormat', construct 'Text' corresponding to--- the Year/Month/Day,Hour/Minute/Second-encoding of+-- the Year\/Month\/Day,Hour\/Minute\/Second-encoding of -- the given 'OffsetDatetime'. encode_YmdHMSz :: OffsetFormat -> SubsecondPrecision -> DatetimeFormat -> OffsetDatetime -> Text encode_YmdHMSz offsetFormat sp datetimeFormat =@@ -1632,14 +1659,14 @@ -- | Given an 'OffsetFormat', a 'SubsecondPrecision', and a -- 'DatetimeFormat', construct a 'Text' 'TB.Builder' corresponding--- to the Day/Month/Year,Hour/Minute/Second-encoding of+-- to the Day\/Month\/Year,Hour\/Minute\/Second-encoding of -- the given 'OffsetDatetime'. builder_DmyHMSz :: OffsetFormat -> SubsecondPrecision -> DatetimeFormat -> OffsetDatetime -> TB.Builder builder_DmyHMSz offsetFormat sp datetimeFormat (OffsetDatetime datetime offset) = builder_DmyHMS sp datetimeFormat datetime <> builderOffset offsetFormat offset --- | Parse a Day/Month/Year,Hour/Minute/Second-encoded 'OffsetDatetime'+-- | Parse a Day\/Month\/Year,Hour\/Minute\/Second-encoded 'OffsetDatetime' -- that was encoded using the given 'OffsetFormat' -- and 'DatetimeFormat'. parser_DmyHMSz :: OffsetFormat -> DatetimeFormat -> AT.Parser OffsetDatetime@@ -1649,7 +1676,7 @@ -- | Given an 'OffsetFormat', a 'MeridiemLocale', a -- 'SubsecondPrecision', and a 'DatetimeFormat', construct a 'Text'--- 'TB.Builder' corresponding to the Day/Month/Year,IMS encoding+-- 'TB.Builder' corresponding to the Day\/Month\/Year,IMS encoding -- of the given 'OffsetDatetime'. builder_DmyIMS_p_z :: OffsetFormat -> MeridiemLocale Text -> SubsecondPrecision -> DatetimeFormat -> OffsetDatetime -> TB.Builder builder_DmyIMS_p_z offsetFormat meridiemLocale sp datetimeFormat (OffsetDatetime datetime offset) =@@ -1659,7 +1686,7 @@ -- | Given an 'OffsetFormat', a 'SubsecondPrecision', and a -- 'DatetimeFormat', construct 'Text' corresponding to the--- Day/Month/Year,Hour/Minute/Second encoding of the given+-- Day\/Month\/Year,Hour\/Minute\/Second encoding of the given -- 'OffsetDatetime'. encode_DmyHMSz :: OffsetFormat -> SubsecondPrecision -> DatetimeFormat -> OffsetDatetime -> Text encode_DmyHMSz offsetFormat sp datetimeFormat =@@ -1804,14 +1831,14 @@ -- | Given an 'OffsetFormat', a 'SubsecondPrecision', and a -- 'DatetimeFormat', construct a 'ByteString' 'BB.Builder'--- corresponding to the Year/Month/Day,Hour/Minute/Second+-- corresponding to the Year\/Month\/Day,Hour\/Minute\/Second -- encoding of the given 'OffsetDatetime'. builderUtf8_YmdHMSz :: OffsetFormat -> SubsecondPrecision -> DatetimeFormat -> OffsetDatetime -> BB.Builder builderUtf8_YmdHMSz offsetFormat sp datetimeFormat (OffsetDatetime datetime offset) = builderUtf8_YmdHMS sp datetimeFormat datetime <> builderOffsetUtf8 offsetFormat offset --- | Parse a Year/Month/Day,Hour/Minute/Second-encoded 'OffsetDatetime'+-- | Parse a Year\/Month\/Day,Hour\/Minute\/Second-encoded 'OffsetDatetime' -- that was encoded using the given 'OffsetFormat' and -- 'DatetimeFormat'. parserUtf8_YmdHMSz :: OffsetFormat -> DatetimeFormat -> AB.Parser OffsetDatetime@@ -1821,7 +1848,7 @@ -- | Given an 'OffsetFormat', a 'MeridiemLocale, a 'SubsecondPrecision', -- and a 'DatetimeFormat', construct a 'ByteString' 'BB.Builder'--- corresponding to a Year/Month/Day,IMS-encoded 'OffsetDatetime'.+-- corresponding to a Year\/Month\/Day,IMS-encoded 'OffsetDatetime'. builderUtf8_YmdIMS_p_z :: OffsetFormat -> MeridiemLocale ByteString -> SubsecondPrecision -> DatetimeFormat -> OffsetDatetime -> BB.Builder builderUtf8_YmdIMS_p_z offsetFormat meridiemLocale sp datetimeFormat (OffsetDatetime datetime offset) = builderUtf8_YmdIMS_p meridiemLocale sp datetimeFormat datetime
src/Chronos/Internal/CTimespec.hs view
@@ -4,19 +4,26 @@ {-# OPTIONS_HADDOCK hide #-} -- for doctests module Chronos.Internal.CTimespec- ( getPosixNanoseconds+ (+#ifndef mingw32_HOST_OS+ getPosixNanoseconds , CTimespec(..)+#endif ) where import Foreign import Foreign.C -#ifdef ghcjs_HOST_OS+#if defined(ghcjs_HOST_OS)+ foreign import javascript unsafe "Date.now()" currentSeconds :: IO Double getPosixNanoseconds :: IO Int64 getPosixNanoseconds = do x <- currentSeconds pure $ fromIntegral $ 1000000 * (round x)++#elif defined(mingw32_HOST_OS)+ #else data CTimespec = CTimespec