module Data.HodaTime.TimeZone.ParseTZ
(
parsePosixString
)
where
import Data.HodaTime.TimeZone.Internal
import Data.HodaTime.Offset.Internal (Offset(..))
import Control.Applicative
import Text.Parsec hiding (many, optional, (<|>))
type ExpParser = Parsec String ()
parsePosixString :: String -> (Either TransitionInfo TransitionExpressionInfo)
parsePosixString :: String -> Either TransitionInfo TransitionExpressionInfo
parsePosixString String
tzStr = case Parsec String () (Either TransitionInfo TransitionExpressionInfo)
-> ()
-> String
-> String
-> Either
ParseError (Either TransitionInfo TransitionExpressionInfo)
forall s t u a.
Stream s Identity t =>
Parsec s u a -> u -> String -> s -> Either ParseError a
runParser Parsec String () (Either TransitionInfo TransitionExpressionInfo)
p_posixTzString () String
tzStr String
tzStr of
Left ParseError
err -> String -> Either TransitionInfo TransitionExpressionInfo
forall a. HasCallStack => String -> a
error (String -> Either TransitionInfo TransitionExpressionInfo)
-> String -> Either TransitionInfo TransitionExpressionInfo
forall a b. (a -> b) -> a -> b
$ ParseError -> String
forall a. Show a => a -> String
show ParseError
err
Right Either TransitionInfo TransitionExpressionInfo
r -> Either TransitionInfo TransitionExpressionInfo
r
p_posixTzString :: ExpParser (Either TransitionInfo TransitionExpressionInfo)
p_posixTzString :: Parsec String () (Either TransitionInfo TransitionExpressionInfo)
p_posixTzString = do
String
stdID <- ExpParser String
p_tzIdentifier ExpParser String -> String -> ExpParser String
forall s u (m :: * -> *) a.
ParsecT s u m a -> String -> ParsecT s u m a
<?> String
"Standard TZ identifier"
Offset
stdOffset <- ExpParser Offset
p_offset ExpParser Offset -> String -> ExpParser Offset
forall s u (m :: * -> *) a.
ParsecT s u m a -> String -> ParsecT s u m a
<?> String
"TZ Offset"
String
-> Offset
-> Parsec
String () (Either TransitionInfo TransitionExpressionInfo)
p_dstExpression String
stdID Offset
stdOffset Parsec String () (Either TransitionInfo TransitionExpressionInfo)
-> Parsec
String () (Either TransitionInfo TransitionExpressionInfo)
-> Parsec
String () (Either TransitionInfo TransitionExpressionInfo)
forall a.
ParsecT String () Identity a
-> ParsecT String () Identity a -> ParsecT String () Identity a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (Either TransitionInfo TransitionExpressionInfo
-> Parsec
String () (Either TransitionInfo TransitionExpressionInfo)
forall a. a -> ParsecT String () Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Either TransitionInfo TransitionExpressionInfo
-> Parsec
String () (Either TransitionInfo TransitionExpressionInfo))
-> (String -> Either TransitionInfo TransitionExpressionInfo)
-> String
-> Parsec
String () (Either TransitionInfo TransitionExpressionInfo)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TransitionInfo -> Either TransitionInfo TransitionExpressionInfo
forall a b. a -> Either a b
Left (TransitionInfo -> Either TransitionInfo TransitionExpressionInfo)
-> (String -> TransitionInfo)
-> String
-> Either TransitionInfo TransitionExpressionInfo
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Offset -> Bool -> String -> TransitionInfo
TransitionInfo Offset
stdOffset Bool
False (String
-> Parsec
String () (Either TransitionInfo TransitionExpressionInfo))
-> String
-> Parsec
String () (Either TransitionInfo TransitionExpressionInfo)
forall a b. (a -> b) -> a -> b
$ String
stdID)
p_dstExpression :: String -> Offset -> ExpParser (Either TransitionInfo TransitionExpressionInfo)
p_dstExpression :: String
-> Offset
-> Parsec
String () (Either TransitionInfo TransitionExpressionInfo)
p_dstExpression String
stdID stdOffset :: Offset
stdOffset@(Offset Int
stdOffsetSecs) = do
String
dstID <- ExpParser String
p_tzIdentifier
Offset
dstOffset <- Offset -> ExpParser Offset -> ExpParser Offset
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option (Int -> Offset
Offset (Int -> Offset) -> Int -> Offset
forall a b. (a -> b) -> a -> b
$ Int
stdOffsetSecs Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int -> Int
toHour Int
1) ExpParser Offset
p_offset
TransitionExpression
startExpr <- Char -> ParsecT String () Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
',' ParsecT String () Identity Char
-> ParsecT String () Identity TransitionExpression
-> ParsecT String () Identity TransitionExpression
forall a b.
ParsecT String () Identity a
-> ParsecT String () Identity b -> ParsecT String () Identity b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Int -> ParsecT String () Identity TransitionExpression
p_transitionExpression Int
stdOffsetSecs
TransitionExpression
endExpr <- Char -> ParsecT String () Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
',' ParsecT String () Identity Char
-> ParsecT String () Identity TransitionExpression
-> ParsecT String () Identity TransitionExpression
forall a b.
ParsecT String () Identity a
-> ParsecT String () Identity b -> ParsecT String () Identity b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Int -> ParsecT String () Identity TransitionExpression
p_transitionExpression (Offset -> Int
toOffsetSecs Offset
dstOffset)
let stdTI :: TransitionInfo
stdTI = Offset -> Bool -> String -> TransitionInfo
TransitionInfo Offset
stdOffset Bool
False String
stdID
let dstTI :: TransitionInfo
dstTI = Offset -> Bool -> String -> TransitionInfo
TransitionInfo Offset
dstOffset Bool
True String
dstID
Either TransitionInfo TransitionExpressionInfo
-> Parsec
String () (Either TransitionInfo TransitionExpressionInfo)
forall a. a -> ParsecT String () Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Either TransitionInfo TransitionExpressionInfo
-> Parsec
String () (Either TransitionInfo TransitionExpressionInfo))
-> (TransitionExpressionInfo
-> Either TransitionInfo TransitionExpressionInfo)
-> TransitionExpressionInfo
-> Parsec
String () (Either TransitionInfo TransitionExpressionInfo)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TransitionExpressionInfo
-> Either TransitionInfo TransitionExpressionInfo
forall a b. b -> Either a b
Right (TransitionExpressionInfo
-> Parsec
String () (Either TransitionInfo TransitionExpressionInfo))
-> TransitionExpressionInfo
-> Parsec
String () (Either TransitionInfo TransitionExpressionInfo)
forall a b. (a -> b) -> a -> b
$ TransitionExpression
-> TransitionExpression
-> TransitionInfo
-> TransitionInfo
-> TransitionExpressionInfo
TransitionExpressionInfo TransitionExpression
startExpr TransitionExpression
endExpr TransitionInfo
stdTI TransitionInfo
dstTI
where
toOffsetSecs :: Offset -> Int
toOffsetSecs (Offset Int
secs) = Int
secs
p_tzIdentifier :: ExpParser String
p_tzIdentifier :: ExpParser String
p_tzIdentifier = ExpParser String
p_tzSpecialIdentifier ExpParser String -> ExpParser String -> ExpParser String
forall a.
ParsecT String () Identity a
-> ParsecT String () Identity a -> ParsecT String () Identity a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> ExpParser String
p_tzNormalIdentifier
p_tzSpecialIdentifier :: ExpParser String
p_tzSpecialIdentifier :: ExpParser String
p_tzSpecialIdentifier = do
String
idt <- Char -> ParsecT String () Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'<' ParsecT String () Identity Char
-> ExpParser String -> ExpParser String
forall a b.
ParsecT String () Identity a
-> ParsecT String () Identity b -> ParsecT String () Identity b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ParsecT String () Identity Char -> ExpParser String
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m [a]
many1 (String -> ParsecT String () Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m Char
noneOf String
">")
(String
"<" String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
idt String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
">") String -> ParsecT String () Identity Char -> ExpParser String
forall a b.
a -> ParsecT String () Identity b -> ParsecT String () Identity a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Char -> ParsecT String () Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'>'
p_tzNormalIdentifier :: ExpParser String
p_tzNormalIdentifier :: ExpParser String
p_tzNormalIdentifier = do
String
start <- Int -> ParsecT String () Identity Char -> ExpParser String
forall s (m :: * -> *) t u a.
Stream s m t =>
Int -> ParsecT s u m a -> ParsecT s u m [a]
count Int
3 ParsecT String () Identity Char
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
letter
String
rest <- ParsecT String () Identity Char -> ExpParser String
forall a.
ParsecT String () Identity a -> ParsecT String () Identity [a]
forall (f :: * -> *) a. Alternative f => f a -> f [a]
many (ParsecT String () Identity Char -> ExpParser String)
-> (String -> ParsecT String () Identity Char)
-> String
-> ExpParser String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ParsecT String () Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m Char
noneOf (String -> ExpParser String) -> String -> ExpParser String
forall a b. (a -> b) -> a -> b
$ String
":,+-" String -> String -> String
forall a. [a] -> [a] -> [a]
++ [Char
'0'..Char
'9']
String -> ExpParser String
forall a. a -> ParsecT String () Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (String -> ExpParser String) -> String -> ExpParser String
forall a b. (a -> b) -> a -> b
$ String
start String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
rest
p_offset :: ExpParser Offset
p_offset :: ExpParser Offset
p_offset = Int -> Offset
Offset (Int -> Offset) -> (Int -> Int) -> Int -> Offset
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Int
forall a. Num a => a -> a
negate (Int -> Offset)
-> ParsecT String () Identity Int -> ExpParser Offset
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT String () Identity Int
p_time
p_time :: ExpParser Int
p_time :: ParsecT String () Identity Int
p_time = do
Int -> Int
sign <- (Int -> Int
forall a. Num a => a -> a
negate (Int -> Int)
-> ParsecT String () Identity Char
-> ParsecT String () Identity (Int -> Int)
forall a b.
a -> ParsecT String () Identity b -> ParsecT String () Identity a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Char -> ParsecT String () Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'-') ParsecT String () Identity (Int -> Int)
-> ParsecT String () Identity (Int -> Int)
-> ParsecT String () Identity (Int -> Int)
forall a.
ParsecT String () Identity a
-> ParsecT String () Identity a -> ParsecT String () Identity a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> ((Int -> Int)
-> ParsecT String () Identity (Int -> Int)
-> ParsecT String () Identity (Int -> Int)
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option Int -> Int
forall a. a -> a
id (Int -> Int
forall a. a -> a
id (Int -> Int)
-> ParsecT String () Identity Char
-> ParsecT String () Identity (Int -> Int)
forall a b.
a -> ParsecT String () Identity b -> ParsecT String () Identity a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Char -> ParsecT String () Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'+'))
Int
hours <- Int -> Int
toHour (Int -> Int) -> (String -> Int) -> String -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Int
forall a. Read a => String -> a
read (String -> Int)
-> ExpParser String -> ParsecT String () Identity Int
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT String () Identity Char -> ExpParser String
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m [a]
many1 ParsecT String () Identity Char
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
digit
Int
minutes <- Int
-> ParsecT String () Identity Int -> ParsecT String () Identity Int
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option Int
0 (ParsecT String () Identity Int -> ParsecT String () Identity Int)
-> ParsecT String () Identity Int -> ParsecT String () Identity Int
forall a b. (a -> b) -> a -> b
$ (Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
60) (Int -> Int) -> (String -> Int) -> String -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Int
forall a. Read a => String -> a
read (String -> Int)
-> ExpParser String -> ParsecT String () Identity Int
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ExpParser String
forall {u}. ParsecT String u Identity String
optionalDigit
Int
seconds <- Int
-> ParsecT String () Identity Int -> ParsecT String () Identity Int
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option Int
0 (ParsecT String () Identity Int -> ParsecT String () Identity Int)
-> ParsecT String () Identity Int -> ParsecT String () Identity Int
forall a b. (a -> b) -> a -> b
$ String -> Int
forall a. Read a => String -> a
read (String -> Int)
-> ExpParser String -> ParsecT String () Identity Int
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ExpParser String
forall {u}. ParsecT String u Identity String
optionalDigit
Int -> ParsecT String () Identity Int
forall a. a -> ParsecT String () Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Int -> ParsecT String () Identity Int)
-> (Int -> Int) -> Int -> ParsecT String () Identity Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Int
sign (Int -> ParsecT String () Identity Int)
-> Int -> ParsecT String () Identity Int
forall a b. (a -> b) -> a -> b
$ Int
hours Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
minutes Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
seconds
where
optionalDigit :: ParsecT String u Identity String
optionalDigit = Char -> ParsecT String u Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
':' ParsecT String u Identity Char
-> ParsecT String u Identity String
-> ParsecT String u Identity String
forall a b.
ParsecT String u Identity a
-> ParsecT String u Identity b -> ParsecT String u Identity b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ParsecT String u Identity Char -> ParsecT String u Identity String
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m [a]
many1 ParsecT String u Identity Char
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
digit
p_transitionExpression :: Int -> ExpParser TransitionExpression
p_transitionExpression :: Int -> ParsecT String () Identity TransitionExpression
p_transitionExpression Int
offsetSecs = ParsecT String () Identity (Int -> TransitionExpression)
te ParsecT String () Identity (Int -> TransitionExpression)
-> ParsecT String () Identity Int
-> ParsecT String () Identity TransitionExpression
forall a b.
ParsecT String () Identity (a -> b)
-> ParsecT String () Identity a -> ParsecT String () Identity b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ParsecT String () Identity Int
time'
where
te :: ParsecT String () Identity (Int -> TransitionExpression)
te = ParsecT String () Identity (Int -> TransitionExpression)
p_julianExpression ParsecT String () Identity (Int -> TransitionExpression)
-> ParsecT String () Identity (Int -> TransitionExpression)
-> ParsecT String () Identity (Int -> TransitionExpression)
forall a.
ParsecT String () Identity a
-> ParsecT String () Identity a -> ParsecT String () Identity a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> ParsecT String () Identity (Int -> TransitionExpression)
p_nthDayExpression
time :: ParsecT String () Identity Int
time = Int
-> ParsecT String () Identity Int -> ParsecT String () Identity Int
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option (Int -> Int
toHour Int
2) (Char -> ParsecT String () Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'/' ParsecT String () Identity Char
-> ParsecT String () Identity Int -> ParsecT String () Identity Int
forall a b.
ParsecT String () Identity a
-> ParsecT String () Identity b -> ParsecT String () Identity b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ParsecT String () Identity Int
p_time)
time' :: ParsecT String () Identity Int
time' = (\Int
x -> Int
x Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
offsetSecs) (Int -> Int)
-> ParsecT String () Identity Int -> ParsecT String () Identity Int
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT String () Identity Int
time
p_julianExpression :: ExpParser (Int -> TransitionExpression)
p_julianExpression :: ParsecT String () Identity (Int -> TransitionExpression)
p_julianExpression = Bool -> Int -> Int -> TransitionExpression
JulianExpression (Bool -> Int -> Int -> TransitionExpression)
-> ParsecT String () Identity Bool
-> ParsecT String () Identity (Int -> Int -> TransitionExpression)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT String () Identity Bool
forall {u}. ParsecT String u Identity Bool
cntLp ParsecT String () Identity (Int -> Int -> TransitionExpression)
-> ParsecT String () Identity Int
-> ParsecT String () Identity (Int -> TransitionExpression)
forall a b.
ParsecT String () Identity (a -> b)
-> ParsecT String () Identity a -> ParsecT String () Identity b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ParsecT String () Identity Int
forall {u}. ParsecT String u Identity Int
d
where
cntLp :: ParsecT String u Identity Bool
cntLp = Bool
-> ParsecT String u Identity Bool -> ParsecT String u Identity Bool
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option Bool
True (Bool
False Bool
-> ParsecT String u Identity Char -> ParsecT String u Identity Bool
forall a b.
a -> ParsecT String u Identity b -> ParsecT String u Identity a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Char -> ParsecT String u Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'J')
d :: ParsecT String u Identity Int
d = String -> Int
forall a. Read a => String -> a
read (String -> Int)
-> ParsecT String u Identity String
-> ParsecT String u Identity Int
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT String u Identity Char -> ParsecT String u Identity String
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m [a]
many1 ParsecT String u Identity Char
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
digit
p_nthDayExpression :: ExpParser (Int -> TransitionExpression)
p_nthDayExpression :: ParsecT String () Identity (Int -> TransitionExpression)
p_nthDayExpression = Int -> Int -> Int -> Int -> TransitionExpression
NthDayExpression (Int -> Int -> Int -> Int -> TransitionExpression)
-> ParsecT String () Identity Int
-> ParsecT
String () Identity (Int -> Int -> Int -> TransitionExpression)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT String () Identity Int
forall {u}. ParsecT String u Identity Int
m ParsecT
String () Identity (Int -> Int -> Int -> TransitionExpression)
-> ParsecT String () Identity Int
-> ParsecT String () Identity (Int -> Int -> TransitionExpression)
forall a b.
ParsecT String () Identity (a -> b)
-> ParsecT String () Identity a -> ParsecT String () Identity b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ParsecT String () Identity Int
forall {u}. ParsecT String u Identity Int
nth ParsecT String () Identity (Int -> Int -> TransitionExpression)
-> ParsecT String () Identity Int
-> ParsecT String () Identity (Int -> TransitionExpression)
forall a b.
ParsecT String () Identity (a -> b)
-> ParsecT String () Identity a -> ParsecT String () Identity b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ParsecT String () Identity Int
forall {u}. ParsecT String u Identity Int
d
where
m :: ParsecT String u Identity Int
m = Char -> ParsecT String u Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'M' ParsecT String u Identity Char
-> ParsecT String u Identity Int -> ParsecT String u Identity Int
forall a b.
ParsecT String u Identity a
-> ParsecT String u Identity b -> ParsecT String u Identity b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> (Int -> Int -> Int
forall a. Num a => a -> a -> a
subtract Int
1 (Int -> Int)
-> ParsecT String u Identity Int -> ParsecT String u Identity Int
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT String u Identity Int
forall {u}. ParsecT String u Identity Int
p_number)
nth :: ParsecT String u Identity Int
nth = Char -> ParsecT String u Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'.' ParsecT String u Identity Char
-> ParsecT String u Identity Int -> ParsecT String u Identity Int
forall a b.
ParsecT String u Identity a
-> ParsecT String u Identity b -> ParsecT String u Identity b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> (Int -> Int
forall {a}. (Eq a, Num a) => a -> a
adjust (Int -> Int)
-> ParsecT String u Identity Int -> ParsecT String u Identity Int
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT String u Identity Int
forall {u}. ParsecT String u Identity Int
p_number)
d :: ParsecT String u Identity Int
d = Char -> ParsecT String u Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'.' ParsecT String u Identity Char
-> ParsecT String u Identity Int -> ParsecT String u Identity Int
forall a b.
ParsecT String u Identity a
-> ParsecT String u Identity b -> ParsecT String u Identity b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ParsecT String u Identity Int
forall {u}. ParsecT String u Identity Int
p_number
p_number :: ParsecT String u Identity Int
p_number = String -> Int
forall a. Read a => String -> a
read (String -> Int)
-> ParsecT String u Identity String
-> ParsecT String u Identity Int
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT String u Identity Char -> ParsecT String u Identity String
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m [a]
many1 ParsecT String u Identity Char
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
digit
adjust :: a -> a
adjust a
5 = -a
1
adjust a
n = a
n a -> a -> a
forall a. Num a => a -> a -> a
- a
1
toHour :: Int -> Int
toHour :: Int -> Int
toHour Int
x = Int
x Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
60 Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
60