{-# LANGUAGE Safe #-}

module Data.Time.Calendar.Types where

-- | Year of Common Era (when positive).
type Year = Integer

-- | Also known as Anno Domini.
pattern CommonEra :: Integer -> Year
pattern $bCommonEra :: Year -> Year
$mCommonEra :: forall {r}. Year -> (Year -> r) -> ((# #) -> r) -> r
CommonEra n <-
    ((\Year
y -> if Year
y Year -> Year -> Bool
forall a. Ord a => a -> a -> Bool
> Year
0 then Year -> Maybe Year
forall a. a -> Maybe a
Just Year
y else Maybe Year
forall a. Maybe a
Nothing) -> Just n)
    where
        CommonEra Year
n = Year
n

-- | Also known as Before Christ.
-- Note that Year 1 = 1 CE, and the previous Year 0 = 1 BCE.
-- 'CommonEra' and 'BeforeCommonEra' form a @COMPLETE@ set.
pattern BeforeCommonEra :: Integer -> Year
pattern $bBeforeCommonEra :: Year -> Year
$mBeforeCommonEra :: forall {r}. Year -> (Year -> r) -> ((# #) -> r) -> r
BeforeCommonEra n <-
    ((\Year
y -> if Year
y Year -> Year -> Bool
forall a. Ord a => a -> a -> Bool
<= Year
0 then Year -> Maybe Year
forall a. a -> Maybe a
Just (Year
1 Year -> Year -> Year
forall a. Num a => a -> a -> a
- Year
y) else Maybe Year
forall a. Maybe a
Nothing) -> Just n)
    where
        BeforeCommonEra Year
n = Year
1 Year -> Year -> Year
forall a. Num a => a -> a -> a
- Year
n

{-# COMPLETE CommonEra, BeforeCommonEra #-}

-- | Month of year, in range 1 (January) to 12 (December).
type MonthOfYear = Int

pattern January :: MonthOfYear
pattern $bJanuary :: MonthOfYear
$mJanuary :: forall {r}. MonthOfYear -> ((# #) -> r) -> ((# #) -> r) -> r
January = 1

pattern February :: MonthOfYear
pattern $bFebruary :: MonthOfYear
$mFebruary :: forall {r}. MonthOfYear -> ((# #) -> r) -> ((# #) -> r) -> r
February = 2

pattern March :: MonthOfYear
pattern $bMarch :: MonthOfYear
$mMarch :: forall {r}. MonthOfYear -> ((# #) -> r) -> ((# #) -> r) -> r
March = 3

pattern April :: MonthOfYear
pattern $bApril :: MonthOfYear
$mApril :: forall {r}. MonthOfYear -> ((# #) -> r) -> ((# #) -> r) -> r
April = 4

pattern May :: MonthOfYear
pattern $bMay :: MonthOfYear
$mMay :: forall {r}. MonthOfYear -> ((# #) -> r) -> ((# #) -> r) -> r
May = 5

pattern June :: MonthOfYear
pattern $bJune :: MonthOfYear
$mJune :: forall {r}. MonthOfYear -> ((# #) -> r) -> ((# #) -> r) -> r
June = 6

pattern July :: MonthOfYear
pattern $bJuly :: MonthOfYear
$mJuly :: forall {r}. MonthOfYear -> ((# #) -> r) -> ((# #) -> r) -> r
July = 7

pattern August :: MonthOfYear
pattern $bAugust :: MonthOfYear
$mAugust :: forall {r}. MonthOfYear -> ((# #) -> r) -> ((# #) -> r) -> r
August = 8

pattern September :: MonthOfYear
pattern $bSeptember :: MonthOfYear
$mSeptember :: forall {r}. MonthOfYear -> ((# #) -> r) -> ((# #) -> r) -> r
September = 9

pattern October :: MonthOfYear
pattern $bOctober :: MonthOfYear
$mOctober :: forall {r}. MonthOfYear -> ((# #) -> r) -> ((# #) -> r) -> r
October = 10

pattern November :: MonthOfYear
pattern $bNovember :: MonthOfYear
$mNovember :: forall {r}. MonthOfYear -> ((# #) -> r) -> ((# #) -> r) -> r
November = 11

-- | The twelve 'MonthOfYear' patterns form a @COMPLETE@ set.
pattern December :: MonthOfYear
pattern $bDecember :: MonthOfYear
$mDecember :: forall {r}. MonthOfYear -> ((# #) -> r) -> ((# #) -> r) -> r
December = 12

{-# COMPLETE January, February, March, April, May, June, July, August, September, October, November, December #-}

-- | Day of month, in range 1 to 31.
type DayOfMonth = Int

-- | Day of quarter, in range 1 to 92.
type DayOfQuarter = Int

-- | Day of year, in range 1 (January 1st) to 366.
-- December 31st is 365 in a common year, 366 in a leap year.
type DayOfYear = Int

-- | Week of year, by various reckonings, generally in range 0-53 depending on reckoning.
type WeekOfYear = Int