-- GENERATED by C->Haskell Compiler, version 0.28.8 Switcheroo, 25 November 2017 (Haskell)
-- Edit the ORIGNAL .chs file instead!


{-# LINE 1 "./QuantLib/Time/Date.chs" #-}
module QuantLib.Time.Date
  (
    -- * Types
    Day
  , Month(..)
  , Weekday(..)
  , ImmMonth(..)

    -- * Constructors
    -- ** Bounds and current date
  , minDate
  , maxDate
  , today
    -- ** Months
  , january
  , february
  , march
  , april
  , may
  , june
  , july
  , august
  , september
  , october
  , november
  , december

    -- * Mutators
  , addEcbDate
  , removeEcbDate

    -- * Inspectors
    -- ** Date arithmetic
  , endOfMonth
  , nextWeekday
  , nthWeekday
  , addPeriod
    -- ** IMM dates and codes
  , immCode
  , immDate
  , nextImmCode
  , nextImmCodeFromCode
  , nextImmDate
  , nextImmDateFromCode
    -- ** ECB maintenance dates
  , ecbCode
  , ecbDateFromCode
  , ecbDate
  , nextEcbCodeFromCode
  , nextEcbCode
  , nextEcbDateFromCode
  , nextEcbDate
  , nextEcbDatesFromCode
  , nextEcbDates
    -- ** Date fields
  , isLeap
  , year
  , month
  , weekday
  , dayOfYear
  , isEndOfMonth
    -- ** IMM and ECB predicates
  , isImmCode
  , isImmDate
  , isEcbCode
  , isEcbDate
  , knownEcbDates
  ) where
import qualified Foreign.C.String as C2HSImp
import qualified Foreign.C.Types as C2HSImp
import qualified Foreign.Marshal.Utils as C2HSImp
import qualified Foreign.Ptr as C2HSImp
import qualified System.IO.Unsafe as C2HSImp


import Data.Time.Calendar(toGregorian, isLeapYear, fromGregorian)
import Data.Time.Clock(getCurrentTime)
import Data.Time.LocalTime(localDay, getTimeZone, utcToLocalTime)

import QuantLib.Internal
import QuantLib.Internal.Common






data Month = January
           | Jan
           | February
           | Feb
           | March
           | Mar
           | April
           | Apr
           | May
           | June
           | Jun
           | July
           | Jul
           | August
           | Aug
           | September
           | Sep
           | October
           | Oct
           | November
           | Nov
           | December
           | Dec
  deriving (Show,Eq,Read,Bounded,Ord)
instance Enum Month where
  succ January = February
  succ Jan = February
  succ February = March
  succ Feb = March
  succ March = April
  succ Mar = April
  succ April = May
  succ Apr = May
  succ May = June
  succ June = July
  succ Jun = July
  succ July = August
  succ Jul = August
  succ August = September
  succ Aug = September
  succ September = October
  succ Sep = October
  succ October = November
  succ Oct = November
  succ November = December
  succ Nov = December
  succ December = error "Month.succ: December has no successor"
  succ Dec = error "Month.succ: Dec has no successor"

  pred February = January
  pred Feb = January
  pred March = February
  pred Mar = February
  pred April = March
  pred Apr = March
  pred May = April
  pred June = May
  pred Jun = May
  pred July = June
  pred Jul = June
  pred August = July
  pred Aug = July
  pred September = August
  pred Sep = August
  pred October = September
  pred Oct = September
  pred November = October
  pred Nov = October
  pred December = November
  pred Dec = November
  pred January = error "Month.pred: January has no predecessor"
  pred Jan = error "Month.pred: Jan has no predecessor"

  enumFromTo from to = go from
    where
      end = fromEnum to
      go v = case compare (fromEnum v) end of
                 LT -> v : go (succ v)
                 EQ -> [v]
                 GT -> []

  enumFrom from = enumFromTo from Dec

  fromEnum January = 1
  fromEnum Jan = 1
  fromEnum February = 2
  fromEnum Feb = 2
  fromEnum March = 3
  fromEnum Mar = 3
  fromEnum April = 4
  fromEnum Apr = 4
  fromEnum May = 5
  fromEnum June = 6
  fromEnum Jun = 6
  fromEnum July = 7
  fromEnum Jul = 7
  fromEnum August = 8
  fromEnum Aug = 8
  fromEnum September = 9
  fromEnum Sep = 9
  fromEnum October = 10
  fromEnum Oct = 10
  fromEnum November = 11
  fromEnum Nov = 11
  fromEnum December = 12
  fromEnum Dec = 12

  toEnum 1 = January
  toEnum 2 = February
  toEnum 3 = March
  toEnum 4 = April
  toEnum 5 = May
  toEnum 6 = June
  toEnum 7 = July
  toEnum 8 = August
  toEnum 9 = September
  toEnum 10 = October
  toEnum 11 = November
  toEnum 12 = December
  toEnum unmatched = error ("Month.toEnum: Cannot match " ++ show unmatched)

{-# LINE 81 "./QuantLib/Time/Date.chs" #-}

data Weekday = Sunday
             | Sun
             | Monday
             | Mon
             | Tuesday
             | Tue
             | Wednesday
             | Wed
             | Thursday
             | Thu
             | Friday
             | Fri
             | Saturday
             | Sat
  deriving (Show,Eq,Read,Bounded,Ord)
instance Enum Weekday where
  succ Sunday = Monday
  succ Sun = Monday
  succ Monday = Tuesday
  succ Mon = Tuesday
  succ Tuesday = Wednesday
  succ Tue = Wednesday
  succ Wednesday = Thursday
  succ Wed = Thursday
  succ Thursday = Friday
  succ Thu = Friday
  succ Friday = Saturday
  succ Fri = Saturday
  succ Saturday = error "Weekday.succ: Saturday has no successor"
  succ Sat = error "Weekday.succ: Sat has no successor"

  pred Monday = Sunday
  pred Mon = Sunday
  pred Tuesday = Monday
  pred Tue = Monday
  pred Wednesday = Tuesday
  pred Wed = Tuesday
  pred Thursday = Wednesday
  pred Thu = Wednesday
  pred Friday = Thursday
  pred Fri = Thursday
  pred Saturday = Friday
  pred Sat = Friday
  pred Sunday = error "Weekday.pred: Sunday has no predecessor"
  pred Sun = error "Weekday.pred: Sun has no predecessor"

  enumFromTo from to = go from
    where
      end = fromEnum to
      go v = case compare (fromEnum v) end of
                 LT -> v : go (succ v)
                 EQ -> [v]
                 GT -> []

  enumFrom from = enumFromTo from Sat

  fromEnum Sunday = 1
  fromEnum Sun = 1
  fromEnum Monday = 2
  fromEnum Mon = 2
  fromEnum Tuesday = 3
  fromEnum Tue = 3
  fromEnum Wednesday = 4
  fromEnum Wed = 4
  fromEnum Thursday = 5
  fromEnum Thu = 5
  fromEnum Friday = 6
  fromEnum Fri = 6
  fromEnum Saturday = 7
  fromEnum Sat = 7

  toEnum 1 = Sunday
  toEnum 2 = Monday
  toEnum 3 = Tuesday
  toEnum 4 = Wednesday
  toEnum 5 = Thursday
  toEnum 6 = Friday
  toEnum 7 = Saturday
  toEnum unmatched = error ("Weekday.toEnum: Cannot match " ++ show unmatched)

{-# LINE 82 "./QuantLib/Time/Date.chs" #-}

data ImmMonth = F
              | G
              | H
              | J
              | K
              | M
              | N
              | Q
              | U
              | V
              | X
              | Z
  deriving (Show,Eq,Read,Bounded,Ord)
instance Enum ImmMonth where
  succ F = G
  succ G = H
  succ H = J
  succ J = K
  succ K = M
  succ M = N
  succ N = Q
  succ Q = U
  succ U = V
  succ V = X
  succ X = Z
  succ Z = error "ImmMonth.succ: Z has no successor"

  pred G = F
  pred H = G
  pred J = H
  pred K = J
  pred M = K
  pred N = M
  pred Q = N
  pred U = Q
  pred V = U
  pred X = V
  pred Z = X
  pred F = error "ImmMonth.pred: F has no predecessor"

  enumFromTo from to = go from
    where
      end = fromEnum to
      go v = case compare (fromEnum v) end of
                 LT -> v : go (succ v)
                 EQ -> [v]
                 GT -> []

  enumFrom from = enumFromTo from Z

  fromEnum F = 1
  fromEnum G = 2
  fromEnum H = 3
  fromEnum J = 4
  fromEnum K = 5
  fromEnum M = 6
  fromEnum N = 7
  fromEnum Q = 8
  fromEnum U = 9
  fromEnum V = 10
  fromEnum X = 11
  fromEnum Z = 12

  toEnum 1 = F
  toEnum 2 = G
  toEnum 3 = H
  toEnum 4 = J
  toEnum 5 = K
  toEnum 6 = M
  toEnum 7 = N
  toEnum 8 = Q
  toEnum 9 = U
  toEnum 10 = V
  toEnum 11 = X
  toEnum 12 = Z
  toEnum unmatched = error ("ImmMonth.toEnum: Cannot match " ++ show unmatched)

{-# LINE 83 "./QuantLib/Time/Date.chs" #-}


year :: Day -> Int
year x = fromIntegral y where (y, _, _) = toGregorian x

-- |returns TRUE if the given date's year is leap
isLeap :: Day -> Bool
isLeap = isLeapYear . fromIntegral . year

month :: Day -> Month
month x = let (_, m, _) = toGregorian x in toEnum m

-- |helper function that is convenient for use as an infix operator
january :: Int -> Int -> Day
january d y = fromGregorian (fromIntegral y) 1 d
february :: Int -> Int -> Day
february d y = fromGregorian (fromIntegral y) 2 d
march :: Int -> Int -> Day
march d y = fromGregorian (fromIntegral y) 3 d
april :: Int -> Int -> Day
april d y = fromGregorian (fromIntegral y) 4 d
may :: Int -> Int -> Day
may d y = fromGregorian (fromIntegral y) 5 d
june :: Int -> Int -> Day
june d y = fromGregorian (fromIntegral y) 6 d
july :: Int -> Int -> Day
july d y = fromGregorian (fromIntegral y) 7 d
august :: Int -> Int -> Day
august d y = fromGregorian (fromIntegral y) 8 d
september :: Int -> Int -> Day
september d y = fromGregorian (fromIntegral y) 9 d
october :: Int -> Int -> Day
october d y = fromGregorian (fromIntegral y) 10 d
november :: Int -> Int -> Day
november d y = fromGregorian (fromIntegral y) 11 d
december :: Int -> Int -> Day
december d y = fromGregorian (fromIntegral y) 12 d

-- |the day of the week for the given date
weekday :: (Day) -> IO ((Weekday))
weekday a1 =
  withDay a1 $ \a1' -> 
  weekday'_ a1' >>= \res ->
  let {res' = (toEnum . fromIntegral) res} in
  return (res')

{-# LINE 122 "./QuantLib/Time/Date.chs" #-}


today :: IO Day
today = do
  now <- getCurrentTime
  tz <- getTimeZone now
  return $ localDay $ utcToLocalTime tz now

-- |One-based (Jan 1st = 1)
dayOfYear :: (Day) -> IO ((Int))
dayOfYear a1 =
  withDay a1 $ \a1' -> 
  dayOfYear'_ a1' >>= \res ->
  let {res' = fromIntegral res} in
  return (res')

{-# LINE 131 "./QuantLib/Time/Date.chs" #-}


-- |last day of the month to which the given date belongs
endOfMonth :: (Day) -> IO ((Day))
endOfMonth a1 =
  withDay a1 $ \a1' -> 
  endOfMonth'_ a1' >>= \res ->
  let {res' = toDay res} in
  return (res')

{-# LINE 134 "./QuantLib/Time/Date.chs" #-}


-- |whether a date is the last day of its month
isEndOfMonth :: (Day) -> IO ((Bool))
isEndOfMonth a1 =
  withDay a1 $ \a1' -> 
  isEndOfMonth'_ a1' >>= \res ->
  let {res' = C2HSImp.toBool res} in
  return (res')

{-# LINE 137 "./QuantLib/Time/Date.chs" #-}


-- |next given weekday following or equal to the given date
-- E.g., the Friday following Tuesday, January 15th, 2002 was January 18th, 2002.see http://www.cpearson.com/excel/DateTimeWS.htm
nextWeekday :: (Day) -> (Weekday) -> IO ((Day))
nextWeekday a1 a2 =
  withDay a1 $ \a1' -> 
  let {a2' = (fromIntegral . fromEnum) a2} in 
  nextWeekday'_ a1' a2' >>= \res ->
  let {res' = toDay res} in
  return (res')

{-# LINE 141 "./QuantLib/Time/Date.chs" #-}


-- |n-th given weekday in the given month and year
-- E.g., the 4th Thursday of March, 1998 was March 26th, 1998.see http://www.cpearson.com/excel/DateTimeWS.htm
-- /Warning/ It raises an exception unless the n-th falls in 1..5
nthWeekday :: (Word) -> (Weekday) -> (Month) -> (Int) -> IO ((Day))
nthWeekday a1 a2 a3 a4 =
  let {a1' = fromIntegral a1} in 
  let {a2' = (fromIntegral . fromEnum) a2} in 
  let {a3' = (fromIntegral . fromEnum) a3} in 
  let {a4' = fromIntegral a4} in 
  preErrorCheck $ \a5' -> 
  nthWeekday'_ a1' a2' a3' a4' a5' >>= \res ->
  let {res' = toDay res} in
  errorCheck  a5'>>
  return (res')

{-# LINE 146 "./QuantLib/Time/Date.chs" #-}


-- |returns the IMM code for the given date (e.g. H3 for March 20th, 2013). /Warning/ It raises an exception if the input date is not an IMM date
immCode :: (Day) -> IO ((String))
immCode a1 =
  withDay a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  immCode'_ a1' a2' >>= \res ->
  peekDynString res >>= \res' ->
  errorCheck  a2'>>
  return (res')

{-# LINE 149 "./QuantLib/Time/Date.chs" #-}


-- |returns the IMM date for the given IMM code (e.g. March 20th, 2013 for H3). /Warning/ It raises an exception if the input string is not an IMM code
immDate :: (String) -> (Day) -> IO ((Day))
immDate a1 a2 =
  C2HSImp.withCString a1 $ \a1' -> 
  withDay a2 $ \a2' -> 
  preErrorCheck $ \a3' -> 
  immDate'_ a1' a2' a3' >>= \res ->
  let {res' = toDay res} in
  errorCheck  a3'>>
  return (res')

{-# LINE 152 "./QuantLib/Time/Date.chs" #-}


-- |returns whether or not the given string is an IMM code
isImmCode :: (String) -- ^immCode
 -> (Bool) -- ^mainCycle
 -> (Bool)
isImmCode a1 a2 =
  C2HSImp.unsafePerformIO $
  C2HSImp.withCString a1 $ \a1' -> 
  let {a2' = C2HSImp.fromBool a2} in 
  isImmCode'_ a1' a2' >>= \res ->
  let {res' = C2HSImp.toBool res} in
  return (res')

{-# LINE 157 "./QuantLib/Time/Date.chs" #-}


-- |returns whether or not the given date is an IMM date
isImmDate :: (Day) -> (Bool) -- ^mainCycle
 -> IO ((Bool))
isImmDate a1 a2 =
  withDay a1 $ \a1' -> 
  let {a2' = C2HSImp.fromBool a2} in 
  isImmDate'_ a1' a2' >>= \res ->
  let {res' = C2HSImp.toBool res} in
  return (res')

{-# LINE 161 "./QuantLib/Time/Date.chs" #-}


-- |next IMM code following the given code
-- returns the IMM code for next contract listed in the International Money Market section of the Chicago Mercantile Exchange.
nextImmCodeFromCode :: (String) -> (Bool) -- ^mainCycle
 -> (Day) -> IO ((String))
nextImmCodeFromCode a1 a2 a3 =
  C2HSImp.withCString a1 $ \a1' -> 
  let {a2' = C2HSImp.fromBool a2} in 
  withDay a3 $ \a3' -> 
  preErrorCheck $ \a4' -> 
  nextImmCodeFromCode'_ a1' a2' a3' a4' >>= \res ->
  peekDynString res >>= \res' ->
  errorCheck  a4'>>
  return (res')

{-# LINE 166 "./QuantLib/Time/Date.chs" #-}


-- |next IMM code following the given date
-- returns the IMM code for next contract listed in the International Money Market section of the Chicago Mercantile Exchange.
nextImmCode :: (Day) -> (Bool) -- ^mainCycle
 -> IO ((String))
nextImmCode a1 a2 =
  withDay a1 $ \a1' -> 
  let {a2' = C2HSImp.fromBool a2} in 
  nextImmCode'_ a1' a2' >>= \res ->
  peekDynString res >>= \res' ->
  return (res')

{-# LINE 171 "./QuantLib/Time/Date.chs" #-}


-- |next IMM date following the given IMM code
-- returns the 1st delivery date for next contract listed in the International Money Market section of the Chicago Mercantile Exchange.
nextImmDateFromCode :: (String) -> (Bool) -- ^mainCycle
 -> (Day) -- ^referenceDate
 -> IO ((Day))
nextImmDateFromCode a1 a2 a3 =
  C2HSImp.withCString a1 $ \a1' -> 
  let {a2' = C2HSImp.fromBool a2} in 
  withDay a3 $ \a3' -> 
  preErrorCheck $ \a4' -> 
  nextImmDateFromCode'_ a1' a2' a3' a4' >>= \res ->
  let {res' = toDay res} in
  errorCheck  a4'>>
  return (res')

{-# LINE 177 "./QuantLib/Time/Date.chs" #-}


-- |next IMM date following the given date
-- returns the 1st delivery date for next contract listed in the International Money Market section of the Chicago Mercantile Exchange.
nextImmDate :: (Day) -> (Bool) -- ^mainCycle
 -> IO ((Day))
nextImmDate a1 a2 =
  withDay a1 $ \a1' -> 
  let {a2' = C2HSImp.fromBool a2} in 
  nextImmDate'_ a1' a2' >>= \res ->
  let {res' = toDay res} in
  return (res')

{-# LINE 182 "./QuantLib/Time/Date.chs" #-}


-- |the given date advanced by a period
addPeriod :: (Day) -> (Int,TimeUnit) -> IO ((Day))
addPeriod a1 a2 =
  withDay a1 $ \a1' -> 
  let {(a2'1, a2'2) = fromEnumQuantity a2} in 
  preErrorCheck $ \a3' -> 
  addPeriod'_ a1' a2'1  a2'2 a3' >>= \res ->
  let {res' = toDay res} in
  errorCheck  a3'>>
  return (res')

{-# LINE 185 "./QuantLib/Time/Date.chs" #-}


-- |adds a date to the set of known ECB maintenance period start dates
addEcbDate :: (Day) -> IO ()
addEcbDate a1 =
  withDay a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  addEcbDate'_ a1' a2' >>
  errorCheck  a2'>>
  return ()

{-# LINE 188 "./QuantLib/Time/Date.chs" #-}


-- |returns the ECB code for the given date (e.g. MAR10 for March xxth, 2010).Warning It raises an exception if the input date is not an ECB date
ecbCode :: (Day) -> IO ((String))
ecbCode a1 =
  withDay a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  ecbCode'_ a1' a2' >>= \res ->
  peekDynString res >>= \res' ->
  errorCheck  a2'>>
  return (res')

{-# LINE 191 "./QuantLib/Time/Date.chs" #-}


-- |returns the ECB date for the given ECB code (e.g. March xxth, 2013 for MAR10).WarningIt raises an exception if the input string is not an ECB code
ecbDateFromCode :: (String) -> (Maybe Day) -> IO ((Day))
ecbDateFromCode a1 a2 =
  C2HSImp.withCString a1 $ \a1' -> 
  withMaybeDay a2 $ \a2' -> 
  preErrorCheck $ \a3' -> 
  ecbDateFromCode'_ a1' a2' a3' >>= \res ->
  let {res' = toDay res} in
  errorCheck  a3'>>
  return (res')

{-# LINE 194 "./QuantLib/Time/Date.chs" #-}


-- |maintenance period start date in the given month/year
ecbDate :: (Month) -> (Int) -> IO ((Day))
ecbDate a1 a2 =
  let {a1' = (fromIntegral . fromEnum) a1} in 
  let {a2' = fromIntegral a2} in 
  preErrorCheck $ \a3' -> 
  ecbDate'_ a1' a2' a3' >>= \res ->
  let {res' = toDay res} in
  errorCheck  a3'>>
  return (res')

{-# LINE 197 "./QuantLib/Time/Date.chs" #-}


-- |returns whether or not the given string is an ECB code
isEcbCode :: (String) -> IO ((Bool))
isEcbCode a1 =
  C2HSImp.withCString a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  isEcbCode'_ a1' a2' >>= \res ->
  let {res' = C2HSImp.toBool res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 200 "./QuantLib/Time/Date.chs" #-}


-- |returns whether or not the given date is a maintenance period start date
isEcbDate :: (Day) -> IO ((Bool))
isEcbDate a1 =
  withDay a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  isEcbDate'_ a1' a2' >>= \res ->
  let {res' = C2HSImp.toBool res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 203 "./QuantLib/Time/Date.chs" #-}


-- |the set of known ECB maintenance period start dates
knownEcbDates :: IO (([Day]))
knownEcbDates =
  preArray $ \(a1'1, a1'2) -> 
  preErrorCheck $ \a2' -> 
  knownEcbDates'_ a1'1  a1'2 a2' >>
  peekDayArray  a1'1  a1'2>>= \a1'' -> 
  errorCheck  a2'>>
  return (a1'')

{-# LINE 206 "./QuantLib/Time/Date.chs" #-}


-- |next ECB code following the given code
nextEcbCodeFromCode :: (String) -> IO ((String))
nextEcbCodeFromCode a1 =
  C2HSImp.withCString a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  nextEcbCodeFromCode'_ a1' a2' >>= \res ->
  C2HSImp.peekCString res >>= \res' ->
  errorCheck  a2'>>
  return (res')

{-# LINE 209 "./QuantLib/Time/Date.chs" #-}


-- |next ECB code following the given date
nextEcbCode :: (Maybe Day) -> IO ((String))
nextEcbCode a1 =
  withMaybeDay a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  nextEcbCode'_ a1' a2' >>= \res ->
  C2HSImp.peekCString res >>= \res' ->
  errorCheck  a2'>>
  return (res')

{-# LINE 212 "./QuantLib/Time/Date.chs" #-}


-- |next maintenance period start date following the given ECB code
nextEcbDateFromCode :: (String) -> (Maybe Day) -> IO ((Day))
nextEcbDateFromCode a1 a2 =
  C2HSImp.withCString a1 $ \a1' -> 
  withMaybeDay a2 $ \a2' -> 
  preErrorCheck $ \a3' -> 
  nextEcbDateFromCode'_ a1' a2' a3' >>= \res ->
  let {res' = toDay res} in
  errorCheck  a3'>>
  return (res')

{-# LINE 215 "./QuantLib/Time/Date.chs" #-}


-- |next maintenance period start date following the given date
nextEcbDate :: (Maybe Day) -> IO ((Day))
nextEcbDate a1 =
  withMaybeDay a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  nextEcbDate'_ a1' a2' >>= \res ->
  let {res' = toDay res} in
  errorCheck  a2'>>
  return (res')

{-# LINE 218 "./QuantLib/Time/Date.chs" #-}


-- |next maintenance period start dates following the given code
nextEcbDatesFromCode :: (String) -> (Maybe Day) -> IO (([Day]))
nextEcbDatesFromCode a1 a2 =
  C2HSImp.withCString a1 $ \a1' -> 
  withMaybeDay a2 $ \a2' -> 
  preArray $ \(a3'1, a3'2) -> 
  preErrorCheck $ \a4' -> 
  nextEcbDatesFromCode'_ a1' a2' a3'1  a3'2 a4' >>
  peekDayArray  a3'1  a3'2>>= \a3'' -> 
  errorCheck  a4'>>
  return (a3'')

{-# LINE 221 "./QuantLib/Time/Date.chs" #-}


-- |next maintenance period start dates following the given date
nextEcbDates :: (Maybe Day) -> IO (([Day]))
nextEcbDates a1 =
  withMaybeDay a1 $ \a1' -> 
  preArray $ \(a2'1, a2'2) -> 
  preErrorCheck $ \a3' -> 
  nextEcbDates'_ a1' a2'1  a2'2 a3' >>
  peekDayArray  a2'1  a2'2>>= \a2'' -> 
  errorCheck  a3'>>
  return (a2'')

{-# LINE 224 "./QuantLib/Time/Date.chs" #-}


-- |removes a date from the set of known ECB maintenance period start dates
removeEcbDate :: (Day) -> IO ()
removeEcbDate a1 =
  withDay a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  removeEcbDate'_ a1' a2' >>
  errorCheck  a2'>>
  return ()

{-# LINE 227 "./QuantLib/Time/Date.chs" #-}


-- vim: set ff=unix ts=8 sts=2 sw=2 et:

foreign import ccall safe "QuantLib/Time/Date.chs.h qlWeekday"
  weekday'_ :: (C2HSImp.CInt -> (IO C2HSImp.CInt))

foreign import ccall safe "QuantLib/Time/Date.chs.h qlDateDayOfYear"
  dayOfYear'_ :: (C2HSImp.CInt -> (IO C2HSImp.CInt))

foreign import ccall safe "QuantLib/Time/Date.chs.h qlDateEndOfMonth"
  endOfMonth'_ :: (C2HSImp.CInt -> (IO C2HSImp.CInt))

foreign import ccall safe "QuantLib/Time/Date.chs.h qlDateIsEndOfMonth"
  isEndOfMonth'_ :: (C2HSImp.CInt -> (IO C2HSImp.CInt))

foreign import ccall safe "QuantLib/Time/Date.chs.h qlDateNextWeekday"
  nextWeekday'_ :: (C2HSImp.CInt -> (C2HSImp.CInt -> (IO C2HSImp.CInt)))

foreign import ccall safe "QuantLib/Time/Date.chs.h qlDateNthWeekday"
  nthWeekday'_ :: (C2HSImp.CUInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CInt))))))

foreign import ccall safe "QuantLib/Time/Date.chs.h qlIMMCode"
  immCode'_ :: (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr C2HSImp.CChar))))

foreign import ccall safe "QuantLib/Time/Date.chs.h qlIMMDate"
  immDate'_ :: ((C2HSImp.Ptr C2HSImp.CChar) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CInt))))

foreign import ccall safe "QuantLib/Time/Date.chs.h qlIMMIsIMMcode"
  isImmCode'_ :: ((C2HSImp.Ptr C2HSImp.CChar) -> (C2HSImp.CInt -> (IO C2HSImp.CInt)))

foreign import ccall safe "QuantLib/Time/Date.chs.h qlIMMIsIMMdate"
  isImmDate'_ :: (C2HSImp.CInt -> (C2HSImp.CInt -> (IO C2HSImp.CInt)))

foreign import ccall safe "QuantLib/Time/Date.chs.h qlIMMNextCode1"
  nextImmCodeFromCode'_ :: ((C2HSImp.Ptr C2HSImp.CChar) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr C2HSImp.CChar))))))

foreign import ccall safe "QuantLib/Time/Date.chs.h qlIMMNextCode"
  nextImmCode'_ :: (C2HSImp.CInt -> (C2HSImp.CInt -> (IO (C2HSImp.Ptr C2HSImp.CChar))))

foreign import ccall safe "QuantLib/Time/Date.chs.h qlIMMNextDate1"
  nextImmDateFromCode'_ :: ((C2HSImp.Ptr C2HSImp.CChar) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CInt)))))

foreign import ccall safe "QuantLib/Time/Date.chs.h qlIMMNextDate"
  nextImmDate'_ :: (C2HSImp.CInt -> (C2HSImp.CInt -> (IO C2HSImp.CInt)))

foreign import ccall safe "QuantLib/Time/Date.chs.h qlAddPeriod"
  addPeriod'_ :: (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CInt)))))

foreign import ccall safe "QuantLib/Time/Date.chs.h qlECBAddDate"
  addEcbDate'_ :: (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ())))

foreign import ccall safe "QuantLib/Time/Date.chs.h qlECBCode"
  ecbCode'_ :: (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr C2HSImp.CChar))))

foreign import ccall safe "QuantLib/Time/Date.chs.h qlECBDate1"
  ecbDateFromCode'_ :: ((C2HSImp.Ptr C2HSImp.CChar) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CInt))))

foreign import ccall safe "QuantLib/Time/Date.chs.h qlECBDate"
  ecbDate'_ :: (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CInt))))

foreign import ccall safe "QuantLib/Time/Date.chs.h qlECBIsECBcode"
  isEcbCode'_ :: ((C2HSImp.Ptr C2HSImp.CChar) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CInt)))

foreign import ccall safe "QuantLib/Time/Date.chs.h qlECBIsECBdate"
  isEcbDate'_ :: (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CInt)))

foreign import ccall safe "QuantLib/Time/Date.chs.h qlECBKnownDates"
  knownEcbDates'_ :: ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CInt)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ()))))

foreign import ccall safe "QuantLib/Time/Date.chs.h qlECBNextCode1"
  nextEcbCodeFromCode'_ :: ((C2HSImp.Ptr C2HSImp.CChar) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr C2HSImp.CChar))))

foreign import ccall safe "QuantLib/Time/Date.chs.h qlECBNextCode"
  nextEcbCode'_ :: (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr C2HSImp.CChar))))

foreign import ccall safe "QuantLib/Time/Date.chs.h qlECBNextDate1"
  nextEcbDateFromCode'_ :: ((C2HSImp.Ptr C2HSImp.CChar) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CInt))))

foreign import ccall safe "QuantLib/Time/Date.chs.h qlECBNextDate"
  nextEcbDate'_ :: (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CInt)))

foreign import ccall safe "QuantLib/Time/Date.chs.h qlECBNextDates1"
  nextEcbDatesFromCode'_ :: ((C2HSImp.Ptr C2HSImp.CChar) -> (C2HSImp.CInt -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CInt)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ()))))))

foreign import ccall safe "QuantLib/Time/Date.chs.h qlECBNextDates"
  nextEcbDates'_ :: (C2HSImp.CInt -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CInt)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ())))))

foreign import ccall safe "QuantLib/Time/Date.chs.h qlECBRemoveDate"
  removeEcbDate'_ :: (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ())))