{-# LINE 1 "System/Time.hsc" #-}

{-# LINE 2 "System/Time.hsc" #-}
{-# LANGUAGE Trustworthy #-}

{-# LINE 4 "System/Time.hsc" #-}

-----------------------------------------------------------------------------
-- |
-- Module      :  System.Time
-- Copyright   :  (c) The University of Glasgow 2001
-- License     :  BSD-style (see the file libraries/old-time/LICENSE)
--
-- Maintainer  :  libraries@haskell.org
-- Stability   :  provisional
-- Portability :  portable
--
-- The standard time library from Haskell 98.  This library is
-- deprecated, please look at @Data.Time@ in the @time@ package
-- instead.
--
-- "System.Time" provides functionality for clock times, including
-- timezone information (i.e, the functionality of \"@time.h@\",
-- adapted to the Haskell environment).  It follows RFC 1129 in its
-- use of Coordinated Universal Time (UTC).
--
-----------------------------------------------------------------------------

{-
Haskell 98 Time of Day Library
------------------------------

2000/06/17 <michael.weber@post.rwth-aachen.de>:
RESTRICTIONS:
  * min./max. time diff currently is restricted to
    [minBound::Int, maxBound::Int]

  * surely other restrictions wrt. min/max bounds


NOTES:
  * printing times

    `showTime' (used in `instance Show ClockTime') always prints time
    converted to the local timezone (even if it is taken from
    `(toClockTime . toUTCTime)'), whereas `calendarTimeToString'
    honors the tzone & tz fields and prints UTC or whatever timezone
    is stored inside CalendarTime.

    Maybe `showTime' should be changed to use UTC, since it would
    better correspond to the actual representation of `ClockTime'
    (can be done by replacing localtime(3) by gmtime(3)).


BUGS:
  * add proper handling of microsecs, currently, they're mostly
    ignored

  * `formatFOO' case of `%s' is currently broken...


TODO:
  * check for unusual date cases, like 1970/1/1 00:00h, and conversions
    between different timezone's etc.

  * check, what needs to be in the IO monad, the current situation
    seems to be a bit inconsistent to me

  * check whether `isDst = -1' works as expected on other arch's
    (Solaris anyone?)

  * add functions to parse strings to `CalendarTime' (some day...)

  * implement padding capabilities ("%_", "%-") in `formatFOO'

  * add rfc822 timezone (+0200 is CEST) representation ("%z") in `formatFOO'
-}

module System.Time
     (
        -- * Clock times

        ClockTime(..) -- non-standard, lib. report gives this as abstract
        -- instance Eq, Ord
        -- instance Show (non-standard)

     ,  getClockTime

        -- * Time differences

     ,  TimeDiff(..)
     ,  noTimeDiff      -- non-standard (but useful when constructing TimeDiff vals.)
     ,  diffClockTimes
     ,  addToClockTime

     ,  normalizeTimeDiff -- non-standard
     ,  timeDiffToString  -- non-standard
     ,  formatTimeDiff    -- non-standard

        -- * Calendar times

     ,  CalendarTime(..)
     ,  Month(..)
     ,  Day(..)
     ,  toCalendarTime
     ,  toUTCTime
     ,  toClockTime
     ,  calendarTimeToString
     ,  formatCalendarTime

     ) where


{-# LINE 111 "System/Time.hsc" #-}


{-# LINE 113 "System/Time.hsc" #-}

import Prelude

import Data.Ix
import System.Locale
import Foreign
import System.IO.Unsafe (unsafePerformIO)


{-# LINE 124 "System/Time.hsc" #-}
import Foreign.C

{-# LINE 126 "System/Time.hsc" #-}

-- One way to partition and give name to chunks of a year and a week:

-- | A month of the year.

data Month
 = January   | February | March    | April
 | May       | June     | July     | August
 | September | October  | November | December
 deriving (Month -> Month -> Bool
(Month -> Month -> Bool) -> (Month -> Month -> Bool) -> Eq Month
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Month -> Month -> Bool
== :: Month -> Month -> Bool
$c/= :: Month -> Month -> Bool
/= :: Month -> Month -> Bool
Eq, Eq Month
Eq Month =>
(Month -> Month -> Ordering)
-> (Month -> Month -> Bool)
-> (Month -> Month -> Bool)
-> (Month -> Month -> Bool)
-> (Month -> Month -> Bool)
-> (Month -> Month -> Month)
-> (Month -> Month -> Month)
-> Ord Month
Month -> Month -> Bool
Month -> Month -> Ordering
Month -> Month -> Month
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: Month -> Month -> Ordering
compare :: Month -> Month -> Ordering
$c< :: Month -> Month -> Bool
< :: Month -> Month -> Bool
$c<= :: Month -> Month -> Bool
<= :: Month -> Month -> Bool
$c> :: Month -> Month -> Bool
> :: Month -> Month -> Bool
$c>= :: Month -> Month -> Bool
>= :: Month -> Month -> Bool
$cmax :: Month -> Month -> Month
max :: Month -> Month -> Month
$cmin :: Month -> Month -> Month
min :: Month -> Month -> Month
Ord, Int -> Month
Month -> Int
Month -> [Month]
Month -> Month
Month -> Month -> [Month]
Month -> Month -> Month -> [Month]
(Month -> Month)
-> (Month -> Month)
-> (Int -> Month)
-> (Month -> Int)
-> (Month -> [Month])
-> (Month -> Month -> [Month])
-> (Month -> Month -> [Month])
-> (Month -> Month -> Month -> [Month])
-> Enum Month
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: Month -> Month
succ :: Month -> Month
$cpred :: Month -> Month
pred :: Month -> Month
$ctoEnum :: Int -> Month
toEnum :: Int -> Month
$cfromEnum :: Month -> Int
fromEnum :: Month -> Int
$cenumFrom :: Month -> [Month]
enumFrom :: Month -> [Month]
$cenumFromThen :: Month -> Month -> [Month]
enumFromThen :: Month -> Month -> [Month]
$cenumFromTo :: Month -> Month -> [Month]
enumFromTo :: Month -> Month -> [Month]
$cenumFromThenTo :: Month -> Month -> Month -> [Month]
enumFromThenTo :: Month -> Month -> Month -> [Month]
Enum, Month
Month -> Month -> Bounded Month
forall a. a -> a -> Bounded a
$cminBound :: Month
minBound :: Month
$cmaxBound :: Month
maxBound :: Month
Bounded, Ord Month
Ord Month =>
((Month, Month) -> [Month])
-> ((Month, Month) -> Month -> Int)
-> ((Month, Month) -> Month -> Int)
-> ((Month, Month) -> Month -> Bool)
-> ((Month, Month) -> Int)
-> ((Month, Month) -> Int)
-> Ix Month
(Month, Month) -> Int
(Month, Month) -> [Month]
(Month, Month) -> Month -> Bool
(Month, Month) -> Month -> Int
forall a.
Ord a =>
((a, a) -> [a])
-> ((a, a) -> a -> Int)
-> ((a, a) -> a -> Int)
-> ((a, a) -> a -> Bool)
-> ((a, a) -> Int)
-> ((a, a) -> Int)
-> Ix a
$crange :: (Month, Month) -> [Month]
range :: (Month, Month) -> [Month]
$cindex :: (Month, Month) -> Month -> Int
index :: (Month, Month) -> Month -> Int
$cunsafeIndex :: (Month, Month) -> Month -> Int
unsafeIndex :: (Month, Month) -> Month -> Int
$cinRange :: (Month, Month) -> Month -> Bool
inRange :: (Month, Month) -> Month -> Bool
$crangeSize :: (Month, Month) -> Int
rangeSize :: (Month, Month) -> Int
$cunsafeRangeSize :: (Month, Month) -> Int
unsafeRangeSize :: (Month, Month) -> Int
Ix, ReadPrec [Month]
ReadPrec Month
Int -> ReadS Month
ReadS [Month]
(Int -> ReadS Month)
-> ReadS [Month]
-> ReadPrec Month
-> ReadPrec [Month]
-> Read Month
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS Month
readsPrec :: Int -> ReadS Month
$creadList :: ReadS [Month]
readList :: ReadS [Month]
$creadPrec :: ReadPrec Month
readPrec :: ReadPrec Month
$creadListPrec :: ReadPrec [Month]
readListPrec :: ReadPrec [Month]
Read, Int -> Month -> ShowS
[Month] -> ShowS
Month -> String
(Int -> Month -> ShowS)
-> (Month -> String) -> ([Month] -> ShowS) -> Show Month
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Month -> ShowS
showsPrec :: Int -> Month -> ShowS
$cshow :: Month -> String
show :: Month -> String
$cshowList :: [Month] -> ShowS
showList :: [Month] -> ShowS
Show)

-- | A day of the week.

data Day
 = Sunday   | Monday | Tuesday | Wednesday
 | Thursday | Friday | Saturday
 deriving (Day -> Day -> Bool
(Day -> Day -> Bool) -> (Day -> Day -> Bool) -> Eq Day
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Day -> Day -> Bool
== :: Day -> Day -> Bool
$c/= :: Day -> Day -> Bool
/= :: Day -> Day -> Bool
Eq, Eq Day
Eq Day =>
(Day -> Day -> Ordering)
-> (Day -> Day -> Bool)
-> (Day -> Day -> Bool)
-> (Day -> Day -> Bool)
-> (Day -> Day -> Bool)
-> (Day -> Day -> Day)
-> (Day -> Day -> Day)
-> Ord Day
Day -> Day -> Bool
Day -> Day -> Ordering
Day -> Day -> Day
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: Day -> Day -> Ordering
compare :: Day -> Day -> Ordering
$c< :: Day -> Day -> Bool
< :: Day -> Day -> Bool
$c<= :: Day -> Day -> Bool
<= :: Day -> Day -> Bool
$c> :: Day -> Day -> Bool
> :: Day -> Day -> Bool
$c>= :: Day -> Day -> Bool
>= :: Day -> Day -> Bool
$cmax :: Day -> Day -> Day
max :: Day -> Day -> Day
$cmin :: Day -> Day -> Day
min :: Day -> Day -> Day
Ord, Int -> Day
Day -> Int
Day -> [Day]
Day -> Day
Day -> Day -> [Day]
Day -> Day -> Day -> [Day]
(Day -> Day)
-> (Day -> Day)
-> (Int -> Day)
-> (Day -> Int)
-> (Day -> [Day])
-> (Day -> Day -> [Day])
-> (Day -> Day -> [Day])
-> (Day -> Day -> Day -> [Day])
-> Enum Day
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: Day -> Day
succ :: Day -> Day
$cpred :: Day -> Day
pred :: Day -> Day
$ctoEnum :: Int -> Day
toEnum :: Int -> Day
$cfromEnum :: Day -> Int
fromEnum :: Day -> Int
$cenumFrom :: Day -> [Day]
enumFrom :: Day -> [Day]
$cenumFromThen :: Day -> Day -> [Day]
enumFromThen :: Day -> Day -> [Day]
$cenumFromTo :: Day -> Day -> [Day]
enumFromTo :: Day -> Day -> [Day]
$cenumFromThenTo :: Day -> Day -> Day -> [Day]
enumFromThenTo :: Day -> Day -> Day -> [Day]
Enum, Day
Day -> Day -> Bounded Day
forall a. a -> a -> Bounded a
$cminBound :: Day
minBound :: Day
$cmaxBound :: Day
maxBound :: Day
Bounded, Ord Day
Ord Day =>
((Day, Day) -> [Day])
-> ((Day, Day) -> Day -> Int)
-> ((Day, Day) -> Day -> Int)
-> ((Day, Day) -> Day -> Bool)
-> ((Day, Day) -> Int)
-> ((Day, Day) -> Int)
-> Ix Day
(Day, Day) -> Int
(Day, Day) -> [Day]
(Day, Day) -> Day -> Bool
(Day, Day) -> Day -> Int
forall a.
Ord a =>
((a, a) -> [a])
-> ((a, a) -> a -> Int)
-> ((a, a) -> a -> Int)
-> ((a, a) -> a -> Bool)
-> ((a, a) -> Int)
-> ((a, a) -> Int)
-> Ix a
$crange :: (Day, Day) -> [Day]
range :: (Day, Day) -> [Day]
$cindex :: (Day, Day) -> Day -> Int
index :: (Day, Day) -> Day -> Int
$cunsafeIndex :: (Day, Day) -> Day -> Int
unsafeIndex :: (Day, Day) -> Day -> Int
$cinRange :: (Day, Day) -> Day -> Bool
inRange :: (Day, Day) -> Day -> Bool
$crangeSize :: (Day, Day) -> Int
rangeSize :: (Day, Day) -> Int
$cunsafeRangeSize :: (Day, Day) -> Int
unsafeRangeSize :: (Day, Day) -> Int
Ix, ReadPrec [Day]
ReadPrec Day
Int -> ReadS Day
ReadS [Day]
(Int -> ReadS Day)
-> ReadS [Day] -> ReadPrec Day -> ReadPrec [Day] -> Read Day
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS Day
readsPrec :: Int -> ReadS Day
$creadList :: ReadS [Day]
readList :: ReadS [Day]
$creadPrec :: ReadPrec Day
readPrec :: ReadPrec Day
$creadListPrec :: ReadPrec [Day]
readListPrec :: ReadPrec [Day]
Read, Int -> Day -> ShowS
[Day] -> ShowS
Day -> String
(Int -> Day -> ShowS)
-> (Day -> String) -> ([Day] -> ShowS) -> Show Day
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Day -> ShowS
showsPrec :: Int -> Day -> ShowS
$cshow :: Day -> String
show :: Day -> String
$cshowList :: [Day] -> ShowS
showList :: [Day] -> ShowS
Show)

-- | A representation of the internal clock time.
-- Clock times may be compared, converted to strings, or converted to an
-- external calendar time 'CalendarTime' for I\/O or other manipulations.

data ClockTime = TOD Integer Integer
                -- ^ Construct a clock time.  The arguments are a number
                -- of seconds since 00:00:00 (UTC) on 1 January 1970,
                -- and an additional number of picoseconds.
                --
                -- In Haskell 98, the 'ClockTime' type is abstract.
               deriving (ClockTime -> ClockTime -> Bool
(ClockTime -> ClockTime -> Bool)
-> (ClockTime -> ClockTime -> Bool) -> Eq ClockTime
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ClockTime -> ClockTime -> Bool
== :: ClockTime -> ClockTime -> Bool
$c/= :: ClockTime -> ClockTime -> Bool
/= :: ClockTime -> ClockTime -> Bool
Eq, Eq ClockTime
Eq ClockTime =>
(ClockTime -> ClockTime -> Ordering)
-> (ClockTime -> ClockTime -> Bool)
-> (ClockTime -> ClockTime -> Bool)
-> (ClockTime -> ClockTime -> Bool)
-> (ClockTime -> ClockTime -> Bool)
-> (ClockTime -> ClockTime -> ClockTime)
-> (ClockTime -> ClockTime -> ClockTime)
-> Ord ClockTime
ClockTime -> ClockTime -> Bool
ClockTime -> ClockTime -> Ordering
ClockTime -> ClockTime -> ClockTime
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: ClockTime -> ClockTime -> Ordering
compare :: ClockTime -> ClockTime -> Ordering
$c< :: ClockTime -> ClockTime -> Bool
< :: ClockTime -> ClockTime -> Bool
$c<= :: ClockTime -> ClockTime -> Bool
<= :: ClockTime -> ClockTime -> Bool
$c> :: ClockTime -> ClockTime -> Bool
> :: ClockTime -> ClockTime -> Bool
$c>= :: ClockTime -> ClockTime -> Bool
>= :: ClockTime -> ClockTime -> Bool
$cmax :: ClockTime -> ClockTime -> ClockTime
max :: ClockTime -> ClockTime -> ClockTime
$cmin :: ClockTime -> ClockTime -> ClockTime
min :: ClockTime -> ClockTime -> ClockTime
Ord)

-- When a ClockTime is shown, it is converted to a CalendarTime in the current
-- timezone and then printed.  FIXME: This is arguably wrong, since we can't
-- get the current timezone without being in the IO monad.

instance Show ClockTime where
    showsPrec :: Int -> ClockTime -> ShowS
showsPrec Int
_ ClockTime
t = String -> ShowS
showString (CalendarTime -> String
calendarTimeToString
                                 (IO CalendarTime -> CalendarTime
forall a. IO a -> a
unsafePerformIO (ClockTime -> IO CalendarTime
toCalendarTime ClockTime
t)))

{-
The numeric fields have the following ranges.

\begin{verbatim}
Value         Range             Comments
-----         -----             --------

year    -maxInt .. maxInt       [Pre-Gregorian dates are inaccurate]
day           1 .. 31
hour          0 .. 23
min           0 .. 59
sec           0 .. 61           [Allows for two leap seconds]
picosec       0 .. (10^12)-1    [This could be over-precise?]
yday          0 .. 365          [364 in non-Leap years]
tz       -43200 .. 50400        [Variation from UTC in seconds]
\end{verbatim}
-}

-- | 'CalendarTime' is a user-readable and manipulable
-- representation of the internal 'ClockTime' type.

data CalendarTime
 = CalendarTime  {
       CalendarTime -> Int
ctYear    :: Int         -- ^ Year (pre-Gregorian dates are inaccurate)
     , CalendarTime -> Month
ctMonth   :: Month       -- ^ Month of the year
     , CalendarTime -> Int
ctDay     :: Int         -- ^ Day of the month (1 to 31)
     , CalendarTime -> Int
ctHour    :: Int         -- ^ Hour of the day (0 to 23)
     , CalendarTime -> Int
ctMin     :: Int         -- ^ Minutes (0 to 59)
     , CalendarTime -> Int
ctSec     :: Int         -- ^ Seconds (0 to 61, allowing for up to
                                -- two leap seconds)
     , CalendarTime -> Integer
ctPicosec :: Integer     -- ^ Picoseconds
     , CalendarTime -> Day
ctWDay    :: Day         -- ^ Day of the week
     , CalendarTime -> Int
ctYDay    :: Int         -- ^ Day of the year
                                -- (0 to 364, or 365 in leap years)
     , CalendarTime -> String
ctTZName  :: String      -- ^ Name of the time zone
     , CalendarTime -> Int
ctTZ      :: Int         -- ^ Variation from UTC in seconds
     , CalendarTime -> Bool
ctIsDST   :: Bool        -- ^ 'True' if Daylight Savings Time would
                                -- be in effect, and 'False' otherwise
 }
 deriving (CalendarTime -> CalendarTime -> Bool
(CalendarTime -> CalendarTime -> Bool)
-> (CalendarTime -> CalendarTime -> Bool) -> Eq CalendarTime
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CalendarTime -> CalendarTime -> Bool
== :: CalendarTime -> CalendarTime -> Bool
$c/= :: CalendarTime -> CalendarTime -> Bool
/= :: CalendarTime -> CalendarTime -> Bool
Eq,Eq CalendarTime
Eq CalendarTime =>
(CalendarTime -> CalendarTime -> Ordering)
-> (CalendarTime -> CalendarTime -> Bool)
-> (CalendarTime -> CalendarTime -> Bool)
-> (CalendarTime -> CalendarTime -> Bool)
-> (CalendarTime -> CalendarTime -> Bool)
-> (CalendarTime -> CalendarTime -> CalendarTime)
-> (CalendarTime -> CalendarTime -> CalendarTime)
-> Ord CalendarTime
CalendarTime -> CalendarTime -> Bool
CalendarTime -> CalendarTime -> Ordering
CalendarTime -> CalendarTime -> CalendarTime
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: CalendarTime -> CalendarTime -> Ordering
compare :: CalendarTime -> CalendarTime -> Ordering
$c< :: CalendarTime -> CalendarTime -> Bool
< :: CalendarTime -> CalendarTime -> Bool
$c<= :: CalendarTime -> CalendarTime -> Bool
<= :: CalendarTime -> CalendarTime -> Bool
$c> :: CalendarTime -> CalendarTime -> Bool
> :: CalendarTime -> CalendarTime -> Bool
$c>= :: CalendarTime -> CalendarTime -> Bool
>= :: CalendarTime -> CalendarTime -> Bool
$cmax :: CalendarTime -> CalendarTime -> CalendarTime
max :: CalendarTime -> CalendarTime -> CalendarTime
$cmin :: CalendarTime -> CalendarTime -> CalendarTime
min :: CalendarTime -> CalendarTime -> CalendarTime
Ord,ReadPrec [CalendarTime]
ReadPrec CalendarTime
Int -> ReadS CalendarTime
ReadS [CalendarTime]
(Int -> ReadS CalendarTime)
-> ReadS [CalendarTime]
-> ReadPrec CalendarTime
-> ReadPrec [CalendarTime]
-> Read CalendarTime
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS CalendarTime
readsPrec :: Int -> ReadS CalendarTime
$creadList :: ReadS [CalendarTime]
readList :: ReadS [CalendarTime]
$creadPrec :: ReadPrec CalendarTime
readPrec :: ReadPrec CalendarTime
$creadListPrec :: ReadPrec [CalendarTime]
readListPrec :: ReadPrec [CalendarTime]
Read,Int -> CalendarTime -> ShowS
[CalendarTime] -> ShowS
CalendarTime -> String
(Int -> CalendarTime -> ShowS)
-> (CalendarTime -> String)
-> ([CalendarTime] -> ShowS)
-> Show CalendarTime
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CalendarTime -> ShowS
showsPrec :: Int -> CalendarTime -> ShowS
$cshow :: CalendarTime -> String
show :: CalendarTime -> String
$cshowList :: [CalendarTime] -> ShowS
showList :: [CalendarTime] -> ShowS
Show)

-- | records the difference between two clock times in a user-readable way.

data TimeDiff
 = TimeDiff {
     TimeDiff -> Int
tdYear    :: Int,
     TimeDiff -> Int
tdMonth   :: Int,
     TimeDiff -> Int
tdDay     :: Int,
     TimeDiff -> Int
tdHour    :: Int,
     TimeDiff -> Int
tdMin     :: Int,
     TimeDiff -> Int
tdSec     :: Int,
     TimeDiff -> Integer
tdPicosec :: Integer -- not standard
   }
   deriving (TimeDiff -> TimeDiff -> Bool
(TimeDiff -> TimeDiff -> Bool)
-> (TimeDiff -> TimeDiff -> Bool) -> Eq TimeDiff
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TimeDiff -> TimeDiff -> Bool
== :: TimeDiff -> TimeDiff -> Bool
$c/= :: TimeDiff -> TimeDiff -> Bool
/= :: TimeDiff -> TimeDiff -> Bool
Eq,Eq TimeDiff
Eq TimeDiff =>
(TimeDiff -> TimeDiff -> Ordering)
-> (TimeDiff -> TimeDiff -> Bool)
-> (TimeDiff -> TimeDiff -> Bool)
-> (TimeDiff -> TimeDiff -> Bool)
-> (TimeDiff -> TimeDiff -> Bool)
-> (TimeDiff -> TimeDiff -> TimeDiff)
-> (TimeDiff -> TimeDiff -> TimeDiff)
-> Ord TimeDiff
TimeDiff -> TimeDiff -> Bool
TimeDiff -> TimeDiff -> Ordering
TimeDiff -> TimeDiff -> TimeDiff
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: TimeDiff -> TimeDiff -> Ordering
compare :: TimeDiff -> TimeDiff -> Ordering
$c< :: TimeDiff -> TimeDiff -> Bool
< :: TimeDiff -> TimeDiff -> Bool
$c<= :: TimeDiff -> TimeDiff -> Bool
<= :: TimeDiff -> TimeDiff -> Bool
$c> :: TimeDiff -> TimeDiff -> Bool
> :: TimeDiff -> TimeDiff -> Bool
$c>= :: TimeDiff -> TimeDiff -> Bool
>= :: TimeDiff -> TimeDiff -> Bool
$cmax :: TimeDiff -> TimeDiff -> TimeDiff
max :: TimeDiff -> TimeDiff -> TimeDiff
$cmin :: TimeDiff -> TimeDiff -> TimeDiff
min :: TimeDiff -> TimeDiff -> TimeDiff
Ord,ReadPrec [TimeDiff]
ReadPrec TimeDiff
Int -> ReadS TimeDiff
ReadS [TimeDiff]
(Int -> ReadS TimeDiff)
-> ReadS [TimeDiff]
-> ReadPrec TimeDiff
-> ReadPrec [TimeDiff]
-> Read TimeDiff
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS TimeDiff
readsPrec :: Int -> ReadS TimeDiff
$creadList :: ReadS [TimeDiff]
readList :: ReadS [TimeDiff]
$creadPrec :: ReadPrec TimeDiff
readPrec :: ReadPrec TimeDiff
$creadListPrec :: ReadPrec [TimeDiff]
readListPrec :: ReadPrec [TimeDiff]
Read,Int -> TimeDiff -> ShowS
[TimeDiff] -> ShowS
TimeDiff -> String
(Int -> TimeDiff -> ShowS)
-> (TimeDiff -> String) -> ([TimeDiff] -> ShowS) -> Show TimeDiff
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TimeDiff -> ShowS
showsPrec :: Int -> TimeDiff -> ShowS
$cshow :: TimeDiff -> String
show :: TimeDiff -> String
$cshowList :: [TimeDiff] -> ShowS
showList :: [TimeDiff] -> ShowS
Show)

-- | null time difference.

noTimeDiff :: TimeDiff
noTimeDiff :: TimeDiff
noTimeDiff = Int -> Int -> Int -> Int -> Int -> Int -> Integer -> TimeDiff
TimeDiff Int
0 Int
0 Int
0 Int
0 Int
0 Int
0 Integer
0

-- -----------------------------------------------------------------------------
-- | returns the current time in its internal representation.

realToInteger :: Real a => a -> Integer
realToInteger :: forall a. Real a => a -> Integer
realToInteger a
ct = Double -> Integer
forall b. Integral b => Double -> b
forall a b. (RealFrac a, Integral b) => a -> b
round (a -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac a
ct :: Double)
  -- CTime, CClock, CUShort etc are in Real but not Fractional,
  -- so we must convert to Double before we can round it

getClockTime :: IO ClockTime

{-# LINE 239 "System/Time.hsc" #-}


{-# LINE 244 "System/Time.hsc" #-}
type Timeval_tv_sec = CTime
type Timeval_tv_usec = CSUSeconds

{-# LINE 247 "System/Time.hsc" #-}

getClockTime :: IO ClockTime
getClockTime = do
  Int -> (Ptr CTimeVal -> IO ClockTime) -> IO ClockTime
forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes (Int
16) ((Ptr CTimeVal -> IO ClockTime) -> IO ClockTime)
-> (Ptr CTimeVal -> IO ClockTime) -> IO ClockTime
forall a b. (a -> b) -> a -> b
$ \ Ptr CTimeVal
p_timeval -> do
{-# LINE 250 "System/Time.hsc" #-}
    throwErrnoIfMinus1_ "getClockTime" $ gettimeofday p_timeval nullPtr
    sec  <- ((\hsc_ptr -> peekByteOff hsc_ptr 0))  p_timeval :: IO Timeval_tv_sec
{-# LINE 252 "System/Time.hsc" #-}
    usec <- ((\hsc_ptr -> peekByteOff hsc_ptr 8)) p_timeval :: IO Timeval_tv_usec
{-# LINE 253 "System/Time.hsc" #-}
    return (TOD (realToInteger sec) ((realToInteger usec) * 1000000))


{-# LINE 269 "System/Time.hsc" #-}

-- -----------------------------------------------------------------------------
-- | @'addToClockTime' d t@ adds a time difference @d@ and a
-- clock time @t@ to yield a new clock time.  The difference @d@
-- may be either positive or negative.

addToClockTime  :: TimeDiff  -> ClockTime -> ClockTime
addToClockTime :: TimeDiff -> ClockTime -> ClockTime
addToClockTime (TimeDiff Int
year Int
mon Int
day Int
hour Int
minute Int
sec Integer
psec)
               (TOD Integer
c_sec Integer
c_psec) =
        let
          sec_diff :: Integer
sec_diff = Int -> Integer
forall a. Integral a => a -> Integer
toInteger Int
sec Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
+
                     Integer
60 Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
* Int -> Integer
forall a. Integral a => a -> Integer
toInteger Int
minute Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
+
                     Integer
3600 Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
* Int -> Integer
forall a. Integral a => a -> Integer
toInteger Int
hour Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
+
                     Integer
24 Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
* Integer
3600 Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
* Int -> Integer
forall a. Integral a => a -> Integer
toInteger Int
day
          (Integer
d_sec, Integer
d_psec) = (Integer
c_psec Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
+ Integer
psec) Integer -> Integer -> (Integer, Integer)
forall a. Integral a => a -> a -> (a, a)
`quotRem` Integer
1000000000000
          cal :: CalendarTime
cal      = ClockTime -> CalendarTime
toUTCTime (Integer -> Integer -> ClockTime
TOD (Integer
c_sec Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
+ Integer
sec_diff Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
+ Integer
d_sec) Integer
d_psec)
          new_mon :: Int
new_mon  = Month -> Int
forall a. Enum a => a -> Int
fromEnum (CalendarTime -> Month
ctMonth CalendarTime
cal) Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
r_mon
          month' :: Month
month' = (Month, Int) -> Month
forall a b. (a, b) -> a
fst (Month, Int)
tmp
          yr_diff :: Int
yr_diff = (Month, Int) -> Int
forall a b. (a, b) -> b
snd (Month, Int)
tmp
          tmp :: (Month, Int)
tmp
            | Int
new_mon Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< Int
0  = (Int -> Month
forall a. Enum a => Int -> a
toEnum (Int
12 Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
new_mon), (-Int
1))
            | Int
new_mon Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
11 = (Int -> Month
forall a. Enum a => Int -> a
toEnum (Int
new_mon Int -> Int -> Int
forall a. Integral a => a -> a -> a
`mod` Int
12), Int
1)
            | Bool
otherwise    = (Int -> Month
forall a. Enum a => Int -> a
toEnum Int
new_mon, Int
0)

          (Int
r_yr, Int
r_mon) = Int
mon Int -> Int -> (Int, Int)
forall a. Integral a => a -> a -> (a, a)
`quotRem` Int
12

          year' :: Int
year' = CalendarTime -> Int
ctYear CalendarTime
cal Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
year Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
r_yr Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
yr_diff
        in
        CalendarTime -> ClockTime
toClockTime CalendarTime
cal{ctMonth=month', ctYear=year'}

-- | @'diffClockTimes' t1 t2@ returns the difference between two clock
-- times @t1@ and @t2@ as a 'TimeDiff'.

diffClockTimes  :: ClockTime -> ClockTime -> TimeDiff
-- diffClockTimes is meant to be the dual to `addToClockTime'.
-- If you want to have the TimeDiff properly splitted, use
-- `normalizeTimeDiff' on this function's result
--
-- CAVEAT: see comment of normalizeTimeDiff
diffClockTimes :: ClockTime -> ClockTime -> TimeDiff
diffClockTimes (TOD Integer
sa Integer
pa) (TOD Integer
sb Integer
pb) =
    TimeDiff
noTimeDiff{ tdSec     = fromIntegral (sa - sb)
                -- FIXME: can handle just 68 years...
              , tdPicosec = pa - pb
              }


-- | converts a time difference to normal form.

normalizeTimeDiff :: TimeDiff -> TimeDiff
-- FIXME: handle psecs properly
-- FIXME: ?should be called by formatTimeDiff automagically?
--
-- when applied to something coming out of `diffClockTimes', you loose
-- the duality to `addToClockTime', since a year does not always have
-- 365 days, etc.
--
-- apply this function as late as possible to prevent those "rounding"
-- errors
normalizeTimeDiff :: TimeDiff -> TimeDiff
normalizeTimeDiff TimeDiff
td =
  let
      rest0 :: Integer
rest0 = Int -> Integer
forall a. Integral a => a -> Integer
toInteger (TimeDiff -> Int
tdSec TimeDiff
td)
               Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
+ Integer
60 Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
* (Int -> Integer
forall a. Integral a => a -> Integer
toInteger (TimeDiff -> Int
tdMin TimeDiff
td)
                    Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
+ Integer
60 Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
* (Int -> Integer
forall a. Integral a => a -> Integer
toInteger (TimeDiff -> Int
tdHour TimeDiff
td)
                         Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
+ Integer
24 Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
* (Int -> Integer
forall a. Integral a => a -> Integer
toInteger (TimeDiff -> Int
tdDay TimeDiff
td)
                              Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
+ Integer
30 Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
* Int -> Integer
forall a. Integral a => a -> Integer
toInteger (TimeDiff -> Int
tdMonth TimeDiff
td)
                              Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
+ Integer
365 Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
* Int -> Integer
forall a. Integral a => a -> Integer
toInteger (TimeDiff -> Int
tdYear TimeDiff
td))))

      (Integer
diffYears,  Integer
rest1)    = Integer
rest0 Integer -> Integer -> (Integer, Integer)
forall a. Integral a => a -> a -> (a, a)
`quotRem` (Integer
365 Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
* Integer
24 Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
* Integer
3600)
      (Integer
diffMonths, Integer
rest2)    = Integer
rest1 Integer -> Integer -> (Integer, Integer)
forall a. Integral a => a -> a -> (a, a)
`quotRem` (Integer
30 Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
* Integer
24 Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
* Integer
3600)
      (Integer
diffDays,   Integer
rest3)    = Integer
rest2 Integer -> Integer -> (Integer, Integer)
forall a. Integral a => a -> a -> (a, a)
`quotRem` (Integer
24 Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
* Integer
3600)
      (Integer
diffHours,  Integer
rest4)    = Integer
rest3 Integer -> Integer -> (Integer, Integer)
forall a. Integral a => a -> a -> (a, a)
`quotRem` Integer
3600
      (Integer
diffMins,   Integer
diffSecs) = Integer
rest4 Integer -> Integer -> (Integer, Integer)
forall a. Integral a => a -> a -> (a, a)
`quotRem` Integer
60
  in
      TimeDiff
td{ tdYear  = fromInteger diffYears
        , tdMonth = fromInteger diffMonths
        , tdDay   = fromInteger diffDays
        , tdHour  = fromInteger diffHours
        , tdMin   = fromInteger diffMins
        , tdSec   = fromInteger diffSecs
        }


{-# LINE 351 "System/Time.hsc" #-}
-- -----------------------------------------------------------------------------
-- How do we deal with timezones on this architecture?

-- The POSIX way to do it is through the global variable tzname[].
-- But that's crap, so we do it The BSD Way if we can: namely use the
-- tm_zone and tm_gmtoff fields of struct tm, if they're available.

zone   :: Ptr CTm -> IO (Ptr CChar)
gmtoff :: Ptr CTm -> IO CLong

{-# LINE 361 "System/Time.hsc" #-}
zone x      = ((\hsc_ptr -> peekByteOff hsc_ptr 48)) x
{-# LINE 362 "System/Time.hsc" #-}
gmtoff x    = ((\hsc_ptr -> peekByteOff hsc_ptr 40)) x
{-# LINE 363 "System/Time.hsc" #-}


{-# LINE 410 "System/Time.hsc" #-}

{-# LINE 411 "System/Time.hsc" #-}

-- -----------------------------------------------------------------------------
-- | converts an internal clock time to a local time, modified by the
-- timezone and daylight savings time settings in force at the time
-- of conversion.  Because of this dependence on the local environment,
-- 'toCalendarTime' is in the 'IO' monad.

toCalendarTime :: ClockTime -> IO CalendarTime

{-# LINE 422 "System/Time.hsc" #-}
toCalendarTime :: ClockTime -> IO CalendarTime
toCalendarTime =  (Ptr CTime -> Ptr CTimeVal -> IO CTimeVal)
-> Bool -> ClockTime -> IO CalendarTime
clockToCalendarTime_reentrant ((Ptr CTime -> Ptr CTimeVal -> IO (Ptr CTimeVal))
-> Ptr CTime -> Ptr CTimeVal -> IO CTimeVal
_throwAwayReturnPointer Ptr CTime -> Ptr CTimeVal -> IO (Ptr CTimeVal)
localtime_r) Bool
False

{-# LINE 426 "System/Time.hsc" #-}

-- | converts an internal clock time into a 'CalendarTime' in standard
-- UTC format.

toUTCTime :: ClockTime -> CalendarTime

{-# LINE 434 "System/Time.hsc" #-}
toUTCTime :: ClockTime -> CalendarTime
toUTCTime      =  IO CalendarTime -> CalendarTime
forall a. IO a -> a
unsafePerformIO (IO CalendarTime -> CalendarTime)
-> (ClockTime -> IO CalendarTime) -> ClockTime -> CalendarTime
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Ptr CTime -> Ptr CTimeVal -> IO CTimeVal)
-> Bool -> ClockTime -> IO CalendarTime
clockToCalendarTime_reentrant ((Ptr CTime -> Ptr CTimeVal -> IO (Ptr CTimeVal))
-> Ptr CTime -> Ptr CTimeVal -> IO CTimeVal
_throwAwayReturnPointer Ptr CTime -> Ptr CTimeVal -> IO (Ptr CTimeVal)
gmtime_r) Bool
True

{-# LINE 438 "System/Time.hsc" #-}


{-# LINE 463 "System/Time.hsc" #-}
_throwAwayReturnPointer :: (Ptr CTime -> Ptr CTm -> IO (Ptr CTm))
                        -> (Ptr CTime -> Ptr CTm -> IO (       ))
_throwAwayReturnPointer :: (Ptr CTime -> Ptr CTimeVal -> IO (Ptr CTimeVal))
-> Ptr CTime -> Ptr CTimeVal -> IO CTimeVal
_throwAwayReturnPointer Ptr CTime -> Ptr CTimeVal -> IO (Ptr CTimeVal)
fun Ptr CTime
x Ptr CTimeVal
y = Ptr CTime -> Ptr CTimeVal -> IO (Ptr CTimeVal)
fun Ptr CTime
x Ptr CTimeVal
y IO (Ptr CTimeVal) -> IO CTimeVal -> IO CTimeVal
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> CTimeVal -> IO CTimeVal
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()


{-# LINE 475 "System/Time.hsc" #-}


{-# LINE 477 "System/Time.hsc" #-}
clockToCalendarTime_reentrant :: (Ptr CTime -> Ptr CTm -> IO ()) -> Bool -> ClockTime
         -> IO CalendarTime
clockToCalendarTime_reentrant :: (Ptr CTime -> Ptr CTimeVal -> IO CTimeVal)
-> Bool -> ClockTime -> IO CalendarTime
clockToCalendarTime_reentrant Ptr CTime -> Ptr CTimeVal -> IO CTimeVal
fun Bool
is_utc (TOD Integer
secs Integer
psec) = do
  CTime -> (Ptr CTime -> IO CalendarTime) -> IO CalendarTime
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with (Integer -> CTime
forall a b. (Integral a, Num b) => a -> b
fromIntegral Integer
secs :: CTime)  ((Ptr CTime -> IO CalendarTime) -> IO CalendarTime)
-> (Ptr CTime -> IO CalendarTime) -> IO CalendarTime
forall a b. (a -> b) -> a -> b
$ \ Ptr CTime
p_timer -> do
    Int -> (Ptr CTimeVal -> IO CalendarTime) -> IO CalendarTime
forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes (Int
56) ((Ptr CTimeVal -> IO CalendarTime) -> IO CalendarTime)
-> (Ptr CTimeVal -> IO CalendarTime) -> IO CalendarTime
forall a b. (a -> b) -> a -> b
$ \ Ptr CTimeVal
p_tm -> do
{-# LINE 482 "System/Time.hsc" #-}
      fun p_timer p_tm
      clockToCalendarTime_aux is_utc p_tm psec

{-# LINE 485 "System/Time.hsc" #-}

clockToCalendarTime_aux :: Bool -> Ptr CTm -> Integer -> IO CalendarTime
clockToCalendarTime_aux :: Bool -> Ptr CTimeVal -> Integer -> IO CalendarTime
clockToCalendarTime_aux Bool
is_utc Ptr CTimeVal
p_tm Integer
psec = do
    CInt
sec   <-  ((\Ptr CTimeVal
hsc_ptr -> Ptr CTimeVal -> Int -> IO CInt
forall b. Ptr b -> Int -> IO CInt
forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr CTimeVal
hsc_ptr Int
0)) Ptr CTimeVal
p_tm :: IO CInt
{-# LINE 489 "System/Time.hsc" #-}
    minute <-  ((\hsc_ptr -> peekByteOff hsc_ptr 4)) p_tm :: IO CInt
{-# LINE 490 "System/Time.hsc" #-}
    hour  <-  ((\hsc_ptr -> peekByteOff hsc_ptr 8)) p_tm :: IO CInt
{-# LINE 491 "System/Time.hsc" #-}
    mday  <-  ((\hsc_ptr -> peekByteOff hsc_ptr 12)) p_tm :: IO CInt
{-# LINE 492 "System/Time.hsc" #-}
    mon   <-  ((\hsc_ptr -> peekByteOff hsc_ptr 16)) p_tm :: IO CInt
{-# LINE 493 "System/Time.hsc" #-}
    year  <-  ((\hsc_ptr -> peekByteOff hsc_ptr 20)) p_tm :: IO CInt
{-# LINE 494 "System/Time.hsc" #-}
    wday  <-  ((\hsc_ptr -> peekByteOff hsc_ptr 24)) p_tm :: IO CInt
{-# LINE 495 "System/Time.hsc" #-}
    yday  <-  ((\hsc_ptr -> peekByteOff hsc_ptr 28)) p_tm :: IO CInt
{-# LINE 496 "System/Time.hsc" #-}
    isdst <-  ((\hsc_ptr -> peekByteOff hsc_ptr 32)) p_tm :: IO CInt
{-# LINE 497 "System/Time.hsc" #-}
    zone' <-  zone p_tm
    CLong
tz    <-  Ptr CTimeVal -> IO CLong
gmtoff Ptr CTimeVal
p_tm

    String
tzname' <- Ptr CChar -> IO String
peekCString Ptr CChar
zone'

    let month :: Month
month  | CInt
mon CInt -> CInt -> Bool
forall a. Ord a => a -> a -> Bool
>= CInt
0 Bool -> Bool -> Bool
&& CInt
mon CInt -> CInt -> Bool
forall a. Ord a => a -> a -> Bool
<= CInt
11 = Int -> Month
forall a. Enum a => Int -> a
toEnum (CInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CInt
mon)
               | Bool
otherwise             = String -> Month
forall a. HasCallStack => String -> a
error (String
"toCalendarTime: illegal month value: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ CInt -> String
forall a. Show a => a -> String
show CInt
mon)

    CalendarTime -> IO CalendarTime
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (Int
-> Month
-> Int
-> Int
-> Int
-> Int
-> Integer
-> Day
-> Int
-> String
-> Int
-> Bool
-> CalendarTime
CalendarTime
                (Int
1900 Int -> Int -> Int
forall a. Num a => a -> a -> a
+ CInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CInt
year)
                Month
month
                (CInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CInt
mday)
                (CInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CInt
hour)
                (CInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CInt
minute)
                (CInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CInt
sec)
                Integer
psec
                (Int -> Day
forall a. Enum a => Int -> a
toEnum (CInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CInt
wday))
                (CInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CInt
yday)
                (if Bool
is_utc then String
"UTC" else String
tzname')
                (if Bool
is_utc then Int
0     else CLong -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CLong
tz)
                (if Bool
is_utc then Bool
False else CInt
isdst CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0))

{-# LINE 519 "System/Time.hsc" #-}

-- | converts a 'CalendarTime' into the corresponding internal
-- 'ClockTime', ignoring the contents of the  'ctWDay', 'ctYDay',
-- 'ctTZName' and 'ctIsDST' fields.

toClockTime :: CalendarTime -> ClockTime

{-# LINE 532 "System/Time.hsc" #-}
toClockTime :: CalendarTime -> ClockTime
toClockTime (CalendarTime Int
year Month
mon Int
mday Int
hour Int
minute Int
sec Integer
psec
                          Day
_wday Int
_yday String
_tzname Int
tz Bool
_isdst) =

     -- `isDst' causes the date to be wrong by one hour...
     -- FIXME: check, whether this works on other arch's than Linux, too...
     --
     -- so we set it to (-1) (means `unknown') and let `mktime' determine
     -- the real value...
    let isDst :: CInt
isDst = -CInt
1 :: CInt in   -- if _isdst then (1::Int) else 0

    if Integer
psec Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
< Integer
0 Bool -> Bool -> Bool
|| Integer
psec Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
> Integer
999999999999 then
        String -> ClockTime
forall a. HasCallStack => String -> a
error String
"Time.toClockTime: picoseconds out of range"
    else if Int
tz Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< -Int
43200 Bool -> Bool -> Bool
|| Int
tz Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
50400 then
        String -> ClockTime
forall a. HasCallStack => String -> a
error String
"Time.toClockTime: timezone offset out of range"
    else
      IO ClockTime -> ClockTime
forall a. IO a -> a
unsafePerformIO (IO ClockTime -> ClockTime) -> IO ClockTime -> ClockTime
forall a b. (a -> b) -> a -> b
$ do
      Int -> (Ptr CTimeVal -> IO ClockTime) -> IO ClockTime
forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes (Int
56) ((Ptr CTimeVal -> IO ClockTime) -> IO ClockTime)
-> (Ptr CTimeVal -> IO ClockTime) -> IO ClockTime
forall a b. (a -> b) -> a -> b
$ \ Ptr CTimeVal
p_tm -> do
{-# LINE 549 "System/Time.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p_tm (fromIntegral sec  :: CInt)
{-# LINE 550 "System/Time.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 4)) p_tm (fromIntegral minute :: CInt)
{-# LINE 551 "System/Time.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 8)) p_tm (fromIntegral hour :: CInt)
{-# LINE 552 "System/Time.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 12)) p_tm (fromIntegral mday :: CInt)
{-# LINE 553 "System/Time.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 16)) p_tm (fromIntegral (fromEnum mon) :: CInt)
{-# LINE 554 "System/Time.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 20)) p_tm (fromIntegral year - 1900 :: CInt)
{-# LINE 555 "System/Time.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 32)) p_tm isDst
{-# LINE 556 "System/Time.hsc" #-}
        t <- throwIf (== -1) (\_ -> "Time.toClockTime: invalid input")
                (mktime p_tm)
        --
        -- mktime expects its argument to be in the local timezone, but
        -- toUTCTime makes UTC-encoded CalendarTime's ...
        --
        -- Since there is no any_tz_struct_tm-to-time_t conversion
        -- function, we have to fake one... :-) If not in all, it works in
        -- most cases (before, it was the other way round...)
        --
        -- Luckily, mktime tells us, what it *thinks* the timezone is, so,
        -- to compensate, we add the timezone difference to mktime's
        -- result.
        --
        gmtoffset <- gmtoff p_tm
        let res = realToInteger t - fromIntegral tz + fromIntegral gmtoffset
        return (TOD res psec)

{-# LINE 574 "System/Time.hsc" #-}

-- -----------------------------------------------------------------------------
-- Converting time values to strings.

-- | formats calendar times using local conventions.

calendarTimeToString  :: CalendarTime -> String
calendarTimeToString :: CalendarTime -> String
calendarTimeToString  =  TimeLocale -> String -> CalendarTime -> String
formatCalendarTime TimeLocale
defaultTimeLocale String
"%c"

-- | formats calendar times using local conventions and a formatting string.
-- The formatting string is that understood by the ISO C @strftime()@
-- function.

formatCalendarTime :: TimeLocale -> String -> CalendarTime -> String
formatCalendarTime :: TimeLocale -> String -> CalendarTime -> String
formatCalendarTime TimeLocale
l String
fmt cal :: CalendarTime
cal@(CalendarTime Int
year Month
mon Int
day Int
hour Int
minute Int
sec Integer
_
                                       Day
wday Int
yday String
tzname' Int
_ Bool
_) =
        ShowS
doFmt String
fmt
  where doFmt :: ShowS
doFmt (Char
'%':Char
'-':String
cs) = ShowS
doFmt (Char
'%'Char -> ShowS
forall a. a -> [a] -> [a]
:String
cs) -- padding not implemented
        doFmt (Char
'%':Char
'_':String
cs) = ShowS
doFmt (Char
'%'Char -> ShowS
forall a. a -> [a] -> [a]
:String
cs) -- padding not implemented
        doFmt (Char
'%':Char
c:String
cs)   = Char -> String
decode Char
c String -> ShowS
forall a. [a] -> [a] -> [a]
++ ShowS
doFmt String
cs
        doFmt (Char
c:String
cs) = Char
c Char -> ShowS
forall a. a -> [a] -> [a]
: ShowS
doFmt String
cs
        doFmt String
"" = String
""

        decode :: Char -> String
decode Char
'A' = (String, String) -> String
forall a b. (a, b) -> a
fst (TimeLocale -> [(String, String)]
wDays TimeLocale
l  [(String, String)] -> Int -> (String, String)
forall a. HasCallStack => [a] -> Int -> a
!! Day -> Int
forall a. Enum a => a -> Int
fromEnum Day
wday) -- day of the week, full name
        decode Char
'a' = (String, String) -> String
forall a b. (a, b) -> b
snd (TimeLocale -> [(String, String)]
wDays TimeLocale
l  [(String, String)] -> Int -> (String, String)
forall a. HasCallStack => [a] -> Int -> a
!! Day -> Int
forall a. Enum a => a -> Int
fromEnum Day
wday) -- day of the week, abbrev.
        decode Char
'B' = (String, String) -> String
forall a b. (a, b) -> a
fst (TimeLocale -> [(String, String)]
months TimeLocale
l [(String, String)] -> Int -> (String, String)
forall a. HasCallStack => [a] -> Int -> a
!! Month -> Int
forall a. Enum a => a -> Int
fromEnum Month
mon)  -- month, full name
        decode Char
'b' = (String, String) -> String
forall a b. (a, b) -> b
snd (TimeLocale -> [(String, String)]
months TimeLocale
l [(String, String)] -> Int -> (String, String)
forall a. HasCallStack => [a] -> Int -> a
!! Month -> Int
forall a. Enum a => a -> Int
fromEnum Month
mon)  -- month, abbrev
        decode Char
'h' = (String, String) -> String
forall a b. (a, b) -> b
snd (TimeLocale -> [(String, String)]
months TimeLocale
l [(String, String)] -> Int -> (String, String)
forall a. HasCallStack => [a] -> Int -> a
!! Month -> Int
forall a. Enum a => a -> Int
fromEnum Month
mon)  -- ditto
        decode Char
'C' = Int -> String
show2 (Int
year Int -> Int -> Int
forall a. Integral a => a -> a -> a
`quot` Int
100)         -- century
        decode Char
'c' = ShowS
doFmt (TimeLocale -> String
dateTimeFmt TimeLocale
l)           -- locale's data and time format.
        decode Char
'D' = ShowS
doFmt String
"%m/%d/%y"
        decode Char
'd' = Int -> String
show2 Int
day                       -- day of the month
        decode Char
'e' = Int -> String
show2' Int
day                      -- ditto, padded
        decode Char
'H' = Int -> String
show2 Int
hour                      -- hours, 24-hour clock, padded
        decode Char
'I' = Int -> String
show2 (Int -> Int
to12 Int
hour)               -- hours, 12-hour clock
        decode Char
'j' = Int -> String
show3 (Int
yday Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
1)                -- day of the year
        decode Char
'k' = Int -> String
show2' Int
hour                     -- hours, 24-hour clock, no padding
        decode Char
'l' = Int -> String
show2' (Int -> Int
to12 Int
hour)              -- hours, 12-hour clock, no padding
        decode Char
'M' = Int -> String
show2 Int
minute                    -- minutes
        decode Char
'm' = Int -> String
show2 (Month -> Int
forall a. Enum a => a -> Int
fromEnum Month
monInt -> Int -> Int
forall a. Num a => a -> a -> a
+Int
1)          -- numeric month
        decode Char
'n' = String
"\n"
        decode Char
'p' = (if Int
hour Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< Int
12 then (String, String) -> String
forall a b. (a, b) -> a
fst else (String, String) -> String
forall a b. (a, b) -> b
snd) (TimeLocale -> (String, String)
amPm TimeLocale
l) -- am or pm
        decode Char
'R' = ShowS
doFmt String
"%H:%M"
        decode Char
'r' = ShowS
doFmt (TimeLocale -> String
time12Fmt TimeLocale
l)
        decode Char
'T' = ShowS
doFmt String
"%H:%M:%S"
        decode Char
't' = String
"\t"
        decode Char
'S' = Int -> String
show2 Int
sec                       -- seconds
        decode Char
's' = let TOD Integer
esecs Integer
_ = CalendarTime -> ClockTime
toClockTime CalendarTime
cal in Integer -> String
forall a. Show a => a -> String
show Integer
esecs
                                                     -- number of secs since Epoch.
        decode Char
'U' = Int -> String
show2 ((Int
yday Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
7 Int -> Int -> Int
forall a. Num a => a -> a -> a
- Day -> Int
forall a. Enum a => a -> Int
fromEnum Day
wday) Int -> Int -> Int
forall a. Integral a => a -> a -> a
`div` Int
7) -- week number, starting on Sunday.
        decode Char
'u' = Int -> String
forall a. Show a => a -> String
show (let n :: Int
n = Day -> Int
forall a. Enum a => a -> Int
fromEnum Day
wday in  -- numeric day of the week (1=Monday, 7=Sunday)
                           if Int
n Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
0 then Int
7 else Int
n)
        decode Char
'V' =                                 -- week number (as per ISO-8601.)
            let (Int
week, Int
days) =                       -- [yep, I've always wanted to be able to display that too.]
                   (Int
yday Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
7 Int -> Int -> Int
forall a. Num a => a -> a -> a
- if Day -> Int
forall a. Enum a => a -> Int
fromEnum Day
wday Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
0 then
                               Day -> Int
forall a. Enum a => a -> Int
fromEnum Day
wday Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1 else Int
6) Int -> Int -> (Int, Int)
forall a. Integral a => a -> a -> (a, a)
`divMod` Int
7
            in  Int -> String
show2 (if Int
days Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= Int
4 then
                          Int
weekInt -> Int -> Int
forall a. Num a => a -> a -> a
+Int
1
                       else if Int
week Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
0 then Int
53 else Int
week)

        decode Char
'W' =                                 -- week number, weeks starting on monday
            Int -> String
show2 ((Int
yday Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
7 Int -> Int -> Int
forall a. Num a => a -> a -> a
- if Day -> Int
forall a. Enum a => a -> Int
fromEnum Day
wday Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
0 then
                               Day -> Int
forall a. Enum a => a -> Int
fromEnum Day
wday Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1 else Int
6) Int -> Int -> Int
forall a. Integral a => a -> a -> a
`div` Int
7)
        decode Char
'w' = Int -> String
forall a. Show a => a -> String
show (Day -> Int
forall a. Enum a => a -> Int
fromEnum Day
wday)            -- numeric day of the week, weeks starting on Sunday.
        decode Char
'X' = ShowS
doFmt (TimeLocale -> String
timeFmt TimeLocale
l)               -- locale's preferred way of printing time.
        decode Char
'x' = ShowS
doFmt (TimeLocale -> String
dateFmt TimeLocale
l)               -- locale's preferred way of printing dates.
        decode Char
'Y' = Int -> String
forall a. Show a => a -> String
show Int
year                       -- year, including century.
        decode Char
'y' = Int -> String
show2 (Int
year Int -> Int -> Int
forall a. Integral a => a -> a -> a
`rem` Int
100)          -- year, within century.
        decode Char
'Z' = String
tzname'                         -- timezone name
        decode Char
'%' = String
"%"
        decode Char
c   = [Char
c]


show2, show2', show3 :: Int -> String
show2 :: Int -> String
show2 Int
x
 | Int
x' Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< Int
10   = Char
'0'Char -> ShowS
forall a. a -> [a] -> [a]
: Int -> String
forall a. Show a => a -> String
show Int
x'
 | Bool
otherwise = Int -> String
forall a. Show a => a -> String
show Int
x'
 where x' :: Int
x' = Int
x Int -> Int -> Int
forall a. Integral a => a -> a -> a
`rem` Int
100

show2' :: Int -> String
show2' Int
x
 | Int
x' Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< Int
10   = Char
' 'Char -> ShowS
forall a. a -> [a] -> [a]
: Int -> String
forall a. Show a => a -> String
show Int
x'
 | Bool
otherwise = Int -> String
forall a. Show a => a -> String
show Int
x'
 where x' :: Int
x' = Int
x Int -> Int -> Int
forall a. Integral a => a -> a -> a
`rem` Int
100

show3 :: Int -> String
show3 Int
x = Int -> String
forall a. Show a => a -> String
show (Int
x Int -> Int -> Int
forall a. Integral a => a -> a -> a
`quot` Int
100) String -> ShowS
forall a. [a] -> [a] -> [a]
++ Int -> String
show2 (Int
x Int -> Int -> Int
forall a. Integral a => a -> a -> a
`rem` Int
100)

to12 :: Int -> Int
to12 :: Int -> Int
to12 Int
h = let h' :: Int
h' = Int
h Int -> Int -> Int
forall a. Integral a => a -> a -> a
`mod` Int
12 in if Int
h' Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
0 then Int
12 else Int
h'

-- Useful extensions for formatting TimeDiffs.

-- | formats time differences using local conventions.

timeDiffToString :: TimeDiff -> String
timeDiffToString :: TimeDiff -> String
timeDiffToString = TimeLocale -> String -> TimeDiff -> String
formatTimeDiff TimeLocale
defaultTimeLocale String
"%c"

-- | formats time differences using local conventions and a formatting string.
-- The formatting string is that understood by the ISO C @strftime()@
-- function.

formatTimeDiff :: TimeLocale -> String -> TimeDiff -> String
formatTimeDiff :: TimeLocale -> String -> TimeDiff -> String
formatTimeDiff TimeLocale
l String
fmt (TimeDiff Int
year Int
month Int
day Int
hour Int
minute Int
sec Integer
_)
 = ShowS
doFmt String
fmt
  where
   doFmt :: ShowS
doFmt String
""         = String
""
   doFmt (Char
'%':Char
'-':String
cs) = ShowS
doFmt (Char
'%'Char -> ShowS
forall a. a -> [a] -> [a]
:String
cs) -- padding not implemented
   doFmt (Char
'%':Char
'_':String
cs) = ShowS
doFmt (Char
'%'Char -> ShowS
forall a. a -> [a] -> [a]
:String
cs) -- padding not implemented
   doFmt (Char
'%':Char
c:String
cs) = Char -> String
decode Char
c String -> ShowS
forall a. [a] -> [a] -> [a]
++ ShowS
doFmt String
cs
   doFmt (Char
c:String
cs)     = Char
c Char -> ShowS
forall a. a -> [a] -> [a]
: ShowS
doFmt String
cs

   decode :: Char -> String
decode Char
spec =
    case Char
spec of
      Char
'B' -> (String, String) -> String
forall a b. (a, b) -> a
fst (TimeLocale -> [(String, String)]
months TimeLocale
l [(String, String)] -> Int -> (String, String)
forall a. HasCallStack => [a] -> Int -> a
!! Int -> Int
forall a. Enum a => a -> Int
fromEnum Int
month)
      Char
'b' -> (String, String) -> String
forall a b. (a, b) -> b
snd (TimeLocale -> [(String, String)]
months TimeLocale
l [(String, String)] -> Int -> (String, String)
forall a. HasCallStack => [a] -> Int -> a
!! Int -> Int
forall a. Enum a => a -> Int
fromEnum Int
month)
      Char
'h' -> (String, String) -> String
forall a b. (a, b) -> b
snd (TimeLocale -> [(String, String)]
months TimeLocale
l [(String, String)] -> Int -> (String, String)
forall a. HasCallStack => [a] -> Int -> a
!! Int -> Int
forall a. Enum a => a -> Int
fromEnum Int
month)
      Char
'c' -> String
defaultTimeDiffFmt
      Char
'C' -> Int -> String
show2 (Int
year Int -> Int -> Int
forall a. Integral a => a -> a -> a
`quot` Int
100)
      Char
'D' -> ShowS
doFmt String
"%m/%d/%y"
      Char
'd' -> Int -> String
show2 Int
day
      Char
'e' -> Int -> String
show2' Int
day
      Char
'H' -> Int -> String
show2 Int
hour
      Char
'I' -> Int -> String
show2 (Int -> Int
to12 Int
hour)
      Char
'k' -> Int -> String
show2' Int
hour
      Char
'l' -> Int -> String
show2' (Int -> Int
to12 Int
hour)
      Char
'M' -> Int -> String
show2 Int
minute
      Char
'm' -> Int -> String
show2 (Int -> Int
forall a. Enum a => a -> Int
fromEnum Int
month Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
1)
      Char
'n' -> String
"\n"
      Char
'p' -> (if Int
hour Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< Int
12 then (String, String) -> String
forall a b. (a, b) -> a
fst else (String, String) -> String
forall a b. (a, b) -> b
snd) (TimeLocale -> (String, String)
amPm TimeLocale
l)
      Char
'R' -> ShowS
doFmt String
"%H:%M"
      Char
'r' -> ShowS
doFmt (TimeLocale -> String
time12Fmt TimeLocale
l)
      Char
'T' -> ShowS
doFmt String
"%H:%M:%S"
      Char
't' -> String
"\t"
      Char
'S' -> Int -> String
show2 Int
sec
      Char
's' -> Int -> String
show2 Int
sec -- Implementation-dependent, sez the lib doc..
      Char
'X' -> ShowS
doFmt (TimeLocale -> String
timeFmt TimeLocale
l)
      Char
'x' -> ShowS
doFmt (TimeLocale -> String
dateFmt TimeLocale
l)
      Char
'Y' -> Int -> String
forall a. Show a => a -> String
show Int
year
      Char
'y' -> Int -> String
show2 (Int
year Int -> Int -> Int
forall a. Integral a => a -> a -> a
`rem` Int
100)
      Char
'%' -> String
"%"
      Char
c   -> [Char
c]

   defaultTimeDiffFmt :: String
defaultTimeDiffFmt =
       ((Int, (String, String)) -> ShowS)
-> String -> [(Int, (String, String))] -> String
forall a b. (a -> b -> b) -> b -> [a] -> b
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr (\ (Int
v,(String, String)
s) String
rest ->
                  (if Int
v Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
/= Int
0
                     then Int -> String
forall a. Show a => a -> String
show Int
v String -> ShowS
forall a. [a] -> [a] -> [a]
++ Char
' 'Char -> ShowS
forall a. a -> [a] -> [a]
:(Int -> (String, String) -> String
forall {a} {a}. (Eq a, Num a) => a -> (a, a) -> a
addS Int
v (String, String)
s)
                       String -> ShowS
forall a. [a] -> [a] -> [a]
++ if String -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null String
rest then String
"" else String
", "
                     else String
"") String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
rest
             )
             String
""
             ([Int] -> [(String, String)] -> [(Int, (String, String))]
forall a b. [a] -> [b] -> [(a, b)]
zip [Int
year, Int
month, Int
day, Int
hour, Int
minute, Int
sec] (TimeLocale -> [(String, String)]
intervals TimeLocale
l))

   addS :: a -> (a, a) -> a
addS a
v (a, a)
s = if a -> a
forall a. Num a => a -> a
abs a
v a -> a -> Bool
forall a. Eq a => a -> a -> Bool
== a
1 then (a, a) -> a
forall a b. (a, b) -> a
fst (a, a)
s else (a, a) -> a
forall a b. (a, b) -> b
snd (a, a)
s


{-# LINE 728 "System/Time.hsc" #-}
-- -----------------------------------------------------------------------------
-- Foreign time interface (POSIX)

type CTm = () -- struct tm


{-# LINE 734 "System/Time.hsc" #-}
foreign import ccall unsafe "HsTime.h __hscore_localtime_r"
    localtime_r :: Ptr CTime -> Ptr CTm -> IO (Ptr CTm)

{-# LINE 740 "System/Time.hsc" #-}

{-# LINE 741 "System/Time.hsc" #-}
foreign import ccall unsafe "HsTime.h __hscore_gmtime_r"
    gmtime_r    :: Ptr CTime -> Ptr CTm -> IO (Ptr CTm)

{-# LINE 747 "System/Time.hsc" #-}
foreign import ccall unsafe "time.h mktime"
    mktime      :: Ptr CTm   -> IO CTime


{-# LINE 751 "System/Time.hsc" #-}
type CTimeVal = ()
type CTimeZone = ()
foreign import ccall unsafe "HsTime.h __hscore_gettimeofday"
    gettimeofday :: Ptr CTimeVal -> Ptr CTimeZone -> IO CInt

{-# LINE 765 "System/Time.hsc" #-}

{-# LINE 766 "System/Time.hsc" #-}