katip-0.7.0.0: A structured logging framework.

Safe HaskellNone
LanguageHaskell2010

Katip.Format.Time

Description

Time and memory efficient time encoding helper functions.

Synopsis

Documentation

formatAsLogTime :: UTCTime -> Text Source #

Format UTCTime into a short human readable format.

>>> formatAsLogTime $ UTCTime (fromGregorian 2016 1 23) 5025.123456789012
"2016-01-23 01:23:45"

formatAsIso8601 :: UTCTime -> Text Source #

Format UTCTime into a Iso8601 format.

Note that this function may overcommit up to 12*2 bytes, depending on sub-second precision. If this is an issue, make a copy with a copy.

>>> formatAsIso8601 $ UTCTime (fromGregorian 2016 1 23) 5025.123456789012
"2016-11-23T01:23:45.123456789012Z"
>>> formatAsIso8601 $ UTCTime (fromGregorian 2016 1 23) 5025.123
"2016-01-23T01:23:45.123Z"
>>> formatAsIso8601 $ UTCTime (fromGregorian 2016 1 23) 5025
"2016-01-23T01:23:45Z"