Skip to content

Instantly share code, notes, and snippets.

@mauriciofierrom
Created May 26, 2018 09:19
Show Gist options
  • Save mauriciofierrom/9f8765931bebc313a9bb08051493f39f to your computer and use it in GitHub Desktop.
Save mauriciofierrom/9f8765931bebc313a9bb08051493f39f to your computer and use it in GitHub Desktop.
Convert from .net ticks to UTCTime in Haskell
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