{-# OPTIONS -fno-warn-orphans #-}
module Data.Time.Format.Parse.Instances() where
#if !MIN_VERSION_base(4,8,0)
import Control.Applicative ((<$>),(<*>))
#endif
import Data.Char
import Data.Fixed
import Data.List
import Data.Ratio
import Data.Traversable
import Text.Read(readMaybe)
import Data.Time.Clock.Internal.DiffTime
import Data.Time.Clock.Internal.NominalDiffTime
import Data.Time.Clock.Internal.UniversalTime
import Data.Time.Clock.POSIX
import Data.Time.Clock.Internal.UTCTime
import Data.Time.Calendar.Days
import Data.Time.Calendar.Gregorian
import Data.Time.Calendar.CalendarDiffDays
import Data.Time.Calendar.OrdinalDate
import Data.Time.Calendar.WeekDate
import Data.Time.Calendar.Private(clipValid)
import Data.Time.LocalTime.Internal.CalendarDiffTime
import Data.Time.LocalTime.Internal.TimeZone
import Data.Time.LocalTime.Internal.TimeOfDay
import Data.Time.LocalTime.Internal.LocalTime
import Data.Time.LocalTime.Internal.ZonedTime
import Data.Time.Format.Locale
import Data.Time.Format.Parse.Class
data DayComponent = Century Integer
| CenturyYear Integer
| YearMonth Int
| MonthDay Int
| YearDay Int
| WeekDay Int
| YearWeek WeekType Int
data WeekType = ISOWeek | SundayWeek | MondayWeek
instance ParseTime Day where
substituteTimeSpecifier :: proxy Day -> TimeLocale -> Char -> Maybe [Char]
substituteTimeSpecifier proxy Day
_ = TimeLocale -> Char -> Maybe [Char]
timeSubstituteTimeSpecifier
parseTimeSpecifier :: proxy Day
-> TimeLocale -> Maybe ParseNumericPadding -> Char -> ReadP [Char]
parseTimeSpecifier proxy Day
_ = TimeLocale -> Maybe ParseNumericPadding -> Char -> ReadP [Char]
timeParseTimeSpecifier
buildTime :: TimeLocale -> [(Char, [Char])] -> Maybe Day
buildTime TimeLocale
l = let
f :: Char -> String -> Maybe [DayComponent]
f :: Char -> [Char] -> Maybe [DayComponent]
f Char
c [Char]
x = let
ra :: (Read a) => Maybe a
ra :: Maybe a
ra = [Char] -> Maybe a
forall a. Read a => [Char] -> Maybe a
Evidence bound by a type signature of the constraint type Read a
readMaybe [Char]
x
zeroBasedListIndex :: [String] -> Maybe Int
zeroBasedListIndex :: [[Char]] -> Maybe Int
zeroBasedListIndex [[Char]]
ss = [Char] -> [[Char]] -> Maybe Int
forall a. Eq a => a -> [a] -> Maybe Int
External instance of the constraint type forall a. Eq a => Eq [a]
External instance of the constraint type Eq Char
elemIndex ((Char -> Char) -> [Char] -> [Char]
forall a b. (a -> b) -> [a] -> [b]
map Char -> Char
toUpper [Char]
x) ([[Char]] -> Maybe Int) -> [[Char]] -> Maybe Int
forall a b. (a -> b) -> a -> b
$ ([Char] -> [Char]) -> [[Char]] -> [[Char]]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
External instance of the constraint type Functor []
fmap ((Char -> Char) -> [Char] -> [Char]
forall a b. (a -> b) -> [a] -> [b]
map Char -> Char
toUpper) [[Char]]
ss
oneBasedListIndex :: [String] -> Maybe Int
oneBasedListIndex :: [[Char]] -> Maybe Int
oneBasedListIndex [[Char]]
ss = do
Int
index <- [[Char]] -> Maybe Int
zeroBasedListIndex [[Char]]
ss
Int -> Maybe Int
forall (m :: * -> *) a. Monad m => a -> m a
External instance of the constraint type Monad Maybe
return (Int -> Maybe Int) -> Int -> Maybe Int
forall a b. (a -> b) -> a -> b
$ Int
1 Int -> Int -> Int
forall a. Num a => a -> a -> a
External instance of the constraint type Num Int
+ Int
index
in case Char
c of
Char
'C' -> do
Integer
a <- Maybe Integer
forall a. Read a => Maybe a
External instance of the constraint type Read Integer
ra
[DayComponent] -> Maybe [DayComponent]
forall (m :: * -> *) a. Monad m => a -> m a
External instance of the constraint type Monad Maybe
return [Integer -> DayComponent
Century Integer
a]
Char
'f' -> do
Integer
a <- Maybe Integer
forall a. Read a => Maybe a
External instance of the constraint type Read Integer
ra
[DayComponent] -> Maybe [DayComponent]
forall (m :: * -> *) a. Monad m => a -> m a
External instance of the constraint type Monad Maybe
return [Integer -> DayComponent
Century Integer
a]
Char
'Y' -> do
Integer
a <- Maybe Integer
forall a. Read a => Maybe a
External instance of the constraint type Read Integer
ra
[DayComponent] -> Maybe [DayComponent]
forall (m :: * -> *) a. Monad m => a -> m a
External instance of the constraint type Monad Maybe
return [Integer -> DayComponent
Century (Integer
a Integer -> Integer -> Integer
forall a. Integral a => a -> a -> a
External instance of the constraint type Integral Integer
`div` Integer
100), Integer -> DayComponent
CenturyYear (Integer
a Integer -> Integer -> Integer
forall a. Integral a => a -> a -> a
External instance of the constraint type Integral Integer
`mod` Integer
100)]
Char
'G' -> do
Integer
a <- Maybe Integer
forall a. Read a => Maybe a
External instance of the constraint type Read Integer
ra
[DayComponent] -> Maybe [DayComponent]
forall (m :: * -> *) a. Monad m => a -> m a
External instance of the constraint type Monad Maybe
return [Integer -> DayComponent
Century (Integer
a Integer -> Integer -> Integer
forall a. Integral a => a -> a -> a
External instance of the constraint type Integral Integer
`div` Integer
100), Integer -> DayComponent
CenturyYear (Integer
a Integer -> Integer -> Integer
forall a. Integral a => a -> a -> a
External instance of the constraint type Integral Integer
`mod` Integer
100)]
Char
'y' -> do
Integer
a <- Maybe Integer
forall a. Read a => Maybe a
External instance of the constraint type Read Integer
ra
[DayComponent] -> Maybe [DayComponent]
forall (m :: * -> *) a. Monad m => a -> m a
External instance of the constraint type Monad Maybe
return [Integer -> DayComponent
CenturyYear Integer
a]
Char
'g' -> do
Integer
a <- Maybe Integer
forall a. Read a => Maybe a
External instance of the constraint type Read Integer
ra
[DayComponent] -> Maybe [DayComponent]
forall (m :: * -> *) a. Monad m => a -> m a
External instance of the constraint type Monad Maybe
return [Integer -> DayComponent
CenturyYear Integer
a]
Char
'B' -> do
Int
a <- [[Char]] -> Maybe Int
oneBasedListIndex ([[Char]] -> Maybe Int) -> [[Char]] -> Maybe Int
forall a b. (a -> b) -> a -> b
$ (([Char], [Char]) -> [Char]) -> [([Char], [Char])] -> [[Char]]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
External instance of the constraint type Functor []
fmap ([Char], [Char]) -> [Char]
forall a b. (a, b) -> a
fst ([([Char], [Char])] -> [[Char]]) -> [([Char], [Char])] -> [[Char]]
forall a b. (a -> b) -> a -> b
$ TimeLocale -> [([Char], [Char])]
months TimeLocale
l
[DayComponent] -> Maybe [DayComponent]
forall (m :: * -> *) a. Monad m => a -> m a
External instance of the constraint type Monad Maybe
return [Int -> DayComponent
YearMonth Int
a]
Char
'b' -> do
Int
a <- [[Char]] -> Maybe Int
oneBasedListIndex ([[Char]] -> Maybe Int) -> [[Char]] -> Maybe Int
forall a b. (a -> b) -> a -> b
$ (([Char], [Char]) -> [Char]) -> [([Char], [Char])] -> [[Char]]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
External instance of the constraint type Functor []
fmap ([Char], [Char]) -> [Char]
forall a b. (a, b) -> b
snd ([([Char], [Char])] -> [[Char]]) -> [([Char], [Char])] -> [[Char]]
forall a b. (a -> b) -> a -> b
$ TimeLocale -> [([Char], [Char])]
months TimeLocale
l
[DayComponent] -> Maybe [DayComponent]
forall (m :: * -> *) a. Monad m => a -> m a
External instance of the constraint type Monad Maybe
return [Int -> DayComponent
YearMonth Int
a]
Char
'm' -> do
Int
raw <- Maybe Int
forall a. Read a => Maybe a
External instance of the constraint type Read Int
ra
Int
a <- Int -> Int -> Int -> Maybe Int
forall t. Ord t => t -> t -> t -> Maybe t
External instance of the constraint type Ord Int
clipValid Int
1 Int
12 Int
raw
[DayComponent] -> Maybe [DayComponent]
forall (m :: * -> *) a. Monad m => a -> m a
External instance of the constraint type Monad Maybe
return [Int -> DayComponent
YearMonth Int
a]
Char
'd' -> do
Int
raw <- Maybe Int
forall a. Read a => Maybe a
External instance of the constraint type Read Int
ra
Int
a <- Int -> Int -> Int -> Maybe Int
forall t. Ord t => t -> t -> t -> Maybe t
External instance of the constraint type Ord Int
clipValid Int
1 Int
31 Int
raw
[DayComponent] -> Maybe [DayComponent]
forall (m :: * -> *) a. Monad m => a -> m a
External instance of the constraint type Monad Maybe
return [Int -> DayComponent
MonthDay Int
a]
Char
'e' -> do
Int
raw <- Maybe Int
forall a. Read a => Maybe a
External instance of the constraint type Read Int
ra
Int
a <- Int -> Int -> Int -> Maybe Int
forall t. Ord t => t -> t -> t -> Maybe t
External instance of the constraint type Ord Int
clipValid Int
1 Int
31 Int
raw
[DayComponent] -> Maybe [DayComponent]
forall (m :: * -> *) a. Monad m => a -> m a
External instance of the constraint type Monad Maybe
return [Int -> DayComponent
MonthDay Int
a]
Char
'V' -> do
Int
raw <- Maybe Int
forall a. Read a => Maybe a
External instance of the constraint type Read Int
ra
Int
a <- Int -> Int -> Int -> Maybe Int
forall t. Ord t => t -> t -> t -> Maybe t
External instance of the constraint type Ord Int
clipValid Int
1 Int
53 Int
raw
[DayComponent] -> Maybe [DayComponent]
forall (m :: * -> *) a. Monad m => a -> m a
External instance of the constraint type Monad Maybe
return [WeekType -> Int -> DayComponent
YearWeek WeekType
ISOWeek Int
a]
Char
'U' -> do
Int
raw <- Maybe Int
forall a. Read a => Maybe a
External instance of the constraint type Read Int
ra
Int
a <- Int -> Int -> Int -> Maybe Int
forall t. Ord t => t -> t -> t -> Maybe t
External instance of the constraint type Ord Int
clipValid Int
0 Int
53 Int
raw
[DayComponent] -> Maybe [DayComponent]
forall (m :: * -> *) a. Monad m => a -> m a
External instance of the constraint type Monad Maybe
return [WeekType -> Int -> DayComponent
YearWeek WeekType
SundayWeek Int
a]
Char
'W' -> do
Int
raw <- Maybe Int
forall a. Read a => Maybe a
External instance of the constraint type Read Int
ra
Int
a <- Int -> Int -> Int -> Maybe Int
forall t. Ord t => t -> t -> t -> Maybe t
External instance of the constraint type Ord Int
clipValid Int
0 Int
53 Int
raw
[DayComponent] -> Maybe [DayComponent]
forall (m :: * -> *) a. Monad m => a -> m a
External instance of the constraint type Monad Maybe
return [WeekType -> Int -> DayComponent
YearWeek WeekType
MondayWeek Int
a]
Char
'u' -> do
Int
raw <- Maybe Int
forall a. Read a => Maybe a
External instance of the constraint type Read Int
ra
Int
a <- Int -> Int -> Int -> Maybe Int
forall t. Ord t => t -> t -> t -> Maybe t
External instance of the constraint type Ord Int
clipValid Int
1 Int
7 Int
raw
[DayComponent] -> Maybe [DayComponent]
forall (m :: * -> *) a. Monad m => a -> m a
External instance of the constraint type Monad Maybe
return [Int -> DayComponent
WeekDay Int
a]
Char
'a' -> do
Int
a' <- [[Char]] -> Maybe Int
zeroBasedListIndex ([[Char]] -> Maybe Int) -> [[Char]] -> Maybe Int
forall a b. (a -> b) -> a -> b
$ (([Char], [Char]) -> [Char]) -> [([Char], [Char])] -> [[Char]]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
External instance of the constraint type Functor []
fmap ([Char], [Char]) -> [Char]
forall a b. (a, b) -> b
snd ([([Char], [Char])] -> [[Char]]) -> [([Char], [Char])] -> [[Char]]
forall a b. (a -> b) -> a -> b
$ TimeLocale -> [([Char], [Char])]
wDays TimeLocale
l
let a :: Int
a = if Int
a' Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
External instance of the constraint type Eq Int
== Int
0 then Int
7 else Int
a'
[DayComponent] -> Maybe [DayComponent]
forall (m :: * -> *) a. Monad m => a -> m a
External instance of the constraint type Monad Maybe
return [Int -> DayComponent
WeekDay Int
a]
Char
'A' -> do
Int
a' <- [[Char]] -> Maybe Int
zeroBasedListIndex ([[Char]] -> Maybe Int) -> [[Char]] -> Maybe Int
forall a b. (a -> b) -> a -> b
$ (([Char], [Char]) -> [Char]) -> [([Char], [Char])] -> [[Char]]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
External instance of the constraint type Functor []
fmap ([Char], [Char]) -> [Char]
forall a b. (a, b) -> a
fst ([([Char], [Char])] -> [[Char]]) -> [([Char], [Char])] -> [[Char]]
forall a b. (a -> b) -> a -> b
$ TimeLocale -> [([Char], [Char])]
wDays TimeLocale
l
let a :: Int
a = if Int
a' Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
External instance of the constraint type Eq Int
== Int
0 then Int
7 else Int
a'
[DayComponent] -> Maybe [DayComponent]
forall (m :: * -> *) a. Monad m => a -> m a
External instance of the constraint type Monad Maybe
return [Int -> DayComponent
WeekDay Int
a]
Char
'w' -> do
Int
raw <- Maybe Int
forall a. Read a => Maybe a
External instance of the constraint type Read Int
ra
Int
a' <- Int -> Int -> Int -> Maybe Int
forall t. Ord t => t -> t -> t -> Maybe t
External instance of the constraint type Ord Int
clipValid Int
0 Int
6 Int
raw
let a :: Int
a = if Int
a' Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
External instance of the constraint type Eq Int
== Int
0 then Int
7 else Int
a'
[DayComponent] -> Maybe [DayComponent]
forall (m :: * -> *) a. Monad m => a -> m a
External instance of the constraint type Monad Maybe
return [Int -> DayComponent
WeekDay Int
a]
Char
'j' -> do
Int
raw <- Maybe Int
forall a. Read a => Maybe a
External instance of the constraint type Read Int
ra
Int
a <- Int -> Int -> Int -> Maybe Int
forall t. Ord t => t -> t -> t -> Maybe t
External instance of the constraint type Ord Int
clipValid Int
1 Int
366 Int
raw
[DayComponent] -> Maybe [DayComponent]
forall (m :: * -> *) a. Monad m => a -> m a
External instance of the constraint type Monad Maybe
return [Int -> DayComponent
YearDay Int
a]
Char
_ -> [DayComponent] -> Maybe [DayComponent]
forall (m :: * -> *) a. Monad m => a -> m a
External instance of the constraint type Monad Maybe
return []
buildDay :: [DayComponent] -> Maybe Day
buildDay :: [DayComponent] -> Maybe Day
buildDay [DayComponent]
cs = let
safeLast :: a -> [a] -> a
safeLast a
x [a]
xs = [a] -> a
forall a. [a] -> a
last (a
xa -> [a] -> [a]
forall a. a -> [a] -> [a]
:[a]
xs)
y :: Integer
y = let
d :: Integer
d = Integer -> [Integer] -> Integer
forall {a}. a -> [a] -> a
safeLast Integer
70 [Integer
x | CenturyYear Integer
x <- [DayComponent]
cs]
c :: Integer
c = Integer -> [Integer] -> Integer
forall {a}. a -> [a] -> a
safeLast (if Integer
d Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
External instance of the constraint type Ord Integer
>= Integer
69 then Integer
19 else Integer
20) [Integer
x | Century Integer
x <- [DayComponent]
cs]
in Integer
100 Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
External instance of the constraint type Num Integer
* Integer
c Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
External instance of the constraint type Num Integer
+ Integer
d
rest :: [DayComponent] -> Maybe Day
rest (YearMonth Int
m:[DayComponent]
_) = let
d :: Int
d = Int -> [Int] -> Int
forall {a}. a -> [a] -> a
safeLast Int
1 [Int
x | MonthDay Int
x <- [DayComponent]
cs]
in Integer -> Int -> Int -> Maybe Day
fromGregorianValid Integer
y Int
m Int
d
rest (YearDay Int
d:[DayComponent]
_) = Integer -> Int -> Maybe Day
fromOrdinalDateValid Integer
y Int
d
rest (YearWeek WeekType
wt Int
w:[DayComponent]
_) = let
d :: Int
d = Int -> [Int] -> Int
forall {a}. a -> [a] -> a
safeLast Int
4 [Int
x | WeekDay Int
x <- [DayComponent]
cs]
in case WeekType
wt of
WeekType
ISOWeek -> Integer -> Int -> Int -> Maybe Day
fromWeekDateValid Integer
y Int
w Int
d
WeekType
SundayWeek -> Integer -> Int -> Int -> Maybe Day
fromSundayStartWeekValid Integer
y Int
w (Int
d Int -> Int -> Int
forall a. Integral a => a -> a -> a
External instance of the constraint type Integral Int
`mod` Int
7)
WeekType
MondayWeek -> Integer -> Int -> Int -> Maybe Day
fromMondayStartWeekValid Integer
y Int
w Int
d
rest (DayComponent
_:[DayComponent]
xs) = [DayComponent] -> Maybe Day
rest [DayComponent]
xs
rest [] = [DayComponent] -> Maybe Day
rest [Int -> DayComponent
YearMonth Int
1]
in [DayComponent] -> Maybe Day
rest [DayComponent]
cs
in \[(Char, [Char])]
pairs -> do
[[DayComponent]]
components <- [(Char, [Char])]
-> ((Char, [Char]) -> Maybe [DayComponent])
-> Maybe [[DayComponent]]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
t a -> (a -> f b) -> f (t b)
External instance of the constraint type Applicative Maybe
External instance of the constraint type Traversable []
for [(Char, [Char])]
pairs (((Char, [Char]) -> Maybe [DayComponent])
-> Maybe [[DayComponent]])
-> ((Char, [Char]) -> Maybe [DayComponent])
-> Maybe [[DayComponent]]
forall a b. (a -> b) -> a -> b
$ \(Char
c,[Char]
x) -> Char -> [Char] -> Maybe [DayComponent]
f Char
c [Char]
x
[DayComponent] -> Maybe Day
buildDay ([DayComponent] -> Maybe Day) -> [DayComponent] -> Maybe Day
forall a b. (a -> b) -> a -> b
$ [[DayComponent]] -> [DayComponent]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
External instance of the constraint type Foldable []
concat [[DayComponent]]
components
mfoldl :: (Monad m) => (a -> b -> m a) -> m a -> [b] -> m a
mfoldl :: (a -> b -> m a) -> m a -> [b] -> m a
mfoldl a -> b -> m a
f = let
mf :: m a -> b -> m a
mf m a
ma b
b = do
a
a <- m a
ma
a -> b -> m a
f a
a b
b
in (m a -> b -> m a) -> m a -> [b] -> m a
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
External instance of the constraint type Foldable []
foldl m a -> b -> m a
mf
instance ParseTime TimeOfDay where
substituteTimeSpecifier :: proxy TimeOfDay -> TimeLocale -> Char -> Maybe [Char]
substituteTimeSpecifier proxy TimeOfDay
_ = TimeLocale -> Char -> Maybe [Char]
timeSubstituteTimeSpecifier
parseTimeSpecifier :: proxy TimeOfDay
-> TimeLocale -> Maybe ParseNumericPadding -> Char -> ReadP [Char]
parseTimeSpecifier proxy TimeOfDay
_ = TimeLocale -> Maybe ParseNumericPadding -> Char -> ReadP [Char]
timeParseTimeSpecifier
buildTime :: TimeLocale -> [(Char, [Char])] -> Maybe TimeOfDay
buildTime TimeLocale
l = let
f :: TimeOfDay -> (Char, [Char]) -> Maybe TimeOfDay
f t :: TimeOfDay
t@(TimeOfDay Int
h Int
m Pico
s) (Char
c,[Char]
x) = let
ra :: (Read a) => Maybe a
ra :: Maybe a
ra = [Char] -> Maybe a
forall a. Read a => [Char] -> Maybe a
Evidence bound by a type signature of the constraint type Read a
readMaybe [Char]
x
getAmPm :: Maybe TimeOfDay
getAmPm = let
upx :: [Char]
upx = (Char -> Char) -> [Char] -> [Char]
forall a b. (a -> b) -> [a] -> [b]
map Char -> Char
toUpper [Char]
x
([Char]
amStr,[Char]
pmStr) = TimeLocale -> ([Char], [Char])
amPm TimeLocale
l
in if [Char]
upx [Char] -> [Char] -> Bool
forall a. Eq a => a -> a -> Bool
External instance of the constraint type forall a. Eq a => Eq [a]
External instance of the constraint type Eq Char
== [Char]
amStr
then TimeOfDay -> Maybe TimeOfDay
forall a. a -> Maybe a
Just (TimeOfDay -> Maybe TimeOfDay) -> TimeOfDay -> Maybe TimeOfDay
forall a b. (a -> b) -> a -> b
$ Int -> Int -> Pico -> TimeOfDay
TimeOfDay (Int
h Int -> Int -> Int
forall a. Integral a => a -> a -> a
External instance of the constraint type Integral Int
`mod` Int
12) Int
m Pico
s
else if [Char]
upx [Char] -> [Char] -> Bool
forall a. Eq a => a -> a -> Bool
External instance of the constraint type forall a. Eq a => Eq [a]
External instance of the constraint type Eq Char
== [Char]
pmStr
then TimeOfDay -> Maybe TimeOfDay
forall a. a -> Maybe a
Just (TimeOfDay -> Maybe TimeOfDay) -> TimeOfDay -> Maybe TimeOfDay
forall a b. (a -> b) -> a -> b
$ Int -> Int -> Pico -> TimeOfDay
TimeOfDay (if Int
h Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
External instance of the constraint type Ord Int
< Int
12 then Int
h Int -> Int -> Int
forall a. Num a => a -> a -> a
External instance of the constraint type Num Int
+ Int
12 else Int
h) Int
m Pico
s
else Maybe TimeOfDay
forall a. Maybe a
Nothing
in case Char
c of
Char
'P' -> Maybe TimeOfDay
getAmPm
Char
'p' -> Maybe TimeOfDay
getAmPm
Char
'H' -> do
Int
raw <- Maybe Int
forall a. Read a => Maybe a
External instance of the constraint type Read Int
ra
Int
a <- Int -> Int -> Int -> Maybe Int
forall t. Ord t => t -> t -> t -> Maybe t
External instance of the constraint type Ord Int
clipValid Int
0 Int
23 Int
raw
TimeOfDay -> Maybe TimeOfDay
forall (m :: * -> *) a. Monad m => a -> m a
External instance of the constraint type Monad Maybe
return (TimeOfDay -> Maybe TimeOfDay) -> TimeOfDay -> Maybe TimeOfDay
forall a b. (a -> b) -> a -> b
$ Int -> Int -> Pico -> TimeOfDay
TimeOfDay Int
a Int
m Pico
s
Char
'I' -> do
Int
raw <- Maybe Int
forall a. Read a => Maybe a
External instance of the constraint type Read Int
ra
Int
a <- Int -> Int -> Int -> Maybe Int
forall t. Ord t => t -> t -> t -> Maybe t
External instance of the constraint type Ord Int
clipValid Int
1 Int
12 Int
raw
TimeOfDay -> Maybe TimeOfDay
forall (m :: * -> *) a. Monad m => a -> m a
External instance of the constraint type Monad Maybe
return (TimeOfDay -> Maybe TimeOfDay) -> TimeOfDay -> Maybe TimeOfDay
forall a b. (a -> b) -> a -> b
$ Int -> Int -> Pico -> TimeOfDay
TimeOfDay Int
a Int
m Pico
s
Char
'k' -> do
Int
raw <- Maybe Int
forall a. Read a => Maybe a
External instance of the constraint type Read Int
ra
Int
a <- Int -> Int -> Int -> Maybe Int
forall t. Ord t => t -> t -> t -> Maybe t
External instance of the constraint type Ord Int
clipValid Int
0 Int
23 Int
raw
TimeOfDay -> Maybe TimeOfDay
forall (m :: * -> *) a. Monad m => a -> m a
External instance of the constraint type Monad Maybe
return (TimeOfDay -> Maybe TimeOfDay) -> TimeOfDay -> Maybe TimeOfDay
forall a b. (a -> b) -> a -> b
$ Int -> Int -> Pico -> TimeOfDay
TimeOfDay Int
a Int
m Pico
s
Char
'l' -> do
Int
raw <- Maybe Int
forall a. Read a => Maybe a
External instance of the constraint type Read Int
ra
Int
a <- Int -> Int -> Int -> Maybe Int
forall t. Ord t => t -> t -> t -> Maybe t
External instance of the constraint type Ord Int
clipValid Int
1 Int
12 Int
raw
TimeOfDay -> Maybe TimeOfDay
forall (m :: * -> *) a. Monad m => a -> m a
External instance of the constraint type Monad Maybe
return (TimeOfDay -> Maybe TimeOfDay) -> TimeOfDay -> Maybe TimeOfDay
forall a b. (a -> b) -> a -> b
$ Int -> Int -> Pico -> TimeOfDay
TimeOfDay Int
a Int
m Pico
s
Char
'M' -> do
Int
raw <- Maybe Int
forall a. Read a => Maybe a
External instance of the constraint type Read Int
ra
Int
a <- Int -> Int -> Int -> Maybe Int
forall t. Ord t => t -> t -> t -> Maybe t
External instance of the constraint type Ord Int
clipValid Int
0 Int
59 Int
raw
TimeOfDay -> Maybe TimeOfDay
forall (m :: * -> *) a. Monad m => a -> m a
External instance of the constraint type Monad Maybe
return (TimeOfDay -> Maybe TimeOfDay) -> TimeOfDay -> Maybe TimeOfDay
forall a b. (a -> b) -> a -> b
$ Int -> Int -> Pico -> TimeOfDay
TimeOfDay Int
h Int
a Pico
s
Char
'S' -> do
Integer
raw <- Maybe Integer
forall a. Read a => Maybe a
External instance of the constraint type Read Integer
ra
Integer
a <- Integer -> Integer -> Integer -> Maybe Integer
forall t. Ord t => t -> t -> t -> Maybe t
External instance of the constraint type Ord Integer
clipValid Integer
0 Integer
60 Integer
raw
TimeOfDay -> Maybe TimeOfDay
forall (m :: * -> *) a. Monad m => a -> m a
External instance of the constraint type Monad Maybe
return (TimeOfDay -> Maybe TimeOfDay) -> TimeOfDay -> Maybe TimeOfDay
forall a b. (a -> b) -> a -> b
$ Int -> Int -> Pico -> TimeOfDay
TimeOfDay Int
h Int
m (Integer -> Pico
forall a. Num a => Integer -> a
External instance of the constraint type forall k (a :: k). HasResolution a => Num (Fixed a)
External instance of the constraint type HasResolution E12
fromInteger Integer
a)
Char
'q' -> do
Integer
a <- Maybe Integer
forall a. Read a => Maybe a
External instance of the constraint type Read Integer
ra
TimeOfDay -> Maybe TimeOfDay
forall (m :: * -> *) a. Monad m => a -> m a
External instance of the constraint type Monad Maybe
return (TimeOfDay -> Maybe TimeOfDay) -> TimeOfDay -> Maybe TimeOfDay
forall a b. (a -> b) -> a -> b
$ Int -> Int -> Pico -> TimeOfDay
TimeOfDay Int
h Int
m (Integer -> Integer -> Pico
mkPico (Pico -> Integer
forall a b. (RealFrac a, Integral b) => a -> b
External instance of the constraint type Integral Integer
External instance of the constraint type forall k (a :: k). HasResolution a => RealFrac (Fixed a)
External instance of the constraint type HasResolution E12
floor Pico
s) Integer
a)
Char
'Q' -> if [Char] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
External instance of the constraint type Foldable []
null [Char]
x then TimeOfDay -> Maybe TimeOfDay
forall a. a -> Maybe a
Just TimeOfDay
t else do
Integer
ps <- [Char] -> Maybe Integer
forall a. Read a => [Char] -> Maybe a
External instance of the constraint type Read Integer
readMaybe ([Char] -> Maybe Integer) -> [Char] -> Maybe Integer
forall a b. (a -> b) -> a -> b
$ Int -> [Char] -> [Char]
forall a. Int -> [a] -> [a]
take Int
12 ([Char] -> [Char]) -> [Char] -> [Char]
forall a b. (a -> b) -> a -> b
$ Int -> Char -> [Char] -> [Char]
forall a. Int -> a -> [a] -> [a]
rpad Int
12 Char
'0' ([Char] -> [Char]) -> [Char] -> [Char]
forall a b. (a -> b) -> a -> b
$ Int -> [Char] -> [Char]
forall a. Int -> [a] -> [a]
drop Int
1 [Char]
x
TimeOfDay -> Maybe TimeOfDay
forall (m :: * -> *) a. Monad m => a -> m a
External instance of the constraint type Monad Maybe
return (TimeOfDay -> Maybe TimeOfDay) -> TimeOfDay -> Maybe TimeOfDay
forall a b. (a -> b) -> a -> b
$ Int -> Int -> Pico -> TimeOfDay
TimeOfDay Int
h Int
m (Integer -> Integer -> Pico
mkPico (Pico -> Integer
forall a b. (RealFrac a, Integral b) => a -> b
External instance of the constraint type Integral Integer
External instance of the constraint type forall k (a :: k). HasResolution a => RealFrac (Fixed a)
External instance of the constraint type HasResolution E12
floor Pico
s) Integer
ps)
Char
_ -> TimeOfDay -> Maybe TimeOfDay
forall a. a -> Maybe a
Just TimeOfDay
t
in (TimeOfDay -> (Char, [Char]) -> Maybe TimeOfDay)
-> Maybe TimeOfDay -> [(Char, [Char])] -> Maybe TimeOfDay
forall (m :: * -> *) a b.
Monad m =>
(a -> b -> m a) -> m a -> [b] -> m a
External instance of the constraint type Monad Maybe
mfoldl TimeOfDay -> (Char, [Char]) -> Maybe TimeOfDay
f (TimeOfDay -> Maybe TimeOfDay
forall a. a -> Maybe a
Just TimeOfDay
midnight)
rpad :: Int -> a -> [a] -> [a]
rpad :: Int -> a -> [a] -> [a]
rpad Int
n a
c [a]
xs = [a]
xs [a] -> [a] -> [a]
forall a. [a] -> [a] -> [a]
++ Int -> a -> [a]
forall a. Int -> a -> [a]
replicate (Int
n Int -> Int -> Int
forall a. Num a => a -> a -> a
External instance of the constraint type Num Int
- [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
External instance of the constraint type Foldable []
length [a]
xs) a
c
mkPico :: Integer -> Integer -> Pico
mkPico :: Integer -> Integer -> Pico
mkPico Integer
i Integer
f = Integer -> Pico
forall a. Num a => Integer -> a
External instance of the constraint type forall k (a :: k). HasResolution a => Num (Fixed a)
External instance of the constraint type HasResolution E12
fromInteger Integer
i Pico -> Pico -> Pico
forall a. Num a => a -> a -> a
External instance of the constraint type forall k (a :: k). HasResolution a => Num (Fixed a)
External instance of the constraint type HasResolution E12
+ Rational -> Pico
forall a. Fractional a => Rational -> a
External instance of the constraint type forall k (a :: k). HasResolution a => Fractional (Fixed a)
External instance of the constraint type HasResolution E12
fromRational (Integer
f Integer -> Integer -> Rational
forall a. Integral a => a -> a -> Ratio a
External instance of the constraint type Integral Integer
% Integer
1000000000000)
instance ParseTime LocalTime where
substituteTimeSpecifier :: proxy LocalTime -> TimeLocale -> Char -> Maybe [Char]
substituteTimeSpecifier proxy LocalTime
_ = TimeLocale -> Char -> Maybe [Char]
timeSubstituteTimeSpecifier
parseTimeSpecifier :: proxy LocalTime
-> TimeLocale -> Maybe ParseNumericPadding -> Char -> ReadP [Char]
parseTimeSpecifier proxy LocalTime
_ = TimeLocale -> Maybe ParseNumericPadding -> Char -> ReadP [Char]
timeParseTimeSpecifier
buildTime :: TimeLocale -> [(Char, [Char])] -> Maybe LocalTime
buildTime TimeLocale
l [(Char, [Char])]
xs = Day -> TimeOfDay -> LocalTime
LocalTime (Day -> TimeOfDay -> LocalTime)
-> Maybe Day -> Maybe (TimeOfDay -> LocalTime)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
External instance of the constraint type Functor Maybe
<$> (TimeLocale -> [(Char, [Char])] -> Maybe Day
forall t. ParseTime t => TimeLocale -> [(Char, [Char])] -> Maybe t
Instance of class: ParseTime of the constraint type ParseTime Day
buildTime TimeLocale
l [(Char, [Char])]
xs) Maybe (TimeOfDay -> LocalTime)
-> Maybe TimeOfDay -> Maybe LocalTime
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
External instance of the constraint type Applicative Maybe
<*> (TimeLocale -> [(Char, [Char])] -> Maybe TimeOfDay
forall t. ParseTime t => TimeLocale -> [(Char, [Char])] -> Maybe t
Instance of class: ParseTime of the constraint type ParseTime TimeOfDay
buildTime TimeLocale
l [(Char, [Char])]
xs)
enumDiff :: (Enum a) => a -> a -> Int
enumDiff :: a -> a -> Int
enumDiff a
a a
b = (a -> Int
forall a. Enum a => a -> Int
Evidence bound by a type signature of the constraint type Enum a
fromEnum a
a) Int -> Int -> Int
forall a. Num a => a -> a -> a
External instance of the constraint type Num Int
- (a -> Int
forall a. Enum a => a -> Int
Evidence bound by a type signature of the constraint type Enum a
fromEnum a
b)
getMilZoneHours :: Char -> Maybe Int
getMilZoneHours :: Char -> Maybe Int
getMilZoneHours Char
c | Char
c Char -> Char -> Bool
forall a. Ord a => a -> a -> Bool
External instance of the constraint type Ord Char
< Char
'A' = Maybe Int
forall a. Maybe a
Nothing
getMilZoneHours Char
c | Char
c Char -> Char -> Bool
forall a. Ord a => a -> a -> Bool
External instance of the constraint type Ord Char
<= Char
'I' = Int -> Maybe Int
forall a. a -> Maybe a
Just (Int -> Maybe Int) -> Int -> Maybe Int
forall a b. (a -> b) -> a -> b
$ Int
1 Int -> Int -> Int
forall a. Num a => a -> a -> a
External instance of the constraint type Num Int
+ Char -> Char -> Int
forall a. Enum a => a -> a -> Int
External instance of the constraint type Enum Char
enumDiff Char
c Char
'A'
getMilZoneHours Char
'J' = Maybe Int
forall a. Maybe a
Nothing
getMilZoneHours Char
c | Char
c Char -> Char -> Bool
forall a. Ord a => a -> a -> Bool
External instance of the constraint type Ord Char
<= Char
'M' = Int -> Maybe Int
forall a. a -> Maybe a
Just (Int -> Maybe Int) -> Int -> Maybe Int
forall a b. (a -> b) -> a -> b
$ Int
10 Int -> Int -> Int
forall a. Num a => a -> a -> a
External instance of the constraint type Num Int
+ Char -> Char -> Int
forall a. Enum a => a -> a -> Int
External instance of the constraint type Enum Char
enumDiff Char
c Char
'K'
getMilZoneHours Char
c | Char
c Char -> Char -> Bool
forall a. Ord a => a -> a -> Bool
External instance of the constraint type Ord Char
<= Char
'Y' = Int -> Maybe Int
forall a. a -> Maybe a
Just (Int -> Maybe Int) -> Int -> Maybe Int
forall a b. (a -> b) -> a -> b
$ (Char -> Char -> Int
forall a. Enum a => a -> a -> Int
External instance of the constraint type Enum Char
enumDiff Char
'N' Char
c) Int -> Int -> Int
forall a. Num a => a -> a -> a
External instance of the constraint type Num Int
- Int
1
getMilZoneHours Char
'Z' = Int -> Maybe Int
forall a. a -> Maybe a
Just Int
0
getMilZoneHours Char
_ = Maybe Int
forall a. Maybe a
Nothing
getMilZone :: Char -> Maybe TimeZone
getMilZone :: Char -> Maybe TimeZone
getMilZone Char
c = let
yc :: Char
yc = Char -> Char
toUpper Char
c
in do
Int
hours <- Char -> Maybe Int
getMilZoneHours Char
yc
TimeZone -> Maybe TimeZone
forall (m :: * -> *) a. Monad m => a -> m a
External instance of the constraint type Monad Maybe
return (TimeZone -> Maybe TimeZone) -> TimeZone -> Maybe TimeZone
forall a b. (a -> b) -> a -> b
$ Int -> Bool -> [Char] -> TimeZone
TimeZone (Int
hours Int -> Int -> Int
forall a. Num a => a -> a -> a
External instance of the constraint type Num Int
* Int
60) Bool
False [Char
yc]
getKnownTimeZone :: TimeLocale -> String -> Maybe TimeZone
getKnownTimeZone :: TimeLocale -> [Char] -> Maybe TimeZone
getKnownTimeZone TimeLocale
locale [Char]
x = (TimeZone -> Bool) -> [TimeZone] -> Maybe TimeZone
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Maybe a
External instance of the constraint type Foldable []
find (\TimeZone
tz -> (Char -> Char) -> [Char] -> [Char]
forall a b. (a -> b) -> [a] -> [b]
map Char -> Char
toUpper [Char]
x [Char] -> [Char] -> Bool
forall a. Eq a => a -> a -> Bool
External instance of the constraint type forall a. Eq a => Eq [a]
External instance of the constraint type Eq Char
== TimeZone -> [Char]
timeZoneName TimeZone
tz) (TimeLocale -> [TimeZone]
knownTimeZones TimeLocale
locale)
instance ParseTime TimeZone where
substituteTimeSpecifier :: proxy TimeZone -> TimeLocale -> Char -> Maybe [Char]
substituteTimeSpecifier proxy TimeZone
_ = TimeLocale -> Char -> Maybe [Char]
timeSubstituteTimeSpecifier
parseTimeSpecifier :: proxy TimeZone
-> TimeLocale -> Maybe ParseNumericPadding -> Char -> ReadP [Char]
parseTimeSpecifier proxy TimeZone
_ = TimeLocale -> Maybe ParseNumericPadding -> Char -> ReadP [Char]
timeParseTimeSpecifier
buildTime :: TimeLocale -> [(Char, [Char])] -> Maybe TimeZone
buildTime TimeLocale
l = let
f :: Char -> String -> TimeZone -> Maybe TimeZone
f :: Char -> [Char] -> TimeZone -> Maybe TimeZone
f Char
'z' [Char]
str (TimeZone Int
_ Bool
dst [Char]
name) | Just Int
offset <- [Char] -> Maybe Int
readTzOffset [Char]
str = TimeZone -> Maybe TimeZone
forall a. a -> Maybe a
Just (TimeZone -> Maybe TimeZone) -> TimeZone -> Maybe TimeZone
forall a b. (a -> b) -> a -> b
$ Int -> Bool -> [Char] -> TimeZone
TimeZone Int
offset Bool
dst [Char]
name
f Char
'z' [Char]
_ TimeZone
_ = Maybe TimeZone
forall a. Maybe a
Nothing
f Char
'Z' [Char]
str TimeZone
_ | Just Int
offset <- [Char] -> Maybe Int
readTzOffset [Char]
str = TimeZone -> Maybe TimeZone
forall a. a -> Maybe a
Just (TimeZone -> Maybe TimeZone) -> TimeZone -> Maybe TimeZone
forall a b. (a -> b) -> a -> b
$ Int -> Bool -> [Char] -> TimeZone
TimeZone Int
offset Bool
False [Char]
""
f Char
'Z' [Char]
str TimeZone
_ | Just TimeZone
zone <- TimeLocale -> [Char] -> Maybe TimeZone
getKnownTimeZone TimeLocale
l [Char]
str = TimeZone -> Maybe TimeZone
forall a. a -> Maybe a
Just TimeZone
zone
f Char
'Z' [Char]
"UTC" TimeZone
_ = TimeZone -> Maybe TimeZone
forall a. a -> Maybe a
Just TimeZone
utc
f Char
'Z' [Char
c] TimeZone
_ | Just TimeZone
zone <- Char -> Maybe TimeZone
getMilZone Char
c = TimeZone -> Maybe TimeZone
forall a. a -> Maybe a
Just TimeZone
zone
f Char
'Z' [Char]
_ TimeZone
_ = Maybe TimeZone
forall a. Maybe a
Nothing
f Char
_ [Char]
_ TimeZone
tz = TimeZone -> Maybe TimeZone
forall a. a -> Maybe a
Just TimeZone
tz
in (Maybe TimeZone -> (Char, [Char]) -> Maybe TimeZone)
-> Maybe TimeZone -> [(Char, [Char])] -> Maybe TimeZone
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
External instance of the constraint type Foldable []
foldl (\Maybe TimeZone
mt (Char
c,[Char]
s) -> Maybe TimeZone
mt Maybe TimeZone -> (TimeZone -> Maybe TimeZone) -> Maybe TimeZone
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
External instance of the constraint type Monad Maybe
>>= Char -> [Char] -> TimeZone -> Maybe TimeZone
f Char
c [Char]
s) (TimeZone -> Maybe TimeZone
forall a. a -> Maybe a
Just (TimeZone -> Maybe TimeZone) -> TimeZone -> Maybe TimeZone
forall a b. (a -> b) -> a -> b
$ Int -> TimeZone
minutesToTimeZone Int
0)
readTzOffset :: String -> Maybe Int
readTzOffset :: [Char] -> Maybe Int
readTzOffset [Char]
str = let
getSign :: Char -> Maybe a
getSign Char
'+' = a -> Maybe a
forall a. a -> Maybe a
Just a
1
getSign Char
'-' = a -> Maybe a
forall a. a -> Maybe a
Just (-a
1)
getSign Char
_ = Maybe a
forall a. Maybe a
Nothing
calc :: Char -> Char -> Char -> Char -> Char -> Maybe b
calc Char
s Char
h1 Char
h2 Char
m1 Char
m2 = do
b
sign <- Char -> Maybe b
forall {a}. Num a => Char -> Maybe a
Evidence bound by a type signature of the constraint type Num b
getSign Char
s
b
h <- [Char] -> Maybe b
forall a. Read a => [Char] -> Maybe a
Evidence bound by a type signature of the constraint type Read b
readMaybe [Char
h1,Char
h2]
b
m <- [Char] -> Maybe b
forall a. Read a => [Char] -> Maybe a
Evidence bound by a type signature of the constraint type Read b
readMaybe [Char
m1,Char
m2]
b -> Maybe b
forall (m :: * -> *) a. Monad m => a -> m a
External instance of the constraint type Monad Maybe
return (b -> Maybe b) -> b -> Maybe b
forall a b. (a -> b) -> a -> b
$ b
sign b -> b -> b
forall a. Num a => a -> a -> a
Evidence bound by a type signature of the constraint type Num b
* (b
60 b -> b -> b
forall a. Num a => a -> a -> a
Evidence bound by a type signature of the constraint type Num b
* b
h b -> b -> b
forall a. Num a => a -> a -> a
Evidence bound by a type signature of the constraint type Num b
+ b
m)
in case [Char]
str of
(Char
s:Char
h1:Char
h2:Char
':':Char
m1:Char
m2:[]) -> Char -> Char -> Char -> Char -> Char -> Maybe Int
forall {b}.
(Num b, Read b) =>
Char -> Char -> Char -> Char -> Char -> Maybe b
External instance of the constraint type Read Int
External instance of the constraint type Num Int
calc Char
s Char
h1 Char
h2 Char
m1 Char
m2
(Char
s:Char
h1:Char
h2:Char
m1:Char
m2:[]) -> Char -> Char -> Char -> Char -> Char -> Maybe Int
forall {b}.
(Num b, Read b) =>
Char -> Char -> Char -> Char -> Char -> Maybe b
External instance of the constraint type Read Int
External instance of the constraint type Num Int
calc Char
s Char
h1 Char
h2 Char
m1 Char
m2
[Char]
_ -> Maybe Int
forall a. Maybe a
Nothing
instance ParseTime ZonedTime where
substituteTimeSpecifier :: proxy ZonedTime -> TimeLocale -> Char -> Maybe [Char]
substituteTimeSpecifier proxy ZonedTime
_ = TimeLocale -> Char -> Maybe [Char]
timeSubstituteTimeSpecifier
parseTimeSpecifier :: proxy ZonedTime
-> TimeLocale -> Maybe ParseNumericPadding -> Char -> ReadP [Char]
parseTimeSpecifier proxy ZonedTime
_ = TimeLocale -> Maybe ParseNumericPadding -> Char -> ReadP [Char]
timeParseTimeSpecifier
buildTime :: TimeLocale -> [(Char, [Char])] -> Maybe ZonedTime
buildTime TimeLocale
l [(Char, [Char])]
xs = let
f :: ZonedTime -> (Char, [Char]) -> Maybe ZonedTime
f (ZonedTime (LocalTime Day
_ TimeOfDay
tod) TimeZone
z) (Char
's',[Char]
x) = do
Integer
a <- [Char] -> Maybe Integer
forall a. Read a => [Char] -> Maybe a
External instance of the constraint type Read Integer
readMaybe [Char]
x
let
s :: NominalDiffTime
s = Integer -> NominalDiffTime
forall a. Num a => Integer -> a
External instance of the constraint type Num NominalDiffTime
fromInteger Integer
a
(Integer
_,Pico
ps) = Pico -> (Integer, Pico)
forall a b. (RealFrac a, Integral b) => a -> (b, a)
External instance of the constraint type Integral Integer
External instance of the constraint type forall k (a :: k). HasResolution a => RealFrac (Fixed a)
External instance of the constraint type HasResolution E12
properFraction (TimeOfDay -> Pico
todSec TimeOfDay
tod) :: (Integer,Pico)
s' :: NominalDiffTime
s' = NominalDiffTime
s NominalDiffTime -> NominalDiffTime -> NominalDiffTime
forall a. Num a => a -> a -> a
External instance of the constraint type Num NominalDiffTime
+ Rational -> NominalDiffTime
forall a. Fractional a => Rational -> a
External instance of the constraint type Fractional NominalDiffTime
fromRational (Pico -> Rational
forall a. Real a => a -> Rational
External instance of the constraint type forall k (a :: k). HasResolution a => Real (Fixed a)
External instance of the constraint type HasResolution E12
toRational Pico
ps)
ZonedTime -> Maybe ZonedTime
forall (m :: * -> *) a. Monad m => a -> m a
External instance of the constraint type Monad Maybe
return (ZonedTime -> Maybe ZonedTime) -> ZonedTime -> Maybe ZonedTime
forall a b. (a -> b) -> a -> b
$ TimeZone -> UTCTime -> ZonedTime
utcToZonedTime TimeZone
z (NominalDiffTime -> UTCTime
posixSecondsToUTCTime NominalDiffTime
s')
f ZonedTime
t (Char, [Char])
_ = ZonedTime -> Maybe ZonedTime
forall a. a -> Maybe a
Just ZonedTime
t
in (ZonedTime -> (Char, [Char]) -> Maybe ZonedTime)
-> Maybe ZonedTime -> [(Char, [Char])] -> Maybe ZonedTime
forall (m :: * -> *) a b.
Monad m =>
(a -> b -> m a) -> m a -> [b] -> m a
External instance of the constraint type Monad Maybe
mfoldl ZonedTime -> (Char, [Char]) -> Maybe ZonedTime
f (LocalTime -> TimeZone -> ZonedTime
ZonedTime (LocalTime -> TimeZone -> ZonedTime)
-> Maybe LocalTime -> Maybe (TimeZone -> ZonedTime)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
External instance of the constraint type Functor Maybe
<$> (TimeLocale -> [(Char, [Char])] -> Maybe LocalTime
forall t. ParseTime t => TimeLocale -> [(Char, [Char])] -> Maybe t
Instance of class: ParseTime of the constraint type ParseTime LocalTime
buildTime TimeLocale
l [(Char, [Char])]
xs) Maybe (TimeZone -> ZonedTime) -> Maybe TimeZone -> Maybe ZonedTime
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
External instance of the constraint type Applicative Maybe
<*> (TimeLocale -> [(Char, [Char])] -> Maybe TimeZone
forall t. ParseTime t => TimeLocale -> [(Char, [Char])] -> Maybe t
Instance of class: ParseTime of the constraint type ParseTime TimeZone
buildTime TimeLocale
l [(Char, [Char])]
xs)) [(Char, [Char])]
xs
instance ParseTime UTCTime where
substituteTimeSpecifier :: proxy UTCTime -> TimeLocale -> Char -> Maybe [Char]
substituteTimeSpecifier proxy UTCTime
_ = TimeLocale -> Char -> Maybe [Char]
timeSubstituteTimeSpecifier
parseTimeSpecifier :: proxy UTCTime
-> TimeLocale -> Maybe ParseNumericPadding -> Char -> ReadP [Char]
parseTimeSpecifier proxy UTCTime
_ = TimeLocale -> Maybe ParseNumericPadding -> Char -> ReadP [Char]
timeParseTimeSpecifier
buildTime :: TimeLocale -> [(Char, [Char])] -> Maybe UTCTime
buildTime TimeLocale
l [(Char, [Char])]
xs = ZonedTime -> UTCTime
zonedTimeToUTC (ZonedTime -> UTCTime) -> Maybe ZonedTime -> Maybe UTCTime
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
External instance of the constraint type Functor Maybe
<$> TimeLocale -> [(Char, [Char])] -> Maybe ZonedTime
forall t. ParseTime t => TimeLocale -> [(Char, [Char])] -> Maybe t
Instance of class: ParseTime of the constraint type ParseTime ZonedTime
buildTime TimeLocale
l [(Char, [Char])]
xs
instance ParseTime UniversalTime where
substituteTimeSpecifier :: proxy UniversalTime -> TimeLocale -> Char -> Maybe [Char]
substituteTimeSpecifier proxy UniversalTime
_ = TimeLocale -> Char -> Maybe [Char]
timeSubstituteTimeSpecifier
parseTimeSpecifier :: proxy UniversalTime
-> TimeLocale -> Maybe ParseNumericPadding -> Char -> ReadP [Char]
parseTimeSpecifier proxy UniversalTime
_ = TimeLocale -> Maybe ParseNumericPadding -> Char -> ReadP [Char]
timeParseTimeSpecifier
buildTime :: TimeLocale -> [(Char, [Char])] -> Maybe UniversalTime
buildTime TimeLocale
l [(Char, [Char])]
xs = Rational -> LocalTime -> UniversalTime
localTimeToUT1 Rational
0 (LocalTime -> UniversalTime)
-> Maybe LocalTime -> Maybe UniversalTime
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
External instance of the constraint type Functor Maybe
<$> TimeLocale -> [(Char, [Char])] -> Maybe LocalTime
forall t. ParseTime t => TimeLocale -> [(Char, [Char])] -> Maybe t
Instance of class: ParseTime of the constraint type ParseTime LocalTime
buildTime TimeLocale
l [(Char, [Char])]
xs
buildTimeMonths :: [(Char,String)] -> Maybe Integer
buildTimeMonths :: [(Char, [Char])] -> Maybe Integer
buildTimeMonths [(Char, [Char])]
xs = do
[Integer]
tt <- [(Char, [Char])]
-> ((Char, [Char]) -> Maybe Integer) -> Maybe [Integer]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
t a -> (a -> f b) -> f (t b)
External instance of the constraint type Applicative Maybe
External instance of the constraint type Traversable []
for [(Char, [Char])]
xs (((Char, [Char]) -> Maybe Integer) -> Maybe [Integer])
-> ((Char, [Char]) -> Maybe Integer) -> Maybe [Integer]
forall a b. (a -> b) -> a -> b
$ \(Char
c,[Char]
s) -> case Char
c of
Char
'y' -> (Integer -> Integer) -> Maybe Integer -> Maybe Integer
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
External instance of the constraint type Functor Maybe
fmap (Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
External instance of the constraint type Num Integer
(*) Integer
12) (Maybe Integer -> Maybe Integer) -> Maybe Integer -> Maybe Integer
forall a b. (a -> b) -> a -> b
$ [Char] -> Maybe Integer
forall a. Read a => [Char] -> Maybe a
External instance of the constraint type Read Integer
readMaybe [Char]
s
Char
'b' -> [Char] -> Maybe Integer
forall a. Read a => [Char] -> Maybe a
External instance of the constraint type Read Integer
readMaybe [Char]
s
Char
'B' -> [Char] -> Maybe Integer
forall a. Read a => [Char] -> Maybe a
External instance of the constraint type Read Integer
readMaybe [Char]
s
Char
_ -> Integer -> Maybe Integer
forall (m :: * -> *) a. Monad m => a -> m a
External instance of the constraint type Monad Maybe
return Integer
0
Integer -> Maybe Integer
forall (m :: * -> *) a. Monad m => a -> m a
External instance of the constraint type Monad Maybe
return (Integer -> Maybe Integer) -> Integer -> Maybe Integer
forall a b. (a -> b) -> a -> b
$ [Integer] -> Integer
forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
External instance of the constraint type Num Integer
External instance of the constraint type Foldable []
sum [Integer]
tt
buildTimeDays :: [(Char,String)] -> Maybe Integer
buildTimeDays :: [(Char, [Char])] -> Maybe Integer
buildTimeDays [(Char, [Char])]
xs = do
[Integer]
tt <- [(Char, [Char])]
-> ((Char, [Char]) -> Maybe Integer) -> Maybe [Integer]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
t a -> (a -> f b) -> f (t b)
External instance of the constraint type Applicative Maybe
External instance of the constraint type Traversable []
for [(Char, [Char])]
xs (((Char, [Char]) -> Maybe Integer) -> Maybe [Integer])
-> ((Char, [Char]) -> Maybe Integer) -> Maybe [Integer]
forall a b. (a -> b) -> a -> b
$ \(Char
c,[Char]
s) -> case Char
c of
Char
'w' -> (Integer -> Integer) -> Maybe Integer -> Maybe Integer
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
External instance of the constraint type Functor Maybe
fmap (Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
External instance of the constraint type Num Integer
(*) Integer
7) (Maybe Integer -> Maybe Integer) -> Maybe Integer -> Maybe Integer
forall a b. (a -> b) -> a -> b
$ [Char] -> Maybe Integer
forall a. Read a => [Char] -> Maybe a
External instance of the constraint type Read Integer
readMaybe [Char]
s
Char
'd' -> [Char] -> Maybe Integer
forall a. Read a => [Char] -> Maybe a
External instance of the constraint type Read Integer
readMaybe [Char]
s
Char
'D' -> [Char] -> Maybe Integer
forall a. Read a => [Char] -> Maybe a
External instance of the constraint type Read Integer
readMaybe [Char]
s
Char
_ -> Integer -> Maybe Integer
forall (m :: * -> *) a. Monad m => a -> m a
External instance of the constraint type Monad Maybe
return Integer
0
Integer -> Maybe Integer
forall (m :: * -> *) a. Monad m => a -> m a
External instance of the constraint type Monad Maybe
return (Integer -> Maybe Integer) -> Integer -> Maybe Integer
forall a b. (a -> b) -> a -> b
$ [Integer] -> Integer
forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
External instance of the constraint type Num Integer
External instance of the constraint type Foldable []
sum [Integer]
tt
buildTimeSeconds :: [(Char,String)] -> Maybe Pico
buildTimeSeconds :: [(Char, [Char])] -> Maybe Pico
buildTimeSeconds [(Char, [Char])]
xs = do
[Pico]
tt <- [(Char, [Char])] -> ((Char, [Char]) -> Maybe Pico) -> Maybe [Pico]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
t a -> (a -> f b) -> f (t b)
External instance of the constraint type Applicative Maybe
External instance of the constraint type Traversable []
for [(Char, [Char])]
xs (((Char, [Char]) -> Maybe Pico) -> Maybe [Pico])
-> ((Char, [Char]) -> Maybe Pico) -> Maybe [Pico]
forall a b. (a -> b) -> a -> b
$ \(Char
c,[Char]
s) -> let
readInt :: Integer -> Maybe Pico
readInt :: Integer -> Maybe Pico
readInt Integer
t = do
Integer
i <- [Char] -> Maybe Integer
forall a. Read a => [Char] -> Maybe a
External instance of the constraint type Read Integer
readMaybe [Char]
s
Pico -> Maybe Pico
forall (m :: * -> *) a. Monad m => a -> m a
External instance of the constraint type Monad Maybe
return (Pico -> Maybe Pico) -> Pico -> Maybe Pico
forall a b. (a -> b) -> a -> b
$ Integer -> Pico
forall a. Num a => Integer -> a
External instance of the constraint type forall k (a :: k). HasResolution a => Num (Fixed a)
External instance of the constraint type HasResolution E12
fromInteger (Integer -> Pico) -> Integer -> Pico
forall a b. (a -> b) -> a -> b
$ Integer
i Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
External instance of the constraint type Num Integer
* Integer
t
in case Char
c of
Char
'h' -> Integer -> Maybe Pico
readInt Integer
3600
Char
'H' -> Integer -> Maybe Pico
readInt Integer
3600
Char
'm' -> Integer -> Maybe Pico
readInt Integer
60
Char
'M' -> Integer -> Maybe Pico
readInt Integer
60
Char
's' -> [Char] -> Maybe Pico
forall a. Read a => [Char] -> Maybe a
External instance of the constraint type forall k (a :: k). HasResolution a => Read (Fixed a)
External instance of the constraint type HasResolution E12
readMaybe [Char]
s
Char
'S' -> [Char] -> Maybe Pico
forall a. Read a => [Char] -> Maybe a
External instance of the constraint type forall k (a :: k). HasResolution a => Read (Fixed a)
External instance of the constraint type HasResolution E12
readMaybe [Char]
s
Char
_ -> Pico -> Maybe Pico
forall (m :: * -> *) a. Monad m => a -> m a
External instance of the constraint type Monad Maybe
return Pico
0
Pico -> Maybe Pico
forall (m :: * -> *) a. Monad m => a -> m a
External instance of the constraint type Monad Maybe
return (Pico -> Maybe Pico) -> Pico -> Maybe Pico
forall a b. (a -> b) -> a -> b
$ [Pico] -> Pico
forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
External instance of the constraint type forall k (a :: k). HasResolution a => Num (Fixed a)
External instance of the constraint type HasResolution E12
External instance of the constraint type Foldable []
sum [Pico]
tt
instance ParseTime NominalDiffTime where
parseTimeSpecifier :: proxy NominalDiffTime
-> TimeLocale -> Maybe ParseNumericPadding -> Char -> ReadP [Char]
parseTimeSpecifier proxy NominalDiffTime
_ = TimeLocale -> Maybe ParseNumericPadding -> Char -> ReadP [Char]
durationParseTimeSpecifier
buildTime :: TimeLocale -> [(Char, [Char])] -> Maybe NominalDiffTime
buildTime TimeLocale
_ [(Char, [Char])]
xs = do
Integer
dd <- [(Char, [Char])] -> Maybe Integer
buildTimeDays [(Char, [Char])]
xs
Pico
tt <- [(Char, [Char])] -> Maybe Pico
buildTimeSeconds [(Char, [Char])]
xs
NominalDiffTime -> Maybe NominalDiffTime
forall (m :: * -> *) a. Monad m => a -> m a
External instance of the constraint type Monad Maybe
return (NominalDiffTime -> Maybe NominalDiffTime)
-> NominalDiffTime -> Maybe NominalDiffTime
forall a b. (a -> b) -> a -> b
$ (Integer -> NominalDiffTime
forall a. Num a => Integer -> a
External instance of the constraint type Num NominalDiffTime
fromInteger Integer
dd NominalDiffTime -> NominalDiffTime -> NominalDiffTime
forall a. Num a => a -> a -> a
External instance of the constraint type Num NominalDiffTime
* NominalDiffTime
86400) NominalDiffTime -> NominalDiffTime -> NominalDiffTime
forall a. Num a => a -> a -> a
External instance of the constraint type Num NominalDiffTime
+ Pico -> NominalDiffTime
forall a b. (Real a, Fractional b) => a -> b
External instance of the constraint type Fractional NominalDiffTime
External instance of the constraint type forall k (a :: k). HasResolution a => Real (Fixed a)
External instance of the constraint type HasResolution E12
realToFrac Pico
tt
instance ParseTime DiffTime where
parseTimeSpecifier :: proxy DiffTime
-> TimeLocale -> Maybe ParseNumericPadding -> Char -> ReadP [Char]
parseTimeSpecifier proxy DiffTime
_ = TimeLocale -> Maybe ParseNumericPadding -> Char -> ReadP [Char]
durationParseTimeSpecifier
buildTime :: TimeLocale -> [(Char, [Char])] -> Maybe DiffTime
buildTime TimeLocale
_ [(Char, [Char])]
xs = do
Integer
dd <- [(Char, [Char])] -> Maybe Integer
buildTimeDays [(Char, [Char])]
xs
Pico
tt <- [(Char, [Char])] -> Maybe Pico
buildTimeSeconds [(Char, [Char])]
xs
DiffTime -> Maybe DiffTime
forall (m :: * -> *) a. Monad m => a -> m a
External instance of the constraint type Monad Maybe
return (DiffTime -> Maybe DiffTime) -> DiffTime -> Maybe DiffTime
forall a b. (a -> b) -> a -> b
$ (Integer -> DiffTime
forall a. Num a => Integer -> a
External instance of the constraint type Num DiffTime
fromInteger Integer
dd DiffTime -> DiffTime -> DiffTime
forall a. Num a => a -> a -> a
External instance of the constraint type Num DiffTime
* DiffTime
86400) DiffTime -> DiffTime -> DiffTime
forall a. Num a => a -> a -> a
External instance of the constraint type Num DiffTime
+ Pico -> DiffTime
forall a b. (Real a, Fractional b) => a -> b
External instance of the constraint type Fractional DiffTime
External instance of the constraint type forall k (a :: k). HasResolution a => Real (Fixed a)
External instance of the constraint type HasResolution E12
realToFrac Pico
tt
instance ParseTime CalendarDiffDays where
parseTimeSpecifier :: proxy CalendarDiffDays
-> TimeLocale -> Maybe ParseNumericPadding -> Char -> ReadP [Char]
parseTimeSpecifier proxy CalendarDiffDays
_ = TimeLocale -> Maybe ParseNumericPadding -> Char -> ReadP [Char]
durationParseTimeSpecifier
buildTime :: TimeLocale -> [(Char, [Char])] -> Maybe CalendarDiffDays
buildTime TimeLocale
_ [(Char, [Char])]
xs = do
Integer
mm <- [(Char, [Char])] -> Maybe Integer
buildTimeMonths [(Char, [Char])]
xs
Integer
dd <- [(Char, [Char])] -> Maybe Integer
buildTimeDays [(Char, [Char])]
xs
CalendarDiffDays -> Maybe CalendarDiffDays
forall (m :: * -> *) a. Monad m => a -> m a
External instance of the constraint type Monad Maybe
return (CalendarDiffDays -> Maybe CalendarDiffDays)
-> CalendarDiffDays -> Maybe CalendarDiffDays
forall a b. (a -> b) -> a -> b
$ Integer -> Integer -> CalendarDiffDays
CalendarDiffDays Integer
mm Integer
dd
instance ParseTime CalendarDiffTime where
parseTimeSpecifier :: proxy CalendarDiffTime
-> TimeLocale -> Maybe ParseNumericPadding -> Char -> ReadP [Char]
parseTimeSpecifier proxy CalendarDiffTime
_ = TimeLocale -> Maybe ParseNumericPadding -> Char -> ReadP [Char]
durationParseTimeSpecifier
buildTime :: TimeLocale -> [(Char, [Char])] -> Maybe CalendarDiffTime
buildTime TimeLocale
locale [(Char, [Char])]
xs = do
Integer
mm <- [(Char, [Char])] -> Maybe Integer
buildTimeMonths [(Char, [Char])]
xs
NominalDiffTime
tt <- TimeLocale -> [(Char, [Char])] -> Maybe NominalDiffTime
forall t. ParseTime t => TimeLocale -> [(Char, [Char])] -> Maybe t
Instance of class: ParseTime of the constraint type ParseTime NominalDiffTime
buildTime TimeLocale
locale [(Char, [Char])]
xs
CalendarDiffTime -> Maybe CalendarDiffTime
forall (m :: * -> *) a. Monad m => a -> m a
External instance of the constraint type Monad Maybe
return (CalendarDiffTime -> Maybe CalendarDiffTime)
-> CalendarDiffTime -> Maybe CalendarDiffTime
forall a b. (a -> b) -> a -> b
$ Integer -> NominalDiffTime -> CalendarDiffTime
CalendarDiffTime Integer
mm NominalDiffTime
tt