aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFélix Sipma <felix.sipma@no-log.org>2018-02-23 16:54:15 +0100
committerFélix Sipma <felix.sipma@no-log.org>2018-02-23 16:54:32 +0100
commit056e0dc4ab30cfa2f14d2e3b1d6ba12c946d9482 (patch)
tree7b40dfa2cefb30deedb3ea4945b75998a9782abc
parent94908a68e380b23e1154402fce7a49c3262b9314 (diff)
parse alternative date formats
-rw-r--r--src/Date.hs14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/Date.hs b/src/Date.hs
index 509c536..9a8a465 100644
--- a/src/Date.hs
+++ b/src/Date.hs
@@ -3,6 +3,7 @@
{-# LANGUAGE TemplateHaskell #-}
module Date
( parseW3
+ , parseW3'
, parseRfc822
, parseRfc822'
, parseW3Rfc822
@@ -28,8 +29,19 @@ parseW3 t = parseTimeM True defaultTimeLocale "%FT%X%z" s
where
s = toS t
+parseW3' :: Text -> Maybe UTCTime
+parseW3' t =
+ parseTimeM True defaultTimeLocale "%F %X %z %Z" s
+ -- ^ 2017-10-17 00:00:00 +0000 UTC
+ <|> parseTimeM True defaultTimeLocale "%F %X %z" s
+ -- ^ 2017-10-17 00:00:00 +0000
+ <|> parseTimeM True defaultTimeLocale "%F %X %Z" s
+ -- ^ 2017-10-17 00:00:00 UTC
+ where
+ s = toS t
+
parseW3Rfc822' :: Text -> Maybe UTCTime
-parseW3Rfc822' t = parseW3 t <|> parseRfc822 t <|> parseRfc822' t
+parseW3Rfc822' t = parseW3 t <|> parseW3' t <|> parseRfc822 t <|> parseRfc822' t
parseW3Rfc822 :: MonadLogger m => Text -> m (Maybe UTCTime)
parseW3Rfc822 t = case parseW3Rfc822' t of