{-# LANGUAGE Safe #-}
module Data.Time.Calendar.CalendarDiffDays (
module Data.Time.Calendar.CalendarDiffDays,
) where
import Control.DeepSeq
import Data.Data
data CalendarDiffDays = CalendarDiffDays
{ CalendarDiffDays -> Integer
cdMonths :: Integer
, CalendarDiffDays -> Integer
cdDays :: Integer
}
deriving
( CalendarDiffDays -> CalendarDiffDays -> Bool
(CalendarDiffDays -> CalendarDiffDays -> Bool)
-> (CalendarDiffDays -> CalendarDiffDays -> Bool)
-> Eq CalendarDiffDays
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CalendarDiffDays -> CalendarDiffDays -> Bool
== :: CalendarDiffDays -> CalendarDiffDays -> Bool
$c/= :: CalendarDiffDays -> CalendarDiffDays -> Bool
/= :: CalendarDiffDays -> CalendarDiffDays -> Bool
Eq
,
Typeable CalendarDiffDays
Typeable CalendarDiffDays =>
(forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CalendarDiffDays -> c CalendarDiffDays)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c CalendarDiffDays)
-> (CalendarDiffDays -> Constr)
-> (CalendarDiffDays -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c CalendarDiffDays))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c CalendarDiffDays))
-> ((forall b. Data b => b -> b)
-> CalendarDiffDays -> CalendarDiffDays)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> CalendarDiffDays -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> CalendarDiffDays -> r)
-> (forall u.
(forall d. Data d => d -> u) -> CalendarDiffDays -> [u])
-> (forall u.
Int -> (forall d. Data d => d -> u) -> CalendarDiffDays -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> CalendarDiffDays -> m CalendarDiffDays)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> CalendarDiffDays -> m CalendarDiffDays)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> CalendarDiffDays -> m CalendarDiffDays)
-> Data CalendarDiffDays
CalendarDiffDays -> Constr
CalendarDiffDays -> DataType
(forall b. Data b => b -> b)
-> CalendarDiffDays -> CalendarDiffDays
forall a.
Typeable a =>
(forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u.
Int -> (forall d. Data d => d -> u) -> CalendarDiffDays -> u
forall u. (forall d. Data d => d -> u) -> CalendarDiffDays -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> CalendarDiffDays -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> CalendarDiffDays -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> CalendarDiffDays -> m CalendarDiffDays
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> CalendarDiffDays -> m CalendarDiffDays
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c CalendarDiffDays
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CalendarDiffDays -> c CalendarDiffDays
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c CalendarDiffDays)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c CalendarDiffDays)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CalendarDiffDays -> c CalendarDiffDays
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CalendarDiffDays -> c CalendarDiffDays
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c CalendarDiffDays
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c CalendarDiffDays
$ctoConstr :: CalendarDiffDays -> Constr
toConstr :: CalendarDiffDays -> Constr
$cdataTypeOf :: CalendarDiffDays -> DataType
dataTypeOf :: CalendarDiffDays -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c CalendarDiffDays)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c CalendarDiffDays)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c CalendarDiffDays)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c CalendarDiffDays)
$cgmapT :: (forall b. Data b => b -> b)
-> CalendarDiffDays -> CalendarDiffDays
gmapT :: (forall b. Data b => b -> b)
-> CalendarDiffDays -> CalendarDiffDays
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> CalendarDiffDays -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> CalendarDiffDays -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> CalendarDiffDays -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> CalendarDiffDays -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> CalendarDiffDays -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> CalendarDiffDays -> [u]
$cgmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> CalendarDiffDays -> u
gmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> CalendarDiffDays -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> CalendarDiffDays -> m CalendarDiffDays
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> CalendarDiffDays -> m CalendarDiffDays
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> CalendarDiffDays -> m CalendarDiffDays
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> CalendarDiffDays -> m CalendarDiffDays
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> CalendarDiffDays -> m CalendarDiffDays
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> CalendarDiffDays -> m CalendarDiffDays
Data
,
Typeable
)
instance NFData CalendarDiffDays where
rnf :: CalendarDiffDays -> ()
rnf (CalendarDiffDays Integer
m Integer
d) = Integer -> ()
forall a. NFData a => a -> ()
rnf Integer
m () -> () -> ()
forall a b. a -> b -> b
`seq` Integer -> ()
forall a. NFData a => a -> ()
rnf Integer
d () -> () -> ()
forall a b. a -> b -> b
`seq` ()
instance Semigroup CalendarDiffDays where
CalendarDiffDays Integer
m1 Integer
d1 <> :: CalendarDiffDays -> CalendarDiffDays -> CalendarDiffDays
<> CalendarDiffDays Integer
m2 Integer
d2 = Integer -> Integer -> CalendarDiffDays
CalendarDiffDays (Integer
m1 Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
+ Integer
m2) (Integer
d1 Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
+ Integer
d2)
instance Monoid CalendarDiffDays where
mempty :: CalendarDiffDays
mempty = Integer -> Integer -> CalendarDiffDays
CalendarDiffDays Integer
0 Integer
0
mappend :: CalendarDiffDays -> CalendarDiffDays -> CalendarDiffDays
mappend = CalendarDiffDays -> CalendarDiffDays -> CalendarDiffDays
forall a. Semigroup a => a -> a -> a
(<>)
instance Show CalendarDiffDays where
show :: CalendarDiffDays -> String
show (CalendarDiffDays Integer
m Integer
d) = String
"P" String -> ShowS
forall a. [a] -> [a] -> [a]
++ Integer -> String
forall a. Show a => a -> String
show Integer
m String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
"M" String -> ShowS
forall a. [a] -> [a] -> [a]
++ Integer -> String
forall a. Show a => a -> String
show Integer
d String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
"D"
calendarDay :: CalendarDiffDays
calendarDay :: CalendarDiffDays
calendarDay = Integer -> Integer -> CalendarDiffDays
CalendarDiffDays Integer
0 Integer
1
calendarWeek :: CalendarDiffDays
calendarWeek :: CalendarDiffDays
calendarWeek = Integer -> Integer -> CalendarDiffDays
CalendarDiffDays Integer
0 Integer
7
calendarMonth :: CalendarDiffDays
calendarMonth :: CalendarDiffDays
calendarMonth = Integer -> Integer -> CalendarDiffDays
CalendarDiffDays Integer
1 Integer
0
calendarYear :: CalendarDiffDays
calendarYear :: CalendarDiffDays
calendarYear = Integer -> Integer -> CalendarDiffDays
CalendarDiffDays Integer
12 Integer
0
scaleCalendarDiffDays :: Integer -> CalendarDiffDays -> CalendarDiffDays
scaleCalendarDiffDays :: Integer -> CalendarDiffDays -> CalendarDiffDays
scaleCalendarDiffDays Integer
k (CalendarDiffDays Integer
m Integer
d) = Integer -> Integer -> CalendarDiffDays
CalendarDiffDays (Integer
k Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
* Integer
m) (Integer
k Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
* Integer
d)