Skip to content

Commit

Permalink
03thyme
Browse files Browse the repository at this point in the history
  • Loading branch information
bartavelle committed Nov 19, 2015
1 parent 93cfc43 commit e4d0aa3
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions performanceparsing/parse.hs
Expand Up @@ -6,12 +6,14 @@ import Data.Bits
import Data.Text (Text)
import qualified Data.Text as T
import qualified Data.Text.IO as T
import Data.Time
import System.Environment
import qualified Data.Map.Strict as M
import Control.Applicative
import Data.AffineSpace ((.-^))
import Data.Char (isSpace, digitToInt, isUpper)
import Data.List (foldl')
import Control.Lens
import Data.Thyme

import Data.Attoparsec.Text

Expand Down Expand Up @@ -64,13 +66,13 @@ timestamp = do
h <- scientific <* char ':'
mi <- scientific <* char ':'
s <- scientific <* char '+'
let day = fromGregorian y m d
difftime = h * 3600 + mi * 60 + s
tm = UTCTime day (realToFrac difftime)
let day = YearMonthDay y m d ^. from gregorian
difftime = fromSeconds $ (h * 3600 + mi * 60) + s
tm = UTCTime day difftime ^. from utcTime
tz <- takeWhile1 isUpper <* skipSpace
return $ case tz of
"CEST" -> addUTCTime (-7200) tm
"CET" -> addUTCTime (-3600) tm
"CEST" -> tm .-^ fromSeconds (7200 :: Int)
"CET" -> tm .-^ fromSeconds (3600 :: Int)
_ -> tm

filetype :: Parser FileType
Expand Down

0 comments on commit e4d0aa3

Please sign in to comment.