Created
May 26, 2018 09:19
-
-
Save mauriciofierrom/9f8765931bebc313a9bb08051493f39f to your computer and use it in GitHub Desktop.
Convert from .net ticks to UTCTime in Haskell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.Time ( UTCTime(..) | |
, fromGregorian | |
, NominalDiffTime(..) | |
, addUTCTime ) | |
ticksToUtc :: Integer -> UTCTime | |
ticksToUtc ticks = | |
let start = UTCTime (fromGregorian 0001 01 01) 0 | |
seconds = realToFrac (ticks `div` 10000000) :: NominalDiffTime | |
in addUTCTime seconds start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment