time 1.1.4 → 1.16
raw patch · 134 files changed
Files
- Data/Time.hs +0/−12
- Data/Time/Calendar.hs +0/−8
- Data/Time/Calendar/Days.hs +0/−62
- Data/Time/Calendar/Easter.hs +0/−36
- Data/Time/Calendar/Gregorian.hs +0/−82
- Data/Time/Calendar/Julian.hs +0/−73
- Data/Time/Calendar/JulianYearDay.hs +0/−46
- Data/Time/Calendar/MonthDay.hs +0/−49
- Data/Time/Calendar/OrdinalDate.hs +0/−127
- Data/Time/Calendar/Private.hs +0/−54
- Data/Time/Calendar/WeekDate.hs +0/−53
- Data/Time/Clock.hs +0/−18
- Data/Time/Clock/CTimeval.hs +0/−34
- Data/Time/Clock/POSIX.hs +0/−66
- Data/Time/Clock/Scale.hs +0/−72
- Data/Time/Clock/TAI.hs +0/−129
- Data/Time/Clock/UTC.hs +0/−93
- Data/Time/Clock/UTCDiff.hs +0/−13
- Data/Time/Format.hs +0/−247
- Data/Time/Format/Parse.hs +0/−560
- Data/Time/LocalTime.hs +0/−10
- Data/Time/LocalTime/LocalTime.hs +0/−89
- Data/Time/LocalTime/TimeOfDay.hs +0/−83
- Data/Time/LocalTime/TimeZone.hs +0/−84
- LICENSE +2/−2
- Setup.hs +4/−22
- aclocal.m4 +17/−19
- benchmark/Main.hs +21/−0
- cbits/HsTime.c +0/−40
- changelog.md +205/−0
- configure +4847/−4976
- configure.ac +12/−6
- include/HsTime.h +0/−23
- include/HsTimeConfig.h +0/−84
- include/HsTimeConfig.h.in +0/−83
- lib/Data/Format.hs +276/−0
- lib/Data/Time.hs +46/−0
- lib/Data/Time/Calendar.hs +78/−0
- lib/Data/Time/Calendar/CalendarDiffDays.hs +47/−0
- lib/Data/Time/Calendar/Days.hs +118/−0
- lib/Data/Time/Calendar/Easter.hs +46/−0
- lib/Data/Time/Calendar/Gregorian.hs +154/−0
- lib/Data/Time/Calendar/Julian.hs +175/−0
- lib/Data/Time/Calendar/JulianYearDay.hs +66/−0
- lib/Data/Time/Calendar/Month.hs +105/−0
- lib/Data/Time/Calendar/MonthDay.hs +108/−0
- lib/Data/Time/Calendar/OrdinalDate.hs +223/−0
- lib/Data/Time/Calendar/Private.hs +81/−0
- lib/Data/Time/Calendar/Quarter.hs +152/−0
- lib/Data/Time/Calendar/Types.hs +79/−0
- lib/Data/Time/Calendar/Week.hs +124/−0
- lib/Data/Time/Calendar/WeekDate.hs +149/−0
- lib/Data/Time/Clock.hs +49/−0
- lib/Data/Time/Clock/Internal/AbsoluteTime.hs +38/−0
- lib/Data/Time/Clock/Internal/CTimespec.hsc +107/−0
- lib/Data/Time/Clock/Internal/CTimeval.hs +47/−0
- lib/Data/Time/Clock/Internal/DiffTime.hs +120/−0
- lib/Data/Time/Clock/Internal/NominalDiffTime.hs +120/−0
- lib/Data/Time/Clock/Internal/POSIXTime.hs +14/−0
- lib/Data/Time/Clock/Internal/SystemTime.hs +111/−0
- lib/Data/Time/Clock/Internal/UTCDiff.hs +15/−0
- lib/Data/Time/Clock/Internal/UTCTime.hs +29/−0
- lib/Data/Time/Clock/Internal/UniversalTime.hs +23/−0
- lib/Data/Time/Clock/POSIX.hs +56/−0
- lib/Data/Time/Clock/System.hs +81/−0
- lib/Data/Time/Clock/TAI.hs +76/−0
- lib/Data/Time/Format.hs +28/−0
- lib/Data/Time/Format/Format/Class.hs +406/−0
- lib/Data/Time/Format/Format/Instances.hs +229/−0
- lib/Data/Time/Format/ISO8601.hs +469/−0
- lib/Data/Time/Format/Internal.hs +15/−0
- lib/Data/Time/Format/Locale.hs +92/−0
- lib/Data/Time/Format/Parse.hs +238/−0
- lib/Data/Time/Format/Parse/Class.hs +293/−0
- lib/Data/Time/Format/Parse/Instances.hs +672/−0
- lib/Data/Time/LocalTime.hs +64/−0
- lib/Data/Time/LocalTime/Internal/CalendarDiffTime.hs +68/−0
- lib/Data/Time/LocalTime/Internal/Foreign.hs +119/−0
- lib/Data/Time/LocalTime/Internal/LocalTime.hs +100/−0
- lib/Data/Time/LocalTime/Internal/TimeOfDay.hs +121/−0
- lib/Data/Time/LocalTime/Internal/TimeZone.hs +78/−0
- lib/Data/Time/LocalTime/Internal/ZonedTime.hs +59/−0
- lib/cbits/HsTime.c +51/−0
- lib/include/HsTime.h +25/−0
- lib/include/HsTimeConfig.h.in +185/−0
- test/ForeignCalls.hs +50/−0
- test/ShowDefaultTZAbbreviations.hs +14/−0
- test/ShowTime.hs +8/−0
- test/main/Main.hs +58/−0
- test/main/Test/AddDiff.hs +20/−0
- test/main/Test/Arbitrary.hs +238/−0
- test/main/Test/Calendar/AddDays.hs +49/−0
- test/main/Test/Calendar/AddDaysRef.hs +251/−0
- test/main/Test/Calendar/CalendarProps.hs +24/−0
- test/main/Test/Calendar/Calendars.hs +26/−0
- test/main/Test/Calendar/CalendarsRef.hs +10/−0
- test/main/Test/Calendar/ClipDates.hs +47/−0
- test/main/Test/Calendar/ClipDatesRef.hs +571/−0
- test/main/Test/Calendar/ConvertBack.hs +41/−0
- test/main/Test/Calendar/DayPeriod.hs +181/−0
- test/main/Test/Calendar/Duration.hs +106/−0
- test/main/Test/Calendar/Easter.hs +39/−0
- test/main/Test/Calendar/EasterRef.hs +63/−0
- test/main/Test/Calendar/LongWeekYears.hs +32/−0
- test/main/Test/Calendar/LongWeekYearsRef.hs +156/−0
- test/main/Test/Calendar/MonthDay.hs +51/−0
- test/main/Test/Calendar/MonthDayRef.hs +752/−0
- test/main/Test/Calendar/MonthOfYear.hs +26/−0
- test/main/Test/Calendar/Valid.hs +164/−0
- test/main/Test/Calendar/Week.hs +248/−0
- test/main/Test/Calendar/Year.hs +29/−0
- test/main/Test/Clock/Conversion.hs +27/−0
- test/main/Test/Clock/Pattern.hs +32/−0
- test/main/Test/Clock/Resolution.hs +65/−0
- test/main/Test/Clock/TAI.hs +60/−0
- test/main/Test/Format/Compile.hs +14/−0
- test/main/Test/Format/Format.hs +212/−0
- test/main/Test/Format/ISO8601.hs +355/−0
- test/main/Test/Format/ParseTime.hs +994/−0
- test/main/Test/LocalTime/CalendarDiffTime.hs +121/−0
- test/main/Test/LocalTime/Time.hs +109/−0
- test/main/Test/LocalTime/TimeOfDay.hs +26/−0
- test/main/Test/LocalTime/TimeRef.hs +896/−0
- test/main/Test/TestUtil.hs +39/−0
- test/main/Test/Types.hs +52/−0
- test/template/Main.hs +31/−0
- test/template/Test/TastyWrapper.hs +20/−0
- test/unix/Main.hs +11/−0
- test/unix/Test/Format/Format.hs +282/−0
- test/unix/Test/Format/FormatStuff.c +15/−0
- test/unix/Test/Format/FormatStuff.h +6/−0
- test/unix/Test/LocalTime/TimeZone.hs +19/−0
- test/unix/Test/TestUtil.hs +45/−0
- time.cabal +252/−25
− Data/Time.hs
@@ -1,12 +0,0 @@-module Data.Time-(- module Data.Time.Calendar,- module Data.Time.Clock,- module Data.Time.LocalTime,- module Data.Time.Format-) where--import Data.Time.Calendar-import Data.Time.Clock-import Data.Time.LocalTime-import Data.Time.Format
− Data/Time/Calendar.hs
@@ -1,8 +0,0 @@-module Data.Time.Calendar-(- module Data.Time.Calendar.Days,- module Data.Time.Calendar.Gregorian-) where--import Data.Time.Calendar.Days-import Data.Time.Calendar.Gregorian
− Data/Time/Calendar/Days.hs
@@ -1,62 +0,0 @@--- #hide-module Data.Time.Calendar.Days-(- -- * Days- Day(..),addDays,diffDays-) where--import Data.Ix-import Data.Typeable---- | The Modified Julian Day is a standard count of days, with zero being the day 1858-11-17.-newtype Day = ModifiedJulianDay {toModifiedJulianDay :: Integer} deriving (Eq,Ord)--instance Typeable Day where- typeOf _ = mkTyConApp (mkTyCon "Data.Time.Calendar.Days.Day") []---- necessary because H98 doesn't have "cunning newtype" derivation-instance Enum Day where- succ (ModifiedJulianDay a) = ModifiedJulianDay (succ a)- pred (ModifiedJulianDay a) = ModifiedJulianDay (pred a)- toEnum = ModifiedJulianDay . toEnum- fromEnum (ModifiedJulianDay a) = fromEnum a- enumFrom (ModifiedJulianDay a) = fmap ModifiedJulianDay (enumFrom a)- enumFromThen (ModifiedJulianDay a) (ModifiedJulianDay b) = fmap ModifiedJulianDay (enumFromThen a b)- enumFromTo (ModifiedJulianDay a) (ModifiedJulianDay b) = fmap ModifiedJulianDay (enumFromTo a b)- enumFromThenTo (ModifiedJulianDay a) (ModifiedJulianDay b) (ModifiedJulianDay c) = fmap ModifiedJulianDay (enumFromThenTo a b c)---- necessary because H98 doesn't have "cunning newtype" derivation-instance Ix Day where- range (ModifiedJulianDay a,ModifiedJulianDay b) = fmap ModifiedJulianDay (range (a,b))- index (ModifiedJulianDay a,ModifiedJulianDay b) (ModifiedJulianDay c) = index (a,b) c- inRange (ModifiedJulianDay a,ModifiedJulianDay b) (ModifiedJulianDay c) = inRange (a,b) c- rangeSize (ModifiedJulianDay a,ModifiedJulianDay b) = rangeSize (a,b)--addDays :: Integer -> Day -> Day-addDays n (ModifiedJulianDay a) = ModifiedJulianDay (a + n)--diffDays :: Day -> Day -> Integer-diffDays (ModifiedJulianDay a) (ModifiedJulianDay b) = a - b--{--instance Show Day where- show (ModifiedJulianDay d) = "MJD " ++ (show d)---- necessary because H98 doesn't have "cunning newtype" derivation-instance Num Day where- (ModifiedJulianDay a) + (ModifiedJulianDay b) = ModifiedJulianDay (a + b)- (ModifiedJulianDay a) - (ModifiedJulianDay b) = ModifiedJulianDay (a - b)- (ModifiedJulianDay a) * (ModifiedJulianDay b) = ModifiedJulianDay (a * b)- negate (ModifiedJulianDay a) = ModifiedJulianDay (negate a)- abs (ModifiedJulianDay a) = ModifiedJulianDay (abs a)- signum (ModifiedJulianDay a) = ModifiedJulianDay (signum a)- fromInteger = ModifiedJulianDay--instance Real Day where- toRational (ModifiedJulianDay a) = toRational a--instance Integral Day where- toInteger (ModifiedJulianDay a) = toInteger a- quotRem (ModifiedJulianDay a) (ModifiedJulianDay b) = (ModifiedJulianDay c,ModifiedJulianDay d) where- (c,d) = quotRem a b--}
− Data/Time/Calendar/Easter.hs
@@ -1,36 +0,0 @@-module Data.Time.Calendar.Easter- (- sundayAfter,- orthodoxPaschalMoon,orthodoxEaster,- gregorianPaschalMoon,gregorianEaster- ) where---- formulae from Reingold & Dershowitz, _Calendrical Calculations_, ch. 8.- -import Data.Time.Calendar-import Data.Time.Calendar.Julian---- | The next Sunday strictly after a given day.-sundayAfter :: Day -> Day-sundayAfter day = addDays (7 - (mod (toModifiedJulianDay day + 3) 7)) day---- | Given a year, find the Paschal full moon according to Orthodox Christian tradition-orthodoxPaschalMoon :: Integer -> Day-orthodoxPaschalMoon year = addDays (- shiftedEpact) (fromJulian jyear 4 19) where- shiftedEpact = mod (14 + 11 * (mod year 19)) 30- jyear = if year > 0 then year else year - 1---- | Given a year, find Easter according to Orthodox Christian tradition-orthodoxEaster :: Integer -> Day-orthodoxEaster = sundayAfter . orthodoxPaschalMoon---- | Given a year, find the Paschal full moon according to the Gregorian method-gregorianPaschalMoon :: Integer -> Day-gregorianPaschalMoon year = addDays (- adjustedEpact) (fromGregorian year 4 19) where- century = (div year 100) + 1- shiftedEpact = mod (14 + 11 * (mod year 19) - (div (3 * century) 4) + (div (5 + 8 * century) 25)) 30- adjustedEpact = if shiftedEpact == 0 || ((shiftedEpact == 1) && (mod year 19 < 10)) then shiftedEpact + 1 else shiftedEpact---- | Given a year, find Easter according to the Gregorian method-gregorianEaster :: Integer -> Day-gregorianEaster = sundayAfter . gregorianPaschalMoon
− Data/Time/Calendar/Gregorian.hs
@@ -1,82 +0,0 @@-{-# OPTIONS -fno-warn-orphans #-}---- #hide-module Data.Time.Calendar.Gregorian-(- -- * Gregorian calendar- toGregorian,fromGregorian,fromGregorianValid,showGregorian,gregorianMonthLength,-- -- calendrical arithmetic- -- e.g. "one month after March 31st"- addGregorianMonthsClip,addGregorianMonthsRollOver,- addGregorianYearsClip,addGregorianYearsRollOver,-- -- re-exported from OrdinalDate- isLeapYear-) where--import Data.Time.Calendar.MonthDay-import Data.Time.Calendar.OrdinalDate-import Data.Time.Calendar.Days-import Data.Time.Calendar.Private---- | convert to proleptic Gregorian calendar. First element of result is year, second month number (1-12), third day (1-31).-toGregorian :: Day -> (Integer,Int,Int)-toGregorian date = (year,month,day) where- (year,yd) = toOrdinalDate date- (month,day) = dayOfYearToMonthAndDay (isLeapYear year) yd---- | convert from proleptic Gregorian calendar. First argument is year, second month number (1-12), third day (1-31).--- Invalid values will be clipped to the correct range, month first, then day.-fromGregorian :: Integer -> Int -> Int -> Day-fromGregorian year month day = fromOrdinalDate year (monthAndDayToDayOfYear (isLeapYear year) month day)---- | convert from proleptic Gregorian calendar. First argument is year, second month number (1-12), third day (1-31).--- Invalid values will return Nothing-fromGregorianValid :: Integer -> Int -> Int -> Maybe Day-fromGregorianValid year month day = do- doy <- monthAndDayToDayOfYearValid (isLeapYear year) month day- fromOrdinalDateValid year doy---- | show in ISO 8601 format (yyyy-mm-dd)-showGregorian :: Day -> String-showGregorian date = (show4 (Just '0') y) ++ "-" ++ (show2 (Just '0') m) ++ "-" ++ (show2 (Just '0') d) where- (y,m,d) = toGregorian date---- | The number of days in a given month according to the proleptic Gregorian calendar. First argument is year, second is month.-gregorianMonthLength :: Integer -> Int -> Int-gregorianMonthLength year = monthLength (isLeapYear year)--rolloverMonths :: (Integer,Integer) -> (Integer,Int)-rolloverMonths (y,m) = (y + (div (m - 1) 12),fromIntegral (mod (m - 1) 12) + 1)--addGregorianMonths :: Integer -> Day -> (Integer,Int,Int)-addGregorianMonths n day = (y',m',d) where- (y,m,d) = toGregorian day- (y',m') = rolloverMonths (y,fromIntegral m + n)---- | Add months, with days past the last day of the month clipped to the last day.--- For instance, 2005-01-30 + 1 month = 2005-02-28.-addGregorianMonthsClip :: Integer -> Day -> Day-addGregorianMonthsClip n day = fromGregorian y m d where- (y,m,d) = addGregorianMonths n day---- | Add months, with days past the last day of the month rolling over to the next month.--- For instance, 2005-01-30 + 1 month = 2005-03-02.-addGregorianMonthsRollOver :: Integer -> Day -> Day-addGregorianMonthsRollOver n day = addDays (fromIntegral d - 1) (fromGregorian y m 1) where- (y,m,d) = addGregorianMonths n day---- | Add years, matching month and day, with Feb 29th clipped to Feb 28th if necessary.--- For instance, 2004-02-29 + 2 years = 2006-02-28.-addGregorianYearsClip :: Integer -> Day -> Day-addGregorianYearsClip n = addGregorianMonthsClip (n * 12)---- | Add years, matching month and day, with Feb 29th rolled over to Mar 1st if necessary.--- For instance, 2004-02-29 + 2 years = 2006-03-01.-addGregorianYearsRollOver :: Integer -> Day -> Day-addGregorianYearsRollOver n = addGregorianMonthsRollOver (n * 12)---- orphan instance-instance Show Day where- show = showGregorian
− Data/Time/Calendar/Julian.hs
@@ -1,73 +0,0 @@-module Data.Time.Calendar.Julian-(- module Data.Time.Calendar.JulianYearDay,-- toJulian,fromJulian,fromJulianValid,showJulian,julianMonthLength,-- -- calendrical arithmetic- -- e.g. "one month after March 31st"- addJulianMonthsClip,addJulianMonthsRollOver,- addJulianYearsClip,addJulianYearsRollOver-) where--import Data.Time.Calendar.MonthDay-import Data.Time.Calendar.JulianYearDay-import Data.Time.Calendar.Days-import Data.Time.Calendar.Private---- | convert to proleptic Julian calendar. First element of result is year, second month number (1-12), third day (1-31).-toJulian :: Day -> (Integer,Int,Int)-toJulian date = (year,month,day) where- (year,yd) = toJulianYearAndDay date- (month,day) = dayOfYearToMonthAndDay (isJulianLeapYear year) yd---- | convert from proleptic Julian calendar. First argument is year, second month number (1-12), third day (1-31).--- Invalid values will be clipped to the correct range, month first, then day.-fromJulian :: Integer -> Int -> Int -> Day-fromJulian year month day = fromJulianYearAndDay year (monthAndDayToDayOfYear (isJulianLeapYear year) month day)---- | convert from proleptic Julian calendar. First argument is year, second month number (1-12), third day (1-31).--- Invalid values will return Nothing.-fromJulianValid :: Integer -> Int -> Int -> Maybe Day-fromJulianValid year month day = do- doy <- monthAndDayToDayOfYearValid (isJulianLeapYear year) month day- fromJulianYearAndDayValid year doy---- | show in ISO 8601 format (yyyy-mm-dd)-showJulian :: Day -> String-showJulian date = (show4 (Just '0') y) ++ "-" ++ (show2 (Just '0') m) ++ "-" ++ (show2 (Just '0') d) where- (y,m,d) = toJulian date---- | The number of days in a given month according to the proleptic Julian calendar. First argument is year, second is month.-julianMonthLength :: Integer -> Int -> Int-julianMonthLength year = monthLength (isJulianLeapYear year)--rolloverMonths :: (Integer,Integer) -> (Integer,Int)-rolloverMonths (y,m) = (y + (div (m - 1) 12),fromIntegral (mod (m - 1) 12) + 1)--addJulianMonths :: Integer -> Day -> (Integer,Int,Int)-addJulianMonths n day = (y',m',d) where- (y,m,d) = toJulian day- (y',m') = rolloverMonths (y,fromIntegral m + n)---- | Add months, with days past the last day of the month clipped to the last day.--- For instance, 2005-01-30 + 1 month = 2005-02-28.-addJulianMonthsClip :: Integer -> Day -> Day-addJulianMonthsClip n day = fromJulian y m d where- (y,m,d) = addJulianMonths n day---- | Add months, with days past the last day of the month rolling over to the next month.--- For instance, 2005-01-30 + 1 month = 2005-03-02.-addJulianMonthsRollOver :: Integer -> Day -> Day-addJulianMonthsRollOver n day = addDays (fromIntegral d - 1) (fromJulian y m 1) where- (y,m,d) = addJulianMonths n day---- | Add years, matching month and day, with Feb 29th clipped to Feb 28th if necessary.--- For instance, 2004-02-29 + 2 years = 2006-02-28.-addJulianYearsClip :: Integer -> Day -> Day-addJulianYearsClip n = addJulianMonthsClip (n * 12)---- | Add years, matching month and day, with Feb 29th rolled over to Mar 1st if necessary.--- For instance, 2004-02-29 + 2 years = 2006-03-01.-addJulianYearsRollOver :: Integer -> Day -> Day-addJulianYearsRollOver n = addJulianMonthsRollOver (n * 12)
− Data/Time/Calendar/JulianYearDay.hs
@@ -1,46 +0,0 @@--- #hide-module Data.Time.Calendar.JulianYearDay- (- -- * Year and day format- module Data.Time.Calendar.JulianYearDay- ) where--import Data.Time.Calendar.Days-import Data.Time.Calendar.Private---- | convert to proleptic Julian year and day format. First element of result is year (proleptic Julian calendar),--- second is the day of the year, with 1 for Jan 1, and 365 (or 366 in leap years) for Dec 31.-toJulianYearAndDay :: Day -> (Integer,Int)-toJulianYearAndDay (ModifiedJulianDay mjd) = (year,yd) where- a = mjd + 678577- quad = div a 1461- d = mod a 1461- y = min (div d 365) 3- yd = fromInteger (d - (y * 365) + 1)- year = quad * 4 + y + 1---- | convert from proleptic Julian year and day format.--- Invalid day numbers will be clipped to the correct range (1 to 365 or 366).-fromJulianYearAndDay :: Integer -> Int -> Day-fromJulianYearAndDay year day = ModifiedJulianDay mjd where- y = year - 1- mjd = (fromIntegral (clip 1 (if isJulianLeapYear year then 366 else 365) day)) + (365 * y) + (div y 4) - 678578---- | convert from proleptic Julian year and day format.--- Invalid day numbers will return Nothing-fromJulianYearAndDayValid :: Integer -> Int -> Maybe Day-fromJulianYearAndDayValid year day = do- day' <- clipValid 1 (if isJulianLeapYear year then 366 else 365) day- let- y = year - 1- mjd = (fromIntegral day') + (365 * y) + (div y 4) - 678578- return (ModifiedJulianDay mjd)---- | show in proleptic Julian year and day format (yyyy-ddd)-showJulianYearAndDay :: Day -> String-showJulianYearAndDay date = (show4 (Just '0') y) ++ "-" ++ (show3 (Just '0') d) where- (y,d) = toJulianYearAndDay date---- | Is this year a leap year according to the proleptic Julian calendar?-isJulianLeapYear :: Integer -> Bool-isJulianLeapYear year = (mod year 4 == 0)
− Data/Time/Calendar/MonthDay.hs
@@ -1,49 +0,0 @@-module Data.Time.Calendar.MonthDay- (- monthAndDayToDayOfYear,monthAndDayToDayOfYearValid,dayOfYearToMonthAndDay,monthLength- ) where--import Data.Time.Calendar.Private---- | convert month and day in the Gregorian or Julian calendars to day of year.--- First arg is leap year flag-monthAndDayToDayOfYear :: Bool -> Int -> Int -> Int-monthAndDayToDayOfYear isLeap month day = (div (367 * month'' - 362) 12) + k + day' where- month' = clip 1 12 month- day' = fromIntegral (clip 1 (monthLength' isLeap month') day)- month'' = fromIntegral month'- k = if month' <= 2 then 0 else if isLeap then -1 else -2---- | convert month and day in the Gregorian or Julian calendars to day of year.--- First arg is leap year flag-monthAndDayToDayOfYearValid :: Bool -> Int -> Int -> Maybe Int-monthAndDayToDayOfYearValid isLeap month day = do- month' <- clipValid 1 12 month- day' <- clipValid 1 (monthLength' isLeap month') day- let- day'' = fromIntegral day'- month'' = fromIntegral month'- k = if month' <= 2 then 0 else if isLeap then -1 else -2- return ((div (367 * month'' - 362) 12) + k + day'')---- | convert day of year in the Gregorian or Julian calendars to month and day.--- First arg is leap year flag-dayOfYearToMonthAndDay :: Bool -> Int -> (Int,Int)-dayOfYearToMonthAndDay isLeap yd = findMonthDay (monthLengths isLeap) (clip 1 (if isLeap then 366 else 365) yd)--findMonthDay :: [Int] -> Int -> (Int,Int)-findMonthDay (n:ns) yd | yd > n = (\(m,d) -> (m + 1,d)) (findMonthDay ns (yd - n))-findMonthDay _ yd = (1,yd)---- | the length of a given month in the Gregorian or Julian calendars.--- First arg is leap year flag-monthLength :: Bool -> Int -> Int-monthLength isLeap month' = monthLength' isLeap (clip 1 12 month')--monthLength' :: Bool -> Int -> Int-monthLength' isLeap month' = (monthLengths isLeap) !! (month' - 1)--monthLengths :: Bool -> [Int]-monthLengths isleap = - [31,if isleap then 29 else 28,31,30,31,30,31,31,30,31,30,31]- --J F M A M J J A S O N D
− Data/Time/Calendar/OrdinalDate.hs
@@ -1,127 +0,0 @@--- | ISO 8601 Ordinal Date format-module Data.Time.Calendar.OrdinalDate where--import Data.Time.Calendar.Days-import Data.Time.Calendar.Private---- | convert to ISO 8601 Ordinal Date format. First element of result is year (proleptic Gregoran calendar),--- second is the day of the year, with 1 for Jan 1, and 365 (or 366 in leap years) for Dec 31.-toOrdinalDate :: Day -> (Integer,Int)-toOrdinalDate (ModifiedJulianDay mjd) = (year,yd) where- a = mjd + 678575- quadcent = div a 146097- b = mod a 146097- cent = min (div b 36524) 3- c = b - (cent * 36524)- quad = div c 1461- d = mod c 1461- y = min (div d 365) 3- yd = fromInteger (d - (y * 365) + 1)- year = quadcent * 400 + cent * 100 + quad * 4 + y + 1---- | convert from ISO 8601 Ordinal Date format.--- Invalid day numbers will be clipped to the correct range (1 to 365 or 366).-fromOrdinalDate :: Integer -> Int -> Day-fromOrdinalDate year day = ModifiedJulianDay mjd where- y = year - 1- mjd = (fromIntegral (clip 1 (if isLeapYear year then 366 else 365) day)) + (365 * y) + (div y 4) - (div y 100) + (div y 400) - 678576---- | convert from ISO 8601 Ordinal Date format.--- Invalid day numbers return Nothing-fromOrdinalDateValid :: Integer -> Int -> Maybe Day-fromOrdinalDateValid year day = do- day' <- clipValid 1 (if isLeapYear year then 366 else 365) day- let- y = year - 1- mjd = (fromIntegral day') + (365 * y) + (div y 4) - (div y 100) + (div y 400) - 678576- return (ModifiedJulianDay mjd)---- | show in ISO 8601 Ordinal Date format (yyyy-ddd)-showOrdinalDate :: Day -> String-showOrdinalDate date = (show4 (Just '0') y) ++ "-" ++ (show3 (Just '0') d) where- (y,d) = toOrdinalDate date---- | Is this year a leap year according to the proleptic Gregorian calendar?-isLeapYear :: Integer -> Bool-isLeapYear year = (mod year 4 == 0) && ((mod year 400 == 0) || not (mod year 100 == 0))---- | Get the number of the Monday-starting week in the year and the day of the week.--- The first Monday is the first day of week 1, any earlier days in the year are week 0 (as \"%W\" in 'Data.Time.Format.formatTime').--- Monday is 1, Sunday is 7 (as \"%u\" in 'Data.Time.Format.formatTime').-mondayStartWeek :: Day -> (Int,Int)-mondayStartWeek date = (fromInteger ((div d 7) - (div k 7)),fromInteger (mod d 7) + 1) where- yd = snd (toOrdinalDate date)- d = (toModifiedJulianDay date) + 2- k = d - (toInteger yd)---- | Get the number of the Sunday-starting week in the year and the day of the week.--- The first Sunday is the first day of week 1, any earlier days in the year are week 0 (as \"%U\" in 'Data.Time.Format.formatTime').--- Sunday is 0, Saturday is 6 (as \"%w\" in 'Data.Time.Format.formatTime').-sundayStartWeek :: Day -> (Int,Int)-sundayStartWeek date =(fromInteger ((div d 7) - (div k 7)),fromInteger (mod d 7)) where- yd = snd (toOrdinalDate date)- d = (toModifiedJulianDay date) + 3- k = d - (toInteger yd)---- | The inverse of 'mondayStartWeek'. Get a 'Day' given the year,--- the number of the Monday-starting week, and the day of the week.--- The first Monday is the first day of week 1, any earlier days in the year --- are week 0 (as \"%W\" in 'Data.Time.Format.formatTime').-fromMondayStartWeek :: Integer -- ^ Year.- -> Int -- ^ Monday-starting week number.- -> Int -- ^ Day of week. - -- Monday is 1, Sunday is 7 (as \"%u\" in 'Data.Time.Format.formatTime').- -> Day-fromMondayStartWeek y w d = ModifiedJulianDay (firstDay + yd)- where yd = firstMonday + 7 * toInteger (w-1) + toInteger d - 1- -- first day of the year- firstDay = toModifiedJulianDay (fromOrdinalDate y 1)- -- 0-based year day of first monday of the year- firstMonday = (5 - firstDay) `mod` 7--fromMondayStartWeekValid :: Integer -- ^ Year.- -> Int -- ^ Monday-starting week number.- -> Int -- ^ Day of week. - -- Monday is 1, Sunday is 7 (as \"%u\" in 'Data.Time.Format.formatTime').- -> Maybe Day-fromMondayStartWeekValid year w d = do- d' <- clipValid 1 7 d- -- first day of the year- let firstDay = toModifiedJulianDay (fromOrdinalDate year 1)- -- 0-based year day of first monday of the year- let firstMonday = (5 - firstDay) `mod` 7- let yd = firstMonday + 7 * toInteger (w-1) + toInteger d'- yd' <- clipValid 1 (if isLeapYear year then 366 else 365) yd- return (ModifiedJulianDay (firstDay - 1 + yd'))---- | The inverse of 'sundayStartWeek'. Get a 'Day' given the year and--- the number of the day of a Sunday-starting week.--- The first Sunday is the first day of week 1, any earlier days in the --- year are week 0 (as \"%U\" in 'Data.Time.Format.formatTime').-fromSundayStartWeek :: Integer -- ^ Year.- -> Int -- ^ Sunday-starting week number.- -> Int -- ^ Day of week- -- Sunday is 0, Saturday is 6 (as \"%w\" in 'Data.Time.Format.formatTime').- -> Day-fromSundayStartWeek y w d = ModifiedJulianDay (firstDay + yd)- where yd = firstSunday + 7 * toInteger (w-1) + toInteger d- -- first day of the year- firstDay = toModifiedJulianDay (fromOrdinalDate y 1)- -- 0-based year day of first sunday of the year- firstSunday = (4 - firstDay) `mod` 7--fromSundayStartWeekValid :: Integer -- ^ Year.- -> Int -- ^ Monday-starting week number.- -> Int -- ^ Day of week. - -- Monday is 1, Sunday is 7 (as \"%u\" in 'Data.Time.Format.formatTime').- -> Maybe Day-fromSundayStartWeekValid year w d = do- d' <- clipValid 1 7 d- -- first day of the year- let firstDay = toModifiedJulianDay (fromOrdinalDate year 1)- -- 0-based year day of first sunday of the year- let firstMonday = (4 - firstDay) `mod` 7- let yd = firstMonday + 7 * toInteger (w-1) + toInteger d'- yd' <- clipValid 1 (if isLeapYear year then 366 else 365) yd- return (ModifiedJulianDay (firstDay - 1 + yd'))-
− Data/Time/Calendar/Private.hs
@@ -1,54 +0,0 @@--- #hide-module Data.Time.Calendar.Private where--import Data.Fixed--type NumericPadOption = Maybe Char--pad1 :: NumericPadOption -> String -> String-pad1 (Just c) s = c:s-pad1 _ s = s--show2Fixed :: NumericPadOption -> Pico -> String-show2Fixed opt x | x < 10 = pad1 opt (showFixed True x)-show2Fixed _ x = showFixed True x--show2 :: (Num t,Ord t,Show t) => NumericPadOption -> t -> String-show2 opt i | i < 0 = '-':(show2 opt (negate i))-show2 opt i = let- s = show i in- case s of- [_] -> pad1 opt s- _ -> s--show3 :: (Num t,Ord t,Show t) => NumericPadOption -> t -> String-show3 opt i | i < 0 = '-':(show3 opt (negate i))-show3 opt i = let- s = show2 opt i in- case s of- [_,_] -> pad1 opt s- _ -> s--show4 :: (Num t,Ord t,Show t) => NumericPadOption -> t -> String-show4 opt i | i < 0 = '-':(show4 opt (negate i))-show4 opt i = let- s = show3 opt i in- case s of- [_,_,_] -> pad1 opt s- _ -> s--mod100 :: (Integral i) => i -> i-mod100 x = mod x 100--div100 :: (Integral i) => i -> i-div100 x = div x 100--clip :: (Ord t) => t -> t -> t -> t-clip a _ x | x < a = a-clip _ b x | x > b = b-clip _ _ x = x--clipValid :: (Ord t) => t -> t -> t -> Maybe t-clipValid a _ x | x < a = Nothing-clipValid _ b x | x > b = Nothing-clipValid _ _ x = Just x
− Data/Time/Calendar/WeekDate.hs
@@ -1,53 +0,0 @@--- | ISO 8601 Week Date format-module Data.Time.Calendar.WeekDate where--import Data.Time.Calendar.OrdinalDate-import Data.Time.Calendar.Days-import Data.Time.Calendar.Private---- | convert to ISO 8601 Week Date format. First element of result is year, second week number (1-53), third day of week (1 for Monday to 7 for Sunday).--- Note that \"Week\" years are not quite the same as Gregorian years, as the first day of the year is always a Monday.--- The first week of a year is the first week to contain at least four days in the corresponding Gregorian year.-toWeekDate :: Day -> (Integer,Int,Int)-toWeekDate date@(ModifiedJulianDay mjd) = (y1,fromInteger (w1 + 1),fromInteger (mod d 7) + 1) where- (y0,yd) = toOrdinalDate date- d = mjd + 2- foo :: Integer -> Integer- foo y = bar (toModifiedJulianDay (fromOrdinalDate y 6))- bar k = (div d 7) - (div k 7)- w0 = bar (d - (toInteger yd) + 4)- (y1,w1) = if w0 == -1- then (y0 - 1,foo (y0 - 1))- else if w0 == 52- then if (foo (y0 + 1)) == 0- then (y0 + 1,0)- else (y0,w0)- else (y0,w0)---- | convert from ISO 8601 Week Date format. First argument is year, second week number (1-52 or 53), third day of week (1 for Monday to 7 for Sunday).--- Invalid week and day values will be clipped to the correct range.-fromWeekDate :: Integer -> Int -> Int -> Day-fromWeekDate y w d = ModifiedJulianDay (k - (mod k 7) + (toInteger (((clip 1 (if longYear then 53 else 52) w) * 7) + (clip 1 7 d))) - 10) where- k = toModifiedJulianDay (fromOrdinalDate y 6)- longYear = case toWeekDate (fromOrdinalDate y 365) of- (_,53,_) -> True- _ -> False---- | convert from ISO 8601 Week Date format. First argument is year, second week number (1-52 or 53), third day of week (1 for Monday to 7 for Sunday).--- Invalid week and day values will return Nothing.-fromWeekDateValid :: Integer -> Int -> Int -> Maybe Day-fromWeekDateValid y w d = do- d' <- clipValid 1 7 d- let- longYear = case toWeekDate (fromOrdinalDate y 365) of- (_,53,_) -> True- _ -> False- w' <- clipValid 1 (if longYear then 53 else 52) w- let- k = toModifiedJulianDay (fromOrdinalDate y 6)- return (ModifiedJulianDay (k - (mod k 7) + (toInteger ((w' * 7) + d')) - 10))---- | show in ISO 8601 Week Date format as yyyy-Www-d (e.g. \"2006-W46-3\").-showWeekDate :: Day -> String-showWeekDate date = (show4 (Just '0') y) ++ "-W" ++ (show2 (Just '0') w) ++ "-" ++ (show d) where- (y,w,d) = toWeekDate date
− Data/Time/Clock.hs
@@ -1,18 +0,0 @@--- | Types and functions for UTC and UT1-module Data.Time.Clock-(- module Data.Time.Clock.Scale,- module Data.Time.Clock.UTC,- module Data.Time.Clock.UTCDiff,- module Data.Time.Clock-) where--import Data.Time.Clock.Scale-import Data.Time.Clock.UTCDiff-import Data.Time.Clock.UTC-import Data.Time.Clock.POSIX-import Control.Monad---- | Get the current UTC time from the system clock.-getCurrentTime :: IO UTCTime-getCurrentTime = liftM posixSecondsToUTCTime getPOSIXTime
− Data/Time/Clock/CTimeval.hs
@@ -1,34 +0,0 @@--- #hide-module Data.Time.Clock.CTimeval where--#ifndef mingw32_HOST_OS--- All Unix-specific, this--import Foreign-import Foreign.C--data CTimeval = MkCTimeval CLong CLong--instance Storable CTimeval where- sizeOf _ = (sizeOf (undefined :: CLong)) * 2- alignment _ = alignment (undefined :: CLong)- peek p = do- s <- peekElemOff (castPtr p) 0- mus <- peekElemOff (castPtr p) 1- return (MkCTimeval s mus)- poke p (MkCTimeval s mus) = do- pokeElemOff (castPtr p) 0 s- pokeElemOff (castPtr p) 1 mus--foreign import ccall unsafe "time.h gettimeofday" gettimeofday :: Ptr CTimeval -> Ptr () -> IO CInt---- | Get the current POSIX time from the system clock.-getCTimeval :: IO CTimeval-getCTimeval = with (MkCTimeval 0 0) (\ptval -> do- result <- gettimeofday ptval nullPtr- if (result == 0)- then peek ptval- else fail ("error in gettimeofday: " ++ (show result))- )--#endif
− Data/Time/Clock/POSIX.hs
@@ -1,66 +0,0 @@--- | POSIX time, if you need to deal with timestamps and the like.--- Most people won't need this module.-module Data.Time.Clock.POSIX-(- posixDayLength,POSIXTime,posixSecondsToUTCTime,utcTimeToPOSIXSeconds,getPOSIXTime-) where--import Data.Time.Clock.UTC-import Data.Time.Calendar.Days-import Data.Fixed-import Control.Monad--#ifdef mingw32_HOST_OS-import Data.Word ( Word64)-import System.Win32.Time-#else-import Data.Time.Clock.CTimeval-#endif---- | 86400 nominal seconds in every day-posixDayLength :: NominalDiffTime-posixDayLength = 86400---- | POSIX time is the nominal time since 1970-01-01 00:00 UTC--- --- To convert from a 'Foreign.C.CTime' or 'System.Posix.EpochTime', use 'realToFrac'.----type POSIXTime = NominalDiffTime--unixEpochDay :: Day-unixEpochDay = ModifiedJulianDay 40587--posixSecondsToUTCTime :: POSIXTime -> UTCTime-posixSecondsToUTCTime i = let- (d,t) = divMod' i posixDayLength- in UTCTime (addDays d unixEpochDay) (realToFrac t)--utcTimeToPOSIXSeconds :: UTCTime -> POSIXTime-utcTimeToPOSIXSeconds (UTCTime d t) =- (fromInteger (diffDays d unixEpochDay) * posixDayLength) + min posixDayLength (realToFrac t)---- | Get the current POSIX time from the system clock.-getPOSIXTime :: IO POSIXTime--#ifdef mingw32_HOST_OS--- On Windows, the equlvalent of POSIX time is "file time", defined as--- the number of 100-nanosecond intervals that have elapsed since--- 12:00 A.M. January 1, 1601 (UTC). We can convert this into a POSIX--- time by adjusting the offset to be relative to the POSIX epoch.--getPOSIXTime = do- FILETIME ft <- System.Win32.Time.getSystemTimeAsFileTime- return (fromIntegral (ft - win32_epoch_adjust) / 10000000)--win32_epoch_adjust :: Word64-win32_epoch_adjust = 116444736000000000--#else---- Use POSIX time-ctimevalToPosixSeconds :: CTimeval -> POSIXTime-ctimevalToPosixSeconds (MkCTimeval s mus) = (fromIntegral s) + (fromIntegral mus) / 1000000--getPOSIXTime = liftM ctimevalToPosixSeconds getCTimeval--#endif
− Data/Time/Clock/Scale.hs
@@ -1,72 +0,0 @@--- #hide-module Data.Time.Clock.Scale-(- -- * Universal Time- -- | Time as measured by the earth.- UniversalTime(..),-- -- * Absolute intervals- DiffTime,- secondsToDiffTime, picosecondsToDiffTime-) where--import Data.Ratio ((%))-import Data.Fixed-import Data.Typeable---- | The Modified Julian Date is the day with the fraction of the day, measured from UT midnight.--- It's used to represent UT1, which is time as measured by the earth's rotation, adjusted for various wobbles.-newtype UniversalTime = ModJulianDate {getModJulianDate :: Rational} deriving (Eq,Ord)--instance Typeable UniversalTime where- typeOf _ = mkTyConApp (mkTyCon "Data.Time.Clock.Scale.UniversalTime") []---- | This is a length of time, as measured by a clock.--- Conversion functions will treat it as seconds.--- It has a precision of 10^-12 s.-newtype DiffTime = MkDiffTime Pico deriving (Eq,Ord)--instance Typeable DiffTime where- typeOf _ = mkTyConApp (mkTyCon "Data.Time.Clock.Scale.DiffTime") []---- necessary because H98 doesn't have "cunning newtype" derivation-instance Enum DiffTime where- succ (MkDiffTime a) = MkDiffTime (succ a)- pred (MkDiffTime a) = MkDiffTime (pred a)- toEnum = MkDiffTime . toEnum- fromEnum (MkDiffTime a) = fromEnum a- enumFrom (MkDiffTime a) = fmap MkDiffTime (enumFrom a)- enumFromThen (MkDiffTime a) (MkDiffTime b) = fmap MkDiffTime (enumFromThen a b)- enumFromTo (MkDiffTime a) (MkDiffTime b) = fmap MkDiffTime (enumFromTo a b)- enumFromThenTo (MkDiffTime a) (MkDiffTime b) (MkDiffTime c) = fmap MkDiffTime (enumFromThenTo a b c)--instance Show DiffTime where- show (MkDiffTime t) = (showFixed True t) ++ "s"---- necessary because H98 doesn't have "cunning newtype" derivation-instance Num DiffTime where- (MkDiffTime a) + (MkDiffTime b) = MkDiffTime (a + b)- (MkDiffTime a) - (MkDiffTime b) = MkDiffTime (a - b)- (MkDiffTime a) * (MkDiffTime b) = MkDiffTime (a * b)- negate (MkDiffTime a) = MkDiffTime (negate a)- abs (MkDiffTime a) = MkDiffTime (abs a)- signum (MkDiffTime a) = MkDiffTime (signum a)- fromInteger i = MkDiffTime (fromInteger i)---- necessary because H98 doesn't have "cunning newtype" derivation-instance Real DiffTime where- toRational (MkDiffTime a) = toRational a---- necessary because H98 doesn't have "cunning newtype" derivation-instance Fractional DiffTime where- (MkDiffTime a) / (MkDiffTime b) = MkDiffTime (a / b)- recip (MkDiffTime a) = MkDiffTime (recip a)- fromRational r = MkDiffTime (fromRational r)---- | Create a 'DiffTime' which represents an integral number of seconds.-secondsToDiffTime :: Integer -> DiffTime-secondsToDiffTime = fromInteger---- | Create a 'DiffTime' from a number of picoseconds.-picosecondsToDiffTime :: Integer -> DiffTime-picosecondsToDiffTime x = fromRational (x % 1000000000000)
− Data/Time/Clock/TAI.hs
@@ -1,129 +0,0 @@--- | TAI and leap-second tables for converting to UTC: most people won't need this module.-module Data.Time.Clock.TAI-(- -- TAI arithmetic- AbsoluteTime,taiEpoch,addAbsoluteTime,diffAbsoluteTime,-- -- leap-second table type- LeapSecondTable,-- -- conversion between UTC and TAI with table- utcDayLength,utcToTAITime,taiToUTCTime,-- parseTAIUTCDATFile-) where--import Data.Time.LocalTime-import Data.Time.Calendar.Days-import Data.Time.Clock-import Data.Typeable-import Data.Fixed---- | AbsoluteTime is TAI, time as measured by a clock.-newtype AbsoluteTime = MkAbsoluteTime {unAbsoluteTime :: DiffTime} deriving (Eq,Ord)--instance Typeable AbsoluteTime where- typeOf _ = mkTyConApp (mkTyCon "Data.Time.Clock.TAI.AbsoluteTime") []--instance Show AbsoluteTime where- show t = show (utcToLocalTime utc (taiToUTCTime (const 0) t)) ++ " TAI" -- ugly, but standard apparently---- | The epoch of TAI, which is 1858-11-17 00:00:00 TAI.-taiEpoch :: AbsoluteTime-taiEpoch = MkAbsoluteTime 0---- | addAbsoluteTime a b = a + b-addAbsoluteTime :: DiffTime -> AbsoluteTime -> AbsoluteTime-addAbsoluteTime t (MkAbsoluteTime a) = MkAbsoluteTime (a + t)---- | diffAbsoluteTime a b = a - b-diffAbsoluteTime :: AbsoluteTime -> AbsoluteTime -> DiffTime-diffAbsoluteTime (MkAbsoluteTime a) (MkAbsoluteTime b) = a - b---- | TAI - UTC during this day.--- No table is provided, as any program compiled with it would become--- out of date in six months.-type LeapSecondTable = Day -> Integer--utcDayLength :: LeapSecondTable -> Day -> DiffTime-utcDayLength table day = realToFrac (86400 + (table (addDays 1 day)) - (table day))--dayStart :: LeapSecondTable -> Day -> AbsoluteTime-dayStart table day = MkAbsoluteTime (realToFrac ((toModifiedJulianDay day) * 86400 + (table day)))--utcToTAITime :: LeapSecondTable -> UTCTime -> AbsoluteTime-utcToTAITime table (UTCTime day dtime) = MkAbsoluteTime (t + dtime) where- MkAbsoluteTime t = dayStart table day--taiToUTCTime :: LeapSecondTable -> AbsoluteTime -> UTCTime-taiToUTCTime table abstime = stable (ModifiedJulianDay (div' (unAbsoluteTime abstime) 86400)) where- stable day = if (day == day') then UTCTime day dtime else stable day' where- dayt = dayStart table day- dtime = diffAbsoluteTime abstime dayt- day' = addDays (div' dtime (utcDayLength table day)) day---- | Parse the contents of a tai-utc.dat file.--- This does not do any kind of validation and will return a bad table for input--- not in the correct format.-parseTAIUTCDATFile :: String -> LeapSecondTable-parseTAIUTCDATFile ss = offsetlist 0 (parse (lines ss)) where- offsetlist :: Integer -> [(Day,Integer)] -> LeapSecondTable- offsetlist i [] _ = i- offsetlist i ((d0,_):_) d | d < d0 = i- offsetlist _ ((_,i0):xx) d = offsetlist i0 xx d- - parse :: [String] -> [(Day,Integer)]- parse [] = []- parse (a:as) = let- ps = parse as- in case matchLine a of- Just di -> di:ps- Nothing -> ps- - matchLine :: String -> Maybe (Day,Integer)- matchLine s = do- check0S s- (d,s') <- findJD s- i <- findOffset s'- return (d,i)- - -- a bit fragile- check0S :: String -> Maybe ()- check0S "X 0.0 S" = Just ()- check0S [] = Nothing- check0S (_:cs) = check0S cs- - findJD :: String -> Maybe (Day,String)- findJD ('=':'J':'D':s) = do- d <- getInteger '5' s- return (ModifiedJulianDay (d - 2400000),s)- findJD [] = Nothing- findJD (_:cs) = findJD cs- - findOffset :: String -> Maybe Integer- findOffset ('T':'A':'I':'-':'U':'T':'C':'=':s) = getInteger '0' s- findOffset [] = Nothing- findOffset (_:cs) = findOffset cs- - getInteger :: Char -> String -> Maybe Integer- getInteger p s = do- digits <- getDigits p s- fromDigits 0 digits- - getDigits :: Char -> String -> Maybe String- getDigits p (' ':s) = getDigits p s- getDigits p (c:cs) | c >= '0' && c <= '9' = do- s <- getDigits p cs- return (c:s)- getDigits p ('.':p1:_) = if p == p1 then Just [] else Nothing- getDigits _ _ = Nothing- - - fromDigits :: Integer -> String -> Maybe Integer- fromDigits i [] = Just i- fromDigits i (c:cs) | c >= '0' && c <= '9' = fromDigits ((i * 10) + (fromIntegral ((fromEnum c) - (fromEnum '0')))) cs- fromDigits _ _ = Nothing---- typical line format:--- 1972 JAN 1 =JD 2441317.5 TAI-UTC= 10.0 S + (MJD - 41317.) X 0.0 S--- 1972 JUL 1 =JD 2441499.5 TAI-UTC= 11.0 S + (MJD - 41317.) X 0.0 S
− Data/Time/Clock/UTC.hs
@@ -1,93 +0,0 @@--- #hide-module Data.Time.Clock.UTC-(- -- * UTC- -- | UTC is time as measured by a clock, corrected to keep pace with the earth by adding or removing- -- occasional seconds, known as \"leap seconds\".- -- These corrections are not predictable and are announced with six month's notice.- -- No table of these corrections is provided, as any program compiled with it would become- -- out of date in six months.- -- - -- If you don't care about leap seconds, use UTCTime and NominalDiffTime for your clock calculations,- -- and you'll be fine.- UTCTime(..),NominalDiffTime-) where--import Data.Time.Calendar.Days-import Data.Time.Clock.Scale-import Data.Fixed-import Data.Typeable---- | This is the simplest representation of UTC.--- It consists of the day number, and a time offset from midnight.--- Note that if a day has a leap second added to it, it will have 86401 seconds.-data UTCTime = UTCTime {- -- | the day- utctDay :: Day,- -- | the time from midnight, 0 <= t < 86401s (because of leap-seconds)- utctDayTime :: DiffTime-}--instance Typeable UTCTime where- typeOf _ = mkTyConApp (mkTyCon "Data.Time.Clock.UTC.UTCTime") []--instance Eq UTCTime where- (UTCTime da ta) == (UTCTime db tb) = (da == db) && (ta == tb)--instance Ord UTCTime where- compare (UTCTime da ta) (UTCTime db tb) = case (compare da db) of- EQ -> compare ta tb- cmp -> cmp---- | This is a length of time, as measured by UTC.--- Conversion functions will treat it as seconds.--- It has a precision of 10^-12 s.--- It ignores leap-seconds, so it's not necessarily a fixed amount of clock time.--- For instance, 23:00 UTC + 2 hours of NominalDiffTime = 01:00 UTC (+ 1 day),--- regardless of whether a leap-second intervened.-newtype NominalDiffTime = MkNominalDiffTime Pico deriving (Eq,Ord)--instance Typeable NominalDiffTime where- typeOf _ = mkTyConApp (mkTyCon "Data.Time.Clock.UTC.NominalDiffTime") []--instance Enum NominalDiffTime where- succ (MkNominalDiffTime a) = MkNominalDiffTime (succ a)- pred (MkNominalDiffTime a) = MkNominalDiffTime (pred a)- toEnum = MkNominalDiffTime . toEnum- fromEnum (MkNominalDiffTime a) = fromEnum a- enumFrom (MkNominalDiffTime a) = fmap MkNominalDiffTime (enumFrom a)- enumFromThen (MkNominalDiffTime a) (MkNominalDiffTime b) = fmap MkNominalDiffTime (enumFromThen a b)- enumFromTo (MkNominalDiffTime a) (MkNominalDiffTime b) = fmap MkNominalDiffTime (enumFromTo a b)- enumFromThenTo (MkNominalDiffTime a) (MkNominalDiffTime b) (MkNominalDiffTime c) = fmap MkNominalDiffTime (enumFromThenTo a b c)--instance Show NominalDiffTime where- show (MkNominalDiffTime t) = (showFixed True t) ++ "s"---- necessary because H98 doesn't have "cunning newtype" derivation-instance Num NominalDiffTime where- (MkNominalDiffTime a) + (MkNominalDiffTime b) = MkNominalDiffTime (a + b)- (MkNominalDiffTime a) - (MkNominalDiffTime b) = MkNominalDiffTime (a - b)- (MkNominalDiffTime a) * (MkNominalDiffTime b) = MkNominalDiffTime (a * b)- negate (MkNominalDiffTime a) = MkNominalDiffTime (negate a)- abs (MkNominalDiffTime a) = MkNominalDiffTime (abs a)- signum (MkNominalDiffTime a) = MkNominalDiffTime (signum a)- fromInteger i = MkNominalDiffTime (fromInteger i)---- necessary because H98 doesn't have "cunning newtype" derivation-instance Real NominalDiffTime where- toRational (MkNominalDiffTime a) = toRational a---- necessary because H98 doesn't have "cunning newtype" derivation-instance Fractional NominalDiffTime where- (MkNominalDiffTime a) / (MkNominalDiffTime b) = MkNominalDiffTime (a / b)- recip (MkNominalDiffTime a) = MkNominalDiffTime (recip a)- fromRational r = MkNominalDiffTime (fromRational r)---- necessary because H98 doesn't have "cunning newtype" derivation-instance RealFrac NominalDiffTime where- properFraction (MkNominalDiffTime a) = (i,MkNominalDiffTime f) where- (i,f) = properFraction a- truncate (MkNominalDiffTime a) = truncate a- round (MkNominalDiffTime a) = round a- ceiling (MkNominalDiffTime a) = ceiling a- floor (MkNominalDiffTime a) = floor a
− Data/Time/Clock/UTCDiff.hs
@@ -1,13 +0,0 @@--- #hide-module Data.Time.Clock.UTCDiff where--import Data.Time.Clock.POSIX-import Data.Time.Clock.UTC---- | addUTCTime a b = a + b-addUTCTime :: NominalDiffTime -> UTCTime -> UTCTime-addUTCTime x t = posixSecondsToUTCTime (x + (utcTimeToPOSIXSeconds t))---- | diffUTCTime a b = a - b-diffUTCTime :: UTCTime -> UTCTime -> NominalDiffTime-diffUTCTime a b = (utcTimeToPOSIXSeconds a) - (utcTimeToPOSIXSeconds b)
− Data/Time/Format.hs
@@ -1,247 +0,0 @@-module Data.Time.Format- (- -- * UNIX-style formatting- NumericPadOption,FormatTime(..),formatTime,- module Data.Time.Format.Parse- ) where--import Data.Time.Format.Parse-import Data.Time.LocalTime-import Data.Time.Calendar.WeekDate-import Data.Time.Calendar.OrdinalDate-import Data.Time.Calendar-import Data.Time.Calendar.Private-import Data.Time.Clock-import Data.Time.Clock.POSIX--import System.Locale-import Data.Maybe-import Data.Char-import Data.Fixed---- <http://www.opengroup.org/onlinepubs/007908799/xsh/strftime.html>-class FormatTime t where- formatCharacter :: Char -> Maybe (TimeLocale -> Maybe NumericPadOption -> t -> String)--formatChar :: (FormatTime t) => Char -> TimeLocale -> Maybe NumericPadOption -> t -> String-formatChar '%' _ _ _ = "%"-formatChar 't' _ _ _ = "\t"-formatChar 'n' _ _ _ = "\n"-formatChar c locale mpado t = case (formatCharacter c) of- Just f -> f locale mpado t- _ -> ""---- | Substitute various time-related information for each %-code in the string, as per 'formatCharacter'.------ For all types (note these three are done here, not by 'formatCharacter'):------ [@%%@] @%@------ [@%t@] tab------ [@%n@] newline------ glibc-style modifiers can be used before the letter (here marked as @z@):------ [@%-z@] no padding------ [@%_z@] pad with spaces------ [@%0z@] pad with zeros------ [@%^z@] convert to upper case------ [@%#z@] convert to lower case (consistently, unlike glibc)------ For 'TimeZone' (and 'ZonedTime' and 'UTCTime'):------ [@%z@] timezone offset on the format @-HHMM@.------ [@%Z@] timezone name------ For 'LocalTime' (and 'ZonedTime' and 'UTCTime'):------ [@%c@] as 'dateTimeFmt' @locale@ (e.g. @%a %b %e %H:%M:%S %Z %Y@)------ For 'TimeOfDay' (and 'LocalTime' and 'ZonedTime' and 'UTCTime'):------ [@%R@] same as @%H:%M@------ [@%T@] same as @%H:%M:%S@------ [@%X@] as 'timeFmt' @locale@ (e.g. @%H:%M:%S@)------ [@%r@] as 'time12Fmt' @locale@ (e.g. @%I:%M:%S %p@)------ [@%P@] day half from ('amPm' @locale@), converted to lowercase, @am@, @pm@------ [@%p@] day half from ('amPm' @locale@), @AM@, @PM@------ [@%H@] hour, 24-hour, leading 0 as needed, @00@ - @23@------ [@%I@] hour, 12-hour, leading 0 as needed, @01@ - @12@------ [@%k@] hour, 24-hour, leading space as needed, @ 0@ - @23@------ [@%l@] hour, 12-hour, leading space as needed, @ 1@ - @12@------ [@%M@] minute, @00@ - @59@------ [@%S@] second, without decimal part, @00@ - @60@------ [@%q@] picosecond, including trailing zeros, @000000000000@ - @999999999999@.------ [@%Q@] decimal point and up to 12 second decimals, without trailing zeros.--- For a whole number of seconds, @%Q@ produces the empty string.------ For 'UTCTime' and 'ZonedTime':------ [@%s@] number of whole seconds since the Unix epoch. For times before--- the Unix epoch, this is a negative number. Note that in @%s.%q@ and @%s%Q@ --- the decimals are positive, not negative. For example, 0.9 seconds--- before the Unix epoch is formatted as @-1.1@ with @%s%Q@.------ For 'Day' (and 'LocalTime' and 'ZonedTime' and 'UTCTime'):------ [@%D@] same as @%m\/%d\/%y@------ [@%F@] same as @%Y-%m-%d@------ [@%x@] as 'dateFmt' @locale@ (e.g. @%m\/%d\/%y@)------ [@%Y@] year------ [@%y@] last two digits of year, @00@ - @99@------ [@%C@] century (being the first two digits of the year), @00@ - @99@------ [@%B@] month name, long form ('fst' from 'months' @locale@), @January@ - @December@------ [@%b@, @%h@] month name, short form ('snd' from 'months' @locale@), @Jan@ - @Dec@------ [@%m@] month of year, leading 0 as needed, @01@ - @12@------ [@%d@] day of month, leading 0 as needed, @01@ - @31@------ [@%e@] day of month, leading space as needed, @ 1@ - @31@------ [@%j@] day of year for Ordinal Date format, @001@ - @366@------ [@%G@] year for Week Date format------ [@%g@] last two digits of year for Week Date format, @00@ - @99@------ [@%f@] century (first two digits of year) for Week Date format, @00@ - @99@------ [@%V@] week for Week Date format, @01@ - @53@------ [@%u@] day for Week Date format, @1@ - @7@------ [@%a@] day of week, short form ('snd' from 'wDays' @locale@), @Sun@ - @Sat@------ [@%A@] day of week, long form ('fst' from 'wDays' @locale@), @Sunday@ - @Saturday@------ [@%U@] week number of year, where weeks start on Sunday (as 'sundayStartWeek'), @00@ - @53@------ [@%w@] day of week number, @0@ (= Sunday) - @6@ (= Saturday)------ [@%W@] week number of year, where weeks start on Monday (as 'mondayStartWeek'), @00@ - @53@-formatTime :: (FormatTime t) => TimeLocale -> String -> t -> String-formatTime _ [] _ = ""-formatTime locale ('%':'_':c:cs) t = (formatChar c locale (Just (Just ' ')) t) ++ (formatTime locale cs t)-formatTime locale ('%':'-':c:cs) t = (formatChar c locale (Just Nothing) t) ++ (formatTime locale cs t)-formatTime locale ('%':'0':c:cs) t = (formatChar c locale (Just (Just '0')) t) ++ (formatTime locale cs t)-formatTime locale ('%':'^':c:cs) t = (fmap toUpper (formatChar c locale Nothing t)) ++ (formatTime locale cs t)-formatTime locale ('%':'#':c:cs) t = (fmap toLower (formatChar c locale Nothing t)) ++ (formatTime locale cs t)-formatTime locale ('%':c:cs) t = (formatChar c locale Nothing t) ++ (formatTime locale cs t)-formatTime locale (c:cs) t = c:(formatTime locale cs t)--instance FormatTime LocalTime where- formatCharacter 'c' = Just (\locale _ -> formatTime locale (dateTimeFmt locale))- formatCharacter c = case (formatCharacter c) of- Just f -> Just (\locale mpado dt -> f locale mpado (localDay dt))- Nothing -> case (formatCharacter c) of- Just f -> Just (\locale mpado dt -> f locale mpado (localTimeOfDay dt))- Nothing -> Nothing--instance FormatTime TimeOfDay where- -- Aggregate- formatCharacter 'R' = Just (\locale _ -> formatTime locale "%H:%M")- formatCharacter 'T' = Just (\locale _ -> formatTime locale "%H:%M:%S")- formatCharacter 'X' = Just (\locale _ -> formatTime locale (timeFmt locale))- formatCharacter 'r' = Just (\locale _ -> formatTime locale (time12Fmt locale))- -- AM/PM- formatCharacter 'P' = Just (\locale _ day -> map toLower ((if (todHour day) < 12 then fst else snd) (amPm locale)))- formatCharacter 'p' = Just (\locale _ day -> (if (todHour day) < 12 then fst else snd) (amPm locale))- -- Hour- formatCharacter 'H' = Just (\_ opt -> (show2 (fromMaybe (Just '0') opt)) . todHour)- formatCharacter 'I' = Just (\_ opt -> (show2 (fromMaybe (Just '0') opt)) . (\h -> (mod (h - 1) 12) + 1) . todHour)- formatCharacter 'k' = Just (\_ opt -> (show2 (fromMaybe (Just ' ') opt)) . todHour)- formatCharacter 'l' = Just (\_ opt -> (show2 (fromMaybe (Just ' ') opt)) . (\h -> (mod (h - 1) 12) + 1) . todHour)- -- Minute- formatCharacter 'M' = Just (\_ opt -> (show2 (fromMaybe (Just '0') opt)) . todMin)- -- Second- formatCharacter 'S' = Just (\_ opt -> (show2 (fromMaybe (Just '0') opt) :: Int -> String) . truncate . todSec)- formatCharacter 'q' = Just (\_ _ -> drop 1 . dropWhile (/='.') . showFixed False . todSec)- formatCharacter 'Q' = Just (\_ _ -> dropWhile (/='.') . showFixed True . todSec)-- -- Default- formatCharacter _ = Nothing--instance FormatTime ZonedTime where- formatCharacter 'c' = Just (\locale _ -> formatTime locale (dateTimeFmt locale))- formatCharacter 's' = Just (\_ _ zt -> show (floor (utcTimeToPOSIXSeconds (zonedTimeToUTC zt)) :: Integer))- formatCharacter c = case (formatCharacter c) of- Just f -> Just (\locale mpado dt -> f locale mpado (zonedTimeToLocalTime dt))- Nothing -> case (formatCharacter c) of- Just f -> Just (\locale mpado dt -> f locale mpado (zonedTimeZone dt))- Nothing -> Nothing--instance FormatTime TimeZone where- formatCharacter 'z' = Just (\_ opt -> timeZoneOffsetString' (fromMaybe (Just '0') opt))- formatCharacter 'Z' = - Just (\_ opt z -> let n = timeZoneName z- in if null n then timeZoneOffsetString' (fromMaybe (Just '0') opt) z else n)- formatCharacter _ = Nothing--instance FormatTime Day where- -- Aggregate- formatCharacter 'D' = Just (\locale _ -> formatTime locale "%m/%d/%y")- formatCharacter 'F' = Just (\locale _ -> formatTime locale "%Y-%m-%d")- formatCharacter 'x' = Just (\locale _ -> formatTime locale (dateFmt locale))-- -- Year Count- formatCharacter 'Y' = Just (\_ _ -> show . fst . toOrdinalDate)- formatCharacter 'y' = Just (\_ opt -> (show2 (fromMaybe (Just '0') opt)) . mod100 . fst . toOrdinalDate)- formatCharacter 'C' = Just (\_ opt -> (show2 (fromMaybe (Just '0') opt)) . div100 . fst . toOrdinalDate)- -- Month of Year- formatCharacter 'B' = Just (\locale _ -> fst . (\(_,m,_) -> (months locale) !! (m - 1)) . toGregorian)- formatCharacter 'b' = Just (\locale _ -> snd . (\(_,m,_) -> (months locale) !! (m - 1)) . toGregorian)- formatCharacter 'h' = Just (\locale _ -> snd . (\(_,m,_) -> (months locale) !! (m - 1)) . toGregorian)- formatCharacter 'm' = Just (\_ opt -> (show2 (fromMaybe (Just '0') opt)) . (\(_,m,_) -> m) . toGregorian)- -- Day of Month- formatCharacter 'd' = Just (\_ opt -> (show2 (fromMaybe (Just '0') opt)) . (\(_,_,d) -> d) . toGregorian)- formatCharacter 'e' = Just (\_ opt -> (show2 (fromMaybe (Just ' ') opt)) . (\(_,_,d) -> d) . toGregorian)- -- Day of Year- formatCharacter 'j' = Just (\_ opt -> (show3 (fromMaybe (Just '0') opt)) . snd . toOrdinalDate)-- -- ISO 8601 Week Date- formatCharacter 'G' = Just (\_ _ -> show . (\(y,_,_) -> y) . toWeekDate)- formatCharacter 'g' = Just (\_ opt -> (show2 (fromMaybe (Just '0') opt)) . mod100 . (\(y,_,_) -> y) . toWeekDate)- formatCharacter 'f' = Just (\_ opt -> (show2 (fromMaybe (Just '0') opt)) . div100 . (\(y,_,_) -> y) . toWeekDate)-- formatCharacter 'V' = Just (\_ opt -> (show2 (fromMaybe (Just '0') opt)) . (\(_,w,_) -> w) . toWeekDate)- formatCharacter 'u' = Just (\_ _ -> show . (\(_,_,d) -> d) . toWeekDate)-- -- Day of week- formatCharacter 'a' = Just (\locale _ -> snd . ((wDays locale) !!) . snd . sundayStartWeek)- formatCharacter 'A' = Just (\locale _ -> fst . ((wDays locale) !!) . snd . sundayStartWeek)- formatCharacter 'U' = Just (\_ opt -> (show2 (fromMaybe (Just '0') opt)) . fst . sundayStartWeek)- formatCharacter 'w' = Just (\_ _ -> show . snd . sundayStartWeek)- formatCharacter 'W' = Just (\_ opt -> (show2 (fromMaybe (Just '0') opt)) . fst . mondayStartWeek)- - -- Default- formatCharacter _ = Nothing--instance FormatTime UTCTime where- formatCharacter c = fmap (\f locale mpado t -> f locale mpado (utcToZonedTime utc t)) (formatCharacter c)
− Data/Time/Format/Parse.hs
@@ -1,560 +0,0 @@-{-# OPTIONS -fno-warn-orphans #-}---- #hide-module Data.Time.Format.Parse - (- -- * UNIX-style parsing- parseTime, readTime, readsTime,- ParseTime(..)- ) where--import Data.Time.Clock.POSIX-import Data.Time.Clock-import Data.Time.Calendar-import Data.Time.Calendar.OrdinalDate-import Data.Time.Calendar.WeekDate-import Data.Time.LocalTime--import Control.Monad-import Data.Char-import Data.Fixed-import Data.List-import Data.Maybe-import Data.Ratio-import System.Locale-import Text.ParserCombinators.ReadP hiding (char, string)----- | Case-insensitive version of 'Text.ParserCombinators.ReadP.char'.-char :: Char -> ReadP Char-char c = satisfy (\x -> toUpper c == toUpper x)--- | Case-insensitive version of 'Text.ParserCombinators.ReadP.string'.-string :: String -> ReadP String-string this = do s <- look; scan this s- where- scan [] _ = do return this- scan (x:xs) (y:ys) | toUpper x == toUpper y = do get; scan xs ys- scan _ _ = do pfail--- | Convert string to upper case.-up :: String -> String-up = map toUpper----- | The class of types which can be parsed given a UNIX-style time format--- string.-class ParseTime t where- -- | Builds a time value from a parsed input string.- -- If the input does not include all the information needed to- -- construct a complete value, any missing parts should be taken- -- from 1970-01-01 00:00:00 +0000 (which was a Thursday).- buildTime :: TimeLocale -- ^ The time locale.- -> [(Char,String)] -- ^ Pairs of format characters and the - -- corresponding part of the input.- -> t---- | Parses a time value given a format string. Supports the same %-codes as--- 'formatTime'. Leading and trailing whitespace is accepted. Case is not--- significant. Some variations in the input are accepted:------ [@%z@] accepts any of @-HHMM@ or @-HH:MM@.------ [@%Z@] accepts any string of letters, or any--- of the formats accepted by @%z@.----parseTime :: ParseTime t =>- TimeLocale -- ^ Time locale.- -> String -- ^ Format string.- -> String -- ^ Input string.- -> Maybe t -- ^ The time value, or 'Nothing' if the input could- -- not be parsed using the given format.-parseTime l fmt s = case readsTime l fmt s of- [(t,r)] | all isSpace r -> Just t- _ -> Nothing---- | Parse a time value given a format string. Fails if the input could--- not be parsed using the given format. See 'parseTime' for details.-readTime :: ParseTime t =>- TimeLocale -- ^ Time locale.- -> String -- ^ Format string.- -> String -- ^ Input string.- -> t -- ^ The time value.-readTime l fmt s = case readsTime l fmt s of- [(t,r)] | all isSpace r -> t- [(_,x)] -> error $ "readTime: junk at end of " ++ show x- _ -> error $ "readsTime: bad input " ++ show s---- | Parse a time value given a format string. See 'parseTime' for details.-readsTime :: ParseTime t =>- TimeLocale -- ^ Time locale.- -> String -- ^ Format string- -> ReadS t-readsTime l f = readP_to_S (liftM (buildTime l) r)- where r = skipSpaces >> parseInput l (parseFormat l f)------- * Internals-----type DateFormat = [DateFormatSpec]--data DateFormatSpec = Value Char- | WhiteSpace- | Literal Char- deriving Show--parseFormat :: TimeLocale -> String -> DateFormat-parseFormat l = p- where p "" = []- p ('%': c :cs) = s ++ p cs- where s = case c of- 'c' -> p (dateTimeFmt l)- 'R' -> p "%H:%M"- 'T' -> p "%H:%M:%S"- 'X' -> p (timeFmt l)- 'r' -> p (time12Fmt l)- 'D' -> p "%m/%d/%y"- 'F' -> p "%Y-%m-%d"- 'x' -> p (dateFmt l)- 'h' -> p "%b"- '%' -> [Literal '%']- _ -> [Value c]- p (c:cs) | isSpace c = WhiteSpace : p cs- p (c:cs) = Literal c : p cs--parseInput :: TimeLocale -> DateFormat -> ReadP [(Char,String)]-parseInput l = liftM catMaybes . mapM p- where p (Value c) = parseValue l c >>= return . Just . (,) c- p WhiteSpace = skipSpaces >> return Nothing- p (Literal c) = char c >> return Nothing---- | Get the string corresponding to the given format specifier.-parseValue :: TimeLocale -> Char -> ReadP String-parseValue l c = - case c of- 'z' -> numericTZ- 'Z' -> munch1 isAlpha <++- numericTZ <++- return "" -- produced by %Z for LocalTime- 'P' -> oneOf (let (am,pm) = amPm l in [am, pm])- 'p' -> oneOf (let (am,pm) = amPm l in [am, pm])- 'H' -> digits 2- 'I' -> digits 2- 'k' -> spdigits 2- 'l' -> spdigits 2- 'M' -> digits 2 - 'S' -> digits 2- 'q' -> digits 12- 'Q' -> liftM2 (:) (char '.') (munch isDigit) <++ return ""- 's' -> (char '-' >> liftM ('-':) (munch1 isDigit)) - <++ munch1 isDigit- 'Y' -> digits 4- 'y' -> digits 2- 'C' -> digits 2- 'B' -> oneOf (map fst (months l))- 'b' -> oneOf (map snd (months l))- 'm' -> digits 2- 'd' -> digits 2- 'e' -> spdigits 2- 'j' -> digits 3- 'G' -> digits 4- 'g' -> digits 2- 'f' -> digits 2- 'V' -> digits 2- 'u' -> oneOf $ map (:[]) ['1'..'7']- 'a' -> oneOf (map snd (wDays l))- 'A' -> oneOf (map fst (wDays l))- 'U' -> digits 2- 'w' -> oneOf $ map (:[]) ['0'..'6']- 'W' -> digits 2- _ -> fail $ "Unknown format character: " ++ show c- where- oneOf = choice . map string- digits n = count n (satisfy isDigit)- spdigits n = skipSpaces >> upTo n (satisfy isDigit)- upTo :: Int -> ReadP a -> ReadP [a]- upTo 0 _ = return []- upTo n x = liftM2 (:) x (upTo (n-1) x) <++ return []- numericTZ = do s <- choice [char '+', char '-']- h <- digits 2- optional (char ':')- m <- digits 2- return (s:h++m)------- * Instances for the time package types-----data DayComponent = Year Integer -- 0-99, last two digits of both real years and week years- | Century Integer -- century of all years- | Month Int -- 1-12- | Day Int -- 1-31- | YearDay Int -- 1-366- | WeekDay Int -- 1-7 (mon-sun)- | Week WeekType Int -- 1-53 or 0-53--data WeekType = ISOWeek | SundayWeek | MondayWeek--instance ParseTime Day where- buildTime l = buildDay . concatMap (uncurry f)- where- f c x = - case c of- -- %Y: year- 'Y' -> let y = read x in [Century (y `div` 100), Year (y `mod` 100)]- -- %y: last two digits of year, 00 - 99- 'y' -> [Year (read x)]- -- %C: century (being the first two digits of the year), 00 - 99- 'C' -> [Century (read x)]- -- %B: month name, long form (fst from months locale), January - December- 'B' -> [Month (1 + fromJust (elemIndex (up x) (map (up . fst) (months l))))]- -- %b: month name, short form (snd from months locale), Jan - Dec- 'b' -> [Month (1 + fromJust (elemIndex (up x) (map (up . snd) (months l))))]- -- %m: month of year, leading 0 as needed, 01 - 12- 'm' -> [Month (read x)]- -- %d: day of month, leading 0 as needed, 01 - 31- 'd' -> [Day (read x)]- -- %e: day of month, leading space as needed, 1 - 31- 'e' -> [Day (read x)]- -- %j: day of year for Ordinal Date format, 001 - 366- 'j' -> [YearDay (read x)]- -- %G: year for Week Date format- 'G' -> let y = read x in [Century (y `div` 100), Year (y `mod` 100)]- -- %g: last two digits of year for Week Date format, 00 - 99- 'g' -> [Year (read x)]- -- %f century (first two digits of year) for Week Date format, 00 - 99- 'f' -> [Century (read x)]- -- %V: week for Week Date format, 01 - 53- 'V' -> [Week ISOWeek (read x)]- -- %u: day for Week Date format, 1 - 7- 'u' -> [WeekDay (read x)]- -- %a: day of week, short form (snd from wDays locale), Sun - Sat- 'a' -> [WeekDay (1 + (fromJust (elemIndex (up x) (map (up . snd) (wDays l))) + 6) `mod` 7)]- -- %A: day of week, long form (fst from wDays locale), Sunday - Saturday- 'A' -> [WeekDay (1 + (fromJust (elemIndex (up x) (map (up . fst) (wDays l))) + 6) `mod` 7)]- -- %U: week number of year, where weeks start on Sunday (as sundayStartWeek), 01 - 53- 'U' -> [Week SundayWeek (read x)]- -- %w: day of week number, 0 (= Sunday) - 6 (= Saturday)- 'w' -> [WeekDay (((read x + 6) `mod` 7) + 1)]- -- %W: week number of year, where weeks start on Monday (as mondayStartWeek), 01 - 53- 'W' -> [Week MondayWeek (read x)]- _ -> []-- buildDay cs = rest cs- where- y = let c = safeLast 19 [x | Century x <- cs]- d = safeLast 70 [x | Year x <- cs]- in 100 * c + d-- rest (Month m:_) = let d = safeLast 1 [x | Day x <- cs]- in fromGregorian y m d- rest (YearDay d:_) = fromOrdinalDate y d- rest (Week wt w:_) = let d = safeLast 4 [x | WeekDay x <- cs]- in case wt of- ISOWeek -> fromWeekDate y w d- SundayWeek -> fromSundayStartWeek y w (d `mod` 7)- MondayWeek -> fromMondayStartWeek y w d- rest (_:xs) = rest xs- rest [] = rest [Month 1]-- safeLast x xs = last (x:xs)--instance ParseTime TimeOfDay where- buildTime l = foldl f midnight- where- f t@(TimeOfDay h m s) (c,x) = - case c of- 'P' -> if up x == fst (amPm l) then am else pm- 'p' -> if up x == fst (amPm l) then am else pm- 'H' -> TimeOfDay (read x) m s- 'I' -> TimeOfDay (read x) m s- 'k' -> TimeOfDay (read x) m s- 'l' -> TimeOfDay (read x) m s- 'M' -> TimeOfDay h (read x) s- 'S' -> TimeOfDay h m (fromInteger (read x))- 'q' -> TimeOfDay h m (mkPico (truncate s) (read x))- 'Q' -> if null x then t - else let ps = read $ take 12 $ rpad 12 '0' $ drop 1 x- in TimeOfDay h m (mkPico (truncate s) ps)- _ -> t- where am = TimeOfDay (h `mod` 12) m s- pm = TimeOfDay (if h < 12 then h + 12 else h) m s--rpad :: Int -> a -> [a] -> [a]-rpad n c xs = xs ++ replicate (n - length xs) c--mkPico :: Integer -> Integer -> Pico-mkPico i f = fromInteger i + fromRational (f % 1000000000000)--instance ParseTime LocalTime where- buildTime l xs = LocalTime (buildTime l xs) (buildTime l xs)--instance ParseTime TimeZone where- buildTime _ = foldl f (minutesToTimeZone 0)- where - f t@(TimeZone offset dst name) (c,x) = - case c of- 'z' -> zone- 'Z' | null x -> t- | isAlpha (head x) -> let y = up x in- case lookup y _TIMEZONES_ of- Just (offset', dst') -> TimeZone offset' dst' y- Nothing -> TimeZone offset dst y- | otherwise -> zone- _ -> t- where zone = TimeZone (readTzOffset x) dst name--instance ParseTime ZonedTime where- buildTime l xs = foldl f (ZonedTime (buildTime l xs) (buildTime l xs)) xs- where- f t@(ZonedTime (LocalTime _ tod) z) (c,x) =- case c of- 's' -> let s = fromInteger (read x)- (_,ps) = properFraction (todSec tod) :: (Integer,Pico)- s' = s + fromRational (toRational ps)- in utcToZonedTime z (posixSecondsToUTCTime s')- _ -> t--instance ParseTime UTCTime where- buildTime l = zonedTimeToUTC . buildTime l---- * Read instances for time package types--instance Read Day where- readsPrec _ = readParen False $ readsTime defaultTimeLocale "%Y-%m-%d"--instance Read TimeOfDay where- readsPrec _ = readParen False $ readsTime defaultTimeLocale "%H:%M:%S%Q"--instance Read LocalTime where- readsPrec _ = readParen False $ readsTime defaultTimeLocale "%Y-%m-%d %H:%M:%S%Q"--instance Read TimeZone where- readsPrec _ = readParen False $ readsTime defaultTimeLocale "%Z"--instance Read ZonedTime where- readsPrec n = readParen False $ \s ->- [(ZonedTime t z, r2) | (t,r1) <- readsPrec n s, (z,r2) <- readsPrec n r1]--instance Read UTCTime where- readsPrec n s = [ (zonedTimeToUTC t, r) | (t,r) <- readsPrec n s ]--readTzOffset :: String -> Int-readTzOffset str =- case str of- (s:h1:h2:':':m1:m2:[]) -> calc s h1 h2 m1 m2- (s:h1:h2:m1:m2:[]) -> calc s h1 h2 m1 m2- _ -> 0- where calc s h1 h2 m1 m2 = sign * (60 * h + m)- where sign = if s == '-' then -1 else 1- h = read [h1,h2]- m = read [m1,m2]--_TIMEZONES_ :: [(String, (Int, Bool))]-_TIMEZONES_ =- -- New Zealand Daylight-Saving Time- [("NZDT", (readTzOffset "+13:00", True))- -- International Date Line, East- ,("IDLE", (readTzOffset "+12:00", False))- -- New Zealand Standard Time- ,("NZST", (readTzOffset "+12:00", False))- -- New Zealand Time- ,("NZT", (readTzOffset "+12:00", False))- -- Australia Eastern Summer Standard Time- ,("AESST", (readTzOffset "+11:00", False))- -- Central Australia Summer Standard Time- ,("ACSST", (readTzOffset "+10:30", False))- -- Central Australia Daylight-Saving Time- ,("CADT", (readTzOffset "+10:30", True))- -- South Australian Daylight-Saving Time- ,("SADT", (readTzOffset "+10:30", True))- -- Australia Eastern Standard Time- ,("AEST", (readTzOffset "+10:00", False))- -- East Australian Standard Time- ,("EAST", (readTzOffset "+10:00", False))- -- Guam Standard Time, Russia zone 9- ,("GST", (readTzOffset "+10:00", False))- -- Melbourne, Australia- ,("LIGT", (readTzOffset "+10:00", False))- -- South Australia Standard Time- ,("SAST", (readTzOffset "+09:30", False))- -- Central Australia Standard Time- ,("CAST", (readTzOffset "+09:30", False))- -- Australia Western Summer Standard Time- ,("AWSST", (readTzOffset "+09:00", False))- -- Japan Standard Time, Russia zone 8- ,("JST", (readTzOffset "+09:00", False))- -- Korea Standard Time- ,("KST", (readTzOffset "+09:00", False))- -- Kwajalein Time- ,("MHT", (readTzOffset "+09:00", False))- -- West Australian Daylight-Saving Time- ,("WDT", (readTzOffset "+09:00", True))- -- Moluccas Time- ,("MT", (readTzOffset "+08:30", False))- -- Australia Western Standard Time- ,("AWST", (readTzOffset "+08:00", False))- -- China Coastal Time- ,("CCT", (readTzOffset "+08:00", False))- -- West Australian Daylight-Saving Time- ,("WADT", (readTzOffset "+08:00", True))- -- West Australian Standard Time- ,("WST", (readTzOffset "+08:00", False))- -- Java Time- ,("JT", (readTzOffset "+07:30", False))- -- Almaty Summer Time- ,("ALMST", (readTzOffset "+07:00", False))- -- West Australian Standard Time- ,("WAST", (readTzOffset "+07:00", False))- -- Christmas (Island) Time- ,("CXT", (readTzOffset "+07:00", False))- -- Myanmar Time- ,("MMT", (readTzOffset "+06:30", False))- -- Almaty Time- ,("ALMT", (readTzOffset "+06:00", False))- -- Mawson (Antarctica) Time- ,("MAWT", (readTzOffset "+06:00", False))- -- Indian Chagos Time- ,("IOT", (readTzOffset "+05:00", False))- -- Maldives Island Time- ,("MVT", (readTzOffset "+05:00", False))- -- Kerguelen Time- ,("TFT", (readTzOffset "+05:00", False))- -- Afghanistan Time- ,("AFT", (readTzOffset "+04:30", False))- -- Antananarivo Summer Time- ,("EAST", (readTzOffset "+04:00", False))- -- Mauritius Island Time- ,("MUT", (readTzOffset "+04:00", False))- -- Reunion Island Time- ,("RET", (readTzOffset "+04:00", False))- -- Mahe Island Time- ,("SCT", (readTzOffset "+04:00", False))- -- Iran Time- ,("IRT", (readTzOffset "+03:30", False))- -- Iran Time- ,("IT", (readTzOffset "+03:30", False))- -- Antananarivo, Comoro Time- ,("EAT", (readTzOffset "+03:00", False))- -- Baghdad Time- ,("BT", (readTzOffset "+03:00", False))- -- Eastern Europe Daylight-Saving Time- ,("EETDST", (readTzOffset "+03:00", True))- -- Hellas Mediterranean Time (?)- ,("HMT", (readTzOffset "+03:00", False))- -- British Double Summer Time- ,("BDST", (readTzOffset "+02:00", False))- -- Central European Summer Time- ,("CEST", (readTzOffset "+02:00", False))- -- Central European Daylight-Saving Time- ,("CETDST", (readTzOffset "+02:00", True))- -- Eastern European Time, Russia zone 1- ,("EET", (readTzOffset "+02:00", False))- -- French Winter Time- ,("FWT", (readTzOffset "+02:00", False))- -- Israel Standard Time- ,("IST", (readTzOffset "+02:00", False))- -- Middle European Summer Time- ,("MEST", (readTzOffset "+02:00", False))- -- Middle Europe Daylight-Saving Time- ,("METDST", (readTzOffset "+02:00", True))- -- Swedish Summer Time- ,("SST", (readTzOffset "+02:00", False))- -- British Summer Time- ,("BST", (readTzOffset "+01:00", False))- -- Central European Time- ,("CET", (readTzOffset "+01:00", False))- -- Dansk Normal Tid- ,("DNT", (readTzOffset "+01:00", False))- -- French Summer Time- ,("FST", (readTzOffset "+01:00", False))- -- Middle European Time- ,("MET", (readTzOffset "+01:00", False))- -- Middle European Winter Time- ,("MEWT", (readTzOffset "+01:00", False))- -- Mitteleuropaeische Zeit- ,("MEZ", (readTzOffset "+01:00", False))- -- Norway Standard Time- ,("NOR", (readTzOffset "+01:00", False))- -- Seychelles Time- ,("SET", (readTzOffset "+01:00", False))- -- Swedish Winter Time- ,("SWT", (readTzOffset "+01:00", False))- -- Western European Daylight-Saving Time- ,("WETDST", (readTzOffset "+01:00", True))- -- Greenwich Mean Time- ,("GMT", (readTzOffset "+00:00", False))- -- Universal Time- ,("UT", (readTzOffset "+00:00", False))- -- Universal Coordinated Time- ,("UTC", (readTzOffset "+00:00", False))- -- Same as UTC- ,("Z", (readTzOffset "+00:00", False))- -- Same as UTC- ,("ZULU", (readTzOffset "+00:00", False))- -- Western European Time- ,("WET", (readTzOffset "+00:00", False))- -- West Africa Time- ,("WAT", (readTzOffset "-01:00", False))- -- Fernando de Noronha Summer Time- ,("FNST", (readTzOffset "-01:00", False))- -- Fernando de Noronha Time- ,("FNT", (readTzOffset "-02:00", False))- -- Brasilia Summer Time- ,("BRST", (readTzOffset "-02:00", False))- -- Newfoundland Daylight-Saving Time- ,("NDT", (readTzOffset "-02:30", True))- -- Atlantic Daylight-Saving Time- ,("ADT", (readTzOffset "-03:00", True))- -- (unknown)- ,("AWT", (readTzOffset "-03:00", False))- -- Brasilia Time- ,("BRT", (readTzOffset "-03:00", False))- -- Newfoundland Standard Time- ,("NFT", (readTzOffset "-03:30", False))- -- Newfoundland Standard Time- ,("NST", (readTzOffset "-03:30", False))- -- Atlantic Standard Time (Canada)- ,("AST", (readTzOffset "-04:00", False))- -- Atlantic/Porto Acre Summer Time- ,("ACST", (readTzOffset "-04:00", False))- -- Eastern Daylight-Saving Time- ,("EDT", (readTzOffset "-04:00", True))- -- Atlantic/Porto Acre Standard Time- ,("ACT", (readTzOffset "-05:00", False))- -- Central Daylight-Saving Time- ,("CDT", (readTzOffset "-05:00", True))- -- Eastern Standard Time- ,("EST", (readTzOffset "-05:00", False))- -- Central Standard Time- ,("CST", (readTzOffset "-06:00", False))- -- Mountain Daylight-Saving Time- ,("MDT", (readTzOffset "-06:00", True))- -- Mountain Standard Time- ,("MST", (readTzOffset "-07:00", False))- -- Pacific Daylight-Saving Time- ,("PDT", (readTzOffset "-07:00", True))- -- Alaska Daylight-Saving Time- ,("AKDT", (readTzOffset "-08:00", True))- -- Pacific Standard Time- ,("PST", (readTzOffset "-08:00", False))- -- Yukon Daylight-Saving Time- ,("YDT", (readTzOffset "-08:00", True))- -- Alaska Standard Time- ,("AKST", (readTzOffset "-09:00", False))- -- Hawaii/Alaska Daylight-Saving Time- ,("HDT", (readTzOffset "-09:00", True))- -- Yukon Standard Time- ,("YST", (readTzOffset "-09:00", False))- -- Marquesas Time- ,("MART", (readTzOffset "-09:30", False))- -- Alaska/Hawaii Standard Time- ,("AHST", (readTzOffset "-10:00", False))- -- Hawaii Standard Time- ,("HST", (readTzOffset "-10:00", False))- -- Central Alaska Time- ,("CAT", (readTzOffset "-10:00", False))- -- Nome Time- ,("NT", (readTzOffset "-11:00", False))- -- International Date Line, West- ,("IDLW", (readTzOffset "-12:00", False))- ]
− Data/Time/LocalTime.hs
@@ -1,10 +0,0 @@-module Data.Time.LocalTime-(- module Data.Time.LocalTime.TimeZone,- module Data.Time.LocalTime.TimeOfDay,- module Data.Time.LocalTime.LocalTime-) where--import Data.Time.LocalTime.TimeZone-import Data.Time.LocalTime.TimeOfDay-import Data.Time.LocalTime.LocalTime
− Data/Time/LocalTime/LocalTime.hs
@@ -1,89 +0,0 @@-{-# OPTIONS -fno-warn-orphans #-}---- #hide-module Data.Time.LocalTime.LocalTime-(- -- * Local Time- LocalTime(..),-- -- converting UTC and UT1 times to LocalTime- utcToLocalTime,localTimeToUTC,ut1ToLocalTime,localTimeToUT1,- - ZonedTime(..),utcToZonedTime,zonedTimeToUTC,getZonedTime,utcToLocalZonedTime-) where--import Data.Time.LocalTime.TimeOfDay-import Data.Time.LocalTime.TimeZone-import Data.Time.Calendar-import Data.Time.Clock-import Data.Typeable---- | A simple day and time aggregate, where the day is of the specified parameter,--- and the time is a TimeOfDay.--- Conversion of this (as local civil time) to UTC depends on the time zone.--- Conversion of this (as local mean time) to UT1 depends on the longitude.-data LocalTime = LocalTime {- localDay :: Day,- localTimeOfDay :: TimeOfDay-} deriving (Eq,Ord)--instance Typeable LocalTime where- typeOf _ = mkTyConApp (mkTyCon "Data.Time.LocalTime.LocalTime.LocalTime") []--instance Show LocalTime where- show (LocalTime d t) = (showGregorian d) ++ " " ++ (show t)---- | show a UTC time in a given time zone as a LocalTime-utcToLocalTime :: TimeZone -> UTCTime -> LocalTime-utcToLocalTime tz (UTCTime day dt) = LocalTime (addDays i day) tod where- (i,tod) = utcToLocalTimeOfDay tz (timeToTimeOfDay dt)---- | find out what UTC time a given LocalTime in a given time zone is-localTimeToUTC :: TimeZone -> LocalTime -> UTCTime-localTimeToUTC tz (LocalTime day tod) = UTCTime (addDays i day) (timeOfDayToTime todUTC) where- (i,todUTC) = localToUTCTimeOfDay tz tod---- | 1st arg is observation meridian in degrees, positive is East-ut1ToLocalTime :: Rational -> UniversalTime -> LocalTime-ut1ToLocalTime long (ModJulianDate date) = LocalTime (ModifiedJulianDay localMJD) (dayFractionToTimeOfDay localToDOffset) where- localTime = date + long / 360 :: Rational- localMJD = floor localTime- localToDOffset = localTime - (fromIntegral localMJD) ---- | 1st arg is observation meridian in degrees, positive is East-localTimeToUT1 :: Rational -> LocalTime -> UniversalTime-localTimeToUT1 long (LocalTime (ModifiedJulianDay localMJD) tod) = ModJulianDate ((fromIntegral localMJD) + (timeOfDayToDayFraction tod) - (long / 360))---- | A local time together with a TimeZone.-data ZonedTime = ZonedTime {- zonedTimeToLocalTime :: LocalTime,- zonedTimeZone :: TimeZone-}--instance Typeable ZonedTime where- typeOf _ = mkTyConApp (mkTyCon "Data.Time.LocalTime.LocalTime.ZonedTime") []--utcToZonedTime :: TimeZone -> UTCTime -> ZonedTime-utcToZonedTime zone time = ZonedTime (utcToLocalTime zone time) zone--zonedTimeToUTC :: ZonedTime -> UTCTime-zonedTimeToUTC (ZonedTime t zone) = localTimeToUTC zone t--instance Show ZonedTime where- show (ZonedTime t zone) = show t ++ " " ++ show zone---- orphan instance-instance Show UTCTime where- show t = show (utcToZonedTime utc t)--getZonedTime :: IO ZonedTime-getZonedTime = do- t <- getCurrentTime- zone <- getTimeZone t- return (utcToZonedTime zone t)---- |-utcToLocalZonedTime :: UTCTime -> IO ZonedTime-utcToLocalZonedTime t = do- zone <- getTimeZone t- return (utcToZonedTime zone t)
− Data/Time/LocalTime/TimeOfDay.hs
@@ -1,83 +0,0 @@--- #hide-module Data.Time.LocalTime.TimeOfDay-(- -- * Time of day- TimeOfDay(..),midnight,midday,makeTimeOfDayValid,- utcToLocalTimeOfDay,localToUTCTimeOfDay,- timeToTimeOfDay,timeOfDayToTime,- dayFractionToTimeOfDay,timeOfDayToDayFraction-) where--import Data.Time.LocalTime.TimeZone-import Data.Time.Calendar.Private-import Data.Time.Clock-import Data.Typeable-import Data.Fixed---- | Time of day as represented in hour, minute and second (with picoseconds), typically used to express local time of day.-data TimeOfDay = TimeOfDay {- -- | range 0 - 23- todHour :: Int,- -- | range 0 - 59- todMin :: Int,- -- | Note that 0 <= todSec < 61, accomodating leap seconds.- -- Any local minute may have a leap second, since leap seconds happen in all zones simultaneously- todSec :: Pico-} deriving (Eq,Ord)--instance Typeable TimeOfDay where- typeOf _ = mkTyConApp (mkTyCon "Data.Time.LocalTime.TimeOfDay.TimeOfDay") []---- | Hour zero-midnight :: TimeOfDay-midnight = TimeOfDay 0 0 0---- | Hour twelve-midday :: TimeOfDay-midday = TimeOfDay 12 0 0--instance Show TimeOfDay where- show (TimeOfDay h m s) = (show2 (Just '0') h) ++ ":" ++ (show2 (Just '0') m) ++ ":" ++ (show2Fixed (Just '0') s)--makeTimeOfDayValid :: Int -> Int -> Pico -> Maybe TimeOfDay-makeTimeOfDayValid h m s = do- clipValid 0 23 h- clipValid 0 59 m- clipValid 0 60.999999999999 s- return (TimeOfDay h m s)---- | Convert a ToD in UTC to a ToD in some timezone, together with a day adjustment.-utcToLocalTimeOfDay :: TimeZone -> TimeOfDay -> (Integer,TimeOfDay)-utcToLocalTimeOfDay zone (TimeOfDay h m s) = (fromIntegral (div h' 24),TimeOfDay (mod h' 24) (mod m' 60) s) where- m' = m + timeZoneMinutes zone- h' = h + (div m' 60)---- | Convert a ToD in some timezone to a ToD in UTC, together with a day adjustment.-localToUTCTimeOfDay :: TimeZone -> TimeOfDay -> (Integer,TimeOfDay)-localToUTCTimeOfDay zone = utcToLocalTimeOfDay (minutesToTimeZone (negate (timeZoneMinutes zone)))--posixDayLength :: DiffTime-posixDayLength = fromInteger 86400---- | Get a TimeOfDay given a time since midnight.--- Time more than 24h will be converted to leap-seconds.-timeToTimeOfDay :: DiffTime -> TimeOfDay-timeToTimeOfDay dt | dt >= posixDayLength = TimeOfDay 23 59 (60 + (realToFrac (dt - posixDayLength)))-timeToTimeOfDay dt = TimeOfDay (fromInteger h) (fromInteger m) s where- s' = realToFrac dt- s = mod' s' 60- m' = div' s' 60- m = mod' m' 60- h = div' m' 60---- | Find out how much time since midnight a given TimeOfDay is.-timeOfDayToTime :: TimeOfDay -> DiffTime-timeOfDayToTime (TimeOfDay h m s) = ((fromIntegral h) * 60 + (fromIntegral m)) * 60 + (realToFrac s)---- | Get a TimeOfDay given the fraction of a day since midnight.-dayFractionToTimeOfDay :: Rational -> TimeOfDay-dayFractionToTimeOfDay df = timeToTimeOfDay (realToFrac (df * 86400))---- | Get the fraction of a day since midnight given a TimeOfDay.-timeOfDayToDayFraction :: TimeOfDay -> Rational-timeOfDayToDayFraction tod = realToFrac (timeOfDayToTime tod / posixDayLength)
− Data/Time/LocalTime/TimeZone.hs
@@ -1,84 +0,0 @@-{-# LANGUAGE ForeignFunctionInterface #-}---- #hide-module Data.Time.LocalTime.TimeZone-(- -- * Time zones- TimeZone(..),timeZoneOffsetString,timeZoneOffsetString',minutesToTimeZone,hoursToTimeZone,utc,-- -- getting the locale time zone- getTimeZone,getCurrentTimeZone-) where----import System.Time.Calendar.Format-import Data.Time.Calendar.Private-import Data.Time.Clock-import Data.Time.Clock.POSIX--import Foreign-import Foreign.C-import Data.Typeable---- | A TimeZone is a whole number of minutes offset from UTC, together with a name and a \"just for summer\" flag.-data TimeZone = TimeZone {- -- | The number of minutes offset from UTC. Positive means local time will be later in the day than UTC.- timeZoneMinutes :: Int,- -- | Is this time zone just persisting for the summer?- timeZoneSummerOnly :: Bool,- -- | The name of the zone, typically a three- or four-letter acronym.- timeZoneName :: String-} deriving (Eq,Ord)--instance Typeable TimeZone where- typeOf _ = mkTyConApp (mkTyCon "Data.Time.LocalTime.TimeZone.TimeZone") []---- | Create a nameless non-summer timezone for this number of minutes-minutesToTimeZone :: Int -> TimeZone-minutesToTimeZone m = TimeZone m False ""---- | Create a nameless non-summer timezone for this number of hours-hoursToTimeZone :: Int -> TimeZone-hoursToTimeZone i = minutesToTimeZone (60 * i)--showT :: NumericPadOption -> Int -> String-showT opt t = show4 opt ((div t 60) * 100 + (mod t 60))---- | Text representing the offset of this timezone, such as \"-0800\" or \"+0400\" (like %z in formatTime), with arbitrary padding-timeZoneOffsetString' :: NumericPadOption -> TimeZone -> String-timeZoneOffsetString' opt (TimeZone t _ _) | t < 0 = '-':(showT opt (negate t))-timeZoneOffsetString' opt (TimeZone t _ _) = '+':(showT opt t)---- | Text representing the offset of this timezone, such as \"-0800\" or \"+0400\" (like %z in formatTime)-timeZoneOffsetString :: TimeZone -> String-timeZoneOffsetString = timeZoneOffsetString' (Just '0')--instance Show TimeZone where- show zone@(TimeZone _ _ "") = timeZoneOffsetString zone- show (TimeZone _ _ name) = name---- | The UTC time zone-utc :: TimeZone-utc = TimeZone 0 False "UTC"--{-# CFILES cbits/HsTime.c #-}-foreign import ccall unsafe "HsTime.h get_current_timezone_seconds" get_current_timezone_seconds :: CTime -> Ptr CInt -> Ptr CString -> IO CLong--posixToCTime :: POSIXTime -> CTime-posixToCTime = fromInteger . floor---- | Get the local time-zone for a given time (varying as per summertime adjustments)-getTimeZone :: UTCTime -> IO TimeZone-getTimeZone time = with 0 (\pdst -> with nullPtr (\pcname -> do- secs <- get_current_timezone_seconds (posixToCTime (utcTimeToPOSIXSeconds time)) pdst pcname- case secs of- 0x80000000 -> fail "localtime_r failed"- _ -> do- dst <- peek pdst- cname <- peek pcname- name <- peekCString cname- return (TimeZone (div (fromIntegral secs) 60) (dst == 1) name)- ))---- | Get the current time-zone-getCurrentTimeZone :: IO TimeZone-getCurrentTimeZone = getCurrentTime >>= getTimeZone
LICENSE view
@@ -1,5 +1,5 @@-TimeLib is Copyright (c) Ashley Yakeley, 2004-2007.-All rights reserved.+TimeLib is Copyright (c) Ashley Yakeley and contributors, 2004-2022. All rights reserved.+Certain sections are Copyright 2004, The University Court of the University of Glasgow. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Setup.hs view
@@ -1,26 +1,8 @@-module Main (main) where+module Main (+ main,+) where -import Control.Exception-import Distribution.PackageDescription import Distribution.Simple-import Distribution.Simple.LocalBuildInfo-import Distribution.Simple.Utils-import System.Cmd-import System.Directory-import System.Info main :: IO ()-main = case os of- "windows" -> defaultMain- "mingw32" -> defaultMain- _ -> let hooks = autoconfUserHooks { runTests = runTestScript } in defaultMainWithHooks hooks--withCurrentDirectory :: FilePath -> IO a -> IO a-withCurrentDirectory path f = do- cur <- getCurrentDirectory- setCurrentDirectory path- finally f (setCurrentDirectory cur)--runTestScript :: Args -> Bool -> PackageDescription -> LocalBuildInfo -> IO ()-runTestScript _args _flag _pd _lbi- = maybeExit $ withCurrentDirectory "test" $ system "make"+main = defaultMainWithHooks autoconfUserHooks
aclocal.m4 view
@@ -1,19 +1,17 @@-# FP_DECL_ALTZONE -# --------------- -# Defines HAVE_DECL_ALTZONE to 1 if declared, 0 otherwise. -# -# Used by base package. -AC_DEFUN([FP_DECL_ALTZONE], -[AC_REQUIRE([AC_HEADER_TIME])dnl -AC_CHECK_HEADERS([sys/time.h]) -AC_CHECK_DECLS([altzone], [], [],[#if TIME_WITH_SYS_TIME -# include <sys/time.h> -# include <time.h> -#else -# if HAVE_SYS_TIME_H -# include <sys/time.h> -# else -# include <time.h> -# endif -#endif]) -])# FP_DECL_ALTZONE +# FP_DECL_ALTZONE+# ---------------+# Defines HAVE_DECL_ALTZONE to 1 if declared, 0 otherwise.+#+# Used by base package.+AC_DEFUN([FP_DECL_ALTZONE],+[+ AC_CHECK_HEADERS_ONCE([sys/time.h])++ AC_CHECK_HEADERS([sys/time.h])+ AC_CHECK_DECLS([altzone], [], [],[+ #if HAVE_SYS_TIME_H+ #include <sys/time.h>+ #endif+ #include <time.h>+ ])+])# FP_DECL_ALTZONE
+ benchmark/Main.hs view
@@ -0,0 +1,21 @@+module Main where++import Criterion.Main+import Data.Time+import Data.Time.Clock.POSIX+import Data.Time.Clock.System++main :: IO ()+main = do+ getCurrentTime >>= print+ getPOSIXTime >>= print . posixSecondsToUTCTime+ getZonedTime >>= print+ ct <- getCurrentTime+ defaultMain+ [ bench "getCurrentTime" $ nfIO getCurrentTime+ , bench "getPOSIXTime" $ nfIO getPOSIXTime+ , bench "getSystemTime" $ nfIO getSystemTime+ , bench "getTimeZone" $ nfIO $ getTimeZone ct+ , bench "getCurrentTimeZone" $ nfIO getCurrentTimeZone+ , bench "getZonedTime" $ nfIO getZonedTime+ ]
− cbits/HsTime.c
@@ -1,40 +0,0 @@-#include "HsTime.h"-#include <stdio.h>--long int get_current_timezone_seconds (time_t t,int* pdst,char const* * pname)-{-#if HAVE_LOCALTIME_R- struct tm tmd;- struct tm* ptm = localtime_r(&t,&tmd);-#else- struct tm* ptm = localtime(&t);-#endif- if (ptm)- {- int dst = ptm -> tm_isdst;- *pdst = dst;-#if HAVE_TM_ZONE- *pname = ptm -> tm_zone;- return ptm -> tm_gmtoff;-#elif defined(_MSC_VER) || defined(__MINGW32__) || defined(_WIN32)- // We don't have a better API to use on Windows, the logic to- // decide whether a given date/time falls within DST is- // implemented as part of localtime() in the CRT. This is_dst- // flag is all we need here.- *pname = dst ? _tzname[1] : _tzname[0];- return - (dst ? _timezone - 3600 : _timezone);-#else-# if HAVE_TZNAME- *pname = *tzname;-# else-# error "Don't know how to get timezone name on your OS"-# endif-# if HAVE_DECL_ALTZONE- return dst ? altzone : timezone;-# else- return dst ? timezone - 3600 : timezone;-# endif-#endif // HAVE_TM_ZONE- }- else return 0x80000000;-}
+ changelog.md view
@@ -0,0 +1,205 @@+# Change Log++## [1.16] - 2026-05-03++- add periodIn+- use template-haskell-lift rather than template-haskell for Lift instances on GHC 9.14 and later+- support GHC 9.14+- improve documentation, test, build, CI++## [1.15] - 2025-08-04++- support compiler / GHC backends (with CI):+ - JavaScript+ - WebAssembly+ - MicroHs+- add diffTimeOfDay+- add \[add/diff\]\[UTC/Local\]Duration\[Clip/Rollover\]+- add patterns for DiffTime & NominalDiffTime+- UNIXish formatting/parsing:+ - add instance ParseTime DayOfWeek+ - make use of %s specifiers in parsing various types+ - instances for Quarter and QuarterOfYear+ - %v specifier for quarter-of-year+- ISO8601 formatting/parsing:+ - loosen up parsing time-zone modifiers+- add Lift instances to all types (really this time)+- hide Data.Time.Format.Internal+- add periodToDayClip+- fix MonthDay and QuarterDay clipping++## [1.14] - 2024-03-10+- add Lift instances to all types+- add Generic instances to all types that have exposed constructors+- fix show of CalendarDiffTime+- fix diffGregorianDurationRollOver, diffJulianDurationRollOver+- Parsing is now maximal munch rather than ambiguous for+ - digits of %q and %Q specifiers+ - optional timezone for UTCTime+ - optional specifiers in ISO8601 formats++## [1.12.2] - 2022-05-14+- add weekFirstDay, weekLastDay, weekAllDays+- expose formatting/parsing internals+- fix: handle +HH format for ISO8601 timeOffsetFormat etc.+- fix clock_REALTIME for WebAssembly++## [1.12.1] - 2021-10-24+- add DayPeriod class for periods of days+- add QuarterDay pattern and DayOfQuarter type synonym+- add CommonEra and BeforeCommonEra patterns++## [1.12] - 2021-06-12+- support GHC 8.8, 8.10, 9.0 only+- add patterns for each month of year+- fix: don't provide TAI clock where it's unavailable (e.g. FreeBSD)+- fix: handle time of day 24:00:00 for ISO 8601 parsing (only)+- fix parsing of %f and %G with negative years++## [1.11.1.2] - 2021-04-24+- fix cabal file+- correct "license" field in cabal file+- add dates to changelog entries++## [1.11.1.1] - 2020-12-09+- fix module Safe status++## [1.11.1] - 2020-11-23+- all modules Safe or Trustworthy+- fix NFData instances for DiffTime, NominalDiffTime, TimeOfDay+- add missing Ix, Enum, NFData instances to DayOfWeek, CalendarDiffDays, CalendarDiffTime, Month, Quarter, QuarterOfYear++## [1.11] - 2020-10-14+- new calendrical type synonyms and abstract constructors+- new Month type, with appropriate functions+- new QuarterOfYear and Quarter type, with appropriate functions+- new functions for working with week-based years+- new parseTimeMultipleM function for a list of (format, input) pairs+- add instance Ord DayOfWeek+- add instance Read DiffTime (and NominalDiffTime)+- change instance Read UTCTime to allow omitted timezone+- parsing dates rejects ambiguity based on digits, even if there's only one valid date++## [1.10] - 2020-03-13+- remove deprecated functions parseTime, readTime, readsTime+- deprecate iso8601DateFormat+- parsing: fix %_Q %-Q %_q %-q+- parsing: fix parsing of BCE years+- formatting: fix %3ES %3Es+- change internal members of ParseTime to allow newtype-deriving+- new functions (aliases) pastMidnight & sinceMidnight++## [1.9.3] - 2019-05-20+- documentation fixes++## [1.9.2] - 2018-08-01+- add Data and Typeable instance for CalendarDiffDays and CalendarDiffTime+- "@since" annotations for everything after 1.9+- fix import issue with GHC 8.6++## [1.9.1] - 2018-02-27+- new functions secondsToNominalDiffTime & nominalDiffTimeToSeconds+- expose FormatTime and ParseTime in Data.Time.Format.Internal++## [1.9] - 2018-01-25+- new conversion functions timeToDaysAndTimeOfDay & daysAndTimeOfDayToTime+- new DayOfWeek type+- new CalendarDiffDays and CalendarDiffTime types+- new ISO8601 module for ISO 8601 formatting & parsing+- new addLocalTime, diffLocalTime+- hide members of FormatTime and ParseTime classes+- formatting & parsing for diff types (NominalDiffTime, DiffTime, CalendarDiffDays, CalendarDiffTime)+- formatting: %Ez and %EZ for ±HH:MM format+- parseTimeM: use MonadFail constraint when supported+- parsing: reject invalid (and empty) time-zones with %z and %Z+- parsing: reject invalid hour/minute/second specifiers++## [1.8.0.4] - 2018-01-09+- Fix "show minBound" bug+- haddock: example for parseTimeM++## [1.8.0.3] - 2017-08-04+- Add "Quick start" documentation++## [1.8.0.2] - 2017-05-13+- Fix behaviour of %Q in format++## [1.8.0.1] - 2017-03-11+- Get building on 32 bit machine++## [1.8] - 2017-02-14+- Added SystemTime+- Data.Time.Format: allow padding widths in specifiers for formatting (but not parsing)+- Test: use tasty, general clean-up+- Test: separate out UNIX-specific tests, so the others can be run on Windows+- Clean up haddock.++## [1.7.0.1] - 2016-12-19+- Fix bounds issue in .cabal file++## [1.7] - 2016-11-19+- Data.Time.Clock.TAI: change LeapSecondTable to LeapSecondMap with Maybe type; remove parseTAIUTCDATFile++## [1.6.0.1] - 2016-05-07+- Get building with earlier GHC versions+- Set lower bound of base correctly++## [1.6] - 2015-12-20++### Added+- FormatTime, ParseTime, Show and Read instances for UniversalTime+- diffTimeToPicoseconds+- this change log++### Changed+- Use clock_gettime where available+- Read and Show instances exported in the same module as their types+- Fixed bug in fromSundayStartWeekValid+- Parsing functions now reject invalid dates+- Various documentation fixes++## [1.5.0.1] - 2014-12-13++## [1.5] - 2014-09-10++## [1.4.2] - 2014-03-03++## [1.4.1] - 2013-06-24++## [1.4.0.2] - 2012-11-25++## [1.4.0.1] - 2011-10-31++## [1.4] - 2011-09-13++## [1.3] - 2011-08-10++## [1.2.0.5] - 2011-05-11++## [1.2.0.4] - 2011-02-03++## [1.2.0.3] - 2010-06-22++## [1.2.0.2] - 2010-04-26++## [1.2.0.1] - 2010-04-11++## [1.2] - 2010-04-11++## [1.1.4] - 2009-07-17++## [1.1.3] - 2009-06-01++## [1.1.2.4] - 2009-04-17++## [1.1.2.3] - 2009-01-17++## [1.1.2.2] - 2008-10-11++## [1.1.2.1] - 2008-06-19++## [1.1.2.0] - 2007-11-03++## [1.1.1] - 2007-04-22++## [1.0] - 2006-11-02
configure view
@@ -1,4979 +1,4850 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles.-# Generated by GNU Autoconf 2.61 for Haskell time package 1.1.2.3.-#-# Report bugs to <ashley@semantic.org>.-#-# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,-# 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.-# This configure script is free software; the Free Software Foundation-# gives unlimited permission to copy, distribute and modify it.-## --------------------- ##-## M4sh Initialization. ##-## --------------------- ##--# Be more Bourne compatible-DUALCASE=1; export DUALCASE # for MKS sh-if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then- emulate sh- NULLCMD=:- # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which- # is contrary to our usage. Disable this feature.- alias -g '${1+"$@"}'='"$@"'- setopt NO_GLOB_SUBST-else- case `(set -o) 2>/dev/null` in- *posix*) set -o posix ;;-esac--fi-----# PATH needs CR-# Avoid depending upon Character Ranges.-as_cr_letters='abcdefghijklmnopqrstuvwxyz'-as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'-as_cr_Letters=$as_cr_letters$as_cr_LETTERS-as_cr_digits='0123456789'-as_cr_alnum=$as_cr_Letters$as_cr_digits--# The user is always right.-if test "${PATH_SEPARATOR+set}" != set; then- echo "#! /bin/sh" >conf$$.sh- echo "exit 0" >>conf$$.sh- chmod +x conf$$.sh- if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then- PATH_SEPARATOR=';'- else- PATH_SEPARATOR=:- fi- rm -f conf$$.sh-fi--# Support unset when possible.-if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then- as_unset=unset-else- as_unset=false-fi---# IFS-# We need space, tab and new line, in precisely that order. Quoting is-# there to prevent editors from complaining about space-tab.-# (If _AS_PATH_WALK were called with IFS unset, it would disable word-# splitting by setting IFS to empty value.)-as_nl='-'-IFS=" "" $as_nl"--# Find who we are. Look in the path if we contain no directory separator.-case $0 in- *[\\/]* ) as_myself=$0 ;;- *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR-for as_dir in $PATH-do- IFS=$as_save_IFS- test -z "$as_dir" && as_dir=.- test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break-done-IFS=$as_save_IFS-- ;;-esac-# We did not find ourselves, most probably we were run as `sh COMMAND'-# in which case we are not to be found in the path.-if test "x$as_myself" = x; then- as_myself=$0-fi-if test ! -f "$as_myself"; then- echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2- { (exit 1); exit 1; }-fi--# Work around bugs in pre-3.0 UWIN ksh.-for as_var in ENV MAIL MAILPATH-do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var-done-PS1='$ '-PS2='> '-PS4='+ '--# NLS nuisances.-for as_var in \- LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \- LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \- LC_TELEPHONE LC_TIME-do- if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then- eval $as_var=C; export $as_var- else- ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var- fi-done--# Required to use basename.-if expr a : '\(a\)' >/dev/null 2>&1 &&- test "X`expr 00001 : '.*\(...\)'`" = X001; then- as_expr=expr-else- as_expr=false-fi--if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then- as_basename=basename-else- as_basename=false-fi---# Name of the executable.-as_me=`$as_basename -- "$0" ||-$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \- X"$0" : 'X\(//\)$' \| \- X"$0" : 'X\(/\)' \| . 2>/dev/null ||-echo X/"$0" |- sed '/^.*\/\([^/][^/]*\)\/*$/{- s//\1/- q- }- /^X\/\(\/\/\)$/{- s//\1/- q- }- /^X\/\(\/\).*/{- s//\1/- q- }- s/.*/./; q'`--# CDPATH.-$as_unset CDPATH---if test "x$CONFIG_SHELL" = x; then- if (eval ":") 2>/dev/null; then- as_have_required=yes-else- as_have_required=no-fi-- if test $as_have_required = yes && (eval ":-(as_func_return () {- (exit \$1)-}-as_func_success () {- as_func_return 0-}-as_func_failure () {- as_func_return 1-}-as_func_ret_success () {- return 0-}-as_func_ret_failure () {- return 1-}--exitcode=0-if as_func_success; then- :-else- exitcode=1- echo as_func_success failed.-fi--if as_func_failure; then- exitcode=1- echo as_func_failure succeeded.-fi--if as_func_ret_success; then- :-else- exitcode=1- echo as_func_ret_success failed.-fi--if as_func_ret_failure; then- exitcode=1- echo as_func_ret_failure succeeded.-fi--if ( set x; as_func_ret_success y && test x = \"\$1\" ); then- :-else- exitcode=1- echo positional parameters were not saved.-fi--test \$exitcode = 0) || { (exit 1); exit 1; }--(- as_lineno_1=\$LINENO- as_lineno_2=\$LINENO- test \"x\$as_lineno_1\" != \"x\$as_lineno_2\" &&- test \"x\`expr \$as_lineno_1 + 1\`\" = \"x\$as_lineno_2\") || { (exit 1); exit 1; }-") 2> /dev/null; then- :-else- as_candidate_shells=- as_save_IFS=$IFS; IFS=$PATH_SEPARATOR-for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH-do- IFS=$as_save_IFS- test -z "$as_dir" && as_dir=.- case $as_dir in- /*)- for as_base in sh bash ksh sh5; do- as_candidate_shells="$as_candidate_shells $as_dir/$as_base"- done;;- esac-done-IFS=$as_save_IFS--- for as_shell in $as_candidate_shells $SHELL; do- # Try only shells that exist, to save several forks.- if { test -f "$as_shell" || test -f "$as_shell.exe"; } &&- { ("$as_shell") 2> /dev/null <<\_ASEOF-if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then- emulate sh- NULLCMD=:- # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which- # is contrary to our usage. Disable this feature.- alias -g '${1+"$@"}'='"$@"'- setopt NO_GLOB_SUBST-else- case `(set -o) 2>/dev/null` in- *posix*) set -o posix ;;-esac--fi---:-_ASEOF-}; then- CONFIG_SHELL=$as_shell- as_have_required=yes- if { "$as_shell" 2> /dev/null <<\_ASEOF-if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then- emulate sh- NULLCMD=:- # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which- # is contrary to our usage. Disable this feature.- alias -g '${1+"$@"}'='"$@"'- setopt NO_GLOB_SUBST-else- case `(set -o) 2>/dev/null` in- *posix*) set -o posix ;;-esac--fi---:-(as_func_return () {- (exit $1)-}-as_func_success () {- as_func_return 0-}-as_func_failure () {- as_func_return 1-}-as_func_ret_success () {- return 0-}-as_func_ret_failure () {- return 1-}--exitcode=0-if as_func_success; then- :-else- exitcode=1- echo as_func_success failed.-fi--if as_func_failure; then- exitcode=1- echo as_func_failure succeeded.-fi--if as_func_ret_success; then- :-else- exitcode=1- echo as_func_ret_success failed.-fi--if as_func_ret_failure; then- exitcode=1- echo as_func_ret_failure succeeded.-fi--if ( set x; as_func_ret_success y && test x = "$1" ); then- :-else- exitcode=1- echo positional parameters were not saved.-fi--test $exitcode = 0) || { (exit 1); exit 1; }--(- as_lineno_1=$LINENO- as_lineno_2=$LINENO- test "x$as_lineno_1" != "x$as_lineno_2" &&- test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2") || { (exit 1); exit 1; }--_ASEOF-}; then- break-fi--fi-- done-- if test "x$CONFIG_SHELL" != x; then- for as_var in BASH_ENV ENV- do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var- done- export CONFIG_SHELL- exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"}-fi--- if test $as_have_required = no; then- echo This script requires a shell more modern than all the- echo shells that I found on your system. Please install a- echo modern shell, or manually run the script under such a- echo shell if you do have one.- { (exit 1); exit 1; }-fi---fi--fi----(eval "as_func_return () {- (exit \$1)-}-as_func_success () {- as_func_return 0-}-as_func_failure () {- as_func_return 1-}-as_func_ret_success () {- return 0-}-as_func_ret_failure () {- return 1-}--exitcode=0-if as_func_success; then- :-else- exitcode=1- echo as_func_success failed.-fi--if as_func_failure; then- exitcode=1- echo as_func_failure succeeded.-fi--if as_func_ret_success; then- :-else- exitcode=1- echo as_func_ret_success failed.-fi--if as_func_ret_failure; then- exitcode=1- echo as_func_ret_failure succeeded.-fi--if ( set x; as_func_ret_success y && test x = \"\$1\" ); then- :-else- exitcode=1- echo positional parameters were not saved.-fi--test \$exitcode = 0") || {- echo No shell found that supports shell functions.- echo Please tell autoconf@gnu.org about your system,- echo including any error possibly output before this- echo message-}---- as_lineno_1=$LINENO- as_lineno_2=$LINENO- test "x$as_lineno_1" != "x$as_lineno_2" &&- test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || {-- # Create $as_me.lineno as a copy of $as_myself, but with $LINENO- # uniformly replaced by the line number. The first 'sed' inserts a- # line-number line after each line using $LINENO; the second 'sed'- # does the real work. The second script uses 'N' to pair each- # line-number line with the line containing $LINENO, and appends- # trailing '-' during substitution so that $LINENO is not a special- # case at line end.- # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the- # scripts with optimization help from Paolo Bonzini. Blame Lee- # E. McMahon (1931-1989) for sed's syntax. :-)- sed -n '- p- /[$]LINENO/=- ' <$as_myself |- sed '- s/[$]LINENO.*/&-/- t lineno- b- :lineno- N- :loop- s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/- t loop- s/-\n.*//- ' >$as_me.lineno &&- chmod +x "$as_me.lineno" ||- { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2- { (exit 1); exit 1; }; }-- # Don't try to exec as it changes $[0], causing all sort of problems- # (the dirname of $[0] is not the place where we might find the- # original and so on. Autoconf is especially sensitive to this).- . "./$as_me.lineno"- # Exit status is that of the last command.- exit-}---if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then- as_dirname=dirname-else- as_dirname=false-fi--ECHO_C= ECHO_N= ECHO_T=-case `echo -n x` in--n*)- case `echo 'x\c'` in- *c*) ECHO_T=' ';; # ECHO_T is single tab character.- *) ECHO_C='\c';;- esac;;-*)- ECHO_N='-n';;-esac--if expr a : '\(a\)' >/dev/null 2>&1 &&- test "X`expr 00001 : '.*\(...\)'`" = X001; then- as_expr=expr-else- as_expr=false-fi--rm -f conf$$ conf$$.exe conf$$.file-if test -d conf$$.dir; then- rm -f conf$$.dir/conf$$.file-else- rm -f conf$$.dir- mkdir conf$$.dir-fi-echo >conf$$.file-if ln -s conf$$.file conf$$ 2>/dev/null; then- as_ln_s='ln -s'- # ... but there are two gotchas:- # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.- # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.- # In both cases, we have to default to `cp -p'.- ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||- as_ln_s='cp -p'-elif ln conf$$.file conf$$ 2>/dev/null; then- as_ln_s=ln-else- as_ln_s='cp -p'-fi-rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file-rmdir conf$$.dir 2>/dev/null--if mkdir -p . 2>/dev/null; then- as_mkdir_p=:-else- test -d ./-p && rmdir ./-p- as_mkdir_p=false-fi--if test -x / >/dev/null 2>&1; then- as_test_x='test -x'-else- if ls -dL / >/dev/null 2>&1; then- as_ls_L_option=L- else- as_ls_L_option=- fi- as_test_x='- eval sh -c '\''- if test -d "$1"; then- test -d "$1/.";- else- case $1 in- -*)set "./$1";;- esac;- case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in- ???[sx]*):;;*)false;;esac;fi- '\'' sh- '-fi-as_executable_p=$as_test_x--# Sed expression to map a string onto a valid CPP name.-as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"--# Sed expression to map a string onto a valid variable name.-as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"----exec 7<&0 </dev/null 6>&1--# Name of the host.-# hostname on some systems (SVR3.2, Linux) returns a bogus exit status,-# so uname gets run too.-ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`--#-# Initializations.-#-ac_default_prefix=/usr/local-ac_clean_files=-ac_config_libobj_dir=.-LIBOBJS=-cross_compiling=no-subdirs=-MFLAGS=-MAKEFLAGS=-SHELL=${CONFIG_SHELL-/bin/sh}--# Identity of this package.-PACKAGE_NAME='Haskell time package'-PACKAGE_TARNAME='time'-PACKAGE_VERSION='1.1.2.3'-PACKAGE_STRING='Haskell time package 1.1.2.3'-PACKAGE_BUGREPORT='ashley@semantic.org'--ac_unique_file="include/HsTime.h"-# Factoring default headers for most tests.-ac_includes_default="\-#include <stdio.h>-#ifdef HAVE_SYS_TYPES_H-# include <sys/types.h>-#endif-#ifdef HAVE_SYS_STAT_H-# include <sys/stat.h>-#endif-#ifdef STDC_HEADERS-# include <stdlib.h>-# include <stddef.h>-#else-# ifdef HAVE_STDLIB_H-# include <stdlib.h>-# endif-#endif-#ifdef HAVE_STRING_H-# if !defined STDC_HEADERS && defined HAVE_MEMORY_H-# include <memory.h>-# endif-# include <string.h>-#endif-#ifdef HAVE_STRINGS_H-# include <strings.h>-#endif-#ifdef HAVE_INTTYPES_H-# include <inttypes.h>-#endif-#ifdef HAVE_STDINT_H-# include <stdint.h>-#endif-#ifdef HAVE_UNISTD_H-# include <unistd.h>-#endif"--ac_subst_vars='SHELL-PATH_SEPARATOR-PACKAGE_NAME-PACKAGE_TARNAME-PACKAGE_VERSION-PACKAGE_STRING-PACKAGE_BUGREPORT-exec_prefix-prefix-program_transform_name-bindir-sbindir-libexecdir-datarootdir-datadir-sysconfdir-sharedstatedir-localstatedir-includedir-oldincludedir-docdir-infodir-htmldir-dvidir-pdfdir-psdir-libdir-localedir-mandir-DEFS-ECHO_C-ECHO_N-ECHO_T-LIBS-build_alias-host_alias-target_alias-CC-CFLAGS-LDFLAGS-CPPFLAGS-ac_ct_CC-EXEEXT-OBJEXT-CPP-GREP-EGREP-LIBOBJS-LTLIBOBJS'-ac_subst_files=''- ac_precious_vars='build_alias-host_alias-target_alias-CC-CFLAGS-LDFLAGS-LIBS-CPPFLAGS-CPP'---# Initialize some variables set by options.-ac_init_help=-ac_init_version=false-# The variables have the same names as the options, with-# dashes changed to underlines.-cache_file=/dev/null-exec_prefix=NONE-no_create=-no_recursion=-prefix=NONE-program_prefix=NONE-program_suffix=NONE-program_transform_name=s,x,x,-silent=-site=-srcdir=-verbose=-x_includes=NONE-x_libraries=NONE--# Installation directory options.-# These are left unexpanded so users can "make install exec_prefix=/foo"-# and all the variables that are supposed to be based on exec_prefix-# by default will actually change.-# Use braces instead of parens because sh, perl, etc. also accept them.-# (The list follows the same order as the GNU Coding Standards.)-bindir='${exec_prefix}/bin'-sbindir='${exec_prefix}/sbin'-libexecdir='${exec_prefix}/libexec'-datarootdir='${prefix}/share'-datadir='${datarootdir}'-sysconfdir='${prefix}/etc'-sharedstatedir='${prefix}/com'-localstatedir='${prefix}/var'-includedir='${prefix}/include'-oldincludedir='/usr/include'-docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'-infodir='${datarootdir}/info'-htmldir='${docdir}'-dvidir='${docdir}'-pdfdir='${docdir}'-psdir='${docdir}'-libdir='${exec_prefix}/lib'-localedir='${datarootdir}/locale'-mandir='${datarootdir}/man'--ac_prev=-ac_dashdash=-for ac_option-do- # If the previous option needs an argument, assign it.- if test -n "$ac_prev"; then- eval $ac_prev=\$ac_option- ac_prev=- continue- fi-- case $ac_option in- *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;- *) ac_optarg=yes ;;- esac-- # Accept the important Cygnus configure options, so we can diagnose typos.-- case $ac_dashdash$ac_option in- --)- ac_dashdash=yes ;;-- -bindir | --bindir | --bindi | --bind | --bin | --bi)- ac_prev=bindir ;;- -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)- bindir=$ac_optarg ;;-- -build | --build | --buil | --bui | --bu)- ac_prev=build_alias ;;- -build=* | --build=* | --buil=* | --bui=* | --bu=*)- build_alias=$ac_optarg ;;-- -cache-file | --cache-file | --cache-fil | --cache-fi \- | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)- ac_prev=cache_file ;;- -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \- | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)- cache_file=$ac_optarg ;;-- --config-cache | -C)- cache_file=config.cache ;;-- -datadir | --datadir | --datadi | --datad)- ac_prev=datadir ;;- -datadir=* | --datadir=* | --datadi=* | --datad=*)- datadir=$ac_optarg ;;-- -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \- | --dataroo | --dataro | --datar)- ac_prev=datarootdir ;;- -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \- | --dataroot=* | --dataroo=* | --dataro=* | --datar=*)- datarootdir=$ac_optarg ;;-- -disable-* | --disable-*)- ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'`- # Reject names that are not valid shell variable names.- expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null &&- { echo "$as_me: error: invalid feature name: $ac_feature" >&2- { (exit 1); exit 1; }; }- ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'`- eval enable_$ac_feature=no ;;-- -docdir | --docdir | --docdi | --doc | --do)- ac_prev=docdir ;;- -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*)- docdir=$ac_optarg ;;-- -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv)- ac_prev=dvidir ;;- -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*)- dvidir=$ac_optarg ;;-- -enable-* | --enable-*)- ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`- # Reject names that are not valid shell variable names.- expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null &&- { echo "$as_me: error: invalid feature name: $ac_feature" >&2- { (exit 1); exit 1; }; }- ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'`- eval enable_$ac_feature=\$ac_optarg ;;-- -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \- | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \- | --exec | --exe | --ex)- ac_prev=exec_prefix ;;- -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \- | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \- | --exec=* | --exe=* | --ex=*)- exec_prefix=$ac_optarg ;;-- -gas | --gas | --ga | --g)- # Obsolete; use --with-gas.- with_gas=yes ;;-- -help | --help | --hel | --he | -h)- ac_init_help=long ;;- -help=r* | --help=r* | --hel=r* | --he=r* | -hr*)- ac_init_help=recursive ;;- -help=s* | --help=s* | --hel=s* | --he=s* | -hs*)- ac_init_help=short ;;-- -host | --host | --hos | --ho)- ac_prev=host_alias ;;- -host=* | --host=* | --hos=* | --ho=*)- host_alias=$ac_optarg ;;-- -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht)- ac_prev=htmldir ;;- -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \- | --ht=*)- htmldir=$ac_optarg ;;-- -includedir | --includedir | --includedi | --included | --include \- | --includ | --inclu | --incl | --inc)- ac_prev=includedir ;;- -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \- | --includ=* | --inclu=* | --incl=* | --inc=*)- includedir=$ac_optarg ;;-- -infodir | --infodir | --infodi | --infod | --info | --inf)- ac_prev=infodir ;;- -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)- infodir=$ac_optarg ;;-- -libdir | --libdir | --libdi | --libd)- ac_prev=libdir ;;- -libdir=* | --libdir=* | --libdi=* | --libd=*)- libdir=$ac_optarg ;;-- -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \- | --libexe | --libex | --libe)- ac_prev=libexecdir ;;- -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \- | --libexe=* | --libex=* | --libe=*)- libexecdir=$ac_optarg ;;-- -localedir | --localedir | --localedi | --localed | --locale)- ac_prev=localedir ;;- -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*)- localedir=$ac_optarg ;;-- -localstatedir | --localstatedir | --localstatedi | --localstated \- | --localstate | --localstat | --localsta | --localst | --locals)- ac_prev=localstatedir ;;- -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \- | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*)- localstatedir=$ac_optarg ;;-- -mandir | --mandir | --mandi | --mand | --man | --ma | --m)- ac_prev=mandir ;;- -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)- mandir=$ac_optarg ;;-- -nfp | --nfp | --nf)- # Obsolete; use --without-fp.- with_fp=no ;;-- -no-create | --no-create | --no-creat | --no-crea | --no-cre \- | --no-cr | --no-c | -n)- no_create=yes ;;-- -no-recursion | --no-recursion | --no-recursio | --no-recursi \- | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)- no_recursion=yes ;;-- -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \- | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \- | --oldin | --oldi | --old | --ol | --o)- ac_prev=oldincludedir ;;- -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \- | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \- | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)- oldincludedir=$ac_optarg ;;-- -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)- ac_prev=prefix ;;- -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)- prefix=$ac_optarg ;;-- -program-prefix | --program-prefix | --program-prefi | --program-pref \- | --program-pre | --program-pr | --program-p)- ac_prev=program_prefix ;;- -program-prefix=* | --program-prefix=* | --program-prefi=* \- | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)- program_prefix=$ac_optarg ;;-- -program-suffix | --program-suffix | --program-suffi | --program-suff \- | --program-suf | --program-su | --program-s)- ac_prev=program_suffix ;;- -program-suffix=* | --program-suffix=* | --program-suffi=* \- | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)- program_suffix=$ac_optarg ;;-- -program-transform-name | --program-transform-name \- | --program-transform-nam | --program-transform-na \- | --program-transform-n | --program-transform- \- | --program-transform | --program-transfor \- | --program-transfo | --program-transf \- | --program-trans | --program-tran \- | --progr-tra | --program-tr | --program-t)- ac_prev=program_transform_name ;;- -program-transform-name=* | --program-transform-name=* \- | --program-transform-nam=* | --program-transform-na=* \- | --program-transform-n=* | --program-transform-=* \- | --program-transform=* | --program-transfor=* \- | --program-transfo=* | --program-transf=* \- | --program-trans=* | --program-tran=* \- | --progr-tra=* | --program-tr=* | --program-t=*)- program_transform_name=$ac_optarg ;;-- -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd)- ac_prev=pdfdir ;;- -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*)- pdfdir=$ac_optarg ;;-- -psdir | --psdir | --psdi | --psd | --ps)- ac_prev=psdir ;;- -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*)- psdir=$ac_optarg ;;-- -q | -quiet | --quiet | --quie | --qui | --qu | --q \- | -silent | --silent | --silen | --sile | --sil)- silent=yes ;;-- -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)- ac_prev=sbindir ;;- -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \- | --sbi=* | --sb=*)- sbindir=$ac_optarg ;;-- -sharedstatedir | --sharedstatedir | --sharedstatedi \- | --sharedstated | --sharedstate | --sharedstat | --sharedsta \- | --sharedst | --shareds | --shared | --share | --shar \- | --sha | --sh)- ac_prev=sharedstatedir ;;- -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \- | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \- | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \- | --sha=* | --sh=*)- sharedstatedir=$ac_optarg ;;-- -site | --site | --sit)- ac_prev=site ;;- -site=* | --site=* | --sit=*)- site=$ac_optarg ;;-- -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)- ac_prev=srcdir ;;- -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)- srcdir=$ac_optarg ;;-- -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \- | --syscon | --sysco | --sysc | --sys | --sy)- ac_prev=sysconfdir ;;- -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \- | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)- sysconfdir=$ac_optarg ;;-- -target | --target | --targe | --targ | --tar | --ta | --t)- ac_prev=target_alias ;;- -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)- target_alias=$ac_optarg ;;-- -v | -verbose | --verbose | --verbos | --verbo | --verb)- verbose=yes ;;-- -version | --version | --versio | --versi | --vers | -V)- ac_init_version=: ;;-- -with-* | --with-*)- ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`- # Reject names that are not valid shell variable names.- expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null &&- { echo "$as_me: error: invalid package name: $ac_package" >&2- { (exit 1); exit 1; }; }- ac_package=`echo $ac_package | sed 's/[-.]/_/g'`- eval with_$ac_package=\$ac_optarg ;;-- -without-* | --without-*)- ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'`- # Reject names that are not valid shell variable names.- expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null &&- { echo "$as_me: error: invalid package name: $ac_package" >&2- { (exit 1); exit 1; }; }- ac_package=`echo $ac_package | sed 's/[-.]/_/g'`- eval with_$ac_package=no ;;-- --x)- # Obsolete; use --with-x.- with_x=yes ;;-- -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \- | --x-incl | --x-inc | --x-in | --x-i)- ac_prev=x_includes ;;- -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \- | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)- x_includes=$ac_optarg ;;-- -x-libraries | --x-libraries | --x-librarie | --x-librari \- | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)- ac_prev=x_libraries ;;- -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \- | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)- x_libraries=$ac_optarg ;;-- -*) { echo "$as_me: error: unrecognized option: $ac_option-Try \`$0 --help' for more information." >&2- { (exit 1); exit 1; }; }- ;;-- *=*)- ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`- # Reject names that are not valid shell variable names.- expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null &&- { echo "$as_me: error: invalid variable name: $ac_envvar" >&2- { (exit 1); exit 1; }; }- eval $ac_envvar=\$ac_optarg- export $ac_envvar ;;-- *)- # FIXME: should be removed in autoconf 3.0.- echo "$as_me: WARNING: you should use --build, --host, --target" >&2- expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&- echo "$as_me: WARNING: invalid host type: $ac_option" >&2- : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}- ;;-- esac-done--if test -n "$ac_prev"; then- ac_option=--`echo $ac_prev | sed 's/_/-/g'`- { echo "$as_me: error: missing argument to $ac_option" >&2- { (exit 1); exit 1; }; }-fi--# Be sure to have absolute directory names.-for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \- datadir sysconfdir sharedstatedir localstatedir includedir \- oldincludedir docdir infodir htmldir dvidir pdfdir psdir \- libdir localedir mandir-do- eval ac_val=\$$ac_var- case $ac_val in- [\\/$]* | ?:[\\/]* ) continue;;- NONE | '' ) case $ac_var in *prefix ) continue;; esac;;- esac- { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2- { (exit 1); exit 1; }; }-done--# There might be people who depend on the old broken behavior: `$host'-# used to hold the argument of --host etc.-# FIXME: To remove some day.-build=$build_alias-host=$host_alias-target=$target_alias--# FIXME: To remove some day.-if test "x$host_alias" != x; then- if test "x$build_alias" = x; then- cross_compiling=maybe- echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host.- If a cross compiler is detected then cross compile mode will be used." >&2- elif test "x$build_alias" != "x$host_alias"; then- cross_compiling=yes- fi-fi--ac_tool_prefix=-test -n "$host_alias" && ac_tool_prefix=$host_alias---test "$silent" = yes && exec 6>/dev/null---ac_pwd=`pwd` && test -n "$ac_pwd" &&-ac_ls_di=`ls -di .` &&-ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` ||- { echo "$as_me: error: Working directory cannot be determined" >&2- { (exit 1); exit 1; }; }-test "X$ac_ls_di" = "X$ac_pwd_ls_di" ||- { echo "$as_me: error: pwd does not report name of working directory" >&2- { (exit 1); exit 1; }; }---# Find the source files, if location was not specified.-if test -z "$srcdir"; then- ac_srcdir_defaulted=yes- # Try the directory containing this script, then the parent directory.- ac_confdir=`$as_dirname -- "$0" ||-$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \- X"$0" : 'X\(//\)[^/]' \| \- X"$0" : 'X\(//\)$' \| \- X"$0" : 'X\(/\)' \| . 2>/dev/null ||-echo X"$0" |- sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{- s//\1/- q- }- /^X\(\/\/\)[^/].*/{- s//\1/- q- }- /^X\(\/\/\)$/{- s//\1/- q- }- /^X\(\/\).*/{- s//\1/- q- }- s/.*/./; q'`- srcdir=$ac_confdir- if test ! -r "$srcdir/$ac_unique_file"; then- srcdir=..- fi-else- ac_srcdir_defaulted=no-fi-if test ! -r "$srcdir/$ac_unique_file"; then- test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .."- { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2- { (exit 1); exit 1; }; }-fi-ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work"-ac_abs_confdir=`(- cd "$srcdir" && test -r "./$ac_unique_file" || { echo "$as_me: error: $ac_msg" >&2- { (exit 1); exit 1; }; }- pwd)`-# When building in place, set srcdir=.-if test "$ac_abs_confdir" = "$ac_pwd"; then- srcdir=.-fi-# Remove unnecessary trailing slashes from srcdir.-# Double slashes in file names in object file debugging info-# mess up M-x gdb in Emacs.-case $srcdir in-*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;;-esac-for ac_var in $ac_precious_vars; do- eval ac_env_${ac_var}_set=\${${ac_var}+set}- eval ac_env_${ac_var}_value=\$${ac_var}- eval ac_cv_env_${ac_var}_set=\${${ac_var}+set}- eval ac_cv_env_${ac_var}_value=\$${ac_var}-done--#-# Report the --help message.-#-if test "$ac_init_help" = "long"; then- # Omit some internal or obsolete options to make the list less imposing.- # This message is too long to be a string in the A/UX 3.1 sh.- cat <<_ACEOF-\`configure' configures Haskell time package 1.1.2.3 to adapt to many kinds of systems.--Usage: $0 [OPTION]... [VAR=VALUE]...--To assign environment variables (e.g., CC, CFLAGS...), specify them as-VAR=VALUE. See below for descriptions of some of the useful variables.--Defaults for the options are specified in brackets.--Configuration:- -h, --help display this help and exit- --help=short display options specific to this package- --help=recursive display the short help of all the included packages- -V, --version display version information and exit- -q, --quiet, --silent do not print \`checking...' messages- --cache-file=FILE cache test results in FILE [disabled]- -C, --config-cache alias for \`--cache-file=config.cache'- -n, --no-create do not create output files- --srcdir=DIR find the sources in DIR [configure dir or \`..']--Installation directories:- --prefix=PREFIX install architecture-independent files in PREFIX- [$ac_default_prefix]- --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX- [PREFIX]--By default, \`make install' will install all the files in-\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify-an installation prefix other than \`$ac_default_prefix' using \`--prefix',-for instance \`--prefix=\$HOME'.--For better control, use the options below.--Fine tuning of the installation directories:- --bindir=DIR user executables [EPREFIX/bin]- --sbindir=DIR system admin executables [EPREFIX/sbin]- --libexecdir=DIR program executables [EPREFIX/libexec]- --sysconfdir=DIR read-only single-machine data [PREFIX/etc]- --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]- --localstatedir=DIR modifiable single-machine data [PREFIX/var]- --libdir=DIR object code libraries [EPREFIX/lib]- --includedir=DIR C header files [PREFIX/include]- --oldincludedir=DIR C header files for non-gcc [/usr/include]- --datarootdir=DIR read-only arch.-independent data root [PREFIX/share]- --datadir=DIR read-only architecture-independent data [DATAROOTDIR]- --infodir=DIR info documentation [DATAROOTDIR/info]- --localedir=DIR locale-dependent data [DATAROOTDIR/locale]- --mandir=DIR man documentation [DATAROOTDIR/man]- --docdir=DIR documentation root [DATAROOTDIR/doc/time]- --htmldir=DIR html documentation [DOCDIR]- --dvidir=DIR dvi documentation [DOCDIR]- --pdfdir=DIR pdf documentation [DOCDIR]- --psdir=DIR ps documentation [DOCDIR]-_ACEOF-- cat <<\_ACEOF-_ACEOF-fi--if test -n "$ac_init_help"; then- case $ac_init_help in- short | recursive ) echo "Configuration of Haskell time package 1.1.2.3:";;- esac- cat <<\_ACEOF--Optional Packages:- --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]- --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)-C compiler--Some influential environment variables:- CC C compiler command- CFLAGS C compiler flags- LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a- nonstandard directory <lib dir>- LIBS libraries to pass to the linker, e.g. -l<library>- CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I<include dir> if- you have headers in a nonstandard directory <include dir>- CPP C preprocessor--Use these variables to override the choices made by `configure' or to help-it to find libraries and programs with nonstandard names/locations.--Report bugs to <ashley@semantic.org>.-_ACEOF-ac_status=$?-fi--if test "$ac_init_help" = "recursive"; then- # If there are subdirs, report their specific --help.- for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue- test -d "$ac_dir" || continue- ac_builddir=.--case "$ac_dir" in-.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;-*)- ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`- # A ".." for each directory in $ac_dir_suffix.- ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'`- case $ac_top_builddir_sub in- "") ac_top_builddir_sub=. ac_top_build_prefix= ;;- *) ac_top_build_prefix=$ac_top_builddir_sub/ ;;- esac ;;-esac-ac_abs_top_builddir=$ac_pwd-ac_abs_builddir=$ac_pwd$ac_dir_suffix-# for backward compatibility:-ac_top_builddir=$ac_top_build_prefix--case $srcdir in- .) # We are building in place.- ac_srcdir=.- ac_top_srcdir=$ac_top_builddir_sub- ac_abs_top_srcdir=$ac_pwd ;;- [\\/]* | ?:[\\/]* ) # Absolute name.- ac_srcdir=$srcdir$ac_dir_suffix;- ac_top_srcdir=$srcdir- ac_abs_top_srcdir=$srcdir ;;- *) # Relative name.- ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix- ac_top_srcdir=$ac_top_build_prefix$srcdir- ac_abs_top_srcdir=$ac_pwd/$srcdir ;;-esac-ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix-- cd "$ac_dir" || { ac_status=$?; continue; }- # Check for guested configure.- if test -f "$ac_srcdir/configure.gnu"; then- echo &&- $SHELL "$ac_srcdir/configure.gnu" --help=recursive- elif test -f "$ac_srcdir/configure"; then- echo &&- $SHELL "$ac_srcdir/configure" --help=recursive- else- echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2- fi || ac_status=$?- cd "$ac_pwd" || { ac_status=$?; break; }- done-fi--test -n "$ac_init_help" && exit $ac_status-if $ac_init_version; then- cat <<\_ACEOF-Haskell time package configure 1.1.2.3-generated by GNU Autoconf 2.61--Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,-2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.-This configure script is free software; the Free Software Foundation-gives unlimited permission to copy, distribute and modify it.-_ACEOF- exit-fi-cat >config.log <<_ACEOF-This file contains any messages produced by compilers while-running configure, to aid debugging if configure makes a mistake.--It was created by Haskell time package $as_me 1.1.2.3, which was-generated by GNU Autoconf 2.61. Invocation command line was-- $ $0 $@--_ACEOF-exec 5>>config.log-{-cat <<_ASUNAME-## --------- ##-## Platform. ##-## --------- ##--hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`-uname -m = `(uname -m) 2>/dev/null || echo unknown`-uname -r = `(uname -r) 2>/dev/null || echo unknown`-uname -s = `(uname -s) 2>/dev/null || echo unknown`-uname -v = `(uname -v) 2>/dev/null || echo unknown`--/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`-/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown`--/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown`-/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown`-/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`-/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown`-/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown`-/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown`-/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown`--_ASUNAME--as_save_IFS=$IFS; IFS=$PATH_SEPARATOR-for as_dir in $PATH-do- IFS=$as_save_IFS- test -z "$as_dir" && as_dir=.- echo "PATH: $as_dir"-done-IFS=$as_save_IFS--} >&5--cat >&5 <<_ACEOF---## ----------- ##-## Core tests. ##-## ----------- ##--_ACEOF---# Keep a trace of the command line.-# Strip out --no-create and --no-recursion so they do not pile up.-# Strip out --silent because we don't want to record it for future runs.-# Also quote any args containing shell meta-characters.-# Make two passes to allow for proper duplicate-argument suppression.-ac_configure_args=-ac_configure_args0=-ac_configure_args1=-ac_must_keep_next=false-for ac_pass in 1 2-do- for ac_arg- do- case $ac_arg in- -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;- -q | -quiet | --quiet | --quie | --qui | --qu | --q \- | -silent | --silent | --silen | --sile | --sil)- continue ;;- *\'*)- ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;- esac- case $ac_pass in- 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;;- 2)- ac_configure_args1="$ac_configure_args1 '$ac_arg'"- if test $ac_must_keep_next = true; then- ac_must_keep_next=false # Got value, back to normal.- else- case $ac_arg in- *=* | --config-cache | -C | -disable-* | --disable-* \- | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \- | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \- | -with-* | --with-* | -without-* | --without-* | --x)- case "$ac_configure_args0 " in- "$ac_configure_args1"*" '$ac_arg' "* ) continue ;;- esac- ;;- -* ) ac_must_keep_next=true ;;- esac- fi- ac_configure_args="$ac_configure_args '$ac_arg'"- ;;- esac- done-done-$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; }-$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; }--# When interrupted or exit'd, cleanup temporary files, and complete-# config.log. We remove comments because anyway the quotes in there-# would cause problems or look ugly.-# WARNING: Use '\'' to represent an apostrophe within the trap.-# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug.-trap 'exit_status=$?- # Save into config.log some information that might help in debugging.- {- echo-- cat <<\_ASBOX-## ---------------- ##-## Cache variables. ##-## ---------------- ##-_ASBOX- echo- # The following way of writing the cache mishandles newlines in values,-(- for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do- eval ac_val=\$$ac_var- case $ac_val in #(- *${as_nl}*)- case $ac_var in #(- *_cv_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5-echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;;- esac- case $ac_var in #(- _ | IFS | as_nl) ;; #(- *) $as_unset $ac_var ;;- esac ;;- esac- done- (set) 2>&1 |- case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #(- *${as_nl}ac_space=\ *)- sed -n \- "s/'\''/'\''\\\\'\'''\''/g;- s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p"- ;; #(- *)- sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"- ;;- esac |- sort-)- echo-- cat <<\_ASBOX-## ----------------- ##-## Output variables. ##-## ----------------- ##-_ASBOX- echo- for ac_var in $ac_subst_vars- do- eval ac_val=\$$ac_var- case $ac_val in- *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;- esac- echo "$ac_var='\''$ac_val'\''"- done | sort- echo-- if test -n "$ac_subst_files"; then- cat <<\_ASBOX-## ------------------- ##-## File substitutions. ##-## ------------------- ##-_ASBOX- echo- for ac_var in $ac_subst_files- do- eval ac_val=\$$ac_var- case $ac_val in- *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;- esac- echo "$ac_var='\''$ac_val'\''"- done | sort- echo- fi-- if test -s confdefs.h; then- cat <<\_ASBOX-## ----------- ##-## confdefs.h. ##-## ----------- ##-_ASBOX- echo- cat confdefs.h- echo- fi- test "$ac_signal" != 0 &&- echo "$as_me: caught signal $ac_signal"- echo "$as_me: exit $exit_status"- } >&5- rm -f core *.core core.conftest.* &&- rm -f -r conftest* confdefs* conf$$* $ac_clean_files &&- exit $exit_status-' 0-for ac_signal in 1 2 13 15; do- trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal-done-ac_signal=0--# confdefs.h avoids OS command line length limits that DEFS can exceed.-rm -f -r conftest* confdefs.h--# Predefined preprocessor variables.--cat >>confdefs.h <<_ACEOF-#define PACKAGE_NAME "$PACKAGE_NAME"-_ACEOF---cat >>confdefs.h <<_ACEOF-#define PACKAGE_TARNAME "$PACKAGE_TARNAME"-_ACEOF---cat >>confdefs.h <<_ACEOF-#define PACKAGE_VERSION "$PACKAGE_VERSION"-_ACEOF---cat >>confdefs.h <<_ACEOF-#define PACKAGE_STRING "$PACKAGE_STRING"-_ACEOF---cat >>confdefs.h <<_ACEOF-#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"-_ACEOF---# Let the site file select an alternate cache file if it wants to.-# Prefer explicitly selected file to automatically selected ones.-if test -n "$CONFIG_SITE"; then- set x "$CONFIG_SITE"-elif test "x$prefix" != xNONE; then- set x "$prefix/share/config.site" "$prefix/etc/config.site"-else- set x "$ac_default_prefix/share/config.site" \- "$ac_default_prefix/etc/config.site"-fi-shift-for ac_site_file-do- if test -r "$ac_site_file"; then- { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5-echo "$as_me: loading site script $ac_site_file" >&6;}- sed 's/^/| /' "$ac_site_file" >&5- . "$ac_site_file"- fi-done--if test -r "$cache_file"; then- # Some versions of bash will fail to source /dev/null (special- # files actually), so we avoid doing that.- if test -f "$cache_file"; then- { echo "$as_me:$LINENO: loading cache $cache_file" >&5-echo "$as_me: loading cache $cache_file" >&6;}- case $cache_file in- [\\/]* | ?:[\\/]* ) . "$cache_file";;- *) . "./$cache_file";;- esac- fi-else- { echo "$as_me:$LINENO: creating cache $cache_file" >&5-echo "$as_me: creating cache $cache_file" >&6;}- >$cache_file-fi--# Check that the precious variables saved in the cache have kept the same-# value.-ac_cache_corrupted=false-for ac_var in $ac_precious_vars; do- eval ac_old_set=\$ac_cv_env_${ac_var}_set- eval ac_new_set=\$ac_env_${ac_var}_set- eval ac_old_val=\$ac_cv_env_${ac_var}_value- eval ac_new_val=\$ac_env_${ac_var}_value- case $ac_old_set,$ac_new_set in- set,)- { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5-echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}- ac_cache_corrupted=: ;;- ,set)- { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5-echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}- ac_cache_corrupted=: ;;- ,);;- *)- if test "x$ac_old_val" != "x$ac_new_val"; then- { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5-echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}- { echo "$as_me:$LINENO: former value: $ac_old_val" >&5-echo "$as_me: former value: $ac_old_val" >&2;}- { echo "$as_me:$LINENO: current value: $ac_new_val" >&5-echo "$as_me: current value: $ac_new_val" >&2;}- ac_cache_corrupted=:- fi;;- esac- # Pass precious variables to config.status.- if test "$ac_new_set" = set; then- case $ac_new_val in- *\'*) ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;- *) ac_arg=$ac_var=$ac_new_val ;;- esac- case " $ac_configure_args " in- *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy.- *) ac_configure_args="$ac_configure_args '$ac_arg'" ;;- esac- fi-done-if $ac_cache_corrupted; then- { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5-echo "$as_me: error: changes in the environment can compromise the build" >&2;}- { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5-echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;}- { (exit 1); exit 1; }; }-fi--------------------------ac_ext=c-ac_cpp='$CPP $CPPFLAGS'-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'-ac_compiler_gnu=$ac_cv_c_compiler_gnu----# Safety check: Ensure that we are in the correct source directory.----# Check whether --with-cc was given.-if test "${with_cc+set}" = set; then- withval=$with_cc; CC=$withval-fi--ac_ext=c-ac_cpp='$CPP $CPPFLAGS'-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'-ac_compiler_gnu=$ac_cv_c_compiler_gnu-if test -n "$ac_tool_prefix"; then- # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.-set dummy ${ac_tool_prefix}gcc; ac_word=$2-{ echo "$as_me:$LINENO: checking for $ac_word" >&5-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }-if test "${ac_cv_prog_CC+set}" = set; then- echo $ECHO_N "(cached) $ECHO_C" >&6-else- if test -n "$CC"; then- ac_cv_prog_CC="$CC" # Let the user override the test.-else-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR-for as_dir in $PATH-do- IFS=$as_save_IFS- test -z "$as_dir" && as_dir=.- for ac_exec_ext in '' $ac_executable_extensions; do- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then- ac_cv_prog_CC="${ac_tool_prefix}gcc"- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5- break 2- fi-done-done-IFS=$as_save_IFS--fi-fi-CC=$ac_cv_prog_CC-if test -n "$CC"; then- { echo "$as_me:$LINENO: result: $CC" >&5-echo "${ECHO_T}$CC" >&6; }-else- { echo "$as_me:$LINENO: result: no" >&5-echo "${ECHO_T}no" >&6; }-fi---fi-if test -z "$ac_cv_prog_CC"; then- ac_ct_CC=$CC- # Extract the first word of "gcc", so it can be a program name with args.-set dummy gcc; ac_word=$2-{ echo "$as_me:$LINENO: checking for $ac_word" >&5-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }-if test "${ac_cv_prog_ac_ct_CC+set}" = set; then- echo $ECHO_N "(cached) $ECHO_C" >&6-else- if test -n "$ac_ct_CC"; then- ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.-else-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR-for as_dir in $PATH-do- IFS=$as_save_IFS- test -z "$as_dir" && as_dir=.- for ac_exec_ext in '' $ac_executable_extensions; do- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then- ac_cv_prog_ac_ct_CC="gcc"- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5- break 2- fi-done-done-IFS=$as_save_IFS--fi-fi-ac_ct_CC=$ac_cv_prog_ac_ct_CC-if test -n "$ac_ct_CC"; then- { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5-echo "${ECHO_T}$ac_ct_CC" >&6; }-else- { echo "$as_me:$LINENO: result: no" >&5-echo "${ECHO_T}no" >&6; }-fi-- if test "x$ac_ct_CC" = x; then- CC=""- else- case $cross_compiling:$ac_tool_warned in-yes:)-{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools-whose name does not start with the host triplet. If you think this-configuration is useful to you, please write to autoconf@gnu.org." >&5-echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools-whose name does not start with the host triplet. If you think this-configuration is useful to you, please write to autoconf@gnu.org." >&2;}-ac_tool_warned=yes ;;-esac- CC=$ac_ct_CC- fi-else- CC="$ac_cv_prog_CC"-fi--if test -z "$CC"; then- if test -n "$ac_tool_prefix"; then- # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.-set dummy ${ac_tool_prefix}cc; ac_word=$2-{ echo "$as_me:$LINENO: checking for $ac_word" >&5-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }-if test "${ac_cv_prog_CC+set}" = set; then- echo $ECHO_N "(cached) $ECHO_C" >&6-else- if test -n "$CC"; then- ac_cv_prog_CC="$CC" # Let the user override the test.-else-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR-for as_dir in $PATH-do- IFS=$as_save_IFS- test -z "$as_dir" && as_dir=.- for ac_exec_ext in '' $ac_executable_extensions; do- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then- ac_cv_prog_CC="${ac_tool_prefix}cc"- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5- break 2- fi-done-done-IFS=$as_save_IFS--fi-fi-CC=$ac_cv_prog_CC-if test -n "$CC"; then- { echo "$as_me:$LINENO: result: $CC" >&5-echo "${ECHO_T}$CC" >&6; }-else- { echo "$as_me:$LINENO: result: no" >&5-echo "${ECHO_T}no" >&6; }-fi--- fi-fi-if test -z "$CC"; then- # Extract the first word of "cc", so it can be a program name with args.-set dummy cc; ac_word=$2-{ echo "$as_me:$LINENO: checking for $ac_word" >&5-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }-if test "${ac_cv_prog_CC+set}" = set; then- echo $ECHO_N "(cached) $ECHO_C" >&6-else- if test -n "$CC"; then- ac_cv_prog_CC="$CC" # Let the user override the test.-else- ac_prog_rejected=no-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR-for as_dir in $PATH-do- IFS=$as_save_IFS- test -z "$as_dir" && as_dir=.- for ac_exec_ext in '' $ac_executable_extensions; do- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then- if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then- ac_prog_rejected=yes- continue- fi- ac_cv_prog_CC="cc"- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5- break 2- fi-done-done-IFS=$as_save_IFS--if test $ac_prog_rejected = yes; then- # We found a bogon in the path, so make sure we never use it.- set dummy $ac_cv_prog_CC- shift- if test $# != 0; then- # We chose a different compiler from the bogus one.- # However, it has the same basename, so the bogon will be chosen- # first if we set CC to just the basename; use the full file name.- shift- ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"- fi-fi-fi-fi-CC=$ac_cv_prog_CC-if test -n "$CC"; then- { echo "$as_me:$LINENO: result: $CC" >&5-echo "${ECHO_T}$CC" >&6; }-else- { echo "$as_me:$LINENO: result: no" >&5-echo "${ECHO_T}no" >&6; }-fi---fi-if test -z "$CC"; then- if test -n "$ac_tool_prefix"; then- for ac_prog in cl.exe- do- # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.-set dummy $ac_tool_prefix$ac_prog; ac_word=$2-{ echo "$as_me:$LINENO: checking for $ac_word" >&5-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }-if test "${ac_cv_prog_CC+set}" = set; then- echo $ECHO_N "(cached) $ECHO_C" >&6-else- if test -n "$CC"; then- ac_cv_prog_CC="$CC" # Let the user override the test.-else-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR-for as_dir in $PATH-do- IFS=$as_save_IFS- test -z "$as_dir" && as_dir=.- for ac_exec_ext in '' $ac_executable_extensions; do- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then- ac_cv_prog_CC="$ac_tool_prefix$ac_prog"- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5- break 2- fi-done-done-IFS=$as_save_IFS--fi-fi-CC=$ac_cv_prog_CC-if test -n "$CC"; then- { echo "$as_me:$LINENO: result: $CC" >&5-echo "${ECHO_T}$CC" >&6; }-else- { echo "$as_me:$LINENO: result: no" >&5-echo "${ECHO_T}no" >&6; }-fi--- test -n "$CC" && break- done-fi-if test -z "$CC"; then- ac_ct_CC=$CC- for ac_prog in cl.exe-do- # Extract the first word of "$ac_prog", so it can be a program name with args.-set dummy $ac_prog; ac_word=$2-{ echo "$as_me:$LINENO: checking for $ac_word" >&5-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }-if test "${ac_cv_prog_ac_ct_CC+set}" = set; then- echo $ECHO_N "(cached) $ECHO_C" >&6-else- if test -n "$ac_ct_CC"; then- ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.-else-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR-for as_dir in $PATH-do- IFS=$as_save_IFS- test -z "$as_dir" && as_dir=.- for ac_exec_ext in '' $ac_executable_extensions; do- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then- ac_cv_prog_ac_ct_CC="$ac_prog"- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5- break 2- fi-done-done-IFS=$as_save_IFS--fi-fi-ac_ct_CC=$ac_cv_prog_ac_ct_CC-if test -n "$ac_ct_CC"; then- { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5-echo "${ECHO_T}$ac_ct_CC" >&6; }-else- { echo "$as_me:$LINENO: result: no" >&5-echo "${ECHO_T}no" >&6; }-fi--- test -n "$ac_ct_CC" && break-done-- if test "x$ac_ct_CC" = x; then- CC=""- else- case $cross_compiling:$ac_tool_warned in-yes:)-{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools-whose name does not start with the host triplet. If you think this-configuration is useful to you, please write to autoconf@gnu.org." >&5-echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools-whose name does not start with the host triplet. If you think this-configuration is useful to you, please write to autoconf@gnu.org." >&2;}-ac_tool_warned=yes ;;-esac- CC=$ac_ct_CC- fi-fi--fi---test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH-See \`config.log' for more details." >&5-echo "$as_me: error: no acceptable C compiler found in \$PATH-See \`config.log' for more details." >&2;}- { (exit 1); exit 1; }; }--# Provide some information about the compiler.-echo "$as_me:$LINENO: checking for C compiler version" >&5-ac_compiler=`set X $ac_compile; echo $2`-{ (ac_try="$ac_compiler --version >&5"-case "(($ac_try" in- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;- *) ac_try_echo=$ac_try;;-esac-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5- (eval "$ac_compiler --version >&5") 2>&5- ac_status=$?- echo "$as_me:$LINENO: \$? = $ac_status" >&5- (exit $ac_status); }-{ (ac_try="$ac_compiler -v >&5"-case "(($ac_try" in- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;- *) ac_try_echo=$ac_try;;-esac-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5- (eval "$ac_compiler -v >&5") 2>&5- ac_status=$?- echo "$as_me:$LINENO: \$? = $ac_status" >&5- (exit $ac_status); }-{ (ac_try="$ac_compiler -V >&5"-case "(($ac_try" in- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;- *) ac_try_echo=$ac_try;;-esac-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5- (eval "$ac_compiler -V >&5") 2>&5- ac_status=$?- echo "$as_me:$LINENO: \$? = $ac_status" >&5- (exit $ac_status); }--cat >conftest.$ac_ext <<_ACEOF-/* confdefs.h. */-_ACEOF-cat confdefs.h >>conftest.$ac_ext-cat >>conftest.$ac_ext <<_ACEOF-/* end confdefs.h. */--int-main ()-{-- ;- return 0;-}-_ACEOF-ac_clean_files_save=$ac_clean_files-ac_clean_files="$ac_clean_files a.out a.exe b.out"-# Try to create an executable without -o first, disregard a.out.-# It will help us diagnose broken compilers, and finding out an intuition-# of exeext.-{ echo "$as_me:$LINENO: checking for C compiler default output file name" >&5-echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6; }-ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`-#-# List of possible output files, starting from the most likely.-# The algorithm is not robust to junk in `.', hence go to wildcards (a.*)-# only as a last resort. b.out is created by i960 compilers.-ac_files='a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out'-#-# The IRIX 6 linker writes into existing files which may not be-# executable, retaining their permissions. Remove them first so a-# subsequent execution test works.-ac_rmfiles=-for ac_file in $ac_files-do- case $ac_file in- *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;;- * ) ac_rmfiles="$ac_rmfiles $ac_file";;- esac-done-rm -f $ac_rmfiles--if { (ac_try="$ac_link_default"-case "(($ac_try" in- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;- *) ac_try_echo=$ac_try;;-esac-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5- (eval "$ac_link_default") 2>&5- ac_status=$?- echo "$as_me:$LINENO: \$? = $ac_status" >&5- (exit $ac_status); }; then- # Autoconf-2.13 could set the ac_cv_exeext variable to `no'.-# So ignore a value of `no', otherwise this would lead to `EXEEXT = no'-# in a Makefile. We should not override ac_cv_exeext if it was cached,-# so that the user can short-circuit this test for compilers unknown to-# Autoconf.-for ac_file in $ac_files ''-do- test -f "$ac_file" || continue- case $ac_file in- *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj )- ;;- [ab].out )- # We found the default executable, but exeext='' is most- # certainly right.- break;;- *.* )- if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no;- then :; else- ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`- fi- # We set ac_cv_exeext here because the later test for it is not- # safe: cross compilers may not add the suffix if given an `-o'- # argument, so we may need to know it at that point already.- # Even if this section looks crufty: it has the advantage of- # actually working.- break;;- * )- break;;- esac-done-test "$ac_cv_exeext" = no && ac_cv_exeext=--else- ac_file=''-fi--{ echo "$as_me:$LINENO: result: $ac_file" >&5-echo "${ECHO_T}$ac_file" >&6; }-if test -z "$ac_file"; then- echo "$as_me: failed program was:" >&5-sed 's/^/| /' conftest.$ac_ext >&5--{ { echo "$as_me:$LINENO: error: C compiler cannot create executables-See \`config.log' for more details." >&5-echo "$as_me: error: C compiler cannot create executables-See \`config.log' for more details." >&2;}- { (exit 77); exit 77; }; }-fi--ac_exeext=$ac_cv_exeext--# Check that the compiler produces executables we can run. If not, either-# the compiler is broken, or we cross compile.-{ echo "$as_me:$LINENO: checking whether the C compiler works" >&5-echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6; }-# FIXME: These cross compiler hacks should be removed for Autoconf 3.0-# If not cross compiling, check that we can run a simple program.-if test "$cross_compiling" != yes; then- if { ac_try='./$ac_file'- { (case "(($ac_try" in- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;- *) ac_try_echo=$ac_try;;-esac-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5- (eval "$ac_try") 2>&5- ac_status=$?- echo "$as_me:$LINENO: \$? = $ac_status" >&5- (exit $ac_status); }; }; then- cross_compiling=no- else- if test "$cross_compiling" = maybe; then- cross_compiling=yes- else- { { echo "$as_me:$LINENO: error: cannot run C compiled programs.-If you meant to cross compile, use \`--host'.-See \`config.log' for more details." >&5-echo "$as_me: error: cannot run C compiled programs.-If you meant to cross compile, use \`--host'.-See \`config.log' for more details." >&2;}- { (exit 1); exit 1; }; }- fi- fi-fi-{ echo "$as_me:$LINENO: result: yes" >&5-echo "${ECHO_T}yes" >&6; }--rm -f a.out a.exe conftest$ac_cv_exeext b.out-ac_clean_files=$ac_clean_files_save-# Check that the compiler produces executables we can run. If not, either-# the compiler is broken, or we cross compile.-{ echo "$as_me:$LINENO: checking whether we are cross compiling" >&5-echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6; }-{ echo "$as_me:$LINENO: result: $cross_compiling" >&5-echo "${ECHO_T}$cross_compiling" >&6; }--{ echo "$as_me:$LINENO: checking for suffix of executables" >&5-echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6; }-if { (ac_try="$ac_link"-case "(($ac_try" in- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;- *) ac_try_echo=$ac_try;;-esac-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5- (eval "$ac_link") 2>&5- ac_status=$?- echo "$as_me:$LINENO: \$? = $ac_status" >&5- (exit $ac_status); }; then- # If both `conftest.exe' and `conftest' are `present' (well, observable)-# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will-# work properly (i.e., refer to `conftest.exe'), while it won't with-# `rm'.-for ac_file in conftest.exe conftest conftest.*; do- test -f "$ac_file" || continue- case $ac_file in- *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;;- *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`- break;;- * ) break;;- esac-done-else- { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link-See \`config.log' for more details." >&5-echo "$as_me: error: cannot compute suffix of executables: cannot compile and link-See \`config.log' for more details." >&2;}- { (exit 1); exit 1; }; }-fi--rm -f conftest$ac_cv_exeext-{ echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5-echo "${ECHO_T}$ac_cv_exeext" >&6; }--rm -f conftest.$ac_ext-EXEEXT=$ac_cv_exeext-ac_exeext=$EXEEXT-{ echo "$as_me:$LINENO: checking for suffix of object files" >&5-echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6; }-if test "${ac_cv_objext+set}" = set; then- echo $ECHO_N "(cached) $ECHO_C" >&6-else- cat >conftest.$ac_ext <<_ACEOF-/* confdefs.h. */-_ACEOF-cat confdefs.h >>conftest.$ac_ext-cat >>conftest.$ac_ext <<_ACEOF-/* end confdefs.h. */--int-main ()-{-- ;- return 0;-}-_ACEOF-rm -f conftest.o conftest.obj-if { (ac_try="$ac_compile"-case "(($ac_try" in- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;- *) ac_try_echo=$ac_try;;-esac-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5- (eval "$ac_compile") 2>&5- ac_status=$?- echo "$as_me:$LINENO: \$? = $ac_status" >&5- (exit $ac_status); }; then- for ac_file in conftest.o conftest.obj conftest.*; do- test -f "$ac_file" || continue;- case $ac_file in- *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf ) ;;- *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`- break;;- esac-done-else- echo "$as_me: failed program was:" >&5-sed 's/^/| /' conftest.$ac_ext >&5--{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile-See \`config.log' for more details." >&5-echo "$as_me: error: cannot compute suffix of object files: cannot compile-See \`config.log' for more details." >&2;}- { (exit 1); exit 1; }; }-fi--rm -f conftest.$ac_cv_objext conftest.$ac_ext-fi-{ echo "$as_me:$LINENO: result: $ac_cv_objext" >&5-echo "${ECHO_T}$ac_cv_objext" >&6; }-OBJEXT=$ac_cv_objext-ac_objext=$OBJEXT-{ echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5-echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6; }-if test "${ac_cv_c_compiler_gnu+set}" = set; then- echo $ECHO_N "(cached) $ECHO_C" >&6-else- cat >conftest.$ac_ext <<_ACEOF-/* confdefs.h. */-_ACEOF-cat confdefs.h >>conftest.$ac_ext-cat >>conftest.$ac_ext <<_ACEOF-/* end confdefs.h. */--int-main ()-{-#ifndef __GNUC__- choke me-#endif-- ;- return 0;-}-_ACEOF-rm -f conftest.$ac_objext-if { (ac_try="$ac_compile"-case "(($ac_try" in- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;- *) ac_try_echo=$ac_try;;-esac-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5- (eval "$ac_compile") 2>conftest.er1- ac_status=$?- grep -v '^ *+' conftest.er1 >conftest.err- rm -f conftest.er1- cat conftest.err >&5- echo "$as_me:$LINENO: \$? = $ac_status" >&5- (exit $ac_status); } && {- test -z "$ac_c_werror_flag" ||- test ! -s conftest.err- } && test -s conftest.$ac_objext; then- ac_compiler_gnu=yes-else- echo "$as_me: failed program was:" >&5-sed 's/^/| /' conftest.$ac_ext >&5-- ac_compiler_gnu=no-fi--rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext-ac_cv_c_compiler_gnu=$ac_compiler_gnu--fi-{ echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5-echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6; }-GCC=`test $ac_compiler_gnu = yes && echo yes`-ac_test_CFLAGS=${CFLAGS+set}-ac_save_CFLAGS=$CFLAGS-{ echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5-echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6; }-if test "${ac_cv_prog_cc_g+set}" = set; then- echo $ECHO_N "(cached) $ECHO_C" >&6-else- ac_save_c_werror_flag=$ac_c_werror_flag- ac_c_werror_flag=yes- ac_cv_prog_cc_g=no- CFLAGS="-g"- cat >conftest.$ac_ext <<_ACEOF-/* confdefs.h. */-_ACEOF-cat confdefs.h >>conftest.$ac_ext-cat >>conftest.$ac_ext <<_ACEOF-/* end confdefs.h. */--int-main ()-{-- ;- return 0;-}-_ACEOF-rm -f conftest.$ac_objext-if { (ac_try="$ac_compile"-case "(($ac_try" in- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;- *) ac_try_echo=$ac_try;;-esac-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5- (eval "$ac_compile") 2>conftest.er1- ac_status=$?- grep -v '^ *+' conftest.er1 >conftest.err- rm -f conftest.er1- cat conftest.err >&5- echo "$as_me:$LINENO: \$? = $ac_status" >&5- (exit $ac_status); } && {- test -z "$ac_c_werror_flag" ||- test ! -s conftest.err- } && test -s conftest.$ac_objext; then- ac_cv_prog_cc_g=yes-else- echo "$as_me: failed program was:" >&5-sed 's/^/| /' conftest.$ac_ext >&5-- CFLAGS=""- cat >conftest.$ac_ext <<_ACEOF-/* confdefs.h. */-_ACEOF-cat confdefs.h >>conftest.$ac_ext-cat >>conftest.$ac_ext <<_ACEOF-/* end confdefs.h. */--int-main ()-{-- ;- return 0;-}-_ACEOF-rm -f conftest.$ac_objext-if { (ac_try="$ac_compile"-case "(($ac_try" in- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;- *) ac_try_echo=$ac_try;;-esac-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5- (eval "$ac_compile") 2>conftest.er1- ac_status=$?- grep -v '^ *+' conftest.er1 >conftest.err- rm -f conftest.er1- cat conftest.err >&5- echo "$as_me:$LINENO: \$? = $ac_status" >&5- (exit $ac_status); } && {- test -z "$ac_c_werror_flag" ||- test ! -s conftest.err- } && test -s conftest.$ac_objext; then- :-else- echo "$as_me: failed program was:" >&5-sed 's/^/| /' conftest.$ac_ext >&5-- ac_c_werror_flag=$ac_save_c_werror_flag- CFLAGS="-g"- cat >conftest.$ac_ext <<_ACEOF-/* confdefs.h. */-_ACEOF-cat confdefs.h >>conftest.$ac_ext-cat >>conftest.$ac_ext <<_ACEOF-/* end confdefs.h. */--int-main ()-{-- ;- return 0;-}-_ACEOF-rm -f conftest.$ac_objext-if { (ac_try="$ac_compile"-case "(($ac_try" in- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;- *) ac_try_echo=$ac_try;;-esac-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5- (eval "$ac_compile") 2>conftest.er1- ac_status=$?- grep -v '^ *+' conftest.er1 >conftest.err- rm -f conftest.er1- cat conftest.err >&5- echo "$as_me:$LINENO: \$? = $ac_status" >&5- (exit $ac_status); } && {- test -z "$ac_c_werror_flag" ||- test ! -s conftest.err- } && test -s conftest.$ac_objext; then- ac_cv_prog_cc_g=yes-else- echo "$as_me: failed program was:" >&5-sed 's/^/| /' conftest.$ac_ext >&5---fi--rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext-fi--rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext-fi--rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext- ac_c_werror_flag=$ac_save_c_werror_flag-fi-{ echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5-echo "${ECHO_T}$ac_cv_prog_cc_g" >&6; }-if test "$ac_test_CFLAGS" = set; then- CFLAGS=$ac_save_CFLAGS-elif test $ac_cv_prog_cc_g = yes; then- if test "$GCC" = yes; then- CFLAGS="-g -O2"- else- CFLAGS="-g"- fi-else- if test "$GCC" = yes; then- CFLAGS="-O2"- else- CFLAGS=- fi-fi-{ echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5-echo $ECHO_N "checking for $CC option to accept ISO C89... $ECHO_C" >&6; }-if test "${ac_cv_prog_cc_c89+set}" = set; then- echo $ECHO_N "(cached) $ECHO_C" >&6-else- ac_cv_prog_cc_c89=no-ac_save_CC=$CC-cat >conftest.$ac_ext <<_ACEOF-/* confdefs.h. */-_ACEOF-cat confdefs.h >>conftest.$ac_ext-cat >>conftest.$ac_ext <<_ACEOF-/* end confdefs.h. */-#include <stdarg.h>-#include <stdio.h>-#include <sys/types.h>-#include <sys/stat.h>-/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */-struct buf { int x; };-FILE * (*rcsopen) (struct buf *, struct stat *, int);-static char *e (p, i)- char **p;- int i;-{- return p[i];-}-static char *f (char * (*g) (char **, int), char **p, ...)-{- char *s;- va_list v;- va_start (v,p);- s = g (p, va_arg (v,int));- va_end (v);- return s;-}--/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has- function prototypes and stuff, but not '\xHH' hex character constants.- These don't provoke an error unfortunately, instead are silently treated- as 'x'. The following induces an error, until -std is added to get- proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an- array size at least. It's necessary to write '\x00'==0 to get something- that's true only with -std. */-int osf4_cc_array ['\x00' == 0 ? 1 : -1];--/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters- inside strings and character constants. */-#define FOO(x) 'x'-int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];--int test (int i, double x);-struct s1 {int (*f) (int a);};-struct s2 {int (*f) (double a);};-int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);-int argc;-char **argv;-int-main ()-{-return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];- ;- return 0;-}-_ACEOF-for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \- -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"-do- CC="$ac_save_CC $ac_arg"- rm -f conftest.$ac_objext-if { (ac_try="$ac_compile"-case "(($ac_try" in- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;- *) ac_try_echo=$ac_try;;-esac-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5- (eval "$ac_compile") 2>conftest.er1- ac_status=$?- grep -v '^ *+' conftest.er1 >conftest.err- rm -f conftest.er1- cat conftest.err >&5- echo "$as_me:$LINENO: \$? = $ac_status" >&5- (exit $ac_status); } && {- test -z "$ac_c_werror_flag" ||- test ! -s conftest.err- } && test -s conftest.$ac_objext; then- ac_cv_prog_cc_c89=$ac_arg-else- echo "$as_me: failed program was:" >&5-sed 's/^/| /' conftest.$ac_ext >&5---fi--rm -f core conftest.err conftest.$ac_objext- test "x$ac_cv_prog_cc_c89" != "xno" && break-done-rm -f conftest.$ac_ext-CC=$ac_save_CC--fi-# AC_CACHE_VAL-case "x$ac_cv_prog_cc_c89" in- x)- { echo "$as_me:$LINENO: result: none needed" >&5-echo "${ECHO_T}none needed" >&6; } ;;- xno)- { echo "$as_me:$LINENO: result: unsupported" >&5-echo "${ECHO_T}unsupported" >&6; } ;;- *)- CC="$CC $ac_cv_prog_cc_c89"- { echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5-echo "${ECHO_T}$ac_cv_prog_cc_c89" >&6; } ;;-esac---ac_ext=c-ac_cpp='$CPP $CPPFLAGS'-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'-ac_compiler_gnu=$ac_cv_c_compiler_gnu---ac_config_headers="$ac_config_headers include/HsTimeConfig.h"----ac_ext=c-ac_cpp='$CPP $CPPFLAGS'-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'-ac_compiler_gnu=$ac_cv_c_compiler_gnu-{ echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5-echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6; }-# On Suns, sometimes $CPP names a directory.-if test -n "$CPP" && test -d "$CPP"; then- CPP=-fi-if test -z "$CPP"; then- if test "${ac_cv_prog_CPP+set}" = set; then- echo $ECHO_N "(cached) $ECHO_C" >&6-else- # Double quotes because CPP needs to be expanded- for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"- do- ac_preproc_ok=false-for ac_c_preproc_warn_flag in '' yes-do- # Use a header file that comes with gcc, so configuring glibc- # with a fresh cross-compiler works.- # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since- # <limits.h> exists even on freestanding compilers.- # On the NeXT, cc -E runs the code through the compiler's parser,- # not just through cpp. "Syntax error" is here to catch this case.- cat >conftest.$ac_ext <<_ACEOF-/* confdefs.h. */-_ACEOF-cat confdefs.h >>conftest.$ac_ext-cat >>conftest.$ac_ext <<_ACEOF-/* end confdefs.h. */-#ifdef __STDC__-# include <limits.h>-#else-# include <assert.h>-#endif- Syntax error-_ACEOF-if { (ac_try="$ac_cpp conftest.$ac_ext"-case "(($ac_try" in- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;- *) ac_try_echo=$ac_try;;-esac-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5- (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1- ac_status=$?- grep -v '^ *+' conftest.er1 >conftest.err- rm -f conftest.er1- cat conftest.err >&5- echo "$as_me:$LINENO: \$? = $ac_status" >&5- (exit $ac_status); } >/dev/null && {- test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||- test ! -s conftest.err- }; then- :-else- echo "$as_me: failed program was:" >&5-sed 's/^/| /' conftest.$ac_ext >&5-- # Broken: fails on valid input.-continue-fi--rm -f conftest.err conftest.$ac_ext-- # OK, works on sane cases. Now check whether nonexistent headers- # can be detected and how.- cat >conftest.$ac_ext <<_ACEOF-/* confdefs.h. */-_ACEOF-cat confdefs.h >>conftest.$ac_ext-cat >>conftest.$ac_ext <<_ACEOF-/* end confdefs.h. */-#include <ac_nonexistent.h>-_ACEOF-if { (ac_try="$ac_cpp conftest.$ac_ext"-case "(($ac_try" in- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;- *) ac_try_echo=$ac_try;;-esac-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5- (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1- ac_status=$?- grep -v '^ *+' conftest.er1 >conftest.err- rm -f conftest.er1- cat conftest.err >&5- echo "$as_me:$LINENO: \$? = $ac_status" >&5- (exit $ac_status); } >/dev/null && {- test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||- test ! -s conftest.err- }; then- # Broken: success on invalid input.-continue-else- echo "$as_me: failed program was:" >&5-sed 's/^/| /' conftest.$ac_ext >&5-- # Passes both tests.-ac_preproc_ok=:-break-fi--rm -f conftest.err conftest.$ac_ext--done-# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.-rm -f conftest.err conftest.$ac_ext-if $ac_preproc_ok; then- break-fi-- done- ac_cv_prog_CPP=$CPP--fi- CPP=$ac_cv_prog_CPP-else- ac_cv_prog_CPP=$CPP-fi-{ echo "$as_me:$LINENO: result: $CPP" >&5-echo "${ECHO_T}$CPP" >&6; }-ac_preproc_ok=false-for ac_c_preproc_warn_flag in '' yes-do- # Use a header file that comes with gcc, so configuring glibc- # with a fresh cross-compiler works.- # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since- # <limits.h> exists even on freestanding compilers.- # On the NeXT, cc -E runs the code through the compiler's parser,- # not just through cpp. "Syntax error" is here to catch this case.- cat >conftest.$ac_ext <<_ACEOF-/* confdefs.h. */-_ACEOF-cat confdefs.h >>conftest.$ac_ext-cat >>conftest.$ac_ext <<_ACEOF-/* end confdefs.h. */-#ifdef __STDC__-# include <limits.h>-#else-# include <assert.h>-#endif- Syntax error-_ACEOF-if { (ac_try="$ac_cpp conftest.$ac_ext"-case "(($ac_try" in- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;- *) ac_try_echo=$ac_try;;-esac-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5- (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1- ac_status=$?- grep -v '^ *+' conftest.er1 >conftest.err- rm -f conftest.er1- cat conftest.err >&5- echo "$as_me:$LINENO: \$? = $ac_status" >&5- (exit $ac_status); } >/dev/null && {- test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||- test ! -s conftest.err- }; then- :-else- echo "$as_me: failed program was:" >&5-sed 's/^/| /' conftest.$ac_ext >&5-- # Broken: fails on valid input.-continue-fi--rm -f conftest.err conftest.$ac_ext-- # OK, works on sane cases. Now check whether nonexistent headers- # can be detected and how.- cat >conftest.$ac_ext <<_ACEOF-/* confdefs.h. */-_ACEOF-cat confdefs.h >>conftest.$ac_ext-cat >>conftest.$ac_ext <<_ACEOF-/* end confdefs.h. */-#include <ac_nonexistent.h>-_ACEOF-if { (ac_try="$ac_cpp conftest.$ac_ext"-case "(($ac_try" in- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;- *) ac_try_echo=$ac_try;;-esac-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5- (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1- ac_status=$?- grep -v '^ *+' conftest.er1 >conftest.err- rm -f conftest.er1- cat conftest.err >&5- echo "$as_me:$LINENO: \$? = $ac_status" >&5- (exit $ac_status); } >/dev/null && {- test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||- test ! -s conftest.err- }; then- # Broken: success on invalid input.-continue-else- echo "$as_me: failed program was:" >&5-sed 's/^/| /' conftest.$ac_ext >&5-- # Passes both tests.-ac_preproc_ok=:-break-fi--rm -f conftest.err conftest.$ac_ext--done-# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.-rm -f conftest.err conftest.$ac_ext-if $ac_preproc_ok; then- :-else- { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check-See \`config.log' for more details." >&5-echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check-See \`config.log' for more details." >&2;}- { (exit 1); exit 1; }; }-fi--ac_ext=c-ac_cpp='$CPP $CPPFLAGS'-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'-ac_compiler_gnu=$ac_cv_c_compiler_gnu---{ echo "$as_me:$LINENO: checking for grep that handles long lines and -e" >&5-echo $ECHO_N "checking for grep that handles long lines and -e... $ECHO_C" >&6; }-if test "${ac_cv_path_GREP+set}" = set; then- echo $ECHO_N "(cached) $ECHO_C" >&6-else- # Extract the first word of "grep ggrep" to use in msg output-if test -z "$GREP"; then-set dummy grep ggrep; ac_prog_name=$2-if test "${ac_cv_path_GREP+set}" = set; then- echo $ECHO_N "(cached) $ECHO_C" >&6-else- ac_path_GREP_found=false-# Loop through the user's path and test for each of PROGNAME-LIST-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR-for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin-do- IFS=$as_save_IFS- test -z "$as_dir" && as_dir=.- for ac_prog in grep ggrep; do- for ac_exec_ext in '' $ac_executable_extensions; do- ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"- { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue- # Check for GNU ac_path_GREP and select it if it is found.- # Check for GNU $ac_path_GREP-case `"$ac_path_GREP" --version 2>&1` in-*GNU*)- ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;-*)- ac_count=0- echo $ECHO_N "0123456789$ECHO_C" >"conftest.in"- while :- do- cat "conftest.in" "conftest.in" >"conftest.tmp"- mv "conftest.tmp" "conftest.in"- cp "conftest.in" "conftest.nl"- echo 'GREP' >> "conftest.nl"- "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break- diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break- ac_count=`expr $ac_count + 1`- if test $ac_count -gt ${ac_path_GREP_max-0}; then- # Best one so far, save it but keep looking for a better one- ac_cv_path_GREP="$ac_path_GREP"- ac_path_GREP_max=$ac_count- fi- # 10*(2^10) chars as input seems more than enough- test $ac_count -gt 10 && break- done- rm -f conftest.in conftest.tmp conftest.nl conftest.out;;-esac--- $ac_path_GREP_found && break 3- done-done--done-IFS=$as_save_IFS---fi--GREP="$ac_cv_path_GREP"-if test -z "$GREP"; then- { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5-echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;}- { (exit 1); exit 1; }; }-fi--else- ac_cv_path_GREP=$GREP-fi---fi-{ echo "$as_me:$LINENO: result: $ac_cv_path_GREP" >&5-echo "${ECHO_T}$ac_cv_path_GREP" >&6; }- GREP="$ac_cv_path_GREP"---{ echo "$as_me:$LINENO: checking for egrep" >&5-echo $ECHO_N "checking for egrep... $ECHO_C" >&6; }-if test "${ac_cv_path_EGREP+set}" = set; then- echo $ECHO_N "(cached) $ECHO_C" >&6-else- if echo a | $GREP -E '(a|b)' >/dev/null 2>&1- then ac_cv_path_EGREP="$GREP -E"- else- # Extract the first word of "egrep" to use in msg output-if test -z "$EGREP"; then-set dummy egrep; ac_prog_name=$2-if test "${ac_cv_path_EGREP+set}" = set; then- echo $ECHO_N "(cached) $ECHO_C" >&6-else- ac_path_EGREP_found=false-# Loop through the user's path and test for each of PROGNAME-LIST-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR-for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin-do- IFS=$as_save_IFS- test -z "$as_dir" && as_dir=.- for ac_prog in egrep; do- for ac_exec_ext in '' $ac_executable_extensions; do- ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"- { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue- # Check for GNU ac_path_EGREP and select it if it is found.- # Check for GNU $ac_path_EGREP-case `"$ac_path_EGREP" --version 2>&1` in-*GNU*)- ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;-*)- ac_count=0- echo $ECHO_N "0123456789$ECHO_C" >"conftest.in"- while :- do- cat "conftest.in" "conftest.in" >"conftest.tmp"- mv "conftest.tmp" "conftest.in"- cp "conftest.in" "conftest.nl"- echo 'EGREP' >> "conftest.nl"- "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break- diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break- ac_count=`expr $ac_count + 1`- if test $ac_count -gt ${ac_path_EGREP_max-0}; then- # Best one so far, save it but keep looking for a better one- ac_cv_path_EGREP="$ac_path_EGREP"- ac_path_EGREP_max=$ac_count- fi- # 10*(2^10) chars as input seems more than enough- test $ac_count -gt 10 && break- done- rm -f conftest.in conftest.tmp conftest.nl conftest.out;;-esac--- $ac_path_EGREP_found && break 3- done-done--done-IFS=$as_save_IFS---fi--EGREP="$ac_cv_path_EGREP"-if test -z "$EGREP"; then- { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5-echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;}- { (exit 1); exit 1; }; }-fi--else- ac_cv_path_EGREP=$EGREP-fi--- fi-fi-{ echo "$as_me:$LINENO: result: $ac_cv_path_EGREP" >&5-echo "${ECHO_T}$ac_cv_path_EGREP" >&6; }- EGREP="$ac_cv_path_EGREP"---{ echo "$as_me:$LINENO: checking for ANSI C header files" >&5-echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6; }-if test "${ac_cv_header_stdc+set}" = set; then- echo $ECHO_N "(cached) $ECHO_C" >&6-else- cat >conftest.$ac_ext <<_ACEOF-/* confdefs.h. */-_ACEOF-cat confdefs.h >>conftest.$ac_ext-cat >>conftest.$ac_ext <<_ACEOF-/* end confdefs.h. */-#include <stdlib.h>-#include <stdarg.h>-#include <string.h>-#include <float.h>--int-main ()-{-- ;- return 0;-}-_ACEOF-rm -f conftest.$ac_objext-if { (ac_try="$ac_compile"-case "(($ac_try" in- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;- *) ac_try_echo=$ac_try;;-esac-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5- (eval "$ac_compile") 2>conftest.er1- ac_status=$?- grep -v '^ *+' conftest.er1 >conftest.err- rm -f conftest.er1- cat conftest.err >&5- echo "$as_me:$LINENO: \$? = $ac_status" >&5- (exit $ac_status); } && {- test -z "$ac_c_werror_flag" ||- test ! -s conftest.err- } && test -s conftest.$ac_objext; then- ac_cv_header_stdc=yes-else- echo "$as_me: failed program was:" >&5-sed 's/^/| /' conftest.$ac_ext >&5-- ac_cv_header_stdc=no-fi--rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext--if test $ac_cv_header_stdc = yes; then- # SunOS 4.x string.h does not declare mem*, contrary to ANSI.- cat >conftest.$ac_ext <<_ACEOF-/* confdefs.h. */-_ACEOF-cat confdefs.h >>conftest.$ac_ext-cat >>conftest.$ac_ext <<_ACEOF-/* end confdefs.h. */-#include <string.h>--_ACEOF-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |- $EGREP "memchr" >/dev/null 2>&1; then- :-else- ac_cv_header_stdc=no-fi-rm -f conftest*--fi--if test $ac_cv_header_stdc = yes; then- # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.- cat >conftest.$ac_ext <<_ACEOF-/* confdefs.h. */-_ACEOF-cat confdefs.h >>conftest.$ac_ext-cat >>conftest.$ac_ext <<_ACEOF-/* end confdefs.h. */-#include <stdlib.h>--_ACEOF-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |- $EGREP "free" >/dev/null 2>&1; then- :-else- ac_cv_header_stdc=no-fi-rm -f conftest*--fi--if test $ac_cv_header_stdc = yes; then- # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.- if test "$cross_compiling" = yes; then- :-else- cat >conftest.$ac_ext <<_ACEOF-/* confdefs.h. */-_ACEOF-cat confdefs.h >>conftest.$ac_ext-cat >>conftest.$ac_ext <<_ACEOF-/* end confdefs.h. */-#include <ctype.h>-#include <stdlib.h>-#if ((' ' & 0x0FF) == 0x020)-# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')-# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))-#else-# define ISLOWER(c) \- (('a' <= (c) && (c) <= 'i') \- || ('j' <= (c) && (c) <= 'r') \- || ('s' <= (c) && (c) <= 'z'))-# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))-#endif--#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))-int-main ()-{- int i;- for (i = 0; i < 256; i++)- if (XOR (islower (i), ISLOWER (i))- || toupper (i) != TOUPPER (i))- return 2;- return 0;-}-_ACEOF-rm -f conftest$ac_exeext-if { (ac_try="$ac_link"-case "(($ac_try" in- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;- *) ac_try_echo=$ac_try;;-esac-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5- (eval "$ac_link") 2>&5- ac_status=$?- echo "$as_me:$LINENO: \$? = $ac_status" >&5- (exit $ac_status); } && { ac_try='./conftest$ac_exeext'- { (case "(($ac_try" in- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;- *) ac_try_echo=$ac_try;;-esac-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5- (eval "$ac_try") 2>&5- ac_status=$?- echo "$as_me:$LINENO: \$? = $ac_status" >&5- (exit $ac_status); }; }; then- :-else- echo "$as_me: program exited with status $ac_status" >&5-echo "$as_me: failed program was:" >&5-sed 's/^/| /' conftest.$ac_ext >&5--( exit $ac_status )-ac_cv_header_stdc=no-fi-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext-fi---fi-fi-{ echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5-echo "${ECHO_T}$ac_cv_header_stdc" >&6; }-if test $ac_cv_header_stdc = yes; then--cat >>confdefs.h <<\_ACEOF-#define STDC_HEADERS 1-_ACEOF--fi--# On IRIX 5.3, sys/types and inttypes.h are conflicting.----------for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \- inttypes.h stdint.h unistd.h-do-as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`-{ echo "$as_me:$LINENO: checking for $ac_header" >&5-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }-if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then- echo $ECHO_N "(cached) $ECHO_C" >&6-else- cat >conftest.$ac_ext <<_ACEOF-/* confdefs.h. */-_ACEOF-cat confdefs.h >>conftest.$ac_ext-cat >>conftest.$ac_ext <<_ACEOF-/* end confdefs.h. */-$ac_includes_default--#include <$ac_header>-_ACEOF-rm -f conftest.$ac_objext-if { (ac_try="$ac_compile"-case "(($ac_try" in- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;- *) ac_try_echo=$ac_try;;-esac-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5- (eval "$ac_compile") 2>conftest.er1- ac_status=$?- grep -v '^ *+' conftest.er1 >conftest.err- rm -f conftest.er1- cat conftest.err >&5- echo "$as_me:$LINENO: \$? = $ac_status" >&5- (exit $ac_status); } && {- test -z "$ac_c_werror_flag" ||- test ! -s conftest.err- } && test -s conftest.$ac_objext; then- eval "$as_ac_Header=yes"-else- echo "$as_me: failed program was:" >&5-sed 's/^/| /' conftest.$ac_ext >&5-- eval "$as_ac_Header=no"-fi--rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext-fi-ac_res=`eval echo '${'$as_ac_Header'}'`- { echo "$as_me:$LINENO: result: $ac_res" >&5-echo "${ECHO_T}$ac_res" >&6; }-if test `eval echo '${'$as_ac_Header'}'` = yes; then- cat >>confdefs.h <<_ACEOF-#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1-_ACEOF--fi--done----for ac_header in time.h-do-as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`-if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then- { echo "$as_me:$LINENO: checking for $ac_header" >&5-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }-if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then- echo $ECHO_N "(cached) $ECHO_C" >&6-fi-ac_res=`eval echo '${'$as_ac_Header'}'`- { echo "$as_me:$LINENO: result: $ac_res" >&5-echo "${ECHO_T}$ac_res" >&6; }-else- # Is the header compilable?-{ echo "$as_me:$LINENO: checking $ac_header usability" >&5-echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }-cat >conftest.$ac_ext <<_ACEOF-/* confdefs.h. */-_ACEOF-cat confdefs.h >>conftest.$ac_ext-cat >>conftest.$ac_ext <<_ACEOF-/* end confdefs.h. */-$ac_includes_default-#include <$ac_header>-_ACEOF-rm -f conftest.$ac_objext-if { (ac_try="$ac_compile"-case "(($ac_try" in- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;- *) ac_try_echo=$ac_try;;-esac-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5- (eval "$ac_compile") 2>conftest.er1- ac_status=$?- grep -v '^ *+' conftest.er1 >conftest.err- rm -f conftest.er1- cat conftest.err >&5- echo "$as_me:$LINENO: \$? = $ac_status" >&5- (exit $ac_status); } && {- test -z "$ac_c_werror_flag" ||- test ! -s conftest.err- } && test -s conftest.$ac_objext; then- ac_header_compiler=yes-else- echo "$as_me: failed program was:" >&5-sed 's/^/| /' conftest.$ac_ext >&5-- ac_header_compiler=no-fi--rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext-{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5-echo "${ECHO_T}$ac_header_compiler" >&6; }--# Is the header present?-{ echo "$as_me:$LINENO: checking $ac_header presence" >&5-echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }-cat >conftest.$ac_ext <<_ACEOF-/* confdefs.h. */-_ACEOF-cat confdefs.h >>conftest.$ac_ext-cat >>conftest.$ac_ext <<_ACEOF-/* end confdefs.h. */-#include <$ac_header>-_ACEOF-if { (ac_try="$ac_cpp conftest.$ac_ext"-case "(($ac_try" in- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;- *) ac_try_echo=$ac_try;;-esac-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5- (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1- ac_status=$?- grep -v '^ *+' conftest.er1 >conftest.err- rm -f conftest.er1- cat conftest.err >&5- echo "$as_me:$LINENO: \$? = $ac_status" >&5- (exit $ac_status); } >/dev/null && {- test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||- test ! -s conftest.err- }; then- ac_header_preproc=yes-else- echo "$as_me: failed program was:" >&5-sed 's/^/| /' conftest.$ac_ext >&5-- ac_header_preproc=no-fi--rm -f conftest.err conftest.$ac_ext-{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5-echo "${ECHO_T}$ac_header_preproc" >&6; }--# So? What about this header?-case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in- yes:no: )- { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5-echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}- { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5-echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}- ac_header_preproc=yes- ;;- no:yes:* )- { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5-echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}- { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5-echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}- { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5-echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}- { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5-echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}- { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5-echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}- { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5-echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}- ( cat <<\_ASBOX-## ---------------------------------- ##-## Report this to ashley@semantic.org ##-## ---------------------------------- ##-_ASBOX- ) | sed "s/^/$as_me: WARNING: /" >&2- ;;-esac-{ echo "$as_me:$LINENO: checking for $ac_header" >&5-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }-if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then- echo $ECHO_N "(cached) $ECHO_C" >&6-else- eval "$as_ac_Header=\$ac_header_preproc"-fi-ac_res=`eval echo '${'$as_ac_Header'}'`- { echo "$as_me:$LINENO: result: $ac_res" >&5-echo "${ECHO_T}$ac_res" >&6; }--fi-if test `eval echo '${'$as_ac_Header'}'` = yes; then- cat >>confdefs.h <<_ACEOF-#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1-_ACEOF--fi--done----for ac_func in gmtime_r localtime_r-do-as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`-{ echo "$as_me:$LINENO: checking for $ac_func" >&5-echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; }-if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then- echo $ECHO_N "(cached) $ECHO_C" >&6-else- cat >conftest.$ac_ext <<_ACEOF-/* confdefs.h. */-_ACEOF-cat confdefs.h >>conftest.$ac_ext-cat >>conftest.$ac_ext <<_ACEOF-/* end confdefs.h. */-/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.- For example, HP-UX 11i <limits.h> declares gettimeofday. */-#define $ac_func innocuous_$ac_func--/* System header to define __stub macros and hopefully few prototypes,- which can conflict with char $ac_func (); below.- Prefer <limits.h> to <assert.h> if __STDC__ is defined, since- <limits.h> exists even on freestanding compilers. */--#ifdef __STDC__-# include <limits.h>-#else-# include <assert.h>-#endif--#undef $ac_func--/* Override any GCC internal prototype to avoid an error.- Use char because int might match the return type of a GCC- builtin and then its argument prototype would still apply. */-#ifdef __cplusplus-extern "C"-#endif-char $ac_func ();-/* The GNU C library defines this for functions which it implements- to always fail with ENOSYS. Some functions are actually named- something starting with __ and the normal name is an alias. */-#if defined __stub_$ac_func || defined __stub___$ac_func-choke me-#endif--int-main ()-{-return $ac_func ();- ;- return 0;-}-_ACEOF-rm -f conftest.$ac_objext conftest$ac_exeext-if { (ac_try="$ac_link"-case "(($ac_try" in- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;- *) ac_try_echo=$ac_try;;-esac-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5- (eval "$ac_link") 2>conftest.er1- ac_status=$?- grep -v '^ *+' conftest.er1 >conftest.err- rm -f conftest.er1- cat conftest.err >&5- echo "$as_me:$LINENO: \$? = $ac_status" >&5- (exit $ac_status); } && {- test -z "$ac_c_werror_flag" ||- test ! -s conftest.err- } && test -s conftest$ac_exeext &&- $as_test_x conftest$ac_exeext; then- eval "$as_ac_var=yes"-else- echo "$as_me: failed program was:" >&5-sed 's/^/| /' conftest.$ac_ext >&5-- eval "$as_ac_var=no"-fi--rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \- conftest$ac_exeext conftest.$ac_ext-fi-ac_res=`eval echo '${'$as_ac_var'}'`- { echo "$as_me:$LINENO: result: $ac_res" >&5-echo "${ECHO_T}$ac_res" >&6; }-if test `eval echo '${'$as_ac_var'}'` = yes; then- cat >>confdefs.h <<_ACEOF-#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1-_ACEOF--fi-done---{ echo "$as_me:$LINENO: checking whether struct tm is in sys/time.h or time.h" >&5-echo $ECHO_N "checking whether struct tm is in sys/time.h or time.h... $ECHO_C" >&6; }-if test "${ac_cv_struct_tm+set}" = set; then- echo $ECHO_N "(cached) $ECHO_C" >&6-else- cat >conftest.$ac_ext <<_ACEOF-/* confdefs.h. */-_ACEOF-cat confdefs.h >>conftest.$ac_ext-cat >>conftest.$ac_ext <<_ACEOF-/* end confdefs.h. */-#include <sys/types.h>-#include <time.h>--int-main ()-{-struct tm tm;- int *p = &tm.tm_sec;- return !p;- ;- return 0;-}-_ACEOF-rm -f conftest.$ac_objext-if { (ac_try="$ac_compile"-case "(($ac_try" in- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;- *) ac_try_echo=$ac_try;;-esac-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5- (eval "$ac_compile") 2>conftest.er1- ac_status=$?- grep -v '^ *+' conftest.er1 >conftest.err- rm -f conftest.er1- cat conftest.err >&5- echo "$as_me:$LINENO: \$? = $ac_status" >&5- (exit $ac_status); } && {- test -z "$ac_c_werror_flag" ||- test ! -s conftest.err- } && test -s conftest.$ac_objext; then- ac_cv_struct_tm=time.h-else- echo "$as_me: failed program was:" >&5-sed 's/^/| /' conftest.$ac_ext >&5-- ac_cv_struct_tm=sys/time.h-fi--rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext-fi-{ echo "$as_me:$LINENO: result: $ac_cv_struct_tm" >&5-echo "${ECHO_T}$ac_cv_struct_tm" >&6; }-if test $ac_cv_struct_tm = sys/time.h; then--cat >>confdefs.h <<\_ACEOF-#define TM_IN_SYS_TIME 1-_ACEOF--fi--{ echo "$as_me:$LINENO: checking for struct tm.tm_zone" >&5-echo $ECHO_N "checking for struct tm.tm_zone... $ECHO_C" >&6; }-if test "${ac_cv_member_struct_tm_tm_zone+set}" = set; then- echo $ECHO_N "(cached) $ECHO_C" >&6-else- cat >conftest.$ac_ext <<_ACEOF-/* confdefs.h. */-_ACEOF-cat confdefs.h >>conftest.$ac_ext-cat >>conftest.$ac_ext <<_ACEOF-/* end confdefs.h. */-#include <sys/types.h>-#include <$ac_cv_struct_tm>---int-main ()-{-static struct tm ac_aggr;-if (ac_aggr.tm_zone)-return 0;- ;- return 0;-}-_ACEOF-rm -f conftest.$ac_objext-if { (ac_try="$ac_compile"-case "(($ac_try" in- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;- *) ac_try_echo=$ac_try;;-esac-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5- (eval "$ac_compile") 2>conftest.er1- ac_status=$?- grep -v '^ *+' conftest.er1 >conftest.err- rm -f conftest.er1- cat conftest.err >&5- echo "$as_me:$LINENO: \$? = $ac_status" >&5- (exit $ac_status); } && {- test -z "$ac_c_werror_flag" ||- test ! -s conftest.err- } && test -s conftest.$ac_objext; then- ac_cv_member_struct_tm_tm_zone=yes-else- echo "$as_me: failed program was:" >&5-sed 's/^/| /' conftest.$ac_ext >&5-- cat >conftest.$ac_ext <<_ACEOF-/* confdefs.h. */-_ACEOF-cat confdefs.h >>conftest.$ac_ext-cat >>conftest.$ac_ext <<_ACEOF-/* end confdefs.h. */-#include <sys/types.h>-#include <$ac_cv_struct_tm>---int-main ()-{-static struct tm ac_aggr;-if (sizeof ac_aggr.tm_zone)-return 0;- ;- return 0;-}-_ACEOF-rm -f conftest.$ac_objext-if { (ac_try="$ac_compile"-case "(($ac_try" in- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;- *) ac_try_echo=$ac_try;;-esac-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5- (eval "$ac_compile") 2>conftest.er1- ac_status=$?- grep -v '^ *+' conftest.er1 >conftest.err- rm -f conftest.er1- cat conftest.err >&5- echo "$as_me:$LINENO: \$? = $ac_status" >&5- (exit $ac_status); } && {- test -z "$ac_c_werror_flag" ||- test ! -s conftest.err- } && test -s conftest.$ac_objext; then- ac_cv_member_struct_tm_tm_zone=yes-else- echo "$as_me: failed program was:" >&5-sed 's/^/| /' conftest.$ac_ext >&5-- ac_cv_member_struct_tm_tm_zone=no-fi--rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext-fi--rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext-fi-{ echo "$as_me:$LINENO: result: $ac_cv_member_struct_tm_tm_zone" >&5-echo "${ECHO_T}$ac_cv_member_struct_tm_tm_zone" >&6; }-if test $ac_cv_member_struct_tm_tm_zone = yes; then--cat >>confdefs.h <<_ACEOF-#define HAVE_STRUCT_TM_TM_ZONE 1-_ACEOF---fi--if test "$ac_cv_member_struct_tm_tm_zone" = yes; then--cat >>confdefs.h <<\_ACEOF-#define HAVE_TM_ZONE 1-_ACEOF--else- { echo "$as_me:$LINENO: checking whether tzname is declared" >&5-echo $ECHO_N "checking whether tzname is declared... $ECHO_C" >&6; }-if test "${ac_cv_have_decl_tzname+set}" = set; then- echo $ECHO_N "(cached) $ECHO_C" >&6-else- cat >conftest.$ac_ext <<_ACEOF-/* confdefs.h. */-_ACEOF-cat confdefs.h >>conftest.$ac_ext-cat >>conftest.$ac_ext <<_ACEOF-/* end confdefs.h. */-#include <time.h>--int-main ()-{-#ifndef tzname- (void) tzname;-#endif-- ;- return 0;-}-_ACEOF-rm -f conftest.$ac_objext-if { (ac_try="$ac_compile"-case "(($ac_try" in- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;- *) ac_try_echo=$ac_try;;-esac-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5- (eval "$ac_compile") 2>conftest.er1- ac_status=$?- grep -v '^ *+' conftest.er1 >conftest.err- rm -f conftest.er1- cat conftest.err >&5- echo "$as_me:$LINENO: \$? = $ac_status" >&5- (exit $ac_status); } && {- test -z "$ac_c_werror_flag" ||- test ! -s conftest.err- } && test -s conftest.$ac_objext; then- ac_cv_have_decl_tzname=yes-else- echo "$as_me: failed program was:" >&5-sed 's/^/| /' conftest.$ac_ext >&5-- ac_cv_have_decl_tzname=no-fi--rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext-fi-{ echo "$as_me:$LINENO: result: $ac_cv_have_decl_tzname" >&5-echo "${ECHO_T}$ac_cv_have_decl_tzname" >&6; }-if test $ac_cv_have_decl_tzname = yes; then--cat >>confdefs.h <<_ACEOF-#define HAVE_DECL_TZNAME 1-_ACEOF---else- cat >>confdefs.h <<_ACEOF-#define HAVE_DECL_TZNAME 0-_ACEOF---fi--- { echo "$as_me:$LINENO: checking for tzname" >&5-echo $ECHO_N "checking for tzname... $ECHO_C" >&6; }-if test "${ac_cv_var_tzname+set}" = set; then- echo $ECHO_N "(cached) $ECHO_C" >&6-else- cat >conftest.$ac_ext <<_ACEOF-/* confdefs.h. */-_ACEOF-cat confdefs.h >>conftest.$ac_ext-cat >>conftest.$ac_ext <<_ACEOF-/* end confdefs.h. */-#include <time.h>-#if !HAVE_DECL_TZNAME-extern char *tzname[];-#endif--int-main ()-{-return tzname[0][0];- ;- return 0;-}-_ACEOF-rm -f conftest.$ac_objext conftest$ac_exeext-if { (ac_try="$ac_link"-case "(($ac_try" in- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;- *) ac_try_echo=$ac_try;;-esac-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5- (eval "$ac_link") 2>conftest.er1- ac_status=$?- grep -v '^ *+' conftest.er1 >conftest.err- rm -f conftest.er1- cat conftest.err >&5- echo "$as_me:$LINENO: \$? = $ac_status" >&5- (exit $ac_status); } && {- test -z "$ac_c_werror_flag" ||- test ! -s conftest.err- } && test -s conftest$ac_exeext &&- $as_test_x conftest$ac_exeext; then- ac_cv_var_tzname=yes-else- echo "$as_me: failed program was:" >&5-sed 's/^/| /' conftest.$ac_ext >&5-- ac_cv_var_tzname=no-fi--rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \- conftest$ac_exeext conftest.$ac_ext-fi-{ echo "$as_me:$LINENO: result: $ac_cv_var_tzname" >&5-echo "${ECHO_T}$ac_cv_var_tzname" >&6; }- if test $ac_cv_var_tzname = yes; then--cat >>confdefs.h <<\_ACEOF-#define HAVE_TZNAME 1-_ACEOF-- fi-fi---{ echo "$as_me:$LINENO: checking whether time.h and sys/time.h may both be included" >&5-echo $ECHO_N "checking whether time.h and sys/time.h may both be included... $ECHO_C" >&6; }-if test "${ac_cv_header_time+set}" = set; then- echo $ECHO_N "(cached) $ECHO_C" >&6-else- cat >conftest.$ac_ext <<_ACEOF-/* confdefs.h. */-_ACEOF-cat confdefs.h >>conftest.$ac_ext-cat >>conftest.$ac_ext <<_ACEOF-/* end confdefs.h. */-#include <sys/types.h>-#include <sys/time.h>-#include <time.h>--int-main ()-{-if ((struct tm *) 0)-return 0;- ;- return 0;-}-_ACEOF-rm -f conftest.$ac_objext-if { (ac_try="$ac_compile"-case "(($ac_try" in- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;- *) ac_try_echo=$ac_try;;-esac-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5- (eval "$ac_compile") 2>conftest.er1- ac_status=$?- grep -v '^ *+' conftest.er1 >conftest.err- rm -f conftest.er1- cat conftest.err >&5- echo "$as_me:$LINENO: \$? = $ac_status" >&5- (exit $ac_status); } && {- test -z "$ac_c_werror_flag" ||- test ! -s conftest.err- } && test -s conftest.$ac_objext; then- ac_cv_header_time=yes-else- echo "$as_me: failed program was:" >&5-sed 's/^/| /' conftest.$ac_ext >&5-- ac_cv_header_time=no-fi--rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext-fi-{ echo "$as_me:$LINENO: result: $ac_cv_header_time" >&5-echo "${ECHO_T}$ac_cv_header_time" >&6; }-if test $ac_cv_header_time = yes; then--cat >>confdefs.h <<\_ACEOF-#define TIME_WITH_SYS_TIME 1-_ACEOF--fi---for ac_header in sys/time.h-do-as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`-if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then- { echo "$as_me:$LINENO: checking for $ac_header" >&5-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }-if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then- echo $ECHO_N "(cached) $ECHO_C" >&6-fi-ac_res=`eval echo '${'$as_ac_Header'}'`- { echo "$as_me:$LINENO: result: $ac_res" >&5-echo "${ECHO_T}$ac_res" >&6; }-else- # Is the header compilable?-{ echo "$as_me:$LINENO: checking $ac_header usability" >&5-echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }-cat >conftest.$ac_ext <<_ACEOF-/* confdefs.h. */-_ACEOF-cat confdefs.h >>conftest.$ac_ext-cat >>conftest.$ac_ext <<_ACEOF-/* end confdefs.h. */-$ac_includes_default-#include <$ac_header>-_ACEOF-rm -f conftest.$ac_objext-if { (ac_try="$ac_compile"-case "(($ac_try" in- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;- *) ac_try_echo=$ac_try;;-esac-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5- (eval "$ac_compile") 2>conftest.er1- ac_status=$?- grep -v '^ *+' conftest.er1 >conftest.err- rm -f conftest.er1- cat conftest.err >&5- echo "$as_me:$LINENO: \$? = $ac_status" >&5- (exit $ac_status); } && {- test -z "$ac_c_werror_flag" ||- test ! -s conftest.err- } && test -s conftest.$ac_objext; then- ac_header_compiler=yes-else- echo "$as_me: failed program was:" >&5-sed 's/^/| /' conftest.$ac_ext >&5-- ac_header_compiler=no-fi--rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext-{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5-echo "${ECHO_T}$ac_header_compiler" >&6; }--# Is the header present?-{ echo "$as_me:$LINENO: checking $ac_header presence" >&5-echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }-cat >conftest.$ac_ext <<_ACEOF-/* confdefs.h. */-_ACEOF-cat confdefs.h >>conftest.$ac_ext-cat >>conftest.$ac_ext <<_ACEOF-/* end confdefs.h. */-#include <$ac_header>-_ACEOF-if { (ac_try="$ac_cpp conftest.$ac_ext"-case "(($ac_try" in- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;- *) ac_try_echo=$ac_try;;-esac-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5- (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1- ac_status=$?- grep -v '^ *+' conftest.er1 >conftest.err- rm -f conftest.er1- cat conftest.err >&5- echo "$as_me:$LINENO: \$? = $ac_status" >&5- (exit $ac_status); } >/dev/null && {- test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||- test ! -s conftest.err- }; then- ac_header_preproc=yes-else- echo "$as_me: failed program was:" >&5-sed 's/^/| /' conftest.$ac_ext >&5-- ac_header_preproc=no-fi--rm -f conftest.err conftest.$ac_ext-{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5-echo "${ECHO_T}$ac_header_preproc" >&6; }--# So? What about this header?-case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in- yes:no: )- { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5-echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}- { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5-echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}- ac_header_preproc=yes- ;;- no:yes:* )- { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5-echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}- { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5-echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}- { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5-echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}- { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5-echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}- { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5-echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}- { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5-echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}- ( cat <<\_ASBOX-## ---------------------------------- ##-## Report this to ashley@semantic.org ##-## ---------------------------------- ##-_ASBOX- ) | sed "s/^/$as_me: WARNING: /" >&2- ;;-esac-{ echo "$as_me:$LINENO: checking for $ac_header" >&5-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }-if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then- echo $ECHO_N "(cached) $ECHO_C" >&6-else- eval "$as_ac_Header=\$ac_header_preproc"-fi-ac_res=`eval echo '${'$as_ac_Header'}'`- { echo "$as_me:$LINENO: result: $ac_res" >&5-echo "${ECHO_T}$ac_res" >&6; }--fi-if test `eval echo '${'$as_ac_Header'}'` = yes; then- cat >>confdefs.h <<_ACEOF-#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1-_ACEOF--fi--done--{ echo "$as_me:$LINENO: checking whether altzone is declared" >&5-echo $ECHO_N "checking whether altzone is declared... $ECHO_C" >&6; }-if test "${ac_cv_have_decl_altzone+set}" = set; then- echo $ECHO_N "(cached) $ECHO_C" >&6-else- cat >conftest.$ac_ext <<_ACEOF-/* confdefs.h. */-_ACEOF-cat confdefs.h >>conftest.$ac_ext-cat >>conftest.$ac_ext <<_ACEOF-/* end confdefs.h. */-#if TIME_WITH_SYS_TIME-# include <sys/time.h>-# include <time.h>-#else-# if HAVE_SYS_TIME_H-# include <sys/time.h>-# else-# include <time.h>-# endif-#endif--int-main ()-{-#ifndef altzone- (void) altzone;-#endif-- ;- return 0;-}-_ACEOF-rm -f conftest.$ac_objext-if { (ac_try="$ac_compile"-case "(($ac_try" in- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;- *) ac_try_echo=$ac_try;;-esac-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5- (eval "$ac_compile") 2>conftest.er1- ac_status=$?- grep -v '^ *+' conftest.er1 >conftest.err- rm -f conftest.er1- cat conftest.err >&5- echo "$as_me:$LINENO: \$? = $ac_status" >&5- (exit $ac_status); } && {- test -z "$ac_c_werror_flag" ||- test ! -s conftest.err- } && test -s conftest.$ac_objext; then- ac_cv_have_decl_altzone=yes-else- echo "$as_me: failed program was:" >&5-sed 's/^/| /' conftest.$ac_ext >&5-- ac_cv_have_decl_altzone=no-fi--rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext-fi-{ echo "$as_me:$LINENO: result: $ac_cv_have_decl_altzone" >&5-echo "${ECHO_T}$ac_cv_have_decl_altzone" >&6; }-if test $ac_cv_have_decl_altzone = yes; then--cat >>confdefs.h <<_ACEOF-#define HAVE_DECL_ALTZONE 1-_ACEOF---else- cat >>confdefs.h <<_ACEOF-#define HAVE_DECL_ALTZONE 0-_ACEOF---fi-----cat >confcache <<\_ACEOF-# This file is a shell script that caches the results of configure-# tests run on this system so they can be shared between configure-# scripts and configure runs, see configure's option --config-cache.-# It is not useful on other systems. If it contains results you don't-# want to keep, you may remove or edit it.-#-# config.status only pays attention to the cache file if you give it-# the --recheck option to rerun configure.-#-# `ac_cv_env_foo' variables (set or unset) will be overridden when-# loading this file, other *unset* `ac_cv_foo' will be assigned the-# following values.--_ACEOF--# The following way of writing the cache mishandles newlines in values,-# but we know of no workaround that is simple, portable, and efficient.-# So, we kill variables containing newlines.-# Ultrix sh set writes to stderr and can't be redirected directly,-# and sets the high bit in the cache file unless we assign to the vars.-(- for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do- eval ac_val=\$$ac_var- case $ac_val in #(- *${as_nl}*)- case $ac_var in #(- *_cv_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5-echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;;- esac- case $ac_var in #(- _ | IFS | as_nl) ;; #(- *) $as_unset $ac_var ;;- esac ;;- esac- done-- (set) 2>&1 |- case $as_nl`(ac_space=' '; set) 2>&1` in #(- *${as_nl}ac_space=\ *)- # `set' does not quote correctly, so add quotes (double-quote- # substitution turns \\\\ into \\, and sed turns \\ into \).- sed -n \- "s/'/'\\\\''/g;- s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"- ;; #(- *)- # `set' quotes correctly as required by POSIX, so do not add quotes.- sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"- ;;- esac |- sort-) |- sed '- /^ac_cv_env_/b end- t clear- :clear- s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/- t end- s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/- :end' >>confcache-if diff "$cache_file" confcache >/dev/null 2>&1; then :; else- if test -w "$cache_file"; then- test "x$cache_file" != "x/dev/null" &&- { echo "$as_me:$LINENO: updating cache $cache_file" >&5-echo "$as_me: updating cache $cache_file" >&6;}- cat confcache >$cache_file- else- { echo "$as_me:$LINENO: not updating unwritable cache $cache_file" >&5-echo "$as_me: not updating unwritable cache $cache_file" >&6;}- fi-fi-rm -f confcache--test "x$prefix" = xNONE && prefix=$ac_default_prefix-# Let make expand exec_prefix.-test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'--DEFS=-DHAVE_CONFIG_H--ac_libobjs=-ac_ltlibobjs=-for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue- # 1. Remove the extension, and $U if already installed.- ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'- ac_i=`echo "$ac_i" | sed "$ac_script"`- # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR- # will be set to the directory where LIBOBJS objects are built.- ac_libobjs="$ac_libobjs \${LIBOBJDIR}$ac_i\$U.$ac_objext"- ac_ltlibobjs="$ac_ltlibobjs \${LIBOBJDIR}$ac_i"'$U.lo'-done-LIBOBJS=$ac_libobjs--LTLIBOBJS=$ac_ltlibobjs----: ${CONFIG_STATUS=./config.status}-ac_clean_files_save=$ac_clean_files-ac_clean_files="$ac_clean_files $CONFIG_STATUS"-{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5-echo "$as_me: creating $CONFIG_STATUS" >&6;}-cat >$CONFIG_STATUS <<_ACEOF-#! $SHELL-# Generated by $as_me.-# Run this file to recreate the current configuration.-# Compiler output produced by configure, useful for debugging-# configure, is in config.log if it exists.--debug=false-ac_cs_recheck=false-ac_cs_silent=false-SHELL=\${CONFIG_SHELL-$SHELL}-_ACEOF--cat >>$CONFIG_STATUS <<\_ACEOF-## --------------------- ##-## M4sh Initialization. ##-## --------------------- ##--# Be more Bourne compatible-DUALCASE=1; export DUALCASE # for MKS sh-if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then- emulate sh- NULLCMD=:- # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which- # is contrary to our usage. Disable this feature.- alias -g '${1+"$@"}'='"$@"'- setopt NO_GLOB_SUBST-else- case `(set -o) 2>/dev/null` in- *posix*) set -o posix ;;-esac--fi-----# PATH needs CR-# Avoid depending upon Character Ranges.-as_cr_letters='abcdefghijklmnopqrstuvwxyz'-as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'-as_cr_Letters=$as_cr_letters$as_cr_LETTERS-as_cr_digits='0123456789'-as_cr_alnum=$as_cr_Letters$as_cr_digits--# The user is always right.-if test "${PATH_SEPARATOR+set}" != set; then- echo "#! /bin/sh" >conf$$.sh- echo "exit 0" >>conf$$.sh- chmod +x conf$$.sh- if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then- PATH_SEPARATOR=';'- else- PATH_SEPARATOR=:- fi- rm -f conf$$.sh-fi--# Support unset when possible.-if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then- as_unset=unset-else- as_unset=false-fi---# IFS-# We need space, tab and new line, in precisely that order. Quoting is-# there to prevent editors from complaining about space-tab.-# (If _AS_PATH_WALK were called with IFS unset, it would disable word-# splitting by setting IFS to empty value.)-as_nl='-'-IFS=" "" $as_nl"--# Find who we are. Look in the path if we contain no directory separator.-case $0 in- *[\\/]* ) as_myself=$0 ;;- *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR-for as_dir in $PATH-do- IFS=$as_save_IFS- test -z "$as_dir" && as_dir=.- test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break-done-IFS=$as_save_IFS-- ;;-esac-# We did not find ourselves, most probably we were run as `sh COMMAND'-# in which case we are not to be found in the path.-if test "x$as_myself" = x; then- as_myself=$0-fi-if test ! -f "$as_myself"; then- echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2- { (exit 1); exit 1; }-fi--# Work around bugs in pre-3.0 UWIN ksh.-for as_var in ENV MAIL MAILPATH-do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var-done-PS1='$ '-PS2='> '-PS4='+ '--# NLS nuisances.-for as_var in \- LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \- LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \- LC_TELEPHONE LC_TIME-do- if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then- eval $as_var=C; export $as_var- else- ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var- fi-done--# Required to use basename.-if expr a : '\(a\)' >/dev/null 2>&1 &&- test "X`expr 00001 : '.*\(...\)'`" = X001; then- as_expr=expr-else- as_expr=false-fi--if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then- as_basename=basename-else- as_basename=false-fi---# Name of the executable.-as_me=`$as_basename -- "$0" ||-$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \- X"$0" : 'X\(//\)$' \| \- X"$0" : 'X\(/\)' \| . 2>/dev/null ||-echo X/"$0" |- sed '/^.*\/\([^/][^/]*\)\/*$/{- s//\1/- q- }- /^X\/\(\/\/\)$/{- s//\1/- q- }- /^X\/\(\/\).*/{- s//\1/- q- }- s/.*/./; q'`--# CDPATH.-$as_unset CDPATH---- as_lineno_1=$LINENO- as_lineno_2=$LINENO- test "x$as_lineno_1" != "x$as_lineno_2" &&- test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || {-- # Create $as_me.lineno as a copy of $as_myself, but with $LINENO- # uniformly replaced by the line number. The first 'sed' inserts a- # line-number line after each line using $LINENO; the second 'sed'- # does the real work. The second script uses 'N' to pair each- # line-number line with the line containing $LINENO, and appends- # trailing '-' during substitution so that $LINENO is not a special- # case at line end.- # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the- # scripts with optimization help from Paolo Bonzini. Blame Lee- # E. McMahon (1931-1989) for sed's syntax. :-)- sed -n '- p- /[$]LINENO/=- ' <$as_myself |- sed '- s/[$]LINENO.*/&-/- t lineno- b- :lineno- N- :loop- s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/- t loop- s/-\n.*//- ' >$as_me.lineno &&- chmod +x "$as_me.lineno" ||- { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2- { (exit 1); exit 1; }; }-- # Don't try to exec as it changes $[0], causing all sort of problems- # (the dirname of $[0] is not the place where we might find the- # original and so on. Autoconf is especially sensitive to this).- . "./$as_me.lineno"- # Exit status is that of the last command.- exit-}---if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then- as_dirname=dirname-else- as_dirname=false-fi--ECHO_C= ECHO_N= ECHO_T=-case `echo -n x` in--n*)- case `echo 'x\c'` in- *c*) ECHO_T=' ';; # ECHO_T is single tab character.- *) ECHO_C='\c';;- esac;;-*)- ECHO_N='-n';;-esac--if expr a : '\(a\)' >/dev/null 2>&1 &&- test "X`expr 00001 : '.*\(...\)'`" = X001; then- as_expr=expr-else- as_expr=false-fi--rm -f conf$$ conf$$.exe conf$$.file-if test -d conf$$.dir; then- rm -f conf$$.dir/conf$$.file-else- rm -f conf$$.dir- mkdir conf$$.dir-fi-echo >conf$$.file-if ln -s conf$$.file conf$$ 2>/dev/null; then- as_ln_s='ln -s'- # ... but there are two gotchas:- # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.- # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.- # In both cases, we have to default to `cp -p'.- ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||- as_ln_s='cp -p'-elif ln conf$$.file conf$$ 2>/dev/null; then- as_ln_s=ln-else- as_ln_s='cp -p'-fi-rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file-rmdir conf$$.dir 2>/dev/null--if mkdir -p . 2>/dev/null; then- as_mkdir_p=:-else- test -d ./-p && rmdir ./-p- as_mkdir_p=false-fi--if test -x / >/dev/null 2>&1; then- as_test_x='test -x'-else- if ls -dL / >/dev/null 2>&1; then- as_ls_L_option=L- else- as_ls_L_option=- fi- as_test_x='- eval sh -c '\''- if test -d "$1"; then- test -d "$1/.";- else- case $1 in- -*)set "./$1";;- esac;- case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in- ???[sx]*):;;*)false;;esac;fi- '\'' sh- '-fi-as_executable_p=$as_test_x--# Sed expression to map a string onto a valid CPP name.-as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"--# Sed expression to map a string onto a valid variable name.-as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"---exec 6>&1--# Save the log message, to keep $[0] and so on meaningful, and to-# report actual input values of CONFIG_FILES etc. instead of their-# values after options handling.-ac_log="-This file was extended by Haskell time package $as_me 1.1.2.3, which was-generated by GNU Autoconf 2.61. Invocation command line was-- CONFIG_FILES = $CONFIG_FILES- CONFIG_HEADERS = $CONFIG_HEADERS- CONFIG_LINKS = $CONFIG_LINKS- CONFIG_COMMANDS = $CONFIG_COMMANDS- $ $0 $@--on `(hostname || uname -n) 2>/dev/null | sed 1q`-"--_ACEOF--cat >>$CONFIG_STATUS <<_ACEOF-# Files that config.status was made for.-config_headers="$ac_config_headers"--_ACEOF--cat >>$CONFIG_STATUS <<\_ACEOF-ac_cs_usage="\-\`$as_me' instantiates files from templates according to the-current configuration.--Usage: $0 [OPTIONS] [FILE]...-- -h, --help print this help, then exit- -V, --version print version number and configuration settings, then exit- -q, --quiet do not print progress messages- -d, --debug don't remove temporary files- --recheck update $as_me by reconfiguring in the same conditions- --header=FILE[:TEMPLATE]- instantiate the configuration header FILE--Configuration headers:-$config_headers--Report bugs to <bug-autoconf@gnu.org>."--_ACEOF-cat >>$CONFIG_STATUS <<_ACEOF-ac_cs_version="\\-Haskell time package config.status 1.1.2.3-configured by $0, generated by GNU Autoconf 2.61,- with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"--Copyright (C) 2006 Free Software Foundation, Inc.-This config.status script is free software; the Free Software Foundation-gives unlimited permission to copy, distribute and modify it."--ac_pwd='$ac_pwd'-srcdir='$srcdir'-_ACEOF--cat >>$CONFIG_STATUS <<\_ACEOF-# If no file are specified by the user, then we need to provide default-# value. By we need to know if files were specified by the user.-ac_need_defaults=:-while test $# != 0-do- case $1 in- --*=*)- ac_option=`expr "X$1" : 'X\([^=]*\)='`- ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'`- ac_shift=:- ;;- *)- ac_option=$1- ac_optarg=$2- ac_shift=shift- ;;- esac-- case $ac_option in- # Handling of the options.- -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)- ac_cs_recheck=: ;;- --version | --versio | --versi | --vers | --ver | --ve | --v | -V )- echo "$ac_cs_version"; exit ;;- --debug | --debu | --deb | --de | --d | -d )- debug=: ;;- --header | --heade | --head | --hea )- $ac_shift- CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg"- ac_need_defaults=false;;- --he | --h)- # Conflict between --help and --header- { echo "$as_me: error: ambiguous option: $1-Try \`$0 --help' for more information." >&2- { (exit 1); exit 1; }; };;- --help | --hel | -h )- echo "$ac_cs_usage"; exit ;;- -q | -quiet | --quiet | --quie | --qui | --qu | --q \- | -silent | --silent | --silen | --sile | --sil | --si | --s)- ac_cs_silent=: ;;-- # This is an error.- -*) { echo "$as_me: error: unrecognized option: $1-Try \`$0 --help' for more information." >&2- { (exit 1); exit 1; }; } ;;-- *) ac_config_targets="$ac_config_targets $1"- ac_need_defaults=false ;;-- esac- shift-done--ac_configure_extra_args=--if $ac_cs_silent; then- exec 6>/dev/null- ac_configure_extra_args="$ac_configure_extra_args --silent"-fi--_ACEOF-cat >>$CONFIG_STATUS <<_ACEOF-if \$ac_cs_recheck; then- echo "running CONFIG_SHELL=$SHELL $SHELL $0 "$ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6- CONFIG_SHELL=$SHELL- export CONFIG_SHELL- exec $SHELL "$0"$ac_configure_args \$ac_configure_extra_args --no-create --no-recursion-fi--_ACEOF-cat >>$CONFIG_STATUS <<\_ACEOF-exec 5>>config.log-{- echo- sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX-## Running $as_me. ##-_ASBOX- echo "$ac_log"-} >&5--_ACEOF-cat >>$CONFIG_STATUS <<_ACEOF-_ACEOF--cat >>$CONFIG_STATUS <<\_ACEOF--# Handling of arguments.-for ac_config_target in $ac_config_targets-do- case $ac_config_target in- "include/HsTimeConfig.h") CONFIG_HEADERS="$CONFIG_HEADERS include/HsTimeConfig.h" ;;-- *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5-echo "$as_me: error: invalid argument: $ac_config_target" >&2;}- { (exit 1); exit 1; }; };;- esac-done---# If the user did not use the arguments to specify the items to instantiate,-# then the envvar interface is used. Set only those that are not.-# We use the long form for the default assignment because of an extremely-# bizarre bug on SunOS 4.1.3.-if $ac_need_defaults; then- test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers-fi--# Have a temporary directory for convenience. Make it in the build tree-# simply because there is no reason against having it here, and in addition,-# creating and moving files from /tmp can sometimes cause problems.-# Hook for its removal unless debugging.-# Note that there is a small window in which the directory will not be cleaned:-# after its creation but before its name has been assigned to `$tmp'.-$debug ||-{- tmp=- trap 'exit_status=$?- { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status-' 0- trap '{ (exit 1); exit 1; }' 1 2 13 15-}-# Create a (secure) tmp directory for tmp files.--{- tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` &&- test -n "$tmp" && test -d "$tmp"-} ||-{- tmp=./conf$$-$RANDOM- (umask 077 && mkdir "$tmp")-} ||-{- echo "$me: cannot create a temporary directory in ." >&2- { (exit 1); exit 1; }-}---for ac_tag in :H $CONFIG_HEADERS-do- case $ac_tag in- :[FHLC]) ac_mode=$ac_tag; continue;;- esac- case $ac_mode$ac_tag in- :[FHL]*:*);;- :L* | :C*:*) { { echo "$as_me:$LINENO: error: Invalid tag $ac_tag." >&5-echo "$as_me: error: Invalid tag $ac_tag." >&2;}- { (exit 1); exit 1; }; };;- :[FH]-) ac_tag=-:-;;- :[FH]*) ac_tag=$ac_tag:$ac_tag.in;;- esac- ac_save_IFS=$IFS- IFS=:- set x $ac_tag- IFS=$ac_save_IFS- shift- ac_file=$1- shift-- case $ac_mode in- :L) ac_source=$1;;- :[FH])- ac_file_inputs=- for ac_f- do- case $ac_f in- -) ac_f="$tmp/stdin";;- *) # Look for the file first in the build tree, then in the source tree- # (if the path is not absolute). The absolute path cannot be DOS-style,- # because $ac_f cannot contain `:'.- test -f "$ac_f" ||- case $ac_f in- [\\/$]*) false;;- *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;- esac ||- { { echo "$as_me:$LINENO: error: cannot find input file: $ac_f" >&5-echo "$as_me: error: cannot find input file: $ac_f" >&2;}- { (exit 1); exit 1; }; };;- esac- ac_file_inputs="$ac_file_inputs $ac_f"- done-- # Let's still pretend it is `configure' which instantiates (i.e., don't- # use $as_me), people would be surprised to read:- # /* config.h. Generated by config.status. */- configure_input="Generated from "`IFS=:- echo $* | sed 's|^[^:]*/||;s|:[^:]*/|, |g'`" by configure."- if test x"$ac_file" != x-; then- configure_input="$ac_file. $configure_input"- { echo "$as_me:$LINENO: creating $ac_file" >&5-echo "$as_me: creating $ac_file" >&6;}- fi-- case $ac_tag in- *:-:* | *:-) cat >"$tmp/stdin";;- esac- ;;- esac-- ac_dir=`$as_dirname -- "$ac_file" ||-$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \- X"$ac_file" : 'X\(//\)[^/]' \| \- X"$ac_file" : 'X\(//\)$' \| \- X"$ac_file" : 'X\(/\)' \| . 2>/dev/null ||-echo X"$ac_file" |- sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{- s//\1/- q- }- /^X\(\/\/\)[^/].*/{- s//\1/- q- }- /^X\(\/\/\)$/{- s//\1/- q- }- /^X\(\/\).*/{- s//\1/- q- }- s/.*/./; q'`- { as_dir="$ac_dir"- case $as_dir in #(- -*) as_dir=./$as_dir;;- esac- test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || {- as_dirs=- while :; do- case $as_dir in #(- *\'*) as_qdir=`echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #(- *) as_qdir=$as_dir;;- esac- as_dirs="'$as_qdir' $as_dirs"- as_dir=`$as_dirname -- "$as_dir" ||-$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \- X"$as_dir" : 'X\(//\)[^/]' \| \- X"$as_dir" : 'X\(//\)$' \| \- X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||-echo X"$as_dir" |- sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{- s//\1/- q- }- /^X\(\/\/\)[^/].*/{- s//\1/- q- }- /^X\(\/\/\)$/{- s//\1/- q- }- /^X\(\/\).*/{- s//\1/- q- }- s/.*/./; q'`- test -d "$as_dir" && break- done- test -z "$as_dirs" || eval "mkdir $as_dirs"- } || test -d "$as_dir" || { { echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5-echo "$as_me: error: cannot create directory $as_dir" >&2;}- { (exit 1); exit 1; }; }; }- ac_builddir=.--case "$ac_dir" in-.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;-*)- ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`- # A ".." for each directory in $ac_dir_suffix.- ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'`- case $ac_top_builddir_sub in- "") ac_top_builddir_sub=. ac_top_build_prefix= ;;- *) ac_top_build_prefix=$ac_top_builddir_sub/ ;;- esac ;;-esac-ac_abs_top_builddir=$ac_pwd-ac_abs_builddir=$ac_pwd$ac_dir_suffix-# for backward compatibility:-ac_top_builddir=$ac_top_build_prefix--case $srcdir in- .) # We are building in place.- ac_srcdir=.- ac_top_srcdir=$ac_top_builddir_sub- ac_abs_top_srcdir=$ac_pwd ;;- [\\/]* | ?:[\\/]* ) # Absolute name.- ac_srcdir=$srcdir$ac_dir_suffix;- ac_top_srcdir=$srcdir- ac_abs_top_srcdir=$srcdir ;;- *) # Relative name.- ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix- ac_top_srcdir=$ac_top_build_prefix$srcdir- ac_abs_top_srcdir=$ac_pwd/$srcdir ;;-esac-ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix--- case $ac_mode in-- :H)- #- # CONFIG_HEADER- #-_ACEOF--# Transform confdefs.h into a sed script `conftest.defines', that-# substitutes the proper values into config.h.in to produce config.h.-rm -f conftest.defines conftest.tail-# First, append a space to every undef/define line, to ease matching.-echo 's/$/ /' >conftest.defines-# Then, protect against being on the right side of a sed subst, or in-# an unquoted here document, in config.status. If some macros were-# called several times there might be several #defines for the same-# symbol, which is useless. But do not sort them, since the last-# AC_DEFINE must be honored.-ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]*-# These sed commands are passed to sed as "A NAME B PARAMS C VALUE D", where-# NAME is the cpp macro being defined, VALUE is the value it is being given.-# PARAMS is the parameter list in the macro definition--in most cases, it's-# just an empty string.-ac_dA='s,^\\([ #]*\\)[^ ]*\\([ ]*'-ac_dB='\\)[ (].*,\\1define\\2'-ac_dC=' '-ac_dD=' ,'--uniq confdefs.h |- sed -n '- t rset- :rset- s/^[ ]*#[ ]*define[ ][ ]*//- t ok- d- :ok- s/[\\&,]/\\&/g- s/^\('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/ '"$ac_dA"'\1'"$ac_dB"'\2'"${ac_dC}"'\3'"$ac_dD"'/p- s/^\('"$ac_word_re"'\)[ ]*\(.*\)/'"$ac_dA"'\1'"$ac_dB$ac_dC"'\2'"$ac_dD"'/p- ' >>conftest.defines--# Remove the space that was appended to ease matching.-# Then replace #undef with comments. This is necessary, for-# example, in the case of _POSIX_SOURCE, which is predefined and required-# on some systems where configure will not decide to define it.-# (The regexp can be short, since the line contains either #define or #undef.)-echo 's/ $//-s,^[ #]*u.*,/* & */,' >>conftest.defines--# Break up conftest.defines:-ac_max_sed_lines=50--# First sed command is: sed -f defines.sed $ac_file_inputs >"$tmp/out1"-# Second one is: sed -f defines.sed "$tmp/out1" >"$tmp/out2"-# Third one will be: sed -f defines.sed "$tmp/out2" >"$tmp/out1"-# et cetera.-ac_in='$ac_file_inputs'-ac_out='"$tmp/out1"'-ac_nxt='"$tmp/out2"'--while :-do- # Write a here document:- cat >>$CONFIG_STATUS <<_ACEOF- # First, check the format of the line:- cat >"\$tmp/defines.sed" <<\\CEOF-/^[ ]*#[ ]*undef[ ][ ]*$ac_word_re[ ]*\$/b def-/^[ ]*#[ ]*define[ ][ ]*$ac_word_re[( ]/b def-b-:def-_ACEOF- sed ${ac_max_sed_lines}q conftest.defines >>$CONFIG_STATUS- echo 'CEOF- sed -f "$tmp/defines.sed"' "$ac_in >$ac_out" >>$CONFIG_STATUS- ac_in=$ac_out; ac_out=$ac_nxt; ac_nxt=$ac_in- sed 1,${ac_max_sed_lines}d conftest.defines >conftest.tail- grep . conftest.tail >/dev/null || break- rm -f conftest.defines- mv conftest.tail conftest.defines-done-rm -f conftest.defines conftest.tail--echo "ac_result=$ac_in" >>$CONFIG_STATUS-cat >>$CONFIG_STATUS <<\_ACEOF- if test x"$ac_file" != x-; then- echo "/* $configure_input */" >"$tmp/config.h"- cat "$ac_result" >>"$tmp/config.h"- if diff $ac_file "$tmp/config.h" >/dev/null 2>&1; then- { echo "$as_me:$LINENO: $ac_file is unchanged" >&5-echo "$as_me: $ac_file is unchanged" >&6;}- else- rm -f $ac_file- mv "$tmp/config.h" $ac_file- fi- else- echo "/* $configure_input */"- cat "$ac_result"- fi- rm -f "$tmp/out12"- ;;--- esac--done # for ac_tag---{ (exit 0); exit 0; }-_ACEOF-chmod +x $CONFIG_STATUS-ac_clean_files=$ac_clean_files_save---# configure is writing to config.log, and then calls config.status.-# config.status does its own redirection, appending to config.log.-# Unfortunately, on DOS this fails, as config.log is still kept open-# by configure, so config.status won't be able to write to it; its-# output is simply discarded. So we exec the FD to /dev/null,-# effectively closing config.log, so it can be properly (re)opened and-# appended to by config.status. When coming back to configure, we-# need to make the FD available again.-if test "$no_create" != yes; then- ac_cs_success=:- ac_config_status_args=- test "$silent" = yes &&- ac_config_status_args="$ac_config_status_args --quiet"- exec 5>/dev/null- $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false- exec 5>>config.log- # Use ||, not &&, to avoid exiting from the if with $? = 1, which- # would make configure fail if this is the last instruction.- $ac_cs_success || { (exit 1); exit 1; }-fi+# Generated by GNU Autoconf 2.71 for Haskell time package 1.16.+#+# Report bugs to <ashley@semantic.org>.+#+#+# Copyright (C) 1992-1996, 1998-2017, 2020-2021 Free Software Foundation,+# Inc.+#+#+# This configure script is free software; the Free Software Foundation+# gives unlimited permission to copy, distribute and modify it.+## -------------------- ##+## M4sh Initialization. ##+## -------------------- ##++# Be more Bourne compatible+DUALCASE=1; export DUALCASE # for MKS sh+as_nop=:+if test ${ZSH_VERSION+y} && (emulate sh) >/dev/null 2>&1+then :+ emulate sh+ NULLCMD=:+ # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which+ # is contrary to our usage. Disable this feature.+ alias -g '${1+"$@"}'='"$@"'+ setopt NO_GLOB_SUBST+else $as_nop+ case `(set -o) 2>/dev/null` in #(+ *posix*) :+ set -o posix ;; #(+ *) :+ ;;+esac+fi++++# Reset variables that may have inherited troublesome values from+# the environment.++# IFS needs to be set, to space, tab, and newline, in precisely that order.+# (If _AS_PATH_WALK were called with IFS unset, it would have the+# side effect of setting IFS to empty, thus disabling word splitting.)+# Quoting is to prevent editors from complaining about space-tab.+as_nl='+'+export as_nl+IFS=" "" $as_nl"++PS1='$ '+PS2='> '+PS4='+ '++# Ensure predictable behavior from utilities with locale-dependent output.+LC_ALL=C+export LC_ALL+LANGUAGE=C+export LANGUAGE++# We cannot yet rely on "unset" to work, but we need these variables+# to be unset--not just set to an empty or harmless value--now, to+# avoid bugs in old shells (e.g. pre-3.0 UWIN ksh). This construct+# also avoids known problems related to "unset" and subshell syntax+# in other old shells (e.g. bash 2.01 and pdksh 5.2.14).+for as_var in BASH_ENV ENV MAIL MAILPATH CDPATH+do eval test \${$as_var+y} \+ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :+done++# Ensure that fds 0, 1, and 2 are open.+if (exec 3>&0) 2>/dev/null; then :; else exec 0</dev/null; fi+if (exec 3>&1) 2>/dev/null; then :; else exec 1>/dev/null; fi+if (exec 3>&2) ; then :; else exec 2>/dev/null; fi++# The user is always right.+if ${PATH_SEPARATOR+false} :; then+ PATH_SEPARATOR=:+ (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {+ (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||+ PATH_SEPARATOR=';'+ }+fi+++# Find who we are. Look in the path if we contain no directory separator.+as_myself=+case $0 in #((+ *[\\/]* ) as_myself=$0 ;;+ *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ test -r "$as_dir$0" && as_myself=$as_dir$0 && break+ done+IFS=$as_save_IFS++ ;;+esac+# We did not find ourselves, most probably we were run as `sh COMMAND'+# in which case we are not to be found in the path.+if test "x$as_myself" = x; then+ as_myself=$0+fi+if test ! -f "$as_myself"; then+ printf "%s\n" "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2+ exit 1+fi+++# Use a proper internal environment variable to ensure we don't fall+ # into an infinite loop, continuously re-executing ourselves.+ if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then+ _as_can_reexec=no; export _as_can_reexec;+ # We cannot yet assume a decent shell, so we have to provide a+# neutralization value for shells without unset; and this also+# works around shells that cannot unset nonexistent variables.+# Preserve -v and -x to the replacement shell.+BASH_ENV=/dev/null+ENV=/dev/null+(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV+case $- in # ((((+ *v*x* | *x*v* ) as_opts=-vx ;;+ *v* ) as_opts=-v ;;+ *x* ) as_opts=-x ;;+ * ) as_opts= ;;+esac+exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}+# Admittedly, this is quite paranoid, since all the known shells bail+# out after a failed `exec'.+printf "%s\n" "$0: could not re-execute with $CONFIG_SHELL" >&2+exit 255+ fi+ # We don't want this to propagate to other subprocesses.+ { _as_can_reexec=; unset _as_can_reexec;}+if test "x$CONFIG_SHELL" = x; then+ as_bourne_compatible="as_nop=:+if test \${ZSH_VERSION+y} && (emulate sh) >/dev/null 2>&1+then :+ emulate sh+ NULLCMD=:+ # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which+ # is contrary to our usage. Disable this feature.+ alias -g '\${1+\"\$@\"}'='\"\$@\"'+ setopt NO_GLOB_SUBST+else \$as_nop+ case \`(set -o) 2>/dev/null\` in #(+ *posix*) :+ set -o posix ;; #(+ *) :+ ;;+esac+fi+"+ as_required="as_fn_return () { (exit \$1); }+as_fn_success () { as_fn_return 0; }+as_fn_failure () { as_fn_return 1; }+as_fn_ret_success () { return 0; }+as_fn_ret_failure () { return 1; }++exitcode=0+as_fn_success || { exitcode=1; echo as_fn_success failed.; }+as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; }+as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; }+as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; }+if ( set x; as_fn_ret_success y && test x = \"\$1\" )+then :++else \$as_nop+ exitcode=1; echo positional parameters were not saved.+fi+test x\$exitcode = x0 || exit 1+blah=\$(echo \$(echo blah))+test x\"\$blah\" = xblah || exit 1+test -x / || exit 1"+ as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO+ as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO+ eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" &&+ test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1"+ if (eval "$as_required") 2>/dev/null+then :+ as_have_required=yes+else $as_nop+ as_have_required=no+fi+ if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null+then :++else $as_nop+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+as_found=false+for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ as_found=:+ case $as_dir in #(+ /*)+ for as_base in sh bash ksh sh5; do+ # Try only shells that exist, to save several forks.+ as_shell=$as_dir$as_base+ if { test -f "$as_shell" || test -f "$as_shell.exe"; } &&+ as_run=a "$as_shell" -c "$as_bourne_compatible""$as_required" 2>/dev/null+then :+ CONFIG_SHELL=$as_shell as_have_required=yes+ if as_run=a "$as_shell" -c "$as_bourne_compatible""$as_suggested" 2>/dev/null+then :+ break 2+fi+fi+ done;;+ esac+ as_found=false+done+IFS=$as_save_IFS+if $as_found+then :++else $as_nop+ if { test -f "$SHELL" || test -f "$SHELL.exe"; } &&+ as_run=a "$SHELL" -c "$as_bourne_compatible""$as_required" 2>/dev/null+then :+ CONFIG_SHELL=$SHELL as_have_required=yes+fi+fi+++ if test "x$CONFIG_SHELL" != x+then :+ export CONFIG_SHELL+ # We cannot yet assume a decent shell, so we have to provide a+# neutralization value for shells without unset; and this also+# works around shells that cannot unset nonexistent variables.+# Preserve -v and -x to the replacement shell.+BASH_ENV=/dev/null+ENV=/dev/null+(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV+case $- in # ((((+ *v*x* | *x*v* ) as_opts=-vx ;;+ *v* ) as_opts=-v ;;+ *x* ) as_opts=-x ;;+ * ) as_opts= ;;+esac+exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}+# Admittedly, this is quite paranoid, since all the known shells bail+# out after a failed `exec'.+printf "%s\n" "$0: could not re-execute with $CONFIG_SHELL" >&2+exit 255+fi++ if test x$as_have_required = xno+then :+ printf "%s\n" "$0: This script requires a shell more modern than all"+ printf "%s\n" "$0: the shells that I found on your system."+ if test ${ZSH_VERSION+y} ; then+ printf "%s\n" "$0: In particular, zsh $ZSH_VERSION has bugs and should"+ printf "%s\n" "$0: be upgraded to zsh 4.3.4 or later."+ else+ printf "%s\n" "$0: Please tell bug-autoconf@gnu.org and+$0: ashley@semantic.org about your system, including any+$0: error possibly output before this message. Then install+$0: a modern shell, or manually run the script under such a+$0: shell if you do have one."+ fi+ exit 1+fi+fi+fi+SHELL=${CONFIG_SHELL-/bin/sh}+export SHELL+# Unset more variables known to interfere with behavior of common tools.+CLICOLOR_FORCE= GREP_OPTIONS=+unset CLICOLOR_FORCE GREP_OPTIONS++## --------------------- ##+## M4sh Shell Functions. ##+## --------------------- ##+# as_fn_unset VAR+# ---------------+# Portably unset VAR.+as_fn_unset ()+{+ { eval $1=; unset $1;}+}+as_unset=as_fn_unset+++# as_fn_set_status STATUS+# -----------------------+# Set $? to STATUS, without forking.+as_fn_set_status ()+{+ return $1+} # as_fn_set_status++# as_fn_exit STATUS+# -----------------+# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.+as_fn_exit ()+{+ set +e+ as_fn_set_status $1+ exit $1+} # as_fn_exit+# as_fn_nop+# ---------+# Do nothing but, unlike ":", preserve the value of $?.+as_fn_nop ()+{+ return $?+}+as_nop=as_fn_nop++# as_fn_mkdir_p+# -------------+# Create "$as_dir" as a directory, including parents if necessary.+as_fn_mkdir_p ()+{++ case $as_dir in #(+ -*) as_dir=./$as_dir;;+ esac+ test -d "$as_dir" || eval $as_mkdir_p || {+ as_dirs=+ while :; do+ case $as_dir in #(+ *\'*) as_qdir=`printf "%s\n" "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(+ *) as_qdir=$as_dir;;+ esac+ as_dirs="'$as_qdir' $as_dirs"+ as_dir=`$as_dirname -- "$as_dir" ||+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \+ X"$as_dir" : 'X\(//\)[^/]' \| \+ X"$as_dir" : 'X\(//\)$' \| \+ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||+printf "%s\n" X"$as_dir" |+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{+ s//\1/+ q+ }+ /^X\(\/\/\)[^/].*/{+ s//\1/+ q+ }+ /^X\(\/\/\)$/{+ s//\1/+ q+ }+ /^X\(\/\).*/{+ s//\1/+ q+ }+ s/.*/./; q'`+ test -d "$as_dir" && break+ done+ test -z "$as_dirs" || eval "mkdir $as_dirs"+ } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"+++} # as_fn_mkdir_p++# as_fn_executable_p FILE+# -----------------------+# Test if FILE is an executable regular file.+as_fn_executable_p ()+{+ test -f "$1" && test -x "$1"+} # as_fn_executable_p+# as_fn_append VAR VALUE+# ----------------------+# Append the text in VALUE to the end of the definition contained in VAR. Take+# advantage of any shell optimizations that allow amortized linear growth over+# repeated appends, instead of the typical quadratic growth present in naive+# implementations.+if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null+then :+ eval 'as_fn_append ()+ {+ eval $1+=\$2+ }'+else $as_nop+ as_fn_append ()+ {+ eval $1=\$$1\$2+ }+fi # as_fn_append++# as_fn_arith ARG...+# ------------------+# Perform arithmetic evaluation on the ARGs, and store the result in the+# global $as_val. Take advantage of shells that can avoid forks. The arguments+# must be portable across $(()) and expr.+if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null+then :+ eval 'as_fn_arith ()+ {+ as_val=$(( $* ))+ }'+else $as_nop+ as_fn_arith ()+ {+ as_val=`expr "$@" || test $? -eq 1`+ }+fi # as_fn_arith++# as_fn_nop+# ---------+# Do nothing but, unlike ":", preserve the value of $?.+as_fn_nop ()+{+ return $?+}+as_nop=as_fn_nop++# as_fn_error STATUS ERROR [LINENO LOG_FD]+# ----------------------------------------+# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are+# provided, also output the error to LOG_FD, referencing LINENO. Then exit the+# script with STATUS, using 1 if that was 0.+as_fn_error ()+{+ as_status=$1; test $as_status -eq 0 && as_status=1+ if test "$4"; then+ as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: $2" >&$4+ fi+ printf "%s\n" "$as_me: error: $2" >&2+ as_fn_exit $as_status+} # as_fn_error++if expr a : '\(a\)' >/dev/null 2>&1 &&+ test "X`expr 00001 : '.*\(...\)'`" = X001; then+ as_expr=expr+else+ as_expr=false+fi++if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then+ as_basename=basename+else+ as_basename=false+fi++if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then+ as_dirname=dirname+else+ as_dirname=false+fi++as_me=`$as_basename -- "$0" ||+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \+ X"$0" : 'X\(//\)$' \| \+ X"$0" : 'X\(/\)' \| . 2>/dev/null ||+printf "%s\n" X/"$0" |+ sed '/^.*\/\([^/][^/]*\)\/*$/{+ s//\1/+ q+ }+ /^X\/\(\/\/\)$/{+ s//\1/+ q+ }+ /^X\/\(\/\).*/{+ s//\1/+ q+ }+ s/.*/./; q'`++# Avoid depending upon Character Ranges.+as_cr_letters='abcdefghijklmnopqrstuvwxyz'+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'+as_cr_Letters=$as_cr_letters$as_cr_LETTERS+as_cr_digits='0123456789'+as_cr_alnum=$as_cr_Letters$as_cr_digits+++ as_lineno_1=$LINENO as_lineno_1a=$LINENO+ as_lineno_2=$LINENO as_lineno_2a=$LINENO+ eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" &&+ test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || {+ # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-)+ sed -n '+ p+ /[$]LINENO/=+ ' <$as_myself |+ sed '+ s/[$]LINENO.*/&-/+ t lineno+ b+ :lineno+ N+ :loop+ s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/+ t loop+ s/-\n.*//+ ' >$as_me.lineno &&+ chmod +x "$as_me.lineno" ||+ { printf "%s\n" "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; }++ # If we had to re-execute with $CONFIG_SHELL, we're ensured to have+ # already done that, so ensure we don't try to do so again and fall+ # in an infinite loop. This has already happened in practice.+ _as_can_reexec=no; export _as_can_reexec+ # Don't try to exec as it changes $[0], causing all sort of problems+ # (the dirname of $[0] is not the place where we might find the+ # original and so on. Autoconf is especially sensitive to this).+ . "./$as_me.lineno"+ # Exit status is that of the last command.+ exit+}+++# Determine whether it's possible to make 'echo' print without a newline.+# These variables are no longer used directly by Autoconf, but are AC_SUBSTed+# for compatibility with existing Makefiles.+ECHO_C= ECHO_N= ECHO_T=+case `echo -n x` in #(((((+-n*)+ case `echo 'xy\c'` in+ *c*) ECHO_T=' ';; # ECHO_T is single tab character.+ xy) ECHO_C='\c';;+ *) echo `echo ksh88 bug on AIX 6.1` > /dev/null+ ECHO_T=' ';;+ esac;;+*)+ ECHO_N='-n';;+esac++# For backward compatibility with old third-party macros, we provide+# the shell variables $as_echo and $as_echo_n. New code should use+# AS_ECHO(["message"]) and AS_ECHO_N(["message"]), respectively.+as_echo='printf %s\n'+as_echo_n='printf %s'+++rm -f conf$$ conf$$.exe conf$$.file+if test -d conf$$.dir; then+ rm -f conf$$.dir/conf$$.file+else+ rm -f conf$$.dir+ mkdir conf$$.dir 2>/dev/null+fi+if (echo >conf$$.file) 2>/dev/null; then+ if ln -s conf$$.file conf$$ 2>/dev/null; then+ as_ln_s='ln -s'+ # ... but there are two gotchas:+ # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.+ # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.+ # In both cases, we have to default to `cp -pR'.+ ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||+ as_ln_s='cp -pR'+ elif ln conf$$.file conf$$ 2>/dev/null; then+ as_ln_s=ln+ else+ as_ln_s='cp -pR'+ fi+else+ as_ln_s='cp -pR'+fi+rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file+rmdir conf$$.dir 2>/dev/null++if mkdir -p . 2>/dev/null; then+ as_mkdir_p='mkdir -p "$as_dir"'+else+ test -d ./-p && rmdir ./-p+ as_mkdir_p=false+fi++as_test_x='test -x'+as_executable_p=as_fn_executable_p++# Sed expression to map a string onto a valid CPP name.+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"++# Sed expression to map a string onto a valid variable name.+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"+++test -n "$DJDIR" || exec 7<&0 </dev/null+exec 6>&1++# Name of the host.+# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status,+# so uname gets run too.+ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`++#+# Initializations.+#+ac_default_prefix=/usr/local+ac_clean_files=+ac_config_libobj_dir=.+LIBOBJS=+cross_compiling=no+subdirs=+MFLAGS=+MAKEFLAGS=++# Identity of this package.+PACKAGE_NAME='Haskell time package'+PACKAGE_TARNAME='time'+PACKAGE_VERSION='1.16'+PACKAGE_STRING='Haskell time package 1.16'+PACKAGE_BUGREPORT='ashley@semantic.org'+PACKAGE_URL=''++ac_unique_file="lib/include/HsTime.h"+# Factoring default headers for most tests.+ac_includes_default="\+#include <stddef.h>+#ifdef HAVE_STDIO_H+# include <stdio.h>+#endif+#ifdef HAVE_STDLIB_H+# include <stdlib.h>+#endif+#ifdef HAVE_STRING_H+# include <string.h>+#endif+#ifdef HAVE_INTTYPES_H+# include <inttypes.h>+#endif+#ifdef HAVE_STDINT_H+# include <stdint.h>+#endif+#ifdef HAVE_STRINGS_H+# include <strings.h>+#endif+#ifdef HAVE_SYS_TYPES_H+# include <sys/types.h>+#endif+#ifdef HAVE_SYS_STAT_H+# include <sys/stat.h>+#endif+#ifdef HAVE_UNISTD_H+# include <unistd.h>+#endif"++ac_header_c_list=+ac_subst_vars='LTLIBOBJS+LIBOBJS+OBJEXT+EXEEXT+ac_ct_CC+CPPFLAGS+LDFLAGS+CFLAGS+CC+target_alias+host_alias+build_alias+LIBS+ECHO_T+ECHO_N+ECHO_C+DEFS+mandir+localedir+libdir+psdir+pdfdir+dvidir+htmldir+infodir+docdir+oldincludedir+includedir+runstatedir+localstatedir+sharedstatedir+sysconfdir+datadir+datarootdir+libexecdir+sbindir+bindir+program_transform_name+prefix+exec_prefix+PACKAGE_URL+PACKAGE_BUGREPORT+PACKAGE_STRING+PACKAGE_VERSION+PACKAGE_TARNAME+PACKAGE_NAME+PATH_SEPARATOR+SHELL'+ac_subst_files=''+ac_user_opts='+enable_option_checking+with_gcc+with_compiler+'+ ac_precious_vars='build_alias+host_alias+target_alias+CC+CFLAGS+LDFLAGS+LIBS+CPPFLAGS'+++# Initialize some variables set by options.+ac_init_help=+ac_init_version=false+ac_unrecognized_opts=+ac_unrecognized_sep=+# The variables have the same names as the options, with+# dashes changed to underlines.+cache_file=/dev/null+exec_prefix=NONE+no_create=+no_recursion=+prefix=NONE+program_prefix=NONE+program_suffix=NONE+program_transform_name=s,x,x,+silent=+site=+srcdir=+verbose=+x_includes=NONE+x_libraries=NONE++# Installation directory options.+# These are left unexpanded so users can "make install exec_prefix=/foo"+# and all the variables that are supposed to be based on exec_prefix+# by default will actually change.+# Use braces instead of parens because sh, perl, etc. also accept them.+# (The list follows the same order as the GNU Coding Standards.)+bindir='${exec_prefix}/bin'+sbindir='${exec_prefix}/sbin'+libexecdir='${exec_prefix}/libexec'+datarootdir='${prefix}/share'+datadir='${datarootdir}'+sysconfdir='${prefix}/etc'+sharedstatedir='${prefix}/com'+localstatedir='${prefix}/var'+runstatedir='${localstatedir}/run'+includedir='${prefix}/include'+oldincludedir='/usr/include'+docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'+infodir='${datarootdir}/info'+htmldir='${docdir}'+dvidir='${docdir}'+pdfdir='${docdir}'+psdir='${docdir}'+libdir='${exec_prefix}/lib'+localedir='${datarootdir}/locale'+mandir='${datarootdir}/man'++ac_prev=+ac_dashdash=+for ac_option+do+ # If the previous option needs an argument, assign it.+ if test -n "$ac_prev"; then+ eval $ac_prev=\$ac_option+ ac_prev=+ continue+ fi++ case $ac_option in+ *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;+ *=) ac_optarg= ;;+ *) ac_optarg=yes ;;+ esac++ case $ac_dashdash$ac_option in+ --)+ ac_dashdash=yes ;;++ -bindir | --bindir | --bindi | --bind | --bin | --bi)+ ac_prev=bindir ;;+ -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)+ bindir=$ac_optarg ;;++ -build | --build | --buil | --bui | --bu)+ ac_prev=build_alias ;;+ -build=* | --build=* | --buil=* | --bui=* | --bu=*)+ build_alias=$ac_optarg ;;++ -cache-file | --cache-file | --cache-fil | --cache-fi \+ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)+ ac_prev=cache_file ;;+ -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \+ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)+ cache_file=$ac_optarg ;;++ --config-cache | -C)+ cache_file=config.cache ;;++ -datadir | --datadir | --datadi | --datad)+ ac_prev=datadir ;;+ -datadir=* | --datadir=* | --datadi=* | --datad=*)+ datadir=$ac_optarg ;;++ -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \+ | --dataroo | --dataro | --datar)+ ac_prev=datarootdir ;;+ -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \+ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*)+ datarootdir=$ac_optarg ;;++ -disable-* | --disable-*)+ ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'`+ # Reject names that are not valid shell variable names.+ expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&+ as_fn_error $? "invalid feature name: \`$ac_useropt'"+ ac_useropt_orig=$ac_useropt+ ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'`+ case $ac_user_opts in+ *"+"enable_$ac_useropt"+"*) ;;+ *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig"+ ac_unrecognized_sep=', ';;+ esac+ eval enable_$ac_useropt=no ;;++ -docdir | --docdir | --docdi | --doc | --do)+ ac_prev=docdir ;;+ -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*)+ docdir=$ac_optarg ;;++ -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv)+ ac_prev=dvidir ;;+ -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*)+ dvidir=$ac_optarg ;;++ -enable-* | --enable-*)+ ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`+ # Reject names that are not valid shell variable names.+ expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&+ as_fn_error $? "invalid feature name: \`$ac_useropt'"+ ac_useropt_orig=$ac_useropt+ ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'`+ case $ac_user_opts in+ *"+"enable_$ac_useropt"+"*) ;;+ *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig"+ ac_unrecognized_sep=', ';;+ esac+ eval enable_$ac_useropt=\$ac_optarg ;;++ -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \+ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \+ | --exec | --exe | --ex)+ ac_prev=exec_prefix ;;+ -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \+ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \+ | --exec=* | --exe=* | --ex=*)+ exec_prefix=$ac_optarg ;;++ -gas | --gas | --ga | --g)+ # Obsolete; use --with-gas.+ with_gas=yes ;;++ -help | --help | --hel | --he | -h)+ ac_init_help=long ;;+ -help=r* | --help=r* | --hel=r* | --he=r* | -hr*)+ ac_init_help=recursive ;;+ -help=s* | --help=s* | --hel=s* | --he=s* | -hs*)+ ac_init_help=short ;;++ -host | --host | --hos | --ho)+ ac_prev=host_alias ;;+ -host=* | --host=* | --hos=* | --ho=*)+ host_alias=$ac_optarg ;;++ -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht)+ ac_prev=htmldir ;;+ -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \+ | --ht=*)+ htmldir=$ac_optarg ;;++ -includedir | --includedir | --includedi | --included | --include \+ | --includ | --inclu | --incl | --inc)+ ac_prev=includedir ;;+ -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \+ | --includ=* | --inclu=* | --incl=* | --inc=*)+ includedir=$ac_optarg ;;++ -infodir | --infodir | --infodi | --infod | --info | --inf)+ ac_prev=infodir ;;+ -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)+ infodir=$ac_optarg ;;++ -libdir | --libdir | --libdi | --libd)+ ac_prev=libdir ;;+ -libdir=* | --libdir=* | --libdi=* | --libd=*)+ libdir=$ac_optarg ;;++ -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \+ | --libexe | --libex | --libe)+ ac_prev=libexecdir ;;+ -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \+ | --libexe=* | --libex=* | --libe=*)+ libexecdir=$ac_optarg ;;++ -localedir | --localedir | --localedi | --localed | --locale)+ ac_prev=localedir ;;+ -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*)+ localedir=$ac_optarg ;;++ -localstatedir | --localstatedir | --localstatedi | --localstated \+ | --localstate | --localstat | --localsta | --localst | --locals)+ ac_prev=localstatedir ;;+ -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \+ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*)+ localstatedir=$ac_optarg ;;++ -mandir | --mandir | --mandi | --mand | --man | --ma | --m)+ ac_prev=mandir ;;+ -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)+ mandir=$ac_optarg ;;++ -nfp | --nfp | --nf)+ # Obsolete; use --without-fp.+ with_fp=no ;;++ -no-create | --no-create | --no-creat | --no-crea | --no-cre \+ | --no-cr | --no-c | -n)+ no_create=yes ;;++ -no-recursion | --no-recursion | --no-recursio | --no-recursi \+ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)+ no_recursion=yes ;;++ -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \+ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \+ | --oldin | --oldi | --old | --ol | --o)+ ac_prev=oldincludedir ;;+ -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \+ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \+ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)+ oldincludedir=$ac_optarg ;;++ -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)+ ac_prev=prefix ;;+ -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)+ prefix=$ac_optarg ;;++ -program-prefix | --program-prefix | --program-prefi | --program-pref \+ | --program-pre | --program-pr | --program-p)+ ac_prev=program_prefix ;;+ -program-prefix=* | --program-prefix=* | --program-prefi=* \+ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)+ program_prefix=$ac_optarg ;;++ -program-suffix | --program-suffix | --program-suffi | --program-suff \+ | --program-suf | --program-su | --program-s)+ ac_prev=program_suffix ;;+ -program-suffix=* | --program-suffix=* | --program-suffi=* \+ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)+ program_suffix=$ac_optarg ;;++ -program-transform-name | --program-transform-name \+ | --program-transform-nam | --program-transform-na \+ | --program-transform-n | --program-transform- \+ | --program-transform | --program-transfor \+ | --program-transfo | --program-transf \+ | --program-trans | --program-tran \+ | --progr-tra | --program-tr | --program-t)+ ac_prev=program_transform_name ;;+ -program-transform-name=* | --program-transform-name=* \+ | --program-transform-nam=* | --program-transform-na=* \+ | --program-transform-n=* | --program-transform-=* \+ | --program-transform=* | --program-transfor=* \+ | --program-transfo=* | --program-transf=* \+ | --program-trans=* | --program-tran=* \+ | --progr-tra=* | --program-tr=* | --program-t=*)+ program_transform_name=$ac_optarg ;;++ -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd)+ ac_prev=pdfdir ;;+ -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*)+ pdfdir=$ac_optarg ;;++ -psdir | --psdir | --psdi | --psd | --ps)+ ac_prev=psdir ;;+ -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*)+ psdir=$ac_optarg ;;++ -q | -quiet | --quiet | --quie | --qui | --qu | --q \+ | -silent | --silent | --silen | --sile | --sil)+ silent=yes ;;++ -runstatedir | --runstatedir | --runstatedi | --runstated \+ | --runstate | --runstat | --runsta | --runst | --runs \+ | --run | --ru | --r)+ ac_prev=runstatedir ;;+ -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \+ | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \+ | --run=* | --ru=* | --r=*)+ runstatedir=$ac_optarg ;;++ -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)+ ac_prev=sbindir ;;+ -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \+ | --sbi=* | --sb=*)+ sbindir=$ac_optarg ;;++ -sharedstatedir | --sharedstatedir | --sharedstatedi \+ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \+ | --sharedst | --shareds | --shared | --share | --shar \+ | --sha | --sh)+ ac_prev=sharedstatedir ;;+ -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \+ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \+ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \+ | --sha=* | --sh=*)+ sharedstatedir=$ac_optarg ;;++ -site | --site | --sit)+ ac_prev=site ;;+ -site=* | --site=* | --sit=*)+ site=$ac_optarg ;;++ -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)+ ac_prev=srcdir ;;+ -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)+ srcdir=$ac_optarg ;;++ -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \+ | --syscon | --sysco | --sysc | --sys | --sy)+ ac_prev=sysconfdir ;;+ -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \+ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)+ sysconfdir=$ac_optarg ;;++ -target | --target | --targe | --targ | --tar | --ta | --t)+ ac_prev=target_alias ;;+ -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)+ target_alias=$ac_optarg ;;++ -v | -verbose | --verbose | --verbos | --verbo | --verb)+ verbose=yes ;;++ -version | --version | --versio | --versi | --vers | -V)+ ac_init_version=: ;;++ -with-* | --with-*)+ ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`+ # Reject names that are not valid shell variable names.+ expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&+ as_fn_error $? "invalid package name: \`$ac_useropt'"+ ac_useropt_orig=$ac_useropt+ ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'`+ case $ac_user_opts in+ *"+"with_$ac_useropt"+"*) ;;+ *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig"+ ac_unrecognized_sep=', ';;+ esac+ eval with_$ac_useropt=\$ac_optarg ;;++ -without-* | --without-*)+ ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'`+ # Reject names that are not valid shell variable names.+ expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&+ as_fn_error $? "invalid package name: \`$ac_useropt'"+ ac_useropt_orig=$ac_useropt+ ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'`+ case $ac_user_opts in+ *"+"with_$ac_useropt"+"*) ;;+ *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig"+ ac_unrecognized_sep=', ';;+ esac+ eval with_$ac_useropt=no ;;++ --x)+ # Obsolete; use --with-x.+ with_x=yes ;;++ -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \+ | --x-incl | --x-inc | --x-in | --x-i)+ ac_prev=x_includes ;;+ -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \+ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)+ x_includes=$ac_optarg ;;++ -x-libraries | --x-libraries | --x-librarie | --x-librari \+ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)+ ac_prev=x_libraries ;;+ -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \+ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)+ x_libraries=$ac_optarg ;;++ -*) as_fn_error $? "unrecognized option: \`$ac_option'+Try \`$0 --help' for more information"+ ;;++ *=*)+ ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`+ # Reject names that are not valid shell variable names.+ case $ac_envvar in #(+ '' | [0-9]* | *[!_$as_cr_alnum]* )+ as_fn_error $? "invalid variable name: \`$ac_envvar'" ;;+ esac+ eval $ac_envvar=\$ac_optarg+ export $ac_envvar ;;++ *)+ # FIXME: should be removed in autoconf 3.0.+ printf "%s\n" "$as_me: WARNING: you should use --build, --host, --target" >&2+ expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&+ printf "%s\n" "$as_me: WARNING: invalid host type: $ac_option" >&2+ : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}"+ ;;++ esac+done++if test -n "$ac_prev"; then+ ac_option=--`echo $ac_prev | sed 's/_/-/g'`+ as_fn_error $? "missing argument to $ac_option"+fi++if test -n "$ac_unrecognized_opts"; then+ case $enable_option_checking in+ no) ;;+ fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;;+ *) printf "%s\n" "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;;+ esac+fi++# Check all directory arguments for consistency.+for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \+ datadir sysconfdir sharedstatedir localstatedir includedir \+ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \+ libdir localedir mandir runstatedir+do+ eval ac_val=\$$ac_var+ # Remove trailing slashes.+ case $ac_val in+ */ )+ ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'`+ eval $ac_var=\$ac_val;;+ esac+ # Be sure to have absolute directory names.+ case $ac_val in+ [\\/$]* | ?:[\\/]* ) continue;;+ NONE | '' ) case $ac_var in *prefix ) continue;; esac;;+ esac+ as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val"+done++# There might be people who depend on the old broken behavior: `$host'+# used to hold the argument of --host etc.+# FIXME: To remove some day.+build=$build_alias+host=$host_alias+target=$target_alias++# FIXME: To remove some day.+if test "x$host_alias" != x; then+ if test "x$build_alias" = x; then+ cross_compiling=maybe+ elif test "x$build_alias" != "x$host_alias"; then+ cross_compiling=yes+ fi+fi++ac_tool_prefix=+test -n "$host_alias" && ac_tool_prefix=$host_alias-++test "$silent" = yes && exec 6>/dev/null+++ac_pwd=`pwd` && test -n "$ac_pwd" &&+ac_ls_di=`ls -di .` &&+ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` ||+ as_fn_error $? "working directory cannot be determined"+test "X$ac_ls_di" = "X$ac_pwd_ls_di" ||+ as_fn_error $? "pwd does not report name of working directory"+++# Find the source files, if location was not specified.+if test -z "$srcdir"; then+ ac_srcdir_defaulted=yes+ # Try the directory containing this script, then the parent directory.+ ac_confdir=`$as_dirname -- "$as_myself" ||+$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \+ X"$as_myself" : 'X\(//\)[^/]' \| \+ X"$as_myself" : 'X\(//\)$' \| \+ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null ||+printf "%s\n" X"$as_myself" |+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{+ s//\1/+ q+ }+ /^X\(\/\/\)[^/].*/{+ s//\1/+ q+ }+ /^X\(\/\/\)$/{+ s//\1/+ q+ }+ /^X\(\/\).*/{+ s//\1/+ q+ }+ s/.*/./; q'`+ srcdir=$ac_confdir+ if test ! -r "$srcdir/$ac_unique_file"; then+ srcdir=..+ fi+else+ ac_srcdir_defaulted=no+fi+if test ! -r "$srcdir/$ac_unique_file"; then+ test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .."+ as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir"+fi+ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work"+ac_abs_confdir=`(+ cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg"+ pwd)`+# When building in place, set srcdir=.+if test "$ac_abs_confdir" = "$ac_pwd"; then+ srcdir=.+fi+# Remove unnecessary trailing slashes from srcdir.+# Double slashes in file names in object file debugging info+# mess up M-x gdb in Emacs.+case $srcdir in+*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;;+esac+for ac_var in $ac_precious_vars; do+ eval ac_env_${ac_var}_set=\${${ac_var}+set}+ eval ac_env_${ac_var}_value=\$${ac_var}+ eval ac_cv_env_${ac_var}_set=\${${ac_var}+set}+ eval ac_cv_env_${ac_var}_value=\$${ac_var}+done++#+# Report the --help message.+#+if test "$ac_init_help" = "long"; then+ # Omit some internal or obsolete options to make the list less imposing.+ # This message is too long to be a string in the A/UX 3.1 sh.+ cat <<_ACEOF+\`configure' configures Haskell time package 1.16 to adapt to many kinds of systems.++Usage: $0 [OPTION]... [VAR=VALUE]...++To assign environment variables (e.g., CC, CFLAGS...), specify them as+VAR=VALUE. See below for descriptions of some of the useful variables.++Defaults for the options are specified in brackets.++Configuration:+ -h, --help display this help and exit+ --help=short display options specific to this package+ --help=recursive display the short help of all the included packages+ -V, --version display version information and exit+ -q, --quiet, --silent do not print \`checking ...' messages+ --cache-file=FILE cache test results in FILE [disabled]+ -C, --config-cache alias for \`--cache-file=config.cache'+ -n, --no-create do not create output files+ --srcdir=DIR find the sources in DIR [configure dir or \`..']++Installation directories:+ --prefix=PREFIX install architecture-independent files in PREFIX+ [$ac_default_prefix]+ --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX+ [PREFIX]++By default, \`make install' will install all the files in+\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify+an installation prefix other than \`$ac_default_prefix' using \`--prefix',+for instance \`--prefix=\$HOME'.++For better control, use the options below.++Fine tuning of the installation directories:+ --bindir=DIR user executables [EPREFIX/bin]+ --sbindir=DIR system admin executables [EPREFIX/sbin]+ --libexecdir=DIR program executables [EPREFIX/libexec]+ --sysconfdir=DIR read-only single-machine data [PREFIX/etc]+ --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]+ --localstatedir=DIR modifiable single-machine data [PREFIX/var]+ --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]+ --libdir=DIR object code libraries [EPREFIX/lib]+ --includedir=DIR C header files [PREFIX/include]+ --oldincludedir=DIR C header files for non-gcc [/usr/include]+ --datarootdir=DIR read-only arch.-independent data root [PREFIX/share]+ --datadir=DIR read-only architecture-independent data [DATAROOTDIR]+ --infodir=DIR info documentation [DATAROOTDIR/info]+ --localedir=DIR locale-dependent data [DATAROOTDIR/locale]+ --mandir=DIR man documentation [DATAROOTDIR/man]+ --docdir=DIR documentation root [DATAROOTDIR/doc/time]+ --htmldir=DIR html documentation [DOCDIR]+ --dvidir=DIR dvi documentation [DOCDIR]+ --pdfdir=DIR pdf documentation [DOCDIR]+ --psdir=DIR ps documentation [DOCDIR]+_ACEOF++ cat <<\_ACEOF+_ACEOF+fi++if test -n "$ac_init_help"; then+ case $ac_init_help in+ short | recursive ) echo "Configuration of Haskell time package 1.16:";;+ esac+ cat <<\_ACEOF++Optional Packages:+ --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]+ --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)+Gnu C compiler+Haskell compiler++Some influential environment variables:+ CC C compiler command+ CFLAGS C compiler flags+ LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a+ nonstandard directory <lib dir>+ LIBS libraries to pass to the linker, e.g. -l<library>+ CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if+ you have headers in a nonstandard directory <include dir>++Use these variables to override the choices made by `configure' or to help+it to find libraries and programs with nonstandard names/locations.++Report bugs to <ashley@semantic.org>.+_ACEOF+ac_status=$?+fi++if test "$ac_init_help" = "recursive"; then+ # If there are subdirs, report their specific --help.+ for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue+ test -d "$ac_dir" ||+ { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } ||+ continue+ ac_builddir=.++case "$ac_dir" in+.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;+*)+ ac_dir_suffix=/`printf "%s\n" "$ac_dir" | sed 's|^\.[\\/]||'`+ # A ".." for each directory in $ac_dir_suffix.+ ac_top_builddir_sub=`printf "%s\n" "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`+ case $ac_top_builddir_sub in+ "") ac_top_builddir_sub=. ac_top_build_prefix= ;;+ *) ac_top_build_prefix=$ac_top_builddir_sub/ ;;+ esac ;;+esac+ac_abs_top_builddir=$ac_pwd+ac_abs_builddir=$ac_pwd$ac_dir_suffix+# for backward compatibility:+ac_top_builddir=$ac_top_build_prefix++case $srcdir in+ .) # We are building in place.+ ac_srcdir=.+ ac_top_srcdir=$ac_top_builddir_sub+ ac_abs_top_srcdir=$ac_pwd ;;+ [\\/]* | ?:[\\/]* ) # Absolute name.+ ac_srcdir=$srcdir$ac_dir_suffix;+ ac_top_srcdir=$srcdir+ ac_abs_top_srcdir=$srcdir ;;+ *) # Relative name.+ ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix+ ac_top_srcdir=$ac_top_build_prefix$srcdir+ ac_abs_top_srcdir=$ac_pwd/$srcdir ;;+esac+ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix++ cd "$ac_dir" || { ac_status=$?; continue; }+ # Check for configure.gnu first; this name is used for a wrapper for+ # Metaconfig's "Configure" on case-insensitive file systems.+ if test -f "$ac_srcdir/configure.gnu"; then+ echo &&+ $SHELL "$ac_srcdir/configure.gnu" --help=recursive+ elif test -f "$ac_srcdir/configure"; then+ echo &&+ $SHELL "$ac_srcdir/configure" --help=recursive+ else+ printf "%s\n" "$as_me: WARNING: no configuration information is in $ac_dir" >&2+ fi || ac_status=$?+ cd "$ac_pwd" || { ac_status=$?; break; }+ done+fi++test -n "$ac_init_help" && exit $ac_status+if $ac_init_version; then+ cat <<\_ACEOF+Haskell time package configure 1.16+generated by GNU Autoconf 2.71++Copyright (C) 2021 Free Software Foundation, Inc.+This configure script is free software; the Free Software Foundation+gives unlimited permission to copy, distribute and modify it.+_ACEOF+ exit+fi++## ------------------------ ##+## Autoconf initialization. ##+## ------------------------ ##++# ac_fn_c_try_compile LINENO+# --------------------------+# Try to compile conftest.$ac_ext, and return whether this succeeded.+ac_fn_c_try_compile ()+{+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack+ rm -f conftest.$ac_objext conftest.beam+ if { { ac_try="$ac_compile"+case "(($ac_try" in+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;+ *) ac_try_echo=$ac_try;;+esac+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""+printf "%s\n" "$ac_try_echo"; } >&5+ (eval "$ac_compile") 2>conftest.err+ ac_status=$?+ if test -s conftest.err; then+ grep -v '^ *+' conftest.err >conftest.er1+ cat conftest.er1 >&5+ mv -f conftest.er1 conftest.err+ fi+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5+ test $ac_status = 0; } && {+ test -z "$ac_c_werror_flag" ||+ test ! -s conftest.err+ } && test -s conftest.$ac_objext+then :+ ac_retval=0+else $as_nop+ printf "%s\n" "$as_me: failed program was:" >&5+sed 's/^/| /' conftest.$ac_ext >&5++ ac_retval=1+fi+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno+ as_fn_set_status $ac_retval++} # ac_fn_c_try_compile++# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES+# -------------------------------------------------------+# Tests whether HEADER exists and can be compiled using the include files in+# INCLUDES, setting the cache variable VAR accordingly.+ac_fn_c_check_header_compile ()+{+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $2" >&5+printf %s "checking for $2... " >&6; }+if eval test \${$3+y}+then :+ printf %s "(cached) " >&6+else $as_nop+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+$4+#include <$2>+_ACEOF+if ac_fn_c_try_compile "$LINENO"+then :+ eval "$3=yes"+else $as_nop+ eval "$3=no"+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext+fi+eval ac_res=\$$3+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5+printf "%s\n" "$ac_res" >&6; }+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno++} # ac_fn_c_check_header_compile++# ac_fn_c_try_link LINENO+# -----------------------+# Try to link conftest.$ac_ext, and return whether this succeeded.+ac_fn_c_try_link ()+{+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack+ rm -f conftest.$ac_objext conftest.beam conftest$ac_exeext+ if { { ac_try="$ac_link"+case "(($ac_try" in+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;+ *) ac_try_echo=$ac_try;;+esac+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""+printf "%s\n" "$ac_try_echo"; } >&5+ (eval "$ac_link") 2>conftest.err+ ac_status=$?+ if test -s conftest.err; then+ grep -v '^ *+' conftest.err >conftest.er1+ cat conftest.er1 >&5+ mv -f conftest.er1 conftest.err+ fi+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5+ test $ac_status = 0; } && {+ test -z "$ac_c_werror_flag" ||+ test ! -s conftest.err+ } && test -s conftest$ac_exeext && {+ test "$cross_compiling" = yes ||+ test -x conftest$ac_exeext+ }+then :+ ac_retval=0+else $as_nop+ printf "%s\n" "$as_me: failed program was:" >&5+sed 's/^/| /' conftest.$ac_ext >&5++ ac_retval=1+fi+ # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information+ # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would+ # interfere with the next link command; also delete a directory that is+ # left behind by Apple's compiler. We do this before executing the actions.+ rm -rf conftest.dSYM conftest_ipa8_conftest.oo+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno+ as_fn_set_status $ac_retval++} # ac_fn_c_try_link++# ac_fn_c_check_func LINENO FUNC VAR+# ----------------------------------+# Tests whether FUNC exists, setting the cache variable VAR accordingly+ac_fn_c_check_func ()+{+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $2" >&5+printf %s "checking for $2... " >&6; }+if eval test \${$3+y}+then :+ printf %s "(cached) " >&6+else $as_nop+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+/* Define $2 to an innocuous variant, in case <limits.h> declares $2.+ For example, HP-UX 11i <limits.h> declares gettimeofday. */+#define $2 innocuous_$2++/* System header to define __stub macros and hopefully few prototypes,+ which can conflict with char $2 (); below. */++#include <limits.h>+#undef $2++/* Override any GCC internal prototype to avoid an error.+ Use char because int might match the return type of a GCC+ builtin and then its argument prototype would still apply. */+#ifdef __cplusplus+extern "C"+#endif+char $2 ();+/* The GNU C library defines this for functions which it implements+ to always fail with ENOSYS. Some functions are actually named+ something starting with __ and the normal name is an alias. */+#if defined __stub_$2 || defined __stub___$2+choke me+#endif++int+main (void)+{+return $2 ();+ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_link "$LINENO"+then :+ eval "$3=yes"+else $as_nop+ eval "$3=no"+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam \+ conftest$ac_exeext conftest.$ac_ext+fi+eval ac_res=\$$3+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5+printf "%s\n" "$ac_res" >&6; }+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno++} # ac_fn_c_check_func++# ac_fn_c_check_member LINENO AGGR MEMBER VAR INCLUDES+# ----------------------------------------------------+# Tries to find if the field MEMBER exists in type AGGR, after including+# INCLUDES, setting cache variable VAR accordingly.+ac_fn_c_check_member ()+{+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $2.$3" >&5+printf %s "checking for $2.$3... " >&6; }+if eval test \${$4+y}+then :+ printf %s "(cached) " >&6+else $as_nop+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+$5+int+main (void)+{+static $2 ac_aggr;+if (ac_aggr.$3)+return 0;+ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_compile "$LINENO"+then :+ eval "$4=yes"+else $as_nop+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+$5+int+main (void)+{+static $2 ac_aggr;+if (sizeof ac_aggr.$3)+return 0;+ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_compile "$LINENO"+then :+ eval "$4=yes"+else $as_nop+ eval "$4=no"+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext+fi+eval ac_res=\$$4+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5+printf "%s\n" "$ac_res" >&6; }+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno++} # ac_fn_c_check_member++# ac_fn_check_decl LINENO SYMBOL VAR INCLUDES EXTRA-OPTIONS FLAG-VAR+# ------------------------------------------------------------------+# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR+# accordingly. Pass EXTRA-OPTIONS to the compiler, using FLAG-VAR.+ac_fn_check_decl ()+{+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack+ as_decl_name=`echo $2|sed 's/ *(.*//'`+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5+printf %s "checking whether $as_decl_name is declared... " >&6; }+if eval test \${$3+y}+then :+ printf %s "(cached) " >&6+else $as_nop+ as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`+ eval ac_save_FLAGS=\$$6+ as_fn_append $6 " $5"+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+$4+int+main (void)+{+#ifndef $as_decl_name+#ifdef __cplusplus+ (void) $as_decl_use;+#else+ (void) $as_decl_name;+#endif+#endif++ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_compile "$LINENO"+then :+ eval "$3=yes"+else $as_nop+ eval "$3=no"+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext+ eval $6=\$ac_save_FLAGS++fi+eval ac_res=\$$3+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5+printf "%s\n" "$ac_res" >&6; }+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno++} # ac_fn_check_decl+ac_configure_args_raw=+for ac_arg+do+ case $ac_arg in+ *\'*)+ ac_arg=`printf "%s\n" "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;+ esac+ as_fn_append ac_configure_args_raw " '$ac_arg'"+done++case $ac_configure_args_raw in+ *$as_nl*)+ ac_safe_unquote= ;;+ *)+ ac_unsafe_z='|&;<>()$`\\"*?[ '' ' # This string ends in space, tab.+ ac_unsafe_a="$ac_unsafe_z#~"+ ac_safe_unquote="s/ '\\([^$ac_unsafe_a][^$ac_unsafe_z]*\\)'/ \\1/g"+ ac_configure_args_raw=` printf "%s\n" "$ac_configure_args_raw" | sed "$ac_safe_unquote"`;;+esac++cat >config.log <<_ACEOF+This file contains any messages produced by compilers while+running configure, to aid debugging if configure makes a mistake.++It was created by Haskell time package $as_me 1.16, which was+generated by GNU Autoconf 2.71. Invocation command line was++ $ $0$ac_configure_args_raw++_ACEOF+exec 5>>config.log+{+cat <<_ASUNAME+## --------- ##+## Platform. ##+## --------- ##++hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`+uname -m = `(uname -m) 2>/dev/null || echo unknown`+uname -r = `(uname -r) 2>/dev/null || echo unknown`+uname -s = `(uname -s) 2>/dev/null || echo unknown`+uname -v = `(uname -v) 2>/dev/null || echo unknown`++/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`+/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown`++/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown`+/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown`+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`+/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown`+/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown`+/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown`+/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown`++_ASUNAME++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ printf "%s\n" "PATH: $as_dir"+ done+IFS=$as_save_IFS++} >&5++cat >&5 <<_ACEOF+++## ----------- ##+## Core tests. ##+## ----------- ##++_ACEOF+++# Keep a trace of the command line.+# Strip out --no-create and --no-recursion so they do not pile up.+# Strip out --silent because we don't want to record it for future runs.+# Also quote any args containing shell meta-characters.+# Make two passes to allow for proper duplicate-argument suppression.+ac_configure_args=+ac_configure_args0=+ac_configure_args1=+ac_must_keep_next=false+for ac_pass in 1 2+do+ for ac_arg+ do+ case $ac_arg in+ -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \+ | -silent | --silent | --silen | --sile | --sil)+ continue ;;+ *\'*)+ ac_arg=`printf "%s\n" "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;+ esac+ case $ac_pass in+ 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;;+ 2)+ as_fn_append ac_configure_args1 " '$ac_arg'"+ if test $ac_must_keep_next = true; then+ ac_must_keep_next=false # Got value, back to normal.+ else+ case $ac_arg in+ *=* | --config-cache | -C | -disable-* | --disable-* \+ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \+ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \+ | -with-* | --with-* | -without-* | --without-* | --x)+ case "$ac_configure_args0 " in+ "$ac_configure_args1"*" '$ac_arg' "* ) continue ;;+ esac+ ;;+ -* ) ac_must_keep_next=true ;;+ esac+ fi+ as_fn_append ac_configure_args " '$ac_arg'"+ ;;+ esac+ done+done+{ ac_configure_args0=; unset ac_configure_args0;}+{ ac_configure_args1=; unset ac_configure_args1;}++# When interrupted or exit'd, cleanup temporary files, and complete+# config.log. We remove comments because anyway the quotes in there+# would cause problems or look ugly.+# WARNING: Use '\'' to represent an apostrophe within the trap.+# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug.+trap 'exit_status=$?+ # Sanitize IFS.+ IFS=" "" $as_nl"+ # Save into config.log some information that might help in debugging.+ {+ echo++ printf "%s\n" "## ---------------- ##+## Cache variables. ##+## ---------------- ##"+ echo+ # The following way of writing the cache mishandles newlines in values,+(+ for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do+ eval ac_val=\$$ac_var+ case $ac_val in #(+ *${as_nl}*)+ case $ac_var in #(+ *_cv_*) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5+printf "%s\n" "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;+ esac+ case $ac_var in #(+ _ | IFS | as_nl) ;; #(+ BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(+ *) { eval $ac_var=; unset $ac_var;} ;;+ esac ;;+ esac+ done+ (set) 2>&1 |+ case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #(+ *${as_nl}ac_space=\ *)+ sed -n \+ "s/'\''/'\''\\\\'\'''\''/g;+ s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p"+ ;; #(+ *)+ sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"+ ;;+ esac |+ sort+)+ echo++ printf "%s\n" "## ----------------- ##+## Output variables. ##+## ----------------- ##"+ echo+ for ac_var in $ac_subst_vars+ do+ eval ac_val=\$$ac_var+ case $ac_val in+ *\'\''*) ac_val=`printf "%s\n" "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;+ esac+ printf "%s\n" "$ac_var='\''$ac_val'\''"+ done | sort+ echo++ if test -n "$ac_subst_files"; then+ printf "%s\n" "## ------------------- ##+## File substitutions. ##+## ------------------- ##"+ echo+ for ac_var in $ac_subst_files+ do+ eval ac_val=\$$ac_var+ case $ac_val in+ *\'\''*) ac_val=`printf "%s\n" "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;+ esac+ printf "%s\n" "$ac_var='\''$ac_val'\''"+ done | sort+ echo+ fi++ if test -s confdefs.h; then+ printf "%s\n" "## ----------- ##+## confdefs.h. ##+## ----------- ##"+ echo+ cat confdefs.h+ echo+ fi+ test "$ac_signal" != 0 &&+ printf "%s\n" "$as_me: caught signal $ac_signal"+ printf "%s\n" "$as_me: exit $exit_status"+ } >&5+ rm -f core *.core core.conftest.* &&+ rm -f -r conftest* confdefs* conf$$* $ac_clean_files &&+ exit $exit_status+' 0+for ac_signal in 1 2 13 15; do+ trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal+done+ac_signal=0++# confdefs.h avoids OS command line length limits that DEFS can exceed.+rm -f -r conftest* confdefs.h++printf "%s\n" "/* confdefs.h */" > confdefs.h++# Predefined preprocessor variables.++printf "%s\n" "#define PACKAGE_NAME \"$PACKAGE_NAME\"" >>confdefs.h++printf "%s\n" "#define PACKAGE_TARNAME \"$PACKAGE_TARNAME\"" >>confdefs.h++printf "%s\n" "#define PACKAGE_VERSION \"$PACKAGE_VERSION\"" >>confdefs.h++printf "%s\n" "#define PACKAGE_STRING \"$PACKAGE_STRING\"" >>confdefs.h++printf "%s\n" "#define PACKAGE_BUGREPORT \"$PACKAGE_BUGREPORT\"" >>confdefs.h++printf "%s\n" "#define PACKAGE_URL \"$PACKAGE_URL\"" >>confdefs.h+++# Let the site file select an alternate cache file if it wants to.+# Prefer an explicitly selected file to automatically selected ones.+if test -n "$CONFIG_SITE"; then+ ac_site_files="$CONFIG_SITE"+elif test "x$prefix" != xNONE; then+ ac_site_files="$prefix/share/config.site $prefix/etc/config.site"+else+ ac_site_files="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"+fi++for ac_site_file in $ac_site_files+do+ case $ac_site_file in #(+ */*) :+ ;; #(+ *) :+ ac_site_file=./$ac_site_file ;;+esac+ if test -f "$ac_site_file" && test -r "$ac_site_file"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5+printf "%s\n" "$as_me: loading site script $ac_site_file" >&6;}+ sed 's/^/| /' "$ac_site_file" >&5+ . "$ac_site_file" \+ || { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5+printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;}+as_fn_error $? "failed to load site script $ac_site_file+See \`config.log' for more details" "$LINENO" 5; }+ fi+done++if test -r "$cache_file"; then+ # Some versions of bash will fail to source /dev/null (special files+ # actually), so we avoid doing that. DJGPP emulates it as a regular file.+ if test /dev/null != "$cache_file" && test -f "$cache_file"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5+printf "%s\n" "$as_me: loading cache $cache_file" >&6;}+ case $cache_file in+ [\\/]* | ?:[\\/]* ) . "$cache_file";;+ *) . "./$cache_file";;+ esac+ fi+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5+printf "%s\n" "$as_me: creating cache $cache_file" >&6;}+ >$cache_file+fi++# Test code for whether the C compiler supports C89 (global declarations)+ac_c_conftest_c89_globals='+/* Does the compiler advertise C89 conformance?+ Do not test the value of __STDC__, because some compilers set it to 0+ while being otherwise adequately conformant. */+#if !defined __STDC__+# error "Compiler does not advertise C89 conformance"+#endif++#include <stddef.h>+#include <stdarg.h>+struct stat;+/* Most of the following tests are stolen from RCS 5.7 src/conf.sh. */+struct buf { int x; };+struct buf * (*rcsopen) (struct buf *, struct stat *, int);+static char *e (p, i)+ char **p;+ int i;+{+ return p[i];+}+static char *f (char * (*g) (char **, int), char **p, ...)+{+ char *s;+ va_list v;+ va_start (v,p);+ s = g (p, va_arg (v,int));+ va_end (v);+ return s;+}++/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has+ function prototypes and stuff, but not \xHH hex character constants.+ These do not provoke an error unfortunately, instead are silently treated+ as an "x". The following induces an error, until -std is added to get+ proper ANSI mode. Curiously \x00 != x always comes out true, for an+ array size at least. It is necessary to write \x00 == 0 to get something+ that is true only with -std. */+int osf4_cc_array ['\''\x00'\'' == 0 ? 1 : -1];++/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters+ inside strings and character constants. */+#define FOO(x) '\''x'\''+int xlc6_cc_array[FOO(a) == '\''x'\'' ? 1 : -1];++int test (int i, double x);+struct s1 {int (*f) (int a);};+struct s2 {int (*f) (double a);};+int pairnames (int, char **, int *(*)(struct buf *, struct stat *, int),+ int, int);'++# Test code for whether the C compiler supports C89 (body of main).+ac_c_conftest_c89_main='+ok |= (argc == 0 || f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]);+'++# Test code for whether the C compiler supports C99 (global declarations)+ac_c_conftest_c99_globals='+// Does the compiler advertise C99 conformance?+#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L+# error "Compiler does not advertise C99 conformance"+#endif++#include <stdbool.h>+extern int puts (const char *);+extern int printf (const char *, ...);+extern int dprintf (int, const char *, ...);+extern void *malloc (size_t);++// Check varargs macros. These examples are taken from C99 6.10.3.5.+// dprintf is used instead of fprintf to avoid needing to declare+// FILE and stderr.+#define debug(...) dprintf (2, __VA_ARGS__)+#define showlist(...) puts (#__VA_ARGS__)+#define report(test,...) ((test) ? puts (#test) : printf (__VA_ARGS__))+static void+test_varargs_macros (void)+{+ int x = 1234;+ int y = 5678;+ debug ("Flag");+ debug ("X = %d\n", x);+ showlist (The first, second, and third items.);+ report (x>y, "x is %d but y is %d", x, y);+}++// Check long long types.+#define BIG64 18446744073709551615ull+#define BIG32 4294967295ul+#define BIG_OK (BIG64 / BIG32 == 4294967297ull && BIG64 % BIG32 == 0)+#if !BIG_OK+ #error "your preprocessor is broken"+#endif+#if BIG_OK+#else+ #error "your preprocessor is broken"+#endif+static long long int bignum = -9223372036854775807LL;+static unsigned long long int ubignum = BIG64;++struct incomplete_array+{+ int datasize;+ double data[];+};++struct named_init {+ int number;+ const wchar_t *name;+ double average;+};++typedef const char *ccp;++static inline int+test_restrict (ccp restrict text)+{+ // See if C++-style comments work.+ // Iterate through items via the restricted pointer.+ // Also check for declarations in for loops.+ for (unsigned int i = 0; *(text+i) != '\''\0'\''; ++i)+ continue;+ return 0;+}++// Check varargs and va_copy.+static bool+test_varargs (const char *format, ...)+{+ va_list args;+ va_start (args, format);+ va_list args_copy;+ va_copy (args_copy, args);++ const char *str = "";+ int number = 0;+ float fnumber = 0;++ while (*format)+ {+ switch (*format++)+ {+ case '\''s'\'': // string+ str = va_arg (args_copy, const char *);+ break;+ case '\''d'\'': // int+ number = va_arg (args_copy, int);+ break;+ case '\''f'\'': // float+ fnumber = va_arg (args_copy, double);+ break;+ default:+ break;+ }+ }+ va_end (args_copy);+ va_end (args);++ return *str && number && fnumber;+}+'++# Test code for whether the C compiler supports C99 (body of main).+ac_c_conftest_c99_main='+ // Check bool.+ _Bool success = false;+ success |= (argc != 0);++ // Check restrict.+ if (test_restrict ("String literal") == 0)+ success = true;+ char *restrict newvar = "Another string";++ // Check varargs.+ success &= test_varargs ("s, d'\'' f .", "string", 65, 34.234);+ test_varargs_macros ();++ // Check flexible array members.+ struct incomplete_array *ia =+ malloc (sizeof (struct incomplete_array) + (sizeof (double) * 10));+ ia->datasize = 10;+ for (int i = 0; i < ia->datasize; ++i)+ ia->data[i] = i * 1.234;++ // Check named initializers.+ struct named_init ni = {+ .number = 34,+ .name = L"Test wide string",+ .average = 543.34343,+ };++ ni.number = 58;++ int dynamic_array[ni.number];+ dynamic_array[0] = argv[0][0];+ dynamic_array[ni.number - 1] = 543;++ // work around unused variable warnings+ ok |= (!success || bignum == 0LL || ubignum == 0uLL || newvar[0] == '\''x'\''+ || dynamic_array[ni.number - 1] != 543);+'++# Test code for whether the C compiler supports C11 (global declarations)+ac_c_conftest_c11_globals='+// Does the compiler advertise C11 conformance?+#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112L+# error "Compiler does not advertise C11 conformance"+#endif++// Check _Alignas.+char _Alignas (double) aligned_as_double;+char _Alignas (0) no_special_alignment;+extern char aligned_as_int;+char _Alignas (0) _Alignas (int) aligned_as_int;++// Check _Alignof.+enum+{+ int_alignment = _Alignof (int),+ int_array_alignment = _Alignof (int[100]),+ char_alignment = _Alignof (char)+};+_Static_assert (0 < -_Alignof (int), "_Alignof is signed");++// Check _Noreturn.+int _Noreturn does_not_return (void) { for (;;) continue; }++// Check _Static_assert.+struct test_static_assert+{+ int x;+ _Static_assert (sizeof (int) <= sizeof (long int),+ "_Static_assert does not work in struct");+ long int y;+};++// Check UTF-8 literals.+#define u8 syntax error!+char const utf8_literal[] = u8"happens to be ASCII" "another string";++// Check duplicate typedefs.+typedef long *long_ptr;+typedef long int *long_ptr;+typedef long_ptr long_ptr;++// Anonymous structures and unions -- taken from C11 6.7.2.1 Example 1.+struct anonymous+{+ union {+ struct { int i; int j; };+ struct { int k; long int l; } w;+ };+ int m;+} v1;+'++# Test code for whether the C compiler supports C11 (body of main).+ac_c_conftest_c11_main='+ _Static_assert ((offsetof (struct anonymous, i)+ == offsetof (struct anonymous, w.k)),+ "Anonymous union alignment botch");+ v1.i = 2;+ v1.w.k = 5;+ ok |= v1.i != 5;+'++# Test code for whether the C compiler supports C11 (complete).+ac_c_conftest_c11_program="${ac_c_conftest_c89_globals}+${ac_c_conftest_c99_globals}+${ac_c_conftest_c11_globals}++int+main (int argc, char **argv)+{+ int ok = 0;+ ${ac_c_conftest_c89_main}+ ${ac_c_conftest_c99_main}+ ${ac_c_conftest_c11_main}+ return ok;+}+"++# Test code for whether the C compiler supports C99 (complete).+ac_c_conftest_c99_program="${ac_c_conftest_c89_globals}+${ac_c_conftest_c99_globals}++int+main (int argc, char **argv)+{+ int ok = 0;+ ${ac_c_conftest_c89_main}+ ${ac_c_conftest_c99_main}+ return ok;+}+"++# Test code for whether the C compiler supports C89 (complete).+ac_c_conftest_c89_program="${ac_c_conftest_c89_globals}++int+main (int argc, char **argv)+{+ int ok = 0;+ ${ac_c_conftest_c89_main}+ return ok;+}+"++as_fn_append ac_header_c_list " stdio.h stdio_h HAVE_STDIO_H"+as_fn_append ac_header_c_list " stdlib.h stdlib_h HAVE_STDLIB_H"+as_fn_append ac_header_c_list " string.h string_h HAVE_STRING_H"+as_fn_append ac_header_c_list " inttypes.h inttypes_h HAVE_INTTYPES_H"+as_fn_append ac_header_c_list " stdint.h stdint_h HAVE_STDINT_H"+as_fn_append ac_header_c_list " strings.h strings_h HAVE_STRINGS_H"+as_fn_append ac_header_c_list " sys/stat.h sys_stat_h HAVE_SYS_STAT_H"+as_fn_append ac_header_c_list " sys/types.h sys_types_h HAVE_SYS_TYPES_H"+as_fn_append ac_header_c_list " unistd.h unistd_h HAVE_UNISTD_H"+as_fn_append ac_header_c_list " wchar.h wchar_h HAVE_WCHAR_H"+as_fn_append ac_header_c_list " minix/config.h minix_config_h HAVE_MINIX_CONFIG_H"+as_fn_append ac_header_c_list " sys/time.h sys_time_h HAVE_SYS_TIME_H"+# Check that the precious variables saved in the cache have kept the same+# value.+ac_cache_corrupted=false+for ac_var in $ac_precious_vars; do+ eval ac_old_set=\$ac_cv_env_${ac_var}_set+ eval ac_new_set=\$ac_env_${ac_var}_set+ eval ac_old_val=\$ac_cv_env_${ac_var}_value+ eval ac_new_val=\$ac_env_${ac_var}_value+ case $ac_old_set,$ac_new_set in+ set,)+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5+printf "%s\n" "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}+ ac_cache_corrupted=: ;;+ ,set)+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5+printf "%s\n" "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}+ ac_cache_corrupted=: ;;+ ,);;+ *)+ if test "x$ac_old_val" != "x$ac_new_val"; then+ # differences in whitespace do not lead to failure.+ ac_old_val_w=`echo x $ac_old_val`+ ac_new_val_w=`echo x $ac_new_val`+ if test "$ac_old_val_w" != "$ac_new_val_w"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5+printf "%s\n" "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}+ ac_cache_corrupted=:+ else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5+printf "%s\n" "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;}+ eval $ac_var=\$ac_old_val+ fi+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5+printf "%s\n" "$as_me: former value: \`$ac_old_val'" >&2;}+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5+printf "%s\n" "$as_me: current value: \`$ac_new_val'" >&2;}+ fi;;+ esac+ # Pass precious variables to config.status.+ if test "$ac_new_set" = set; then+ case $ac_new_val in+ *\'*) ac_arg=$ac_var=`printf "%s\n" "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;+ *) ac_arg=$ac_var=$ac_new_val ;;+ esac+ case " $ac_configure_args " in+ *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy.+ *) as_fn_append ac_configure_args " '$ac_arg'" ;;+ esac+ fi+done+if $ac_cache_corrupted; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5+printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;}+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5+printf "%s\n" "$as_me: error: changes in the environment can compromise the build" >&2;}+ as_fn_error $? "run \`${MAKE-make} distclean' and/or \`rm $cache_file'+ and start over" "$LINENO" 5+fi+## -------------------- ##+## Main body of script. ##+## -------------------- ##++ac_ext=c+ac_cpp='$CPP $CPPFLAGS'+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'+ac_compiler_gnu=$ac_cv_c_compiler_gnu++++# Safety check: Ensure that we are in the correct source directory.+++# These are to silence warnings with older Cabal versions++# Check whether --with-gcc was given.+if test ${with_gcc+y}+then :+ withval=$with_gcc;+fi+++# Check whether --with-compiler was given.+if test ${with_compiler+y}+then :+ withval=$with_compiler;+fi++++++++++++ac_ext=c+ac_cpp='$CPP $CPPFLAGS'+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'+ac_compiler_gnu=$ac_cv_c_compiler_gnu+if test -n "$ac_tool_prefix"; then+ # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.+set dummy ${ac_tool_prefix}gcc; ac_word=$2+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+printf %s "checking for $ac_word... " >&6; }+if test ${ac_cv_prog_CC+y}+then :+ printf %s "(cached) " >&6+else $as_nop+ if test -n "$CC"; then+ ac_cv_prog_CC="$CC" # Let the user override the test.+else+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_exec_ext in '' $ac_executable_extensions; do+ if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then+ ac_cv_prog_CC="${ac_tool_prefix}gcc"+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5+ break 2+ fi+done+ done+IFS=$as_save_IFS++fi+fi+CC=$ac_cv_prog_CC+if test -n "$CC"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5+printf "%s\n" "$CC" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi+++fi+if test -z "$ac_cv_prog_CC"; then+ ac_ct_CC=$CC+ # Extract the first word of "gcc", so it can be a program name with args.+set dummy gcc; ac_word=$2+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+printf %s "checking for $ac_word... " >&6; }+if test ${ac_cv_prog_ac_ct_CC+y}+then :+ printf %s "(cached) " >&6+else $as_nop+ if test -n "$ac_ct_CC"; then+ ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.+else+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_exec_ext in '' $ac_executable_extensions; do+ if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then+ ac_cv_prog_ac_ct_CC="gcc"+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5+ break 2+ fi+done+ done+IFS=$as_save_IFS++fi+fi+ac_ct_CC=$ac_cv_prog_ac_ct_CC+if test -n "$ac_ct_CC"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5+printf "%s\n" "$ac_ct_CC" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi++ if test "x$ac_ct_CC" = x; then+ CC=""+ else+ case $cross_compiling:$ac_tool_warned in+yes:)+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5+printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}+ac_tool_warned=yes ;;+esac+ CC=$ac_ct_CC+ fi+else+ CC="$ac_cv_prog_CC"+fi++if test -z "$CC"; then+ if test -n "$ac_tool_prefix"; then+ # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.+set dummy ${ac_tool_prefix}cc; ac_word=$2+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+printf %s "checking for $ac_word... " >&6; }+if test ${ac_cv_prog_CC+y}+then :+ printf %s "(cached) " >&6+else $as_nop+ if test -n "$CC"; then+ ac_cv_prog_CC="$CC" # Let the user override the test.+else+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_exec_ext in '' $ac_executable_extensions; do+ if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then+ ac_cv_prog_CC="${ac_tool_prefix}cc"+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5+ break 2+ fi+done+ done+IFS=$as_save_IFS++fi+fi+CC=$ac_cv_prog_CC+if test -n "$CC"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5+printf "%s\n" "$CC" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi+++ fi+fi+if test -z "$CC"; then+ # Extract the first word of "cc", so it can be a program name with args.+set dummy cc; ac_word=$2+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+printf %s "checking for $ac_word... " >&6; }+if test ${ac_cv_prog_CC+y}+then :+ printf %s "(cached) " >&6+else $as_nop+ if test -n "$CC"; then+ ac_cv_prog_CC="$CC" # Let the user override the test.+else+ ac_prog_rejected=no+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_exec_ext in '' $ac_executable_extensions; do+ if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then+ if test "$as_dir$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then+ ac_prog_rejected=yes+ continue+ fi+ ac_cv_prog_CC="cc"+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5+ break 2+ fi+done+ done+IFS=$as_save_IFS++if test $ac_prog_rejected = yes; then+ # We found a bogon in the path, so make sure we never use it.+ set dummy $ac_cv_prog_CC+ shift+ if test $# != 0; then+ # We chose a different compiler from the bogus one.+ # However, it has the same basename, so the bogon will be chosen+ # first if we set CC to just the basename; use the full file name.+ shift+ ac_cv_prog_CC="$as_dir$ac_word${1+' '}$@"+ fi+fi+fi+fi+CC=$ac_cv_prog_CC+if test -n "$CC"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5+printf "%s\n" "$CC" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi+++fi+if test -z "$CC"; then+ if test -n "$ac_tool_prefix"; then+ for ac_prog in cl.exe+ do+ # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.+set dummy $ac_tool_prefix$ac_prog; ac_word=$2+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+printf %s "checking for $ac_word... " >&6; }+if test ${ac_cv_prog_CC+y}+then :+ printf %s "(cached) " >&6+else $as_nop+ if test -n "$CC"; then+ ac_cv_prog_CC="$CC" # Let the user override the test.+else+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_exec_ext in '' $ac_executable_extensions; do+ if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then+ ac_cv_prog_CC="$ac_tool_prefix$ac_prog"+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5+ break 2+ fi+done+ done+IFS=$as_save_IFS++fi+fi+CC=$ac_cv_prog_CC+if test -n "$CC"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5+printf "%s\n" "$CC" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi+++ test -n "$CC" && break+ done+fi+if test -z "$CC"; then+ ac_ct_CC=$CC+ for ac_prog in cl.exe+do+ # Extract the first word of "$ac_prog", so it can be a program name with args.+set dummy $ac_prog; ac_word=$2+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+printf %s "checking for $ac_word... " >&6; }+if test ${ac_cv_prog_ac_ct_CC+y}+then :+ printf %s "(cached) " >&6+else $as_nop+ if test -n "$ac_ct_CC"; then+ ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.+else+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_exec_ext in '' $ac_executable_extensions; do+ if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then+ ac_cv_prog_ac_ct_CC="$ac_prog"+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5+ break 2+ fi+done+ done+IFS=$as_save_IFS++fi+fi+ac_ct_CC=$ac_cv_prog_ac_ct_CC+if test -n "$ac_ct_CC"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5+printf "%s\n" "$ac_ct_CC" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi+++ test -n "$ac_ct_CC" && break+done++ if test "x$ac_ct_CC" = x; then+ CC=""+ else+ case $cross_compiling:$ac_tool_warned in+yes:)+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5+printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}+ac_tool_warned=yes ;;+esac+ CC=$ac_ct_CC+ fi+fi++fi+if test -z "$CC"; then+ if test -n "$ac_tool_prefix"; then+ # Extract the first word of "${ac_tool_prefix}clang", so it can be a program name with args.+set dummy ${ac_tool_prefix}clang; ac_word=$2+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+printf %s "checking for $ac_word... " >&6; }+if test ${ac_cv_prog_CC+y}+then :+ printf %s "(cached) " >&6+else $as_nop+ if test -n "$CC"; then+ ac_cv_prog_CC="$CC" # Let the user override the test.+else+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_exec_ext in '' $ac_executable_extensions; do+ if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then+ ac_cv_prog_CC="${ac_tool_prefix}clang"+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5+ break 2+ fi+done+ done+IFS=$as_save_IFS++fi+fi+CC=$ac_cv_prog_CC+if test -n "$CC"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5+printf "%s\n" "$CC" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi+++fi+if test -z "$ac_cv_prog_CC"; then+ ac_ct_CC=$CC+ # Extract the first word of "clang", so it can be a program name with args.+set dummy clang; ac_word=$2+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+printf %s "checking for $ac_word... " >&6; }+if test ${ac_cv_prog_ac_ct_CC+y}+then :+ printf %s "(cached) " >&6+else $as_nop+ if test -n "$ac_ct_CC"; then+ ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.+else+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_exec_ext in '' $ac_executable_extensions; do+ if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then+ ac_cv_prog_ac_ct_CC="clang"+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5+ break 2+ fi+done+ done+IFS=$as_save_IFS++fi+fi+ac_ct_CC=$ac_cv_prog_ac_ct_CC+if test -n "$ac_ct_CC"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5+printf "%s\n" "$ac_ct_CC" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi++ if test "x$ac_ct_CC" = x; then+ CC=""+ else+ case $cross_compiling:$ac_tool_warned in+yes:)+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5+printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}+ac_tool_warned=yes ;;+esac+ CC=$ac_ct_CC+ fi+else+ CC="$ac_cv_prog_CC"+fi++fi+++test -z "$CC" && { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5+printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;}+as_fn_error $? "no acceptable C compiler found in \$PATH+See \`config.log' for more details" "$LINENO" 5; }++# Provide some information about the compiler.+printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5+set X $ac_compile+ac_compiler=$2+for ac_option in --version -v -V -qversion -version; do+ { { ac_try="$ac_compiler $ac_option >&5"+case "(($ac_try" in+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;+ *) ac_try_echo=$ac_try;;+esac+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""+printf "%s\n" "$ac_try_echo"; } >&5+ (eval "$ac_compiler $ac_option >&5") 2>conftest.err+ ac_status=$?+ if test -s conftest.err; then+ sed '10a\+... rest of stderr output deleted ...+ 10q' conftest.err >conftest.er1+ cat conftest.er1 >&5+ fi+ rm -f conftest.er1 conftest.err+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5+ test $ac_status = 0; }+done++cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++int+main (void)+{++ ;+ return 0;+}+_ACEOF+ac_clean_files_save=$ac_clean_files+ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out"+# Try to create an executable without -o first, disregard a.out.+# It will help us diagnose broken compilers, and finding out an intuition+# of exeext.+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5+printf %s "checking whether the C compiler works... " >&6; }+ac_link_default=`printf "%s\n" "$ac_link" | sed 's/ -o *conftest[^ ]*//'`++# The possible output files:+ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*"++ac_rmfiles=+for ac_file in $ac_files+do+ case $ac_file in+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;+ * ) ac_rmfiles="$ac_rmfiles $ac_file";;+ esac+done+rm -f $ac_rmfiles++if { { ac_try="$ac_link_default"+case "(($ac_try" in+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;+ *) ac_try_echo=$ac_try;;+esac+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""+printf "%s\n" "$ac_try_echo"; } >&5+ (eval "$ac_link_default") 2>&5+ ac_status=$?+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5+ test $ac_status = 0; }+then :+ # Autoconf-2.13 could set the ac_cv_exeext variable to `no'.+# So ignore a value of `no', otherwise this would lead to `EXEEXT = no'+# in a Makefile. We should not override ac_cv_exeext if it was cached,+# so that the user can short-circuit this test for compilers unknown to+# Autoconf.+for ac_file in $ac_files ''+do+ test -f "$ac_file" || continue+ case $ac_file in+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj )+ ;;+ [ab].out )+ # We found the default executable, but exeext='' is most+ # certainly right.+ break;;+ *.* )+ if test ${ac_cv_exeext+y} && test "$ac_cv_exeext" != no;+ then :; else+ ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`+ fi+ # We set ac_cv_exeext here because the later test for it is not+ # safe: cross compilers may not add the suffix if given an `-o'+ # argument, so we may need to know it at that point already.+ # Even if this section looks crufty: it has the advantage of+ # actually working.+ break;;+ * )+ break;;+ esac+done+test "$ac_cv_exeext" = no && ac_cv_exeext=++else $as_nop+ ac_file=''+fi+if test -z "$ac_file"+then :+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+printf "%s\n" "$as_me: failed program was:" >&5+sed 's/^/| /' conftest.$ac_ext >&5++{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5+printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;}+as_fn_error 77 "C compiler cannot create executables+See \`config.log' for more details" "$LINENO" 5; }+else $as_nop+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5+printf "%s\n" "yes" >&6; }+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5+printf %s "checking for C compiler default output file name... " >&6; }+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5+printf "%s\n" "$ac_file" >&6; }+ac_exeext=$ac_cv_exeext++rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out+ac_clean_files=$ac_clean_files_save+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5+printf %s "checking for suffix of executables... " >&6; }+if { { ac_try="$ac_link"+case "(($ac_try" in+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;+ *) ac_try_echo=$ac_try;;+esac+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""+printf "%s\n" "$ac_try_echo"; } >&5+ (eval "$ac_link") 2>&5+ ac_status=$?+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5+ test $ac_status = 0; }+then :+ # If both `conftest.exe' and `conftest' are `present' (well, observable)+# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will+# work properly (i.e., refer to `conftest.exe'), while it won't with+# `rm'.+for ac_file in conftest.exe conftest conftest.*; do+ test -f "$ac_file" || continue+ case $ac_file in+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;+ *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`+ break;;+ * ) break;;+ esac+done+else $as_nop+ { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5+printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;}+as_fn_error $? "cannot compute suffix of executables: cannot compile and link+See \`config.log' for more details" "$LINENO" 5; }+fi+rm -f conftest conftest$ac_cv_exeext+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5+printf "%s\n" "$ac_cv_exeext" >&6; }++rm -f conftest.$ac_ext+EXEEXT=$ac_cv_exeext+ac_exeext=$EXEEXT+cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+#include <stdio.h>+int+main (void)+{+FILE *f = fopen ("conftest.out", "w");+ return ferror (f) || fclose (f) != 0;++ ;+ return 0;+}+_ACEOF+ac_clean_files="$ac_clean_files conftest.out"+# Check that the compiler produces executables we can run. If not, either+# the compiler is broken, or we cross compile.+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5+printf %s "checking whether we are cross compiling... " >&6; }+if test "$cross_compiling" != yes; then+ { { ac_try="$ac_link"+case "(($ac_try" in+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;+ *) ac_try_echo=$ac_try;;+esac+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""+printf "%s\n" "$ac_try_echo"; } >&5+ (eval "$ac_link") 2>&5+ ac_status=$?+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5+ test $ac_status = 0; }+ if { ac_try='./conftest$ac_cv_exeext'+ { { case "(($ac_try" in+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;+ *) ac_try_echo=$ac_try;;+esac+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""+printf "%s\n" "$ac_try_echo"; } >&5+ (eval "$ac_try") 2>&5+ ac_status=$?+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5+ test $ac_status = 0; }; }; then+ cross_compiling=no+ else+ if test "$cross_compiling" = maybe; then+ cross_compiling=yes+ else+ { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5+printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;}+as_fn_error 77 "cannot run C compiled programs.+If you meant to cross compile, use \`--host'.+See \`config.log' for more details" "$LINENO" 5; }+ fi+ fi+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5+printf "%s\n" "$cross_compiling" >&6; }++rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out+ac_clean_files=$ac_clean_files_save+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5+printf %s "checking for suffix of object files... " >&6; }+if test ${ac_cv_objext+y}+then :+ printf %s "(cached) " >&6+else $as_nop+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++int+main (void)+{++ ;+ return 0;+}+_ACEOF+rm -f conftest.o conftest.obj+if { { ac_try="$ac_compile"+case "(($ac_try" in+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;+ *) ac_try_echo=$ac_try;;+esac+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""+printf "%s\n" "$ac_try_echo"; } >&5+ (eval "$ac_compile") 2>&5+ ac_status=$?+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5+ test $ac_status = 0; }+then :+ for ac_file in conftest.o conftest.obj conftest.*; do+ test -f "$ac_file" || continue;+ case $ac_file in+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;;+ *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`+ break;;+ esac+done+else $as_nop+ printf "%s\n" "$as_me: failed program was:" >&5+sed 's/^/| /' conftest.$ac_ext >&5++{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5+printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;}+as_fn_error $? "cannot compute suffix of object files: cannot compile+See \`config.log' for more details" "$LINENO" 5; }+fi+rm -f conftest.$ac_cv_objext conftest.$ac_ext+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5+printf "%s\n" "$ac_cv_objext" >&6; }+OBJEXT=$ac_cv_objext+ac_objext=$OBJEXT+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports GNU C" >&5+printf %s "checking whether the compiler supports GNU C... " >&6; }+if test ${ac_cv_c_compiler_gnu+y}+then :+ printf %s "(cached) " >&6+else $as_nop+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++int+main (void)+{+#ifndef __GNUC__+ choke me+#endif++ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_compile "$LINENO"+then :+ ac_compiler_gnu=yes+else $as_nop+ ac_compiler_gnu=no+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext+ac_cv_c_compiler_gnu=$ac_compiler_gnu++fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5+printf "%s\n" "$ac_cv_c_compiler_gnu" >&6; }+ac_compiler_gnu=$ac_cv_c_compiler_gnu++if test $ac_compiler_gnu = yes; then+ GCC=yes+else+ GCC=+fi+ac_test_CFLAGS=${CFLAGS+y}+ac_save_CFLAGS=$CFLAGS+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5+printf %s "checking whether $CC accepts -g... " >&6; }+if test ${ac_cv_prog_cc_g+y}+then :+ printf %s "(cached) " >&6+else $as_nop+ ac_save_c_werror_flag=$ac_c_werror_flag+ ac_c_werror_flag=yes+ ac_cv_prog_cc_g=no+ CFLAGS="-g"+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++int+main (void)+{++ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_compile "$LINENO"+then :+ ac_cv_prog_cc_g=yes+else $as_nop+ CFLAGS=""+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++int+main (void)+{++ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_compile "$LINENO"+then :++else $as_nop+ ac_c_werror_flag=$ac_save_c_werror_flag+ CFLAGS="-g"+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++int+main (void)+{++ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_compile "$LINENO"+then :+ ac_cv_prog_cc_g=yes+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext+ ac_c_werror_flag=$ac_save_c_werror_flag+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5+printf "%s\n" "$ac_cv_prog_cc_g" >&6; }+if test $ac_test_CFLAGS; then+ CFLAGS=$ac_save_CFLAGS+elif test $ac_cv_prog_cc_g = yes; then+ if test "$GCC" = yes; then+ CFLAGS="-g -O2"+ else+ CFLAGS="-g"+ fi+else+ if test "$GCC" = yes; then+ CFLAGS="-O2"+ else+ CFLAGS=+ fi+fi+ac_prog_cc_stdc=no+if test x$ac_prog_cc_stdc = xno+then :+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C11 features" >&5+printf %s "checking for $CC option to enable C11 features... " >&6; }+if test ${ac_cv_prog_cc_c11+y}+then :+ printf %s "(cached) " >&6+else $as_nop+ ac_cv_prog_cc_c11=no+ac_save_CC=$CC+cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+$ac_c_conftest_c11_program+_ACEOF+for ac_arg in '' -std=gnu11+do+ CC="$ac_save_CC $ac_arg"+ if ac_fn_c_try_compile "$LINENO"+then :+ ac_cv_prog_cc_c11=$ac_arg+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam+ test "x$ac_cv_prog_cc_c11" != "xno" && break+done+rm -f conftest.$ac_ext+CC=$ac_save_CC+fi++if test "x$ac_cv_prog_cc_c11" = xno+then :+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5+printf "%s\n" "unsupported" >&6; }+else $as_nop+ if test "x$ac_cv_prog_cc_c11" = x+then :+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5+printf "%s\n" "none needed" >&6; }+else $as_nop+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c11" >&5+printf "%s\n" "$ac_cv_prog_cc_c11" >&6; }+ CC="$CC $ac_cv_prog_cc_c11"+fi+ ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c11+ ac_prog_cc_stdc=c11+fi+fi+if test x$ac_prog_cc_stdc = xno+then :+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C99 features" >&5+printf %s "checking for $CC option to enable C99 features... " >&6; }+if test ${ac_cv_prog_cc_c99+y}+then :+ printf %s "(cached) " >&6+else $as_nop+ ac_cv_prog_cc_c99=no+ac_save_CC=$CC+cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+$ac_c_conftest_c99_program+_ACEOF+for ac_arg in '' -std=gnu99 -std=c99 -c99 -qlanglvl=extc1x -qlanglvl=extc99 -AC99 -D_STDC_C99=+do+ CC="$ac_save_CC $ac_arg"+ if ac_fn_c_try_compile "$LINENO"+then :+ ac_cv_prog_cc_c99=$ac_arg+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam+ test "x$ac_cv_prog_cc_c99" != "xno" && break+done+rm -f conftest.$ac_ext+CC=$ac_save_CC+fi++if test "x$ac_cv_prog_cc_c99" = xno+then :+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5+printf "%s\n" "unsupported" >&6; }+else $as_nop+ if test "x$ac_cv_prog_cc_c99" = x+then :+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5+printf "%s\n" "none needed" >&6; }+else $as_nop+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c99" >&5+printf "%s\n" "$ac_cv_prog_cc_c99" >&6; }+ CC="$CC $ac_cv_prog_cc_c99"+fi+ ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c99+ ac_prog_cc_stdc=c99+fi+fi+if test x$ac_prog_cc_stdc = xno+then :+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C89 features" >&5+printf %s "checking for $CC option to enable C89 features... " >&6; }+if test ${ac_cv_prog_cc_c89+y}+then :+ printf %s "(cached) " >&6+else $as_nop+ ac_cv_prog_cc_c89=no+ac_save_CC=$CC+cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+$ac_c_conftest_c89_program+_ACEOF+for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"+do+ CC="$ac_save_CC $ac_arg"+ if ac_fn_c_try_compile "$LINENO"+then :+ ac_cv_prog_cc_c89=$ac_arg+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam+ test "x$ac_cv_prog_cc_c89" != "xno" && break+done+rm -f conftest.$ac_ext+CC=$ac_save_CC+fi++if test "x$ac_cv_prog_cc_c89" = xno+then :+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5+printf "%s\n" "unsupported" >&6; }+else $as_nop+ if test "x$ac_cv_prog_cc_c89" = x+then :+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5+printf "%s\n" "none needed" >&6; }+else $as_nop+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5+printf "%s\n" "$ac_cv_prog_cc_c89" >&6; }+ CC="$CC $ac_cv_prog_cc_c89"+fi+ ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c89+ ac_prog_cc_stdc=c89+fi+fi++ac_ext=c+ac_cpp='$CPP $CPPFLAGS'+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'+ac_compiler_gnu=$ac_cv_c_compiler_gnu++++ac_header= ac_cache=+for ac_item in $ac_header_c_list+do+ if test $ac_cache; then+ ac_fn_c_check_header_compile "$LINENO" $ac_header ac_cv_header_$ac_cache "$ac_includes_default"+ if eval test \"x\$ac_cv_header_$ac_cache\" = xyes; then+ printf "%s\n" "#define $ac_item 1" >> confdefs.h+ fi+ ac_header= ac_cache=+ elif test $ac_header; then+ ac_cache=$ac_item+ else+ ac_header=$ac_item+ fi+done+++++++++if test $ac_cv_header_stdlib_h = yes && test $ac_cv_header_string_h = yes+then :++printf "%s\n" "#define STDC_HEADERS 1" >>confdefs.h++fi+++++++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether it is safe to define __EXTENSIONS__" >&5+printf %s "checking whether it is safe to define __EXTENSIONS__... " >&6; }+if test ${ac_cv_safe_to_define___extensions__+y}+then :+ printf %s "(cached) " >&6+else $as_nop+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++# define __EXTENSIONS__ 1+ $ac_includes_default+int+main (void)+{++ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_compile "$LINENO"+then :+ ac_cv_safe_to_define___extensions__=yes+else $as_nop+ ac_cv_safe_to_define___extensions__=no+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_safe_to_define___extensions__" >&5+printf "%s\n" "$ac_cv_safe_to_define___extensions__" >&6; }++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether _XOPEN_SOURCE should be defined" >&5+printf %s "checking whether _XOPEN_SOURCE should be defined... " >&6; }+if test ${ac_cv_should_define__xopen_source+y}+then :+ printf %s "(cached) " >&6+else $as_nop+ ac_cv_should_define__xopen_source=no+ if test $ac_cv_header_wchar_h = yes+then :+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++ #include <wchar.h>+ mbstate_t x;+int+main (void)+{++ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_compile "$LINENO"+then :++else $as_nop+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++ #define _XOPEN_SOURCE 500+ #include <wchar.h>+ mbstate_t x;+int+main (void)+{++ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_compile "$LINENO"+then :+ ac_cv_should_define__xopen_source=yes+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext+fi+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_should_define__xopen_source" >&5+printf "%s\n" "$ac_cv_should_define__xopen_source" >&6; }++ printf "%s\n" "#define _ALL_SOURCE 1" >>confdefs.h++ printf "%s\n" "#define _DARWIN_C_SOURCE 1" >>confdefs.h++ printf "%s\n" "#define _GNU_SOURCE 1" >>confdefs.h++ printf "%s\n" "#define _HPUX_ALT_XOPEN_SOCKET_API 1" >>confdefs.h++ printf "%s\n" "#define _NETBSD_SOURCE 1" >>confdefs.h++ printf "%s\n" "#define _OPENBSD_SOURCE 1" >>confdefs.h++ printf "%s\n" "#define _POSIX_PTHREAD_SEMANTICS 1" >>confdefs.h++ printf "%s\n" "#define __STDC_WANT_IEC_60559_ATTRIBS_EXT__ 1" >>confdefs.h++ printf "%s\n" "#define __STDC_WANT_IEC_60559_BFP_EXT__ 1" >>confdefs.h++ printf "%s\n" "#define __STDC_WANT_IEC_60559_DFP_EXT__ 1" >>confdefs.h++ printf "%s\n" "#define __STDC_WANT_IEC_60559_FUNCS_EXT__ 1" >>confdefs.h++ printf "%s\n" "#define __STDC_WANT_IEC_60559_TYPES_EXT__ 1" >>confdefs.h++ printf "%s\n" "#define __STDC_WANT_LIB_EXT2__ 1" >>confdefs.h++ printf "%s\n" "#define __STDC_WANT_MATH_SPEC_FUNCS__ 1" >>confdefs.h++ printf "%s\n" "#define _TANDEM_SOURCE 1" >>confdefs.h++ if test $ac_cv_header_minix_config_h = yes+then :+ MINIX=yes+ printf "%s\n" "#define _MINIX 1" >>confdefs.h++ printf "%s\n" "#define _POSIX_SOURCE 1" >>confdefs.h++ printf "%s\n" "#define _POSIX_1_SOURCE 2" >>confdefs.h++else $as_nop+ MINIX=+fi+ if test $ac_cv_safe_to_define___extensions__ = yes+then :+ printf "%s\n" "#define __EXTENSIONS__ 1" >>confdefs.h++fi+ if test $ac_cv_should_define__xopen_source = yes+then :+ printf "%s\n" "#define _XOPEN_SOURCE 500" >>confdefs.h++fi+++ac_config_headers="$ac_config_headers lib/include/HsTimeConfig.h"+++ac_fn_c_check_header_compile "$LINENO" "time.h" "ac_cv_header_time_h" "$ac_includes_default"+if test "x$ac_cv_header_time_h" = xyes+then :+ printf "%s\n" "#define HAVE_TIME_H 1" >>confdefs.h++fi++ac_fn_c_check_func "$LINENO" "gmtime_r" "ac_cv_func_gmtime_r"+if test "x$ac_cv_func_gmtime_r" = xyes+then :+ printf "%s\n" "#define HAVE_GMTIME_R 1" >>confdefs.h++fi+ac_fn_c_check_func "$LINENO" "localtime_r" "ac_cv_func_localtime_r"+if test "x$ac_cv_func_localtime_r" = xyes+then :+ printf "%s\n" "#define HAVE_LOCALTIME_R 1" >>confdefs.h++fi+++ac_fn_c_check_func "$LINENO" "clock_gettime" "ac_cv_func_clock_gettime"+if test "x$ac_cv_func_clock_gettime" = xyes+then :+ printf "%s\n" "#define HAVE_CLOCK_GETTIME 1" >>confdefs.h++fi++ac_fn_c_check_func "$LINENO" "tzset" "ac_cv_func_tzset"+if test "x$ac_cv_func_tzset" = xyes+then :+ printf "%s\n" "#define HAVE_TZSET 1" >>confdefs.h++fi+++{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether struct tm is in sys/time.h or time.h" >&5+printf %s "checking whether struct tm is in sys/time.h or time.h... " >&6; }+if test ${ac_cv_struct_tm+y}+then :+ printf %s "(cached) " >&6+else $as_nop+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+#include <sys/types.h>+#include <time.h>++int+main (void)+{+struct tm tm;+ int *p = &tm.tm_sec;+ return !p;+ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_compile "$LINENO"+then :+ ac_cv_struct_tm=time.h+else $as_nop+ ac_cv_struct_tm=sys/time.h+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_struct_tm" >&5+printf "%s\n" "$ac_cv_struct_tm" >&6; }+if test $ac_cv_struct_tm = sys/time.h; then++printf "%s\n" "#define TM_IN_SYS_TIME 1" >>confdefs.h++fi++{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC options needed to detect all undeclared functions" >&5+printf %s "checking for $CC options needed to detect all undeclared functions... " >&6; }+if test ${ac_cv_c_undeclared_builtin_options+y}+then :+ printf %s "(cached) " >&6+else $as_nop+ ac_save_CFLAGS=$CFLAGS+ ac_cv_c_undeclared_builtin_options='cannot detect'+ for ac_arg in '' -fno-builtin; do+ CFLAGS="$ac_save_CFLAGS $ac_arg"+ # This test program should *not* compile successfully.+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++int+main (void)+{+(void) strchr;+ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_compile "$LINENO"+then :++else $as_nop+ # This test program should compile successfully.+ # No library function is consistently available on+ # freestanding implementations, so test against a dummy+ # declaration. Include always-available headers on the+ # off chance that they somehow elicit warnings.+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+#include <float.h>+#include <limits.h>+#include <stdarg.h>+#include <stddef.h>+extern void ac_decl (int, char *);++int+main (void)+{+(void) ac_decl (0, (char *) 0);+ (void) ac_decl;++ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_compile "$LINENO"+then :+ if test x"$ac_arg" = x+then :+ ac_cv_c_undeclared_builtin_options='none needed'+else $as_nop+ ac_cv_c_undeclared_builtin_options=$ac_arg+fi+ break+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext+ done+ CFLAGS=$ac_save_CFLAGS++fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_undeclared_builtin_options" >&5+printf "%s\n" "$ac_cv_c_undeclared_builtin_options" >&6; }+ case $ac_cv_c_undeclared_builtin_options in #(+ 'cannot detect') :+ { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5+printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;}+as_fn_error $? "cannot make $CC report undeclared builtins+See \`config.log' for more details" "$LINENO" 5; } ;; #(+ 'none needed') :+ ac_c_undeclared_builtin_options='' ;; #(+ *) :+ ac_c_undeclared_builtin_options=$ac_cv_c_undeclared_builtin_options ;;+esac++ac_fn_c_check_member "$LINENO" "struct tm" "tm_zone" "ac_cv_member_struct_tm_tm_zone" "#include <sys/types.h>+#include <$ac_cv_struct_tm>++"+if test "x$ac_cv_member_struct_tm_tm_zone" = xyes+then :++printf "%s\n" "#define HAVE_STRUCT_TM_TM_ZONE 1" >>confdefs.h+++fi++if test "$ac_cv_member_struct_tm_tm_zone" = yes; then++printf "%s\n" "#define HAVE_TM_ZONE 1" >>confdefs.h++else+ ac_fn_check_decl "$LINENO" "tzname" "ac_cv_have_decl_tzname" "#include <time.h>+" "$ac_c_undeclared_builtin_options" "CFLAGS"+if test "x$ac_cv_have_decl_tzname" = xyes+then :+ ac_have_decl=1+else $as_nop+ ac_have_decl=0+fi+printf "%s\n" "#define HAVE_DECL_TZNAME $ac_have_decl" >>confdefs.h++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for tzname" >&5+printf %s "checking for tzname... " >&6; }+if test ${ac_cv_var_tzname+y}+then :+ printf %s "(cached) " >&6+else $as_nop+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+#include <time.h>+#if !HAVE_DECL_TZNAME+extern char *tzname[];+#endif++int+main (void)+{+return tzname[0][0];+ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_link "$LINENO"+then :+ ac_cv_var_tzname=yes+else $as_nop+ ac_cv_var_tzname=no+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam \+ conftest$ac_exeext conftest.$ac_ext+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_var_tzname" >&5+printf "%s\n" "$ac_cv_var_tzname" >&6; }+ if test $ac_cv_var_tzname = yes; then++printf "%s\n" "#define HAVE_TZNAME 1" >>confdefs.h++ fi+fi+++++++ ac_fn_c_check_header_compile "$LINENO" "sys/time.h" "ac_cv_header_sys_time_h" "$ac_includes_default"+if test "x$ac_cv_header_sys_time_h" = xyes+then :+ printf "%s\n" "#define HAVE_SYS_TIME_H 1" >>confdefs.h++fi++ ac_fn_check_decl "$LINENO" "altzone" "ac_cv_have_decl_altzone" "+ #if HAVE_SYS_TIME_H+ #include <sys/time.h>+ #endif+ #include <time.h>++" "$ac_c_undeclared_builtin_options" "CFLAGS"+if test "x$ac_cv_have_decl_altzone" = xyes+then :+ ac_have_decl=1+else $as_nop+ ac_have_decl=0+fi+printf "%s\n" "#define HAVE_DECL_ALTZONE $ac_have_decl" >>confdefs.h++++cat >confcache <<\_ACEOF+# This file is a shell script that caches the results of configure+# tests run on this system so they can be shared between configure+# scripts and configure runs, see configure's option --config-cache.+# It is not useful on other systems. If it contains results you don't+# want to keep, you may remove or edit it.+#+# config.status only pays attention to the cache file if you give it+# the --recheck option to rerun configure.+#+# `ac_cv_env_foo' variables (set or unset) will be overridden when+# loading this file, other *unset* `ac_cv_foo' will be assigned the+# following values.++_ACEOF++# The following way of writing the cache mishandles newlines in values,+# but we know of no workaround that is simple, portable, and efficient.+# So, we kill variables containing newlines.+# Ultrix sh set writes to stderr and can't be redirected directly,+# and sets the high bit in the cache file unless we assign to the vars.+(+ for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do+ eval ac_val=\$$ac_var+ case $ac_val in #(+ *${as_nl}*)+ case $ac_var in #(+ *_cv_*) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5+printf "%s\n" "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;+ esac+ case $ac_var in #(+ _ | IFS | as_nl) ;; #(+ BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(+ *) { eval $ac_var=; unset $ac_var;} ;;+ esac ;;+ esac+ done++ (set) 2>&1 |+ case $as_nl`(ac_space=' '; set) 2>&1` in #(+ *${as_nl}ac_space=\ *)+ # `set' does not quote correctly, so add quotes: double-quote+ # substitution turns \\\\ into \\, and sed turns \\ into \.+ sed -n \+ "s/'/'\\\\''/g;+ s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"+ ;; #(+ *)+ # `set' quotes correctly as required by POSIX, so do not add quotes.+ sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"+ ;;+ esac |+ sort+) |+ sed '+ /^ac_cv_env_/b end+ t clear+ :clear+ s/^\([^=]*\)=\(.*[{}].*\)$/test ${\1+y} || &/+ t end+ s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/+ :end' >>confcache+if diff "$cache_file" confcache >/dev/null 2>&1; then :; else+ if test -w "$cache_file"; then+ if test "x$cache_file" != "x/dev/null"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5+printf "%s\n" "$as_me: updating cache $cache_file" >&6;}+ if test ! -f "$cache_file" || test -h "$cache_file"; then+ cat confcache >"$cache_file"+ else+ case $cache_file in #(+ */* | ?:*)+ mv -f confcache "$cache_file"$$ &&+ mv -f "$cache_file"$$ "$cache_file" ;; #(+ *)+ mv -f confcache "$cache_file" ;;+ esac+ fi+ fi+ else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5+printf "%s\n" "$as_me: not updating unwritable cache $cache_file" >&6;}+ fi+fi+rm -f confcache++test "x$prefix" = xNONE && prefix=$ac_default_prefix+# Let make expand exec_prefix.+test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'++DEFS=-DHAVE_CONFIG_H++ac_libobjs=+ac_ltlibobjs=+U=+for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue+ # 1. Remove the extension, and $U if already installed.+ ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'+ ac_i=`printf "%s\n" "$ac_i" | sed "$ac_script"`+ # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR+ # will be set to the directory where LIBOBJS objects are built.+ as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext"+ as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo'+done+LIBOBJS=$ac_libobjs++LTLIBOBJS=$ac_ltlibobjs++++: "${CONFIG_STATUS=./config.status}"+ac_write_fail=0+ac_clean_files_save=$ac_clean_files+ac_clean_files="$ac_clean_files $CONFIG_STATUS"+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5+printf "%s\n" "$as_me: creating $CONFIG_STATUS" >&6;}+as_write_fail=0+cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1+#! $SHELL+# Generated by $as_me.+# Run this file to recreate the current configuration.+# Compiler output produced by configure, useful for debugging+# configure, is in config.log if it exists.++debug=false+ac_cs_recheck=false+ac_cs_silent=false++SHELL=\${CONFIG_SHELL-$SHELL}+export SHELL+_ASEOF+cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1+## -------------------- ##+## M4sh Initialization. ##+## -------------------- ##++# Be more Bourne compatible+DUALCASE=1; export DUALCASE # for MKS sh+as_nop=:+if test ${ZSH_VERSION+y} && (emulate sh) >/dev/null 2>&1+then :+ emulate sh+ NULLCMD=:+ # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which+ # is contrary to our usage. Disable this feature.+ alias -g '${1+"$@"}'='"$@"'+ setopt NO_GLOB_SUBST+else $as_nop+ case `(set -o) 2>/dev/null` in #(+ *posix*) :+ set -o posix ;; #(+ *) :+ ;;+esac+fi++++# Reset variables that may have inherited troublesome values from+# the environment.++# IFS needs to be set, to space, tab, and newline, in precisely that order.+# (If _AS_PATH_WALK were called with IFS unset, it would have the+# side effect of setting IFS to empty, thus disabling word splitting.)+# Quoting is to prevent editors from complaining about space-tab.+as_nl='+'+export as_nl+IFS=" "" $as_nl"++PS1='$ '+PS2='> '+PS4='+ '++# Ensure predictable behavior from utilities with locale-dependent output.+LC_ALL=C+export LC_ALL+LANGUAGE=C+export LANGUAGE++# We cannot yet rely on "unset" to work, but we need these variables+# to be unset--not just set to an empty or harmless value--now, to+# avoid bugs in old shells (e.g. pre-3.0 UWIN ksh). This construct+# also avoids known problems related to "unset" and subshell syntax+# in other old shells (e.g. bash 2.01 and pdksh 5.2.14).+for as_var in BASH_ENV ENV MAIL MAILPATH CDPATH+do eval test \${$as_var+y} \+ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :+done++# Ensure that fds 0, 1, and 2 are open.+if (exec 3>&0) 2>/dev/null; then :; else exec 0</dev/null; fi+if (exec 3>&1) 2>/dev/null; then :; else exec 1>/dev/null; fi+if (exec 3>&2) ; then :; else exec 2>/dev/null; fi++# The user is always right.+if ${PATH_SEPARATOR+false} :; then+ PATH_SEPARATOR=:+ (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {+ (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||+ PATH_SEPARATOR=';'+ }+fi+++# Find who we are. Look in the path if we contain no directory separator.+as_myself=+case $0 in #((+ *[\\/]* ) as_myself=$0 ;;+ *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ test -r "$as_dir$0" && as_myself=$as_dir$0 && break+ done+IFS=$as_save_IFS++ ;;+esac+# We did not find ourselves, most probably we were run as `sh COMMAND'+# in which case we are not to be found in the path.+if test "x$as_myself" = x; then+ as_myself=$0+fi+if test ! -f "$as_myself"; then+ printf "%s\n" "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2+ exit 1+fi++++# as_fn_error STATUS ERROR [LINENO LOG_FD]+# ----------------------------------------+# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are+# provided, also output the error to LOG_FD, referencing LINENO. Then exit the+# script with STATUS, using 1 if that was 0.+as_fn_error ()+{+ as_status=$1; test $as_status -eq 0 && as_status=1+ if test "$4"; then+ as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: $2" >&$4+ fi+ printf "%s\n" "$as_me: error: $2" >&2+ as_fn_exit $as_status+} # as_fn_error++++# as_fn_set_status STATUS+# -----------------------+# Set $? to STATUS, without forking.+as_fn_set_status ()+{+ return $1+} # as_fn_set_status++# as_fn_exit STATUS+# -----------------+# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.+as_fn_exit ()+{+ set +e+ as_fn_set_status $1+ exit $1+} # as_fn_exit++# as_fn_unset VAR+# ---------------+# Portably unset VAR.+as_fn_unset ()+{+ { eval $1=; unset $1;}+}+as_unset=as_fn_unset++# as_fn_append VAR VALUE+# ----------------------+# Append the text in VALUE to the end of the definition contained in VAR. Take+# advantage of any shell optimizations that allow amortized linear growth over+# repeated appends, instead of the typical quadratic growth present in naive+# implementations.+if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null+then :+ eval 'as_fn_append ()+ {+ eval $1+=\$2+ }'+else $as_nop+ as_fn_append ()+ {+ eval $1=\$$1\$2+ }+fi # as_fn_append++# as_fn_arith ARG...+# ------------------+# Perform arithmetic evaluation on the ARGs, and store the result in the+# global $as_val. Take advantage of shells that can avoid forks. The arguments+# must be portable across $(()) and expr.+if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null+then :+ eval 'as_fn_arith ()+ {+ as_val=$(( $* ))+ }'+else $as_nop+ as_fn_arith ()+ {+ as_val=`expr "$@" || test $? -eq 1`+ }+fi # as_fn_arith+++if expr a : '\(a\)' >/dev/null 2>&1 &&+ test "X`expr 00001 : '.*\(...\)'`" = X001; then+ as_expr=expr+else+ as_expr=false+fi++if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then+ as_basename=basename+else+ as_basename=false+fi++if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then+ as_dirname=dirname+else+ as_dirname=false+fi++as_me=`$as_basename -- "$0" ||+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \+ X"$0" : 'X\(//\)$' \| \+ X"$0" : 'X\(/\)' \| . 2>/dev/null ||+printf "%s\n" X/"$0" |+ sed '/^.*\/\([^/][^/]*\)\/*$/{+ s//\1/+ q+ }+ /^X\/\(\/\/\)$/{+ s//\1/+ q+ }+ /^X\/\(\/\).*/{+ s//\1/+ q+ }+ s/.*/./; q'`++# Avoid depending upon Character Ranges.+as_cr_letters='abcdefghijklmnopqrstuvwxyz'+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'+as_cr_Letters=$as_cr_letters$as_cr_LETTERS+as_cr_digits='0123456789'+as_cr_alnum=$as_cr_Letters$as_cr_digits+++# Determine whether it's possible to make 'echo' print without a newline.+# These variables are no longer used directly by Autoconf, but are AC_SUBSTed+# for compatibility with existing Makefiles.+ECHO_C= ECHO_N= ECHO_T=+case `echo -n x` in #(((((+-n*)+ case `echo 'xy\c'` in+ *c*) ECHO_T=' ';; # ECHO_T is single tab character.+ xy) ECHO_C='\c';;+ *) echo `echo ksh88 bug on AIX 6.1` > /dev/null+ ECHO_T=' ';;+ esac;;+*)+ ECHO_N='-n';;+esac++# For backward compatibility with old third-party macros, we provide+# the shell variables $as_echo and $as_echo_n. New code should use+# AS_ECHO(["message"]) and AS_ECHO_N(["message"]), respectively.+as_echo='printf %s\n'+as_echo_n='printf %s'++rm -f conf$$ conf$$.exe conf$$.file+if test -d conf$$.dir; then+ rm -f conf$$.dir/conf$$.file+else+ rm -f conf$$.dir+ mkdir conf$$.dir 2>/dev/null+fi+if (echo >conf$$.file) 2>/dev/null; then+ if ln -s conf$$.file conf$$ 2>/dev/null; then+ as_ln_s='ln -s'+ # ... but there are two gotchas:+ # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.+ # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.+ # In both cases, we have to default to `cp -pR'.+ ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||+ as_ln_s='cp -pR'+ elif ln conf$$.file conf$$ 2>/dev/null; then+ as_ln_s=ln+ else+ as_ln_s='cp -pR'+ fi+else+ as_ln_s='cp -pR'+fi+rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file+rmdir conf$$.dir 2>/dev/null+++# as_fn_mkdir_p+# -------------+# Create "$as_dir" as a directory, including parents if necessary.+as_fn_mkdir_p ()+{++ case $as_dir in #(+ -*) as_dir=./$as_dir;;+ esac+ test -d "$as_dir" || eval $as_mkdir_p || {+ as_dirs=+ while :; do+ case $as_dir in #(+ *\'*) as_qdir=`printf "%s\n" "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(+ *) as_qdir=$as_dir;;+ esac+ as_dirs="'$as_qdir' $as_dirs"+ as_dir=`$as_dirname -- "$as_dir" ||+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \+ X"$as_dir" : 'X\(//\)[^/]' \| \+ X"$as_dir" : 'X\(//\)$' \| \+ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||+printf "%s\n" X"$as_dir" |+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{+ s//\1/+ q+ }+ /^X\(\/\/\)[^/].*/{+ s//\1/+ q+ }+ /^X\(\/\/\)$/{+ s//\1/+ q+ }+ /^X\(\/\).*/{+ s//\1/+ q+ }+ s/.*/./; q'`+ test -d "$as_dir" && break+ done+ test -z "$as_dirs" || eval "mkdir $as_dirs"+ } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"+++} # as_fn_mkdir_p+if mkdir -p . 2>/dev/null; then+ as_mkdir_p='mkdir -p "$as_dir"'+else+ test -d ./-p && rmdir ./-p+ as_mkdir_p=false+fi+++# as_fn_executable_p FILE+# -----------------------+# Test if FILE is an executable regular file.+as_fn_executable_p ()+{+ test -f "$1" && test -x "$1"+} # as_fn_executable_p+as_test_x='test -x'+as_executable_p=as_fn_executable_p++# Sed expression to map a string onto a valid CPP name.+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"++# Sed expression to map a string onto a valid variable name.+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"+++exec 6>&1+## ----------------------------------- ##+## Main body of $CONFIG_STATUS script. ##+## ----------------------------------- ##+_ASEOF+test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1++cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1+# Save the log message, to keep $0 and so on meaningful, and to+# report actual input values of CONFIG_FILES etc. instead of their+# values after options handling.+ac_log="+This file was extended by Haskell time package $as_me 1.16, which was+generated by GNU Autoconf 2.71. Invocation command line was++ CONFIG_FILES = $CONFIG_FILES+ CONFIG_HEADERS = $CONFIG_HEADERS+ CONFIG_LINKS = $CONFIG_LINKS+ CONFIG_COMMANDS = $CONFIG_COMMANDS+ $ $0 $@++on `(hostname || uname -n) 2>/dev/null | sed 1q`+"++_ACEOF+++case $ac_config_headers in *"+"*) set x $ac_config_headers; shift; ac_config_headers=$*;;+esac+++cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1+# Files that config.status was made for.+config_headers="$ac_config_headers"++_ACEOF++cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1+ac_cs_usage="\+\`$as_me' instantiates files and other configuration actions+from templates according to the current configuration. Unless the files+and actions are specified as TAGs, all are instantiated by default.++Usage: $0 [OPTION]... [TAG]...++ -h, --help print this help, then exit+ -V, --version print version number and configuration settings, then exit+ --config print configuration, then exit+ -q, --quiet, --silent+ do not print progress messages+ -d, --debug don't remove temporary files+ --recheck update $as_me by reconfiguring in the same conditions+ --header=FILE[:TEMPLATE]+ instantiate the configuration header FILE++Configuration headers:+$config_headers++Report bugs to <ashley@semantic.org>."++_ACEOF+ac_cs_config=`printf "%s\n" "$ac_configure_args" | sed "$ac_safe_unquote"`+ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\''/g"`+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1+ac_cs_config='$ac_cs_config_escaped'+ac_cs_version="\\+Haskell time package config.status 1.16+configured by $0, generated by GNU Autoconf 2.71,+ with options \\"\$ac_cs_config\\"++Copyright (C) 2021 Free Software Foundation, Inc.+This config.status script is free software; the Free Software Foundation+gives unlimited permission to copy, distribute and modify it."++ac_pwd='$ac_pwd'+srcdir='$srcdir'+test -n "\$AWK" || AWK=awk+_ACEOF++cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1+# The default lists apply if the user does not specify any file.+ac_need_defaults=:+while test $# != 0+do+ case $1 in+ --*=?*)+ ac_option=`expr "X$1" : 'X\([^=]*\)='`+ ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'`+ ac_shift=:+ ;;+ --*=)+ ac_option=`expr "X$1" : 'X\([^=]*\)='`+ ac_optarg=+ ac_shift=:+ ;;+ *)+ ac_option=$1+ ac_optarg=$2+ ac_shift=shift+ ;;+ esac++ case $ac_option in+ # Handling of the options.+ -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)+ ac_cs_recheck=: ;;+ --version | --versio | --versi | --vers | --ver | --ve | --v | -V )+ printf "%s\n" "$ac_cs_version"; exit ;;+ --config | --confi | --conf | --con | --co | --c )+ printf "%s\n" "$ac_cs_config"; exit ;;+ --debug | --debu | --deb | --de | --d | -d )+ debug=: ;;+ --header | --heade | --head | --hea )+ $ac_shift+ case $ac_optarg in+ *\'*) ac_optarg=`printf "%s\n" "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;+ esac+ as_fn_append CONFIG_HEADERS " '$ac_optarg'"+ ac_need_defaults=false;;+ --he | --h)+ # Conflict between --help and --header+ as_fn_error $? "ambiguous option: \`$1'+Try \`$0 --help' for more information.";;+ --help | --hel | -h )+ printf "%s\n" "$ac_cs_usage"; exit ;;+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \+ | -silent | --silent | --silen | --sile | --sil | --si | --s)+ ac_cs_silent=: ;;++ # This is an error.+ -*) as_fn_error $? "unrecognized option: \`$1'+Try \`$0 --help' for more information." ;;++ *) as_fn_append ac_config_targets " $1"+ ac_need_defaults=false ;;++ esac+ shift+done++ac_configure_extra_args=++if $ac_cs_silent; then+ exec 6>/dev/null+ ac_configure_extra_args="$ac_configure_extra_args --silent"+fi++_ACEOF+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1+if \$ac_cs_recheck; then+ set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion+ shift+ \printf "%s\n" "running CONFIG_SHELL=$SHELL \$*" >&6+ CONFIG_SHELL='$SHELL'+ export CONFIG_SHELL+ exec "\$@"+fi++_ACEOF+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1+exec 5>>config.log+{+ echo+ sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX+## Running $as_me. ##+_ASBOX+ printf "%s\n" "$ac_log"+} >&5++_ACEOF+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1+_ACEOF++cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1++# Handling of arguments.+for ac_config_target in $ac_config_targets+do+ case $ac_config_target in+ "lib/include/HsTimeConfig.h") CONFIG_HEADERS="$CONFIG_HEADERS lib/include/HsTimeConfig.h" ;;++ *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;+ esac+done+++# If the user did not use the arguments to specify the items to instantiate,+# then the envvar interface is used. Set only those that are not.+# We use the long form for the default assignment because of an extremely+# bizarre bug on SunOS 4.1.3.+if $ac_need_defaults; then+ test ${CONFIG_HEADERS+y} || CONFIG_HEADERS=$config_headers+fi++# Have a temporary directory for convenience. Make it in the build tree+# simply because there is no reason against having it here, and in addition,+# creating and moving files from /tmp can sometimes cause problems.+# Hook for its removal unless debugging.+# Note that there is a small window in which the directory will not be cleaned:+# after its creation but before its name has been assigned to `$tmp'.+$debug ||+{+ tmp= ac_tmp=+ trap 'exit_status=$?+ : "${ac_tmp:=$tmp}"+ { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status+' 0+ trap 'as_fn_exit 1' 1 2 13 15+}+# Create a (secure) tmp directory for tmp files.++{+ tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` &&+ test -d "$tmp"+} ||+{+ tmp=./conf$$-$RANDOM+ (umask 077 && mkdir "$tmp")+} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5+ac_tmp=$tmp++# Set up the scripts for CONFIG_HEADERS section.+# No need to generate them if there are no CONFIG_HEADERS.+# This happens for instance with `./config.status Makefile'.+if test -n "$CONFIG_HEADERS"; then+cat >"$ac_tmp/defines.awk" <<\_ACAWK ||+BEGIN {+_ACEOF++# Transform confdefs.h into an awk script `defines.awk', embedded as+# here-document in config.status, that substitutes the proper values into+# config.h.in to produce config.h.++# Create a delimiter string that does not exist in confdefs.h, to ease+# handling of long lines.+ac_delim='%!_!# '+for ac_last_try in false false :; do+ ac_tt=`sed -n "/$ac_delim/p" confdefs.h`+ if test -z "$ac_tt"; then+ break+ elif $ac_last_try; then+ as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5+ else+ ac_delim="$ac_delim!$ac_delim _$ac_delim!! "+ fi+done++# For the awk script, D is an array of macro values keyed by name,+# likewise P contains macro parameters if any. Preserve backslash+# newline sequences.++ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]*+sed -n '+s/.\{148\}/&'"$ac_delim"'/g+t rset+:rset+s/^[ ]*#[ ]*define[ ][ ]*/ /+t def+d+:def+s/\\$//+t bsnl+s/["\\]/\\&/g+s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\+D["\1"]=" \3"/p+s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p+d+:bsnl+s/["\\]/\\&/g+s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\+D["\1"]=" \3\\\\\\n"\\/p+t cont+s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p+t cont+d+:cont+n+s/.\{148\}/&'"$ac_delim"'/g+t clear+:clear+s/\\$//+t bsnlc+s/["\\]/\\&/g; s/^/"/; s/$/"/p+d+:bsnlc+s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p+b cont+' <confdefs.h | sed '+s/'"$ac_delim"'/"\\\+"/g' >>$CONFIG_STATUS || ac_write_fail=1++cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1+ for (key in D) D_is_set[key] = 1+ FS = ""+}+/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ {+ line = \$ 0+ split(line, arg, " ")+ if (arg[1] == "#") {+ defundef = arg[2]+ mac1 = arg[3]+ } else {+ defundef = substr(arg[1], 2)+ mac1 = arg[2]+ }+ split(mac1, mac2, "(") #)+ macro = mac2[1]+ prefix = substr(line, 1, index(line, defundef) - 1)+ if (D_is_set[macro]) {+ # Preserve the white space surrounding the "#".+ print prefix "define", macro P[macro] D[macro]+ next+ } else {+ # Replace #undef with comments. This is necessary, for example,+ # in the case of _POSIX_SOURCE, which is predefined and required+ # on some systems where configure will not decide to define it.+ if (defundef == "undef") {+ print "/*", prefix defundef, macro, "*/"+ next+ }+ }+}+{ print }+_ACAWK+_ACEOF+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1+ as_fn_error $? "could not setup config headers machinery" "$LINENO" 5+fi # test -n "$CONFIG_HEADERS"+++eval set X " :H $CONFIG_HEADERS "+shift+for ac_tag+do+ case $ac_tag in+ :[FHLC]) ac_mode=$ac_tag; continue;;+ esac+ case $ac_mode$ac_tag in+ :[FHL]*:*);;+ :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;;+ :[FH]-) ac_tag=-:-;;+ :[FH]*) ac_tag=$ac_tag:$ac_tag.in;;+ esac+ ac_save_IFS=$IFS+ IFS=:+ set x $ac_tag+ IFS=$ac_save_IFS+ shift+ ac_file=$1+ shift++ case $ac_mode in+ :L) ac_source=$1;;+ :[FH])+ ac_file_inputs=+ for ac_f+ do+ case $ac_f in+ -) ac_f="$ac_tmp/stdin";;+ *) # Look for the file first in the build tree, then in the source tree+ # (if the path is not absolute). The absolute path cannot be DOS-style,+ # because $ac_f cannot contain `:'.+ test -f "$ac_f" ||+ case $ac_f in+ [\\/$]*) false;;+ *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;+ esac ||+ as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;;+ esac+ case $ac_f in *\'*) ac_f=`printf "%s\n" "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac+ as_fn_append ac_file_inputs " '$ac_f'"+ done++ # Let's still pretend it is `configure' which instantiates (i.e., don't+ # use $as_me), people would be surprised to read:+ # /* config.h. Generated by config.status. */+ configure_input='Generated from '`+ printf "%s\n" "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g'+ `' by configure.'+ if test x"$ac_file" != x-; then+ configure_input="$ac_file. $configure_input"+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5+printf "%s\n" "$as_me: creating $ac_file" >&6;}+ fi+ # Neutralize special characters interpreted by sed in replacement strings.+ case $configure_input in #(+ *\&* | *\|* | *\\* )+ ac_sed_conf_input=`printf "%s\n" "$configure_input" |+ sed 's/[\\\\&|]/\\\\&/g'`;; #(+ *) ac_sed_conf_input=$configure_input;;+ esac++ case $ac_tag in+ *:-:* | *:-) cat >"$ac_tmp/stdin" \+ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;;+ esac+ ;;+ esac++ ac_dir=`$as_dirname -- "$ac_file" ||+$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \+ X"$ac_file" : 'X\(//\)[^/]' \| \+ X"$ac_file" : 'X\(//\)$' \| \+ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null ||+printf "%s\n" X"$ac_file" |+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{+ s//\1/+ q+ }+ /^X\(\/\/\)[^/].*/{+ s//\1/+ q+ }+ /^X\(\/\/\)$/{+ s//\1/+ q+ }+ /^X\(\/\).*/{+ s//\1/+ q+ }+ s/.*/./; q'`+ as_dir="$ac_dir"; as_fn_mkdir_p+ ac_builddir=.++case "$ac_dir" in+.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;+*)+ ac_dir_suffix=/`printf "%s\n" "$ac_dir" | sed 's|^\.[\\/]||'`+ # A ".." for each directory in $ac_dir_suffix.+ ac_top_builddir_sub=`printf "%s\n" "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`+ case $ac_top_builddir_sub in+ "") ac_top_builddir_sub=. ac_top_build_prefix= ;;+ *) ac_top_build_prefix=$ac_top_builddir_sub/ ;;+ esac ;;+esac+ac_abs_top_builddir=$ac_pwd+ac_abs_builddir=$ac_pwd$ac_dir_suffix+# for backward compatibility:+ac_top_builddir=$ac_top_build_prefix++case $srcdir in+ .) # We are building in place.+ ac_srcdir=.+ ac_top_srcdir=$ac_top_builddir_sub+ ac_abs_top_srcdir=$ac_pwd ;;+ [\\/]* | ?:[\\/]* ) # Absolute name.+ ac_srcdir=$srcdir$ac_dir_suffix;+ ac_top_srcdir=$srcdir+ ac_abs_top_srcdir=$srcdir ;;+ *) # Relative name.+ ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix+ ac_top_srcdir=$ac_top_build_prefix$srcdir+ ac_abs_top_srcdir=$ac_pwd/$srcdir ;;+esac+ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix+++ case $ac_mode in++ :H)+ #+ # CONFIG_HEADER+ #+ if test x"$ac_file" != x-; then+ {+ printf "%s\n" "/* $configure_input */" >&1 \+ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs"+ } >"$ac_tmp/config.h" \+ || as_fn_error $? "could not create $ac_file" "$LINENO" 5+ if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5+printf "%s\n" "$as_me: $ac_file is unchanged" >&6;}+ else+ rm -f "$ac_file"+ mv "$ac_tmp/config.h" "$ac_file" \+ || as_fn_error $? "could not create $ac_file" "$LINENO" 5+ fi+ else+ printf "%s\n" "/* $configure_input */" >&1 \+ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \+ || as_fn_error $? "could not create -" "$LINENO" 5+ fi+ ;;+++ esac++done # for ac_tag+++as_fn_exit 0+_ACEOF+ac_clean_files=$ac_clean_files_save++test $ac_write_fail = 0 ||+ as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5+++# configure is writing to config.log, and then calls config.status.+# config.status does its own redirection, appending to config.log.+# Unfortunately, on DOS this fails, as config.log is still kept open+# by configure, so config.status won't be able to write to it; its+# output is simply discarded. So we exec the FD to /dev/null,+# effectively closing config.log, so it can be properly (re)opened and+# appended to by config.status. When coming back to configure, we+# need to make the FD available again.+if test "$no_create" != yes; then+ ac_cs_success=:+ ac_config_status_args=+ test "$silent" = yes &&+ ac_config_status_args="$ac_config_status_args --quiet"+ exec 5>/dev/null+ $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false+ exec 5>>config.log+ # Use ||, not &&, to avoid exiting from the if with $? = 1, which+ # would make configure fail if this is the last instruction.+ $ac_cs_success || as_fn_exit 1+fi+if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5+printf "%s\n" "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}+fi+
configure.ac view
@@ -1,17 +1,23 @@-AC_INIT([Haskell time package], [1.1.2.3], [ashley@semantic.org], [time])+AC_INIT([Haskell time package],[1.16],[ashley@semantic.org],[time]) # Safety check: Ensure that we are in the correct source directory.-AC_CONFIG_SRCDIR([include/HsTime.h])+AC_CONFIG_SRCDIR([lib/include/HsTime.h]) -AC_ARG_WITH([cc],- [C compiler],- [CC=$withval])+# These are to silence warnings with older Cabal versions+AC_ARG_WITH([gcc],[Gnu C compiler])+AC_ARG_WITH([compiler],[Haskell compiler])+ AC_PROG_CC() -AC_CONFIG_HEADERS([include/HsTimeConfig.h])+AC_USE_SYSTEM_EXTENSIONS +AC_CONFIG_HEADERS([lib/include/HsTimeConfig.h])+ AC_CHECK_HEADERS([time.h]) AC_CHECK_FUNCS([gmtime_r localtime_r])++AC_CHECK_FUNCS([clock_gettime])+AC_CHECK_FUNCS([tzset]) AC_STRUCT_TM AC_STRUCT_TIMEZONE
− include/HsTime.h
@@ -1,23 +0,0 @@-#ifndef __HSTIME_H__-#define __HSTIME_H__--#if defined(_MSC_VER) || defined(__MINGW32__) || defined(_WIN32)-#define HAVE_TIME_H 1-#else--#include "HsTimeConfig.h"-// Otherwise these clash with similar definitions from other packages:-#undef PACKAGE_BUGREPORT-#undef PACKAGE_NAME-#undef PACKAGE_STRING-#undef PACKAGE_TARNAME-#undef PACKAGE_VERSION-#endif--#if HAVE_TIME_H-#include <time.h>-#endif--long int get_current_timezone_seconds (time_t,int* pdst,char const* * pname);--#endif
− include/HsTimeConfig.h
@@ -1,84 +0,0 @@-/* include/HsTimeConfig.h. Generated from HsTimeConfig.h.in by configure. */-/* include/HsTimeConfig.h.in. Generated from configure.ac by autoheader. */--/* Define to 1 if you have the declaration of `altzone', and to 0 if you- don't. */-#define HAVE_DECL_ALTZONE 0--/* Define to 1 if you have the declaration of `tzname', and to 0 if you don't.- */-/* #undef HAVE_DECL_TZNAME */--/* Define to 1 if you have the `gmtime_r' function. */-#define HAVE_GMTIME_R 1--/* Define to 1 if you have the <inttypes.h> header file. */-#define HAVE_INTTYPES_H 1--/* Define to 1 if you have the `localtime_r' function. */-#define HAVE_LOCALTIME_R 1--/* Define to 1 if you have the <memory.h> header file. */-#define HAVE_MEMORY_H 1--/* Define to 1 if you have the <stdint.h> header file. */-#define HAVE_STDINT_H 1--/* Define to 1 if you have the <stdlib.h> header file. */-#define HAVE_STDLIB_H 1--/* Define to 1 if you have the <strings.h> header file. */-#define HAVE_STRINGS_H 1--/* Define to 1 if you have the <string.h> header file. */-#define HAVE_STRING_H 1--/* Define to 1 if `tm_zone' is member of `struct tm'. */-#define HAVE_STRUCT_TM_TM_ZONE 1--/* Define to 1 if you have the <sys/stat.h> header file. */-#define HAVE_SYS_STAT_H 1--/* Define to 1 if you have the <sys/time.h> header file. */-#define HAVE_SYS_TIME_H 1--/* Define to 1 if you have the <sys/types.h> header file. */-#define HAVE_SYS_TYPES_H 1--/* Define to 1 if you have the <time.h> header file. */-#define HAVE_TIME_H 1--/* Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use- `HAVE_STRUCT_TM_TM_ZONE' instead. */-#define HAVE_TM_ZONE 1--/* Define to 1 if you don't have `tm_zone' but do have the external array- `tzname'. */-/* #undef HAVE_TZNAME */--/* Define to 1 if you have the <unistd.h> header file. */-#define HAVE_UNISTD_H 1--/* Define to the address where bug reports for this package should be sent. */-#define PACKAGE_BUGREPORT "ashley@semantic.org"--/* Define to the full name of this package. */-#define PACKAGE_NAME "Haskell time package"--/* Define to the full name and version of this package. */-#define PACKAGE_STRING "Haskell time package 1.1.2.3"--/* Define to the one symbol short name of this package. */-#define PACKAGE_TARNAME "time"--/* Define to the version of this package. */-#define PACKAGE_VERSION "1.1.2.3"--/* Define to 1 if you have the ANSI C header files. */-#define STDC_HEADERS 1--/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */-#define TIME_WITH_SYS_TIME 1--/* Define to 1 if your <sys/time.h> declares `struct tm'. */-/* #undef TM_IN_SYS_TIME */
− include/HsTimeConfig.h.in
@@ -1,83 +0,0 @@-/* include/HsTimeConfig.h.in. Generated from configure.ac by autoheader. */--/* Define to 1 if you have the declaration of `altzone', and to 0 if you- don't. */-#undef HAVE_DECL_ALTZONE--/* Define to 1 if you have the declaration of `tzname', and to 0 if you don't.- */-#undef HAVE_DECL_TZNAME--/* Define to 1 if you have the `gmtime_r' function. */-#undef HAVE_GMTIME_R--/* Define to 1 if you have the <inttypes.h> header file. */-#undef HAVE_INTTYPES_H--/* Define to 1 if you have the `localtime_r' function. */-#undef HAVE_LOCALTIME_R--/* Define to 1 if you have the <memory.h> header file. */-#undef HAVE_MEMORY_H--/* Define to 1 if you have the <stdint.h> header file. */-#undef HAVE_STDINT_H--/* Define to 1 if you have the <stdlib.h> header file. */-#undef HAVE_STDLIB_H--/* Define to 1 if you have the <strings.h> header file. */-#undef HAVE_STRINGS_H--/* Define to 1 if you have the <string.h> header file. */-#undef HAVE_STRING_H--/* Define to 1 if `tm_zone' is member of `struct tm'. */-#undef HAVE_STRUCT_TM_TM_ZONE--/* Define to 1 if you have the <sys/stat.h> header file. */-#undef HAVE_SYS_STAT_H--/* Define to 1 if you have the <sys/time.h> header file. */-#undef HAVE_SYS_TIME_H--/* Define to 1 if you have the <sys/types.h> header file. */-#undef HAVE_SYS_TYPES_H--/* Define to 1 if you have the <time.h> header file. */-#undef HAVE_TIME_H--/* Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use- `HAVE_STRUCT_TM_TM_ZONE' instead. */-#undef HAVE_TM_ZONE--/* Define to 1 if you don't have `tm_zone' but do have the external array- `tzname'. */-#undef HAVE_TZNAME--/* Define to 1 if you have the <unistd.h> header file. */-#undef HAVE_UNISTD_H--/* Define to the address where bug reports for this package should be sent. */-#undef PACKAGE_BUGREPORT--/* Define to the full name of this package. */-#undef PACKAGE_NAME--/* Define to the full name and version of this package. */-#undef PACKAGE_STRING--/* Define to the one symbol short name of this package. */-#undef PACKAGE_TARNAME--/* Define to the version of this package. */-#undef PACKAGE_VERSION--/* Define to 1 if you have the ANSI C header files. */-#undef STDC_HEADERS--/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */-#undef TIME_WITH_SYS_TIME--/* Define to 1 if your <sys/time.h> declares `struct tm'. */-#undef TM_IN_SYS_TIME
+ lib/Data/Format.hs view
@@ -0,0 +1,276 @@+{-# LANGUAGE Safe #-}++module Data.Format (+ Productish (..),+ Summish (..),+ parseReader,+ Format (..),+ formatShow,+ formatParseM,+ isoMap,+ mapMFormat,+ filterFormat,+ clipFormat,+ enumMap,+ literalFormat,+ specialCaseShowFormat,+ specialCaseFormat,+ specialCaseReadFormat,+ optionalFormat,+ casesFormat,+ optionalSignFormat,+ mandatorySignFormat,+ SignOption (..),+ integerFormat,+ decimalFormat,+) where++import Control.Monad.Fail+import Data.Char+import Data.Void+import Text.ParserCombinators.ReadP+import Prelude hiding (fail)++class IsoVariant f where+ isoMap :: (a -> b) -> (b -> a) -> f a -> f b++enumMap :: (IsoVariant f, Enum a) => f Int -> f a+enumMap = isoMap toEnum fromEnum++infixr 3 <**>, **>, <**++class IsoVariant f => Productish f where+ pUnit :: f ()+ (<**>) :: f a -> f b -> f (a, b)+ (**>) :: f () -> f a -> f a+ fu **> fa = isoMap (\((), a) -> a) (\a -> ((), a)) $ fu <**> fa+ (<**) :: f a -> f () -> f a+ fa <** fu = isoMap (\(a, ()) -> a) (\a -> (a, ())) $ fa <**> fu++infixr 2 <++>++class IsoVariant f => Summish f where+ pVoid :: f Void+ (<++>) :: f a -> f b -> f (Either a b)++parseReader :: MonadFail m => ReadP t -> String -> m t+parseReader readp s =+ case [t | (t, "") <- readP_to_S readp s] of+ [t] -> return t+ [] -> fail $ "no parse of " ++ show s+ _ -> fail $ "multiple parses of " ++ show s++-- | A text format for a type+data Format t = MkFormat+ { formatShowM :: t -> Maybe String+ -- ^ Show a value in the format, if representable+ , formatReadP :: ReadP t+ -- ^ Read a value in the format+ }++-- | Show a value in the format, or error if unrepresentable+formatShow :: Format t -> t -> String+formatShow fmt t =+ case formatShowM fmt t of+ Just str -> str+ Nothing -> error "formatShow: bad value"++-- | Parse a value in the format+formatParseM :: MonadFail m => Format t -> String -> m t+formatParseM format = parseReader $ formatReadP format++instance IsoVariant Format where+ isoMap ab ba (MkFormat sa ra) = MkFormat (\b -> sa $ ba b) (fmap ab ra)++mapMFormat :: (a -> Maybe b) -> (b -> Maybe a) -> Format a -> Format b+mapMFormat amb bma (MkFormat sa ra) =+ MkFormat (\b -> bma b >>= sa) $ do+ a <- ra+ case amb a of+ Just b -> return b+ Nothing -> pfail++filterFormat :: (a -> Bool) -> Format a -> Format a+filterFormat test =+ mapMFormat+ ( \a ->+ if test a+ then Just a+ else Nothing+ )+ ( \a ->+ if test a+ then Just a+ else Nothing+ )++-- | Limits are inclusive+clipFormat :: Ord a => (a, a) -> Format a -> Format a+clipFormat (lo, hi) = filterFormat (\a -> a >= lo && a <= hi)++instance Productish Format where+ pUnit = MkFormat{formatShowM = \_ -> Just "", formatReadP = return ()}+ (<**>) (MkFormat sa ra) (MkFormat sb rb) =+ let+ sab (a, b) = do+ astr <- sa a+ bstr <- sb b+ return $ astr ++ bstr+ rab = do+ a <- ra+ b <- rb+ return (a, b)+ in+ MkFormat sab rab+ (MkFormat sa ra) **> (MkFormat sb rb) =+ let+ s b = do+ astr <- sa ()+ bstr <- sb b+ return $ astr ++ bstr+ r = do+ ra+ rb+ in+ MkFormat s r+ (MkFormat sa ra) <** (MkFormat sb rb) =+ let+ s a = do+ astr <- sa a+ bstr <- sb ()+ return $ astr ++ bstr+ r = do+ a <- ra+ rb+ return a+ in+ MkFormat s r++instance Summish Format where+ pVoid = MkFormat absurd pfail+ (MkFormat sa ra) <++> (MkFormat sb rb) =+ let+ sab (Left a) = sa a+ sab (Right b) = sb b+ rab = (fmap Left ra) +++ (fmap Right rb)+ in+ MkFormat sab rab++literalFormat :: String -> Format ()+literalFormat s = MkFormat{formatShowM = \_ -> Just s, formatReadP = string s >> return ()}++specialCaseShowFormat :: Eq a => (a, String) -> Format a -> Format a+specialCaseShowFormat (val, str) (MkFormat s r) =+ let+ s' t+ | t == val = Just str+ s' t = s t+ in+ MkFormat s' r++specialCaseFormat :: Eq a => (a, String) -> Format a -> Format a+specialCaseFormat (val, str) (MkFormat s r) =+ let+ s' t+ | t == val = Just str+ s' t = s t+ r' = r <++ (string str >> return val)+ in+ MkFormat s' r'++specialCaseReadFormat :: (a, String) -> Format a -> Format a+specialCaseReadFormat (val, str) (MkFormat s r) =+ let+ r' = r <++ (string str >> return val)+ in+ MkFormat s r'++optionalFormat :: Eq a => a -> Format a -> Format a+optionalFormat val = specialCaseFormat (val, "")++casesFormat :: Eq a => [(a, String)] -> Format a+casesFormat pairs =+ let+ s t = lookup t pairs+ r [] = pfail+ r ((v, str) : pp) = (string str >> return v) <++ r pp+ in+ MkFormat s $ r pairs++optionalSignFormat :: (Eq t, Num t) => Format t+optionalSignFormat = casesFormat [(1, ""), (1, "+"), (0, ""), (-1, "-")]++mandatorySignFormat :: (Eq t, Num t) => Format t+mandatorySignFormat = casesFormat [(1, "+"), (0, "+"), (-1, "-")]++data SignOption+ = NoSign+ | NegSign+ | PosNegSign++readSign :: Num t => SignOption -> ReadP (t -> t)+readSign NoSign = return id+readSign NegSign = option id $ char '-' >> return negate+readSign PosNegSign = (char '+' >> return id) +++ (char '-' >> return negate)++readNumber :: (Num t, Read t) => SignOption -> Maybe Int -> Bool -> ReadP t+readNumber signOpt mdigitcount allowDecimal = do+ sign <- readSign signOpt+ digits <-+ case mdigitcount of+ Just digitcount -> count digitcount $ satisfy isDigit+ Nothing -> munch1 isDigit+ moredigits <-+ case allowDecimal of+ False -> return ""+ True ->+ option "" $ do+ _ <- char '.' +++ char ','+ dd <- munch1 isDigit+ return $ '.' : dd+ return $ sign $ read $ digits ++ moredigits++zeroPad :: Maybe Int -> String -> Maybe String+zeroPad Nothing s = Just s+zeroPad (Just i) s =+ let+ padCount = i - length s+ in+ if padCount >= 0+ then Just $ replicate padCount '0' ++ s+ else Nothing++trimTrailing :: String -> String+trimTrailing =+ (\s -> if s == "." then "" else s)+ . reverse+ . dropWhile (== '0')+ . reverse++showNumber :: Show t => SignOption -> Maybe Int -> t -> Maybe String+showNumber signOpt mdigitcount t =+ let+ showIt str = do+ let+ (intPart, decPart) = break ((==) '.') str+ paddedIntPart <- zeroPad mdigitcount intPart+ return $ paddedIntPart ++ trimTrailing decPart+ in+ case show t of+ ('-' : str) ->+ case signOpt of+ NoSign -> Nothing+ _ -> do+ s <- showIt str+ return $ '-' : s+ str -> do+ s <- showIt str+ return $ case signOpt of+ PosNegSign -> '+' : s+ _ -> s++integerFormat :: (Show t, Read t, Num t) => SignOption -> Maybe Int -> Format t+integerFormat signOpt mdigitcount = MkFormat (showNumber signOpt mdigitcount) (readNumber signOpt mdigitcount False)++decimalFormat :: (Show t, Read t, Num t) => SignOption -> Maybe Int -> Format t+decimalFormat signOpt mdigitcount = MkFormat (showNumber signOpt mdigitcount) (readNumber signOpt mdigitcount True)
+ lib/Data/Time.hs view
@@ -0,0 +1,46 @@+{-# LANGUAGE Safe #-}++{-|++= Quick Start++Use these types for time regardless of location (not caring about leap-seconds):++* 'UTCTime' for actual times+* 'NominalDiffTime' for differences between times, i.e. durations++Use these types for the ways people refer to time and time differences:++* 'Day' for something like June 27th 2017+* 'DayOfWeek' for something like Tuesday+* 'Data.Time.Calendar.Month.Month' for something like August 2021+* 'Data.Time.Calendar.Quarter.QuarterOfYear' for something like Q2+* 'Data.Time.Calendar.Quarter.Quarter' for something like Q2 of 2023+* 'TimeOfDay' for something like 5pm+* 'LocalTime' for a 'Day' with a 'TimeOfDay'+* 'TimeZone' for a time zone offset (not actually the time zone itself) like -0700+* 'ZonedTime' for a 'LocalTime' with a 'TimeZone'+* 'CalendarDiffDays' for something like 6 years, 1 month and 5 days+* 'CalendarDiffTime' for something like 6 years, 1 month, 5 days, 3 hours, 7 minutes and 25.784 seconds++Use this for low-latency timing:++* 'Data.Time.Clock.System.SystemTime'++These are less commonly needed:++* 'Data.Time.Clock.TAI.AbsoluteTime' and 'DiffTime' if you do care about leap-seconds.+* 'Data.Time.Clock.TAI.LeapSecondMap' for tracking the leap-seconds+* 'UniversalTime' for time based on Earth rotation+-}+module Data.Time+ ( module Data.Time.Calendar+ , module Data.Time.Clock+ , module Data.Time.LocalTime+ , module Data.Time.Format+ ) where++import Data.Time.Calendar+import Data.Time.Clock+import Data.Time.Format+import Data.Time.LocalTime
+ lib/Data/Time/Calendar.hs view
@@ -0,0 +1,78 @@+{-# LANGUAGE Safe #-}++module Data.Time.Calendar (+ -- * Days+ Day (..),+ addDays,+ diffDays,++ -- * DayPeriod+ DayPeriod (..),+ periodAllDays,+ periodIn,+ periodLength,+ periodFromDay,+ periodToDay,+ periodToDayClip,+ periodToDayValid,++ -- * Calendar Duration+ module Data.Time.Calendar.CalendarDiffDays,++ -- * Year, month and day+ Year,+ pattern CommonEra,+ pattern BeforeCommonEra,+ MonthOfYear,+ pattern January,+ pattern February,+ pattern March,+ pattern April,+ pattern May,+ pattern June,+ pattern July,+ pattern August,+ pattern September,+ pattern October,+ pattern November,+ pattern December,+ DayOfMonth,++ -- * Gregorian calendar+ toGregorian,+ fromGregorian,+ pattern YearMonthDay,+ fromGregorianValid,+ showGregorian,+ gregorianMonthLength,+ -- calendrical arithmetic+ -- e.g. "one month after March 31st"+ addGregorianMonthsClip,+ addGregorianMonthsRollOver,+ addGregorianYearsClip,+ addGregorianYearsRollOver,+ addGregorianDurationClip,+ addGregorianDurationRollOver,+ diffGregorianDurationClip,+ diffGregorianDurationRollOver,+ -- re-exported from OrdinalDate+ isLeapYear,++ -- * Week+ DayOfWeek (..),+ dayOfWeek,+ dayOfWeekDiff,+ firstDayOfWeekOnAfter,+ weekAllDays,+ weekFirstDay,+ weekLastDay,+) where++import Data.Time.Calendar.CalendarDiffDays+import Data.Time.Calendar.Days+import Data.Time.Calendar.Gregorian+import Data.Time.Calendar.MonthDay+import Data.Time.Calendar.OrdinalDate+import Data.Time.Calendar.Types+import Data.Time.Calendar.Week+import Data.Time.Format ()
+ lib/Data/Time/Calendar/CalendarDiffDays.hs view
@@ -0,0 +1,47 @@+{-# LANGUAGE CPP #-}+{-# LANGUAGE Safe #-}++module Data.Time.Calendar.CalendarDiffDays where++import Control.DeepSeq+import Data.Data+import GHC.Generics+#if __GLASGOW_HASKELL__ >= 914+import qualified Language.Haskell.TH.Lift as TH+#else+import qualified Language.Haskell.TH.Syntax as TH+#endif++data CalendarDiffDays = CalendarDiffDays+ { cdMonths :: Integer+ , cdDays :: Integer+ }+ deriving (Eq, Typeable, Data, Generic, TH.Lift)++instance NFData CalendarDiffDays where+ rnf (CalendarDiffDays m d) = rnf m `seq` rnf d `seq` ()++-- | Additive+instance Semigroup CalendarDiffDays where+ CalendarDiffDays m1 d1 <> CalendarDiffDays m2 d2 = CalendarDiffDays (m1 + m2) (d1 + d2)++-- | Additive+instance Monoid CalendarDiffDays where+ mempty = CalendarDiffDays 0 0+ mappend = (<>)++calendarDay :: CalendarDiffDays+calendarDay = CalendarDiffDays 0 1++calendarWeek :: CalendarDiffDays+calendarWeek = CalendarDiffDays 0 7++calendarMonth :: CalendarDiffDays+calendarMonth = CalendarDiffDays 1 0++calendarYear :: CalendarDiffDays+calendarYear = CalendarDiffDays 12 0++-- | Scale by a factor. Note that @scaleCalendarDiffDays (-1)@ will not perfectly invert a duration, due to variable month lengths.+scaleCalendarDiffDays :: Integer -> CalendarDiffDays -> CalendarDiffDays+scaleCalendarDiffDays k (CalendarDiffDays m d) = CalendarDiffDays (k * m) (k * d)
+ lib/Data/Time/Calendar/Days.hs view
@@ -0,0 +1,118 @@+{-# LANGUAGE CPP #-}+{-# LANGUAGE Safe #-}++module Data.Time.Calendar.Days where++import Control.DeepSeq+import Data.Data+import Data.Ix+import Data.Time.Calendar.Private+import GHC.Generics+#if __GLASGOW_HASKELL__ >= 914+import qualified Language.Haskell.TH.Lift as TH+#else+import qualified Language.Haskell.TH.Syntax as TH+#endif++-- | The Modified Julian Day is a standard count of days, with zero being the day 1858-11-17.+newtype Day = ModifiedJulianDay+ { toModifiedJulianDay :: Integer+ }+ deriving (Eq, Ord, Typeable, Data, Generic, TH.Lift)++instance NFData Day where+ rnf (ModifiedJulianDay a) = rnf a++instance Enum Day where+ succ (ModifiedJulianDay a) = ModifiedJulianDay (succ a)+ pred (ModifiedJulianDay a) = ModifiedJulianDay (pred a)+ toEnum = ModifiedJulianDay . toEnum+ fromEnum (ModifiedJulianDay a) = fromEnum a+ enumFrom (ModifiedJulianDay a) = fmap ModifiedJulianDay (enumFrom a)+ enumFromThen (ModifiedJulianDay a) (ModifiedJulianDay b) = fmap ModifiedJulianDay (enumFromThen a b)+ enumFromTo (ModifiedJulianDay a) (ModifiedJulianDay b) = fmap ModifiedJulianDay (enumFromTo a b)+ enumFromThenTo (ModifiedJulianDay a) (ModifiedJulianDay b) (ModifiedJulianDay c) =+ fmap ModifiedJulianDay (enumFromThenTo a b c)++instance Ix Day where+ range (ModifiedJulianDay a, ModifiedJulianDay b) = fmap ModifiedJulianDay (range (a, b))+ index (ModifiedJulianDay a, ModifiedJulianDay b) (ModifiedJulianDay c) = index (a, b) c+ inRange (ModifiedJulianDay a, ModifiedJulianDay b) (ModifiedJulianDay c) = inRange (a, b) c+ rangeSize (ModifiedJulianDay a, ModifiedJulianDay b) = rangeSize (a, b)++addDays :: Integer -> Day -> Day+addDays n (ModifiedJulianDay a) = ModifiedJulianDay (a + n)++diffDays :: Day -> Day -> Integer+diffDays (ModifiedJulianDay a) (ModifiedJulianDay b) = a - b++-- | The class of types which can be represented as a period of days.+--+-- @since 1.12.1+class Ord p => DayPeriod p where+ -- | Returns the first 'Day' in a period of days.+ periodFirstDay :: p -> Day++ -- | Returns the last 'Day' in a period of days.+ periodLastDay :: p -> Day++ -- | Get the period this day is in.+ dayPeriod :: Day -> p++-- | A list of all the days in this period.+--+-- @since 1.12.1+periodAllDays :: DayPeriod p => p -> [Day]+periodAllDays p = [periodFirstDay p .. periodLastDay p]++-- | Test whether a day is in a given period.+--+-- @since 1.16+periodIn :: DayPeriod p => p -> Day -> Bool+periodIn p d = (d >= periodFirstDay p) && (d <= periodLastDay p)++-- | The number of days in this period.+--+-- @since 1.12.1+periodLength :: DayPeriod p => p -> Int+periodLength p = succ $ fromInteger $ diffDays (periodLastDay p) (periodFirstDay p)++-- | Get the period this day is in, with the 1-based day number within the period.+--+-- @periodFromDay (periodFirstDay p) = (p,1)@+--+-- @since 1.12.1+periodFromDay :: DayPeriod p => Day -> (p, Int)+periodFromDay d =+ let+ p = dayPeriod d+ dt = succ $ fromInteger $ diffDays d $ periodFirstDay p+ in+ (p, dt)++-- | Inverse of 'periodFromDay'.+--+-- @since 1.12.1+periodToDay :: DayPeriod p => p -> Int -> Day+periodToDay p i = addDays (toInteger $ pred i) $ periodFirstDay p++-- | Inverse of 'periodFromDay', clipping the day number to the period.+--+-- @since 1.15+periodToDayClip :: DayPeriod p => p -> Int -> Day+periodToDayClip p i = periodToDay p $ clip 1 (periodLength p) i++-- | Validating inverse of 'periodFromDay'.+--+-- @since 1.12.1+periodToDayValid :: DayPeriod p => p -> Int -> Maybe Day+periodToDayValid p i =+ let+ d = periodToDay p i+ in+ if fst (periodFromDay d) == p then Just d else Nothing++instance DayPeriod Day where+ periodFirstDay = id+ periodLastDay = id+ dayPeriod = id
+ lib/Data/Time/Calendar/Easter.hs view
@@ -0,0 +1,46 @@+{-# LANGUAGE Safe #-}++module Data.Time.Calendar.Easter (+ sundayAfter,+ orthodoxPaschalMoon,+ orthodoxEaster,+ gregorianPaschalMoon,+ gregorianEaster,+) where++-- formulae from Reingold & Dershowitz, _Calendrical Calculations_, ch. 8.+import Data.Time.Calendar+import Data.Time.Calendar.Julian++-- | The next Sunday strictly after a given day.+sundayAfter :: Day -> Day+sundayAfter day = addDays (7 - (mod (toModifiedJulianDay day + 3) 7)) day++-- | Given a year, find the Paschal full moon according to Orthodox Christian tradition+orthodoxPaschalMoon :: Year -> Day+orthodoxPaschalMoon year = addDays (-shiftedEpact) (fromJulian jyear 4 19)+ where+ shiftedEpact = mod (14 + 11 * (mod year 19)) 30+ jyear =+ if year > 0+ then year+ else year - 1++-- | Given a year, find Easter according to Orthodox Christian tradition+orthodoxEaster :: Year -> Day+orthodoxEaster = sundayAfter . orthodoxPaschalMoon++-- | Given a year, find the Paschal full moon according to the Gregorian method+gregorianPaschalMoon :: Year -> Day+gregorianPaschalMoon year = addDays (-adjustedEpact) (fromGregorian year 4 19)+ where+ century = (div year 100) + 1+ shiftedEpact = mod (14 + 11 * (mod year 19) - (div (3 * century) 4) + (div (5 + 8 * century) 25)) 30+ adjustedEpact =+ if shiftedEpact == 0 || ((shiftedEpact == 1) && (mod year 19 < 10))+ then shiftedEpact + 1+ else shiftedEpact++-- | Given a year, find Easter according to the Gregorian method+gregorianEaster :: Year -> Day+gregorianEaster = sundayAfter . gregorianPaschalMoon
+ lib/Data/Time/Calendar/Gregorian.hs view
@@ -0,0 +1,154 @@+{-# LANGUAGE Safe #-}++{-# OPTIONS -fno-warn-orphans #-}++module Data.Time.Calendar.Gregorian where++import Data.Time.Calendar.CalendarDiffDays+import Data.Time.Calendar.Days+import Data.Time.Calendar.MonthDay+import Data.Time.Calendar.OrdinalDate+import Data.Time.Calendar.Private++-- | Convert to proleptic Gregorian calendar.+toGregorian :: Day -> (Year, MonthOfYear, DayOfMonth)+toGregorian date = (year, month, day)+ where+ (year, yd) = toOrdinalDate date+ (month, day) = dayOfYearToMonthAndDay (isLeapYear year) yd++-- | Convert from proleptic Gregorian calendar.+-- Invalid values will be clipped to the correct range, month first, then day.+fromGregorian :: Year -> MonthOfYear -> DayOfMonth -> Day+fromGregorian year month day = fromOrdinalDate year (monthAndDayToDayOfYear (isLeapYear year) month day)++-- | Bidirectional abstract constructor for the proleptic Gregorian calendar.+-- Invalid values will be clipped to the correct range, month first, then day.+pattern YearMonthDay :: Year -> MonthOfYear -> DayOfMonth -> Day+pattern YearMonthDay y m d <-+ (toGregorian -> (y, m, d))+ where+ YearMonthDay y m d = fromGregorian y m d++{-# COMPLETE YearMonthDay #-}++-- | Convert from proleptic Gregorian calendar.+-- Invalid values will return Nothing+fromGregorianValid :: Year -> MonthOfYear -> DayOfMonth -> Maybe Day+fromGregorianValid year month day = do+ doy <- monthAndDayToDayOfYearValid (isLeapYear year) month day+ fromOrdinalDateValid year doy++-- | Show in ISO 8601 format (yyyy-mm-dd)+showGregorian :: Day -> String+showGregorian date = (show4 y) ++ "-" ++ (show2 m) ++ "-" ++ (show2 d)+ where+ (y, m, d) = toGregorian date++-- | The number of days in a given month according to the proleptic Gregorian calendar.+gregorianMonthLength :: Year -> MonthOfYear -> DayOfMonth+gregorianMonthLength year = monthLength (isLeapYear year)++rolloverMonths :: (Year, Integer) -> (Year, MonthOfYear)+rolloverMonths (y, m) = (y + (div (m - 1) 12), fromIntegral (mod (m - 1) 12) + 1)++addGregorianMonths :: Integer -> Day -> (Year, MonthOfYear, DayOfMonth)+addGregorianMonths n day = (y', m', d)+ where+ (y, m, d) = toGregorian day+ (y', m') = rolloverMonths (y, fromIntegral m + n)++-- | Add months, with days past the last day of the month clipped to the last day.+-- For instance, 2005-01-30 + 1 month = 2005-02-28.+addGregorianMonthsClip :: Integer -> Day -> Day+addGregorianMonthsClip n day = fromGregorian y m d+ where+ (y, m, d) = addGregorianMonths n day++-- | Add months, with days past the last day of the month rolling over to the next month.+-- For instance, 2005-01-30 + 1 month = 2005-03-02.+addGregorianMonthsRollOver :: Integer -> Day -> Day+addGregorianMonthsRollOver n day = addDays (fromIntegral d - 1) (fromGregorian y m 1)+ where+ (y, m, d) = addGregorianMonths n day++-- | Add years, matching month and day, with Feb 29th clipped to Feb 28th if necessary.+-- For instance, 2004-02-29 + 2 years = 2006-02-28.+addGregorianYearsClip :: Integer -> Day -> Day+addGregorianYearsClip n = addGregorianMonthsClip (n * 12)++-- | Add years, matching month and day, with Feb 29th rolled over to Mar 1st if necessary.+-- For instance, 2004-02-29 + 2 years = 2006-03-01.+addGregorianYearsRollOver :: Integer -> Day -> Day+addGregorianYearsRollOver n = addGregorianMonthsRollOver (n * 12)++-- | Add months (clipped to last day), then add days+addGregorianDurationClip :: CalendarDiffDays -> Day -> Day+addGregorianDurationClip (CalendarDiffDays m d) day = addDays d $ addGregorianMonthsClip m day++-- | Add months (rolling over to next month), then add days+addGregorianDurationRollOver :: CalendarDiffDays -> Day -> Day+addGregorianDurationRollOver (CalendarDiffDays m d) day = addDays d $ addGregorianMonthsRollOver m day++-- | Calendrical difference, with as many whole months as possible.+-- Has the property @addGregorianDurationClip (diffGregorianDurationClip d2 d1) d1 = d2@.+-- For example, 2027-03-01 - 2027-01-31 = 1 month and 1 day.+diffGregorianDurationClip :: Day -> Day -> CalendarDiffDays+diffGregorianDurationClip day2 day1 =+ let+ (y1, m1, d1) = toGregorian day1+ (y2, m2, d2) = toGregorian day2+ ym1 = y1 * 12 + toInteger m1+ ym2 = y2 * 12 + toInteger m2+ ymdiff = ym2 - ym1+ ymAllowed =+ if day2 >= day1+ then+ if d2 >= d1+ then ymdiff+ else ymdiff - 1+ else+ if d2 <= d1+ then ymdiff+ else ymdiff + 1+ dayAllowed = addGregorianDurationClip (CalendarDiffDays ymAllowed 0) day1+ in+ CalendarDiffDays ymAllowed $ diffDays day2 dayAllowed++-- | Calendrical difference, with as many whole months as possible.+-- Has the property @addGregorianDurationRollOver (diffGregorianDurationRollOver d2 d1) d1 = d2@.+-- For example, 2027-03-01 - 2027-01-31 = 29 days.+diffGregorianDurationRollOver :: Day -> Day -> CalendarDiffDays+diffGregorianDurationRollOver day2 day1 =+ let+ (y1, m1, _) = toGregorian day1+ (y2, m2, _) = toGregorian day2+ ym1 = y1 * 12 + toInteger m1+ ym2 = y2 * 12 + toInteger m2+ ymdiff = ym2 - ym1+ findpos mdiff =+ let+ dayAllowed = addGregorianDurationRollOver (CalendarDiffDays mdiff 0) day1+ dd = diffDays day2 dayAllowed+ in+ if dd >= 0 then CalendarDiffDays mdiff dd else findpos (pred mdiff)+ findneg mdiff =+ let+ dayAllowed = addGregorianDurationRollOver (CalendarDiffDays mdiff 0) day1+ dd = diffDays day2 dayAllowed+ in+ if dd <= 0 then CalendarDiffDays mdiff dd else findpos (succ mdiff)+ in+ if day2 >= day1+ then findpos ymdiff+ else findneg ymdiff++-- orphan instance+instance Show Day where+ show = showGregorian++-- orphan instance+instance DayPeriod Year where+ periodFirstDay y = YearMonthDay y January 1+ periodLastDay y = YearMonthDay y December 31+ dayPeriod (YearMonthDay y _ _) = y
+ lib/Data/Time/Calendar/Julian.hs view
@@ -0,0 +1,175 @@+{-# LANGUAGE Safe #-}++module Data.Time.Calendar.Julian (+ Year,+ MonthOfYear,+ pattern January,+ pattern February,+ pattern March,+ pattern April,+ pattern May,+ pattern June,+ pattern July,+ pattern August,+ pattern September,+ pattern October,+ pattern November,+ pattern December,+ DayOfMonth,+ DayOfYear,++ -- * Year and day format+ module Data.Time.Calendar.JulianYearDay,+ toJulian,+ fromJulian,+ pattern JulianYearMonthDay,+ fromJulianValid,+ showJulian,+ julianMonthLength,+ -- calendrical arithmetic+ -- e.g. "one month after March 31st"+ addJulianMonthsClip,+ addJulianMonthsRollOver,+ addJulianYearsClip,+ addJulianYearsRollOver,+ addJulianDurationClip,+ addJulianDurationRollOver,+ diffJulianDurationClip,+ diffJulianDurationRollOver,+) where++import Data.Time.Calendar.CalendarDiffDays+import Data.Time.Calendar.Days+import Data.Time.Calendar.JulianYearDay+import Data.Time.Calendar.MonthDay+import Data.Time.Calendar.Private+import Data.Time.Calendar.Types++-- | Convert to proleptic Julian calendar.+toJulian :: Day -> (Year, MonthOfYear, DayOfMonth)+toJulian date = (year, month, day)+ where+ (year, yd) = toJulianYearAndDay date+ (month, day) = dayOfYearToMonthAndDay (isJulianLeapYear year) yd++-- | Convert from proleptic Julian calendar.+-- Invalid values will be clipped to the correct range, month first, then day.+fromJulian :: Year -> MonthOfYear -> DayOfMonth -> Day+fromJulian year month day = fromJulianYearAndDay year (monthAndDayToDayOfYear (isJulianLeapYear year) month day)++-- | Bidirectional abstract constructor for the proleptic Julian calendar.+-- Invalid values will be clipped to the correct range, month first, then day.+pattern JulianYearMonthDay :: Year -> MonthOfYear -> DayOfMonth -> Day+pattern JulianYearMonthDay y m d <-+ (toJulian -> (y, m, d))+ where+ JulianYearMonthDay y m d = fromJulian y m d++{-# COMPLETE JulianYearMonthDay #-}++-- | Convert from proleptic Julian calendar.+-- Invalid values will return Nothing.+fromJulianValid :: Year -> MonthOfYear -> DayOfMonth -> Maybe Day+fromJulianValid year month day = do+ doy <- monthAndDayToDayOfYearValid (isJulianLeapYear year) month day+ fromJulianYearAndDayValid year doy++-- | Show in ISO 8601 format (yyyy-mm-dd)+showJulian :: Day -> String+showJulian date = (show4 y) ++ "-" ++ (show2 m) ++ "-" ++ (show2 d)+ where+ (y, m, d) = toJulian date++-- | The number of days in a given month according to the proleptic Julian calendar.+julianMonthLength :: Year -> MonthOfYear -> DayOfMonth+julianMonthLength year = monthLength (isJulianLeapYear year)++rolloverMonths :: (Year, Integer) -> (Year, MonthOfYear)+rolloverMonths (y, m) = (y + (div (m - 1) 12), fromIntegral (mod (m - 1) 12) + 1)++addJulianMonths :: Integer -> Day -> (Year, MonthOfYear, DayOfMonth)+addJulianMonths n day = (y', m', d)+ where+ (y, m, d) = toJulian day+ (y', m') = rolloverMonths (y, fromIntegral m + n)++-- | Add months, with days past the last day of the month clipped to the last day.+-- For instance, 2005-01-30 + 1 month = 2005-02-28.+addJulianMonthsClip :: Integer -> Day -> Day+addJulianMonthsClip n day = fromJulian y m d+ where+ (y, m, d) = addJulianMonths n day++-- | Add months, with days past the last day of the month rolling over to the next month.+-- For instance, 2005-01-30 + 1 month = 2005-03-02.+addJulianMonthsRollOver :: Integer -> Day -> Day+addJulianMonthsRollOver n day = addDays (fromIntegral d - 1) (fromJulian y m 1)+ where+ (y, m, d) = addJulianMonths n day++-- | Add years, matching month and day, with Feb 29th clipped to Feb 28th if necessary.+-- For instance, 2004-02-29 + 2 years = 2006-02-28.+addJulianYearsClip :: Integer -> Day -> Day+addJulianYearsClip n = addJulianMonthsClip (n * 12)++-- | Add years, matching month and day, with Feb 29th rolled over to Mar 1st if necessary.+-- For instance, 2004-02-29 + 2 years = 2006-03-01.+addJulianYearsRollOver :: Integer -> Day -> Day+addJulianYearsRollOver n = addJulianMonthsRollOver (n * 12)++-- | Add months (clipped to last day), then add days+addJulianDurationClip :: CalendarDiffDays -> Day -> Day+addJulianDurationClip (CalendarDiffDays m d) day = addDays d $ addJulianMonthsClip m day++-- | Add months (rolling over to next month), then add days+addJulianDurationRollOver :: CalendarDiffDays -> Day -> Day+addJulianDurationRollOver (CalendarDiffDays m d) day = addDays d $ addJulianMonthsRollOver m day++-- | Calendrical difference, with as many whole months as possible+diffJulianDurationClip :: Day -> Day -> CalendarDiffDays+diffJulianDurationClip day2 day1 =+ let+ (y1, m1, d1) = toJulian day1+ (y2, m2, d2) = toJulian day2+ ym1 = y1 * 12 + toInteger m1+ ym2 = y2 * 12 + toInteger m2+ ymdiff = ym2 - ym1+ ymAllowed =+ if day2 >= day1+ then+ if d2 >= d1+ then ymdiff+ else ymdiff - 1+ else+ if d2 <= d1+ then ymdiff+ else ymdiff + 1+ dayAllowed = addJulianDurationClip (CalendarDiffDays ymAllowed 0) day1+ in+ CalendarDiffDays ymAllowed $ diffDays day2 dayAllowed++-- | Calendrical difference, with as many whole months as possible.+diffJulianDurationRollOver :: Day -> Day -> CalendarDiffDays+diffJulianDurationRollOver day2 day1 =+ let+ (y1, m1, _) = toJulian day1+ (y2, m2, _) = toJulian day2+ ym1 = y1 * 12 + toInteger m1+ ym2 = y2 * 12 + toInteger m2+ ymdiff = ym2 - ym1+ findpos mdiff =+ let+ dayAllowed = addJulianDurationRollOver (CalendarDiffDays mdiff 0) day1+ dd = diffDays day2 dayAllowed+ in+ if dd >= 0 then CalendarDiffDays mdiff dd else findpos (pred mdiff)+ findneg mdiff =+ let+ dayAllowed = addJulianDurationRollOver (CalendarDiffDays mdiff 0) day1+ dd = diffDays day2 dayAllowed+ in+ if dd <= 0 then CalendarDiffDays mdiff dd else findpos (succ mdiff)+ in+ if day2 >= day1+ then findpos ymdiff+ else findneg ymdiff
+ lib/Data/Time/Calendar/JulianYearDay.hs view
@@ -0,0 +1,66 @@+{-# LANGUAGE Safe #-}++module Data.Time.Calendar.JulianYearDay where++import Data.Time.Calendar.Days+import Data.Time.Calendar.Private+import Data.Time.Calendar.Types++-- | Convert to proleptic Julian year and day format.+toJulianYearAndDay :: Day -> (Year, DayOfYear)+toJulianYearAndDay (ModifiedJulianDay mjd) = (year, yd)+ where+ a = mjd + 678577+ quad = div a 1461+ d = mod a 1461+ y = min (div d 365) 3+ yd = fromInteger (d - (y * 365) + 1)+ year = quad * 4 + y + 1++-- | Convert from proleptic Julian year and day format.+-- Invalid day numbers will be clipped to the correct range (1 to 365 or 366).+fromJulianYearAndDay :: Year -> DayOfYear -> Day+fromJulianYearAndDay year day = ModifiedJulianDay mjd+ where+ y = year - 1+ mjd =+ ( fromIntegral+ ( clip+ 1+ ( if isJulianLeapYear year+ then 366+ else 365+ )+ day+ )+ )+ + (365 * y)+ + (div y 4)+ - 678578++-- | Convert from proleptic Julian year and day format.+-- Invalid day numbers will return Nothing+fromJulianYearAndDayValid :: Year -> DayOfYear -> Maybe Day+fromJulianYearAndDayValid year day = do+ day' <-+ clipValid+ 1+ ( if isJulianLeapYear year+ then 366+ else 365+ )+ day+ let+ y = year - 1+ mjd = (fromIntegral day') + (365 * y) + (div y 4) - 678578+ return (ModifiedJulianDay mjd)++-- | Show in proleptic Julian year and day format (yyyy-ddd)+showJulianYearAndDay :: Day -> String+showJulianYearAndDay date = (show4 y) ++ "-" ++ (show3 d)+ where+ (y, d) = toJulianYearAndDay date++-- | Is this year a leap year according to the proleptic Julian calendar?+isJulianLeapYear :: Year -> Bool+isJulianLeapYear year = (mod year 4 == 0)
+ lib/Data/Time/Calendar/Month.hs view
@@ -0,0 +1,105 @@+{-# LANGUAGE CPP #-}+{-# LANGUAGE Safe #-}++-- | An absolute count of common calendar months.+module Data.Time.Calendar.Month (+ Month (..),+ addMonths,+ diffMonths,+ pattern YearMonth,+ fromYearMonthValid,+ pattern MonthDay,+ fromMonthDayValid,+) where++import Control.DeepSeq+import Data.Data+import Data.Fixed+import Data.Ix+import Data.Time.Calendar.Days+import Data.Time.Calendar.Gregorian+import Data.Time.Calendar.Private+import Data.Time.Calendar.Types+import GHC.Generics+#if __GLASGOW_HASKELL__ >= 914+import qualified Language.Haskell.TH.Lift as TH+#else+import qualified Language.Haskell.TH.Syntax as TH+#endif+import Text.ParserCombinators.ReadP+import Text.Read++-- | An absolute count of common calendar months.+-- Number is equal to @(year * 12) + (monthOfYear - 1)@.+newtype Month = MkMonth Integer deriving (Eq, Ord, Typeable, Data, Generic, TH.Lift)++instance NFData Month where+ rnf (MkMonth m) = rnf m++instance Enum Month where+ succ (MkMonth a) = MkMonth (succ a)+ pred (MkMonth a) = MkMonth (pred a)+ toEnum = MkMonth . toEnum+ fromEnum (MkMonth a) = fromEnum a+ enumFrom (MkMonth a) = fmap MkMonth (enumFrom a)+ enumFromThen (MkMonth a) (MkMonth b) = fmap MkMonth (enumFromThen a b)+ enumFromTo (MkMonth a) (MkMonth b) = fmap MkMonth (enumFromTo a b)+ enumFromThenTo (MkMonth a) (MkMonth b) (MkMonth c) =+ fmap MkMonth (enumFromThenTo a b c)++instance Ix Month where+ range (MkMonth a, MkMonth b) = fmap MkMonth (range (a, b))+ index (MkMonth a, MkMonth b) (MkMonth c) = index (a, b) c+ inRange (MkMonth a, MkMonth b) (MkMonth c) = inRange (a, b) c+ rangeSize (MkMonth a, MkMonth b) = rangeSize (a, b)++-- | Show as @yyyy-mm@.+instance Show Month where+ show (YearMonth y m) = show4 y ++ "-" ++ show2 m++-- | Read as @yyyy-mm@.+instance Read Month where+ readPrec = do+ y <- readPrec+ _ <- lift $ char '-'+ m <- readPrec+ return $ YearMonth y m++instance DayPeriod Month where+ periodFirstDay (YearMonth y m) = YearMonthDay y m 1+ periodLastDay (YearMonth y m) = YearMonthDay y m 31 -- clips to correct day+ dayPeriod (YearMonthDay y my _) = YearMonth y my++addMonths :: Integer -> Month -> Month+addMonths n (MkMonth a) = MkMonth $ a + n++diffMonths :: Month -> Month -> Integer+diffMonths (MkMonth a) (MkMonth b) = a - b++-- | Bidirectional abstract constructor.+-- Invalid months of year will be clipped to the correct range.+pattern YearMonth :: Year -> MonthOfYear -> Month+pattern YearMonth y my <-+ MkMonth ((\m -> divMod' m 12) -> (y, (succ . fromInteger -> my)))+ where+ YearMonth y my = MkMonth $ (y * 12) + toInteger (pred $ clip 1 12 my)++fromYearMonthValid :: Year -> MonthOfYear -> Maybe Month+fromYearMonthValid y my = do+ my' <- clipValid 1 12 my+ return $ YearMonth y my'++{-# COMPLETE YearMonth #-}++-- | Bidirectional abstract constructor.+-- Invalid days of month will be clipped to the correct range.+pattern MonthDay :: Month -> DayOfMonth -> Day+pattern MonthDay m dm <-+ (periodFromDay -> (m, dm))+ where+ MonthDay = periodToDayClip++fromMonthDayValid :: Month -> DayOfMonth -> Maybe Day+fromMonthDayValid = periodToDayValid++{-# COMPLETE MonthDay #-}
+ lib/Data/Time/Calendar/MonthDay.hs view
@@ -0,0 +1,108 @@+{-# LANGUAGE Safe #-}++module Data.Time.Calendar.MonthDay (+ MonthOfYear,+ pattern January,+ pattern February,+ pattern March,+ pattern April,+ pattern May,+ pattern June,+ pattern July,+ pattern August,+ pattern September,+ pattern October,+ pattern November,+ pattern December,+ DayOfMonth,+ DayOfYear,+ monthAndDayToDayOfYear,+ monthAndDayToDayOfYearValid,+ dayOfYearToMonthAndDay,+ monthLength,+) where++import Data.Time.Calendar.Private+import Data.Time.Calendar.Types++-- | Convert month and day in the Gregorian or Julian calendars to day of year.+-- First arg is leap year flag.+monthAndDayToDayOfYear :: Bool -> MonthOfYear -> DayOfMonth -> DayOfYear+monthAndDayToDayOfYear isLeap month day = (div (367 * month'' - 362) 12) + k + day'+ where+ month' = clip 1 12 month+ day' = fromIntegral (clip 1 (monthLength' isLeap month') day)+ month'' = fromIntegral month'+ k =+ if month' <= 2+ then 0+ else+ if isLeap+ then -1+ else -2++-- | Convert month and day in the Gregorian or Julian calendars to day of year.+-- First arg is leap year flag.+monthAndDayToDayOfYearValid :: Bool -> MonthOfYear -> DayOfMonth -> Maybe DayOfYear+monthAndDayToDayOfYearValid isLeap month day = do+ month' <- clipValid 1 12 month+ day' <- clipValid 1 (monthLength' isLeap month') day+ let+ day'' = fromIntegral day'+ month'' = fromIntegral month'+ k =+ if month' <= 2+ then 0+ else+ if isLeap+ then -1+ else -2+ return ((div (367 * month'' - 362) 12) + k + day'')++-- | Convert day of year in the Gregorian or Julian calendars to month and day.+-- First arg is leap year flag.+dayOfYearToMonthAndDay :: Bool -> DayOfYear -> (MonthOfYear, DayOfMonth)+dayOfYearToMonthAndDay isLeap yd =+ findMonthDay+ (monthLengths isLeap)+ ( clip+ 1+ ( if isLeap+ then 366+ else 365+ )+ yd+ )++findMonthDay :: [Int] -> Int -> (Int, Int)+findMonthDay (n : ns) yd+ | yd > n = (\(m, d) -> (m + 1, d)) (findMonthDay ns (yd - n))+findMonthDay _ yd = (1, yd)++-- | The length of a given month in the Gregorian or Julian calendars.+-- First arg is leap year flag.+monthLength :: Bool -> MonthOfYear -> DayOfMonth+monthLength isLeap month' = monthLength' isLeap (clip 1 12 month')++monthLength' :: Bool -> MonthOfYear -> DayOfMonth+monthLength' isLeap month' = (monthLengths isLeap) !! (month' - 1)++monthLengths :: Bool -> [DayOfMonth]+monthLengths isleap =+ [ 31+ , if isleap+ then 29+ else 28+ , 31+ , 30+ , 31+ , 30+ , 31+ , 31+ , 30+ , 31+ , 30+ , 31+ ]++-- J F M A M J J A S O N D
+ lib/Data/Time/Calendar/OrdinalDate.hs view
@@ -0,0 +1,223 @@+{-# LANGUAGE Safe #-}++-- | ISO 8601 Ordinal Date format+module Data.Time.Calendar.OrdinalDate (Day, Year, DayOfYear, WeekOfYear, module Data.Time.Calendar.OrdinalDate) where++import Data.Time.Calendar.Days+import Data.Time.Calendar.Private+import Data.Time.Calendar.Types++-- | Convert to ISO 8601 Ordinal Date format.+toOrdinalDate :: Day -> (Year, DayOfYear)+toOrdinalDate (ModifiedJulianDay mjd) = (year, yd)+ where+ a = mjd + 678575+ quadcent = div a 146097+ b = mod a 146097+ cent = min (div b 36524) 3+ c = b - (cent * 36524)+ quad = div c 1461+ d = mod c 1461+ y = min (div d 365) 3+ yd = fromInteger (d - (y * 365) + 1)+ year = quadcent * 400 + cent * 100 + quad * 4 + y + 1++-- | Convert from ISO 8601 Ordinal Date format.+-- Invalid day numbers will be clipped to the correct range (1 to 365 or 366).+fromOrdinalDate :: Year -> DayOfYear -> Day+fromOrdinalDate year day = ModifiedJulianDay mjd+ where+ y = year - 1+ mjd =+ ( fromIntegral+ ( clip+ 1+ ( if isLeapYear year+ then 366+ else 365+ )+ day+ )+ )+ + (365 * y)+ + (div y 4)+ - (div y 100)+ + (div y 400)+ - 678576++-- | Bidirectional abstract constructor for ISO 8601 Ordinal Date format.+-- Invalid day numbers will be clipped to the correct range (1 to 365 or 366).+pattern YearDay :: Year -> DayOfYear -> Day+pattern YearDay y d <-+ (toOrdinalDate -> (y, d))+ where+ YearDay y d = fromOrdinalDate y d++{-# COMPLETE YearDay #-}++-- | Convert from ISO 8601 Ordinal Date format.+-- Invalid day numbers return 'Nothing'+fromOrdinalDateValid :: Year -> DayOfYear -> Maybe Day+fromOrdinalDateValid year day = do+ day' <-+ clipValid+ 1+ ( if isLeapYear year+ then 366+ else 365+ )+ day+ let+ y = year - 1+ mjd = (fromIntegral day') + (365 * y) + (div y 4) - (div y 100) + (div y 400) - 678576+ return (ModifiedJulianDay mjd)++-- | Show in ISO 8601 Ordinal Date format (yyyy-ddd)+showOrdinalDate :: Day -> String+showOrdinalDate date = (show4 y) ++ "-" ++ (show3 d)+ where+ (y, d) = toOrdinalDate date++-- | Is this year a leap year according to the proleptic Gregorian calendar?+isLeapYear :: Year -> Bool+isLeapYear year = (mod year 4 == 0) && ((mod year 400 == 0) || not (mod year 100 == 0))++-- | Get the number of the Monday-starting week in the year and the day of the week.+-- The first Monday is the first day of week 1, any earlier days in the year are week 0 (as @%W@ in 'Data.Time.Format.formatTime').+-- Monday is 1, Sunday is 7 (as @%u@ in 'Data.Time.Format.formatTime').+mondayStartWeek :: Day -> (WeekOfYear, Int)+mondayStartWeek date = (fromInteger ((div d 7) - (div k 7)), fromInteger (mod d 7) + 1)+ where+ yd = snd (toOrdinalDate date)+ d = (toModifiedJulianDay date) + 2+ k = d - (toInteger yd)++-- | Get the number of the Sunday-starting week in the year and the day of the week.+-- The first Sunday is the first day of week 1, any earlier days in the year are week 0 (as @%U@ in 'Data.Time.Format.formatTime').+-- Sunday is 0, Saturday is 6 (as @%w@ in 'Data.Time.Format.formatTime').+sundayStartWeek :: Day -> (WeekOfYear, Int)+sundayStartWeek date = (fromInteger ((div d 7) - (div k 7)), fromInteger (mod d 7))+ where+ yd = snd (toOrdinalDate date)+ d = (toModifiedJulianDay date) + 3+ k = d - (toInteger yd)++-- | The inverse of 'mondayStartWeek'. Get a 'Day' given the year,+-- the number of the Monday-starting week, and the day of the week.+-- The first Monday is the first day of week 1, any earlier days in the year+-- are week 0 (as @%W@ in 'Data.Time.Format.formatTime').+fromMondayStartWeek ::+ -- | Year.+ Year ->+ -- | Monday-starting week number (as @%W@ in 'Data.Time.Format.formatTime').+ WeekOfYear ->+ -- | Day of week.+ -- Monday is 1, Sunday is 7 (as @%u@ in 'Data.Time.Format.formatTime').+ Int ->+ Day+fromMondayStartWeek year w d =+ let+ -- first day of the year+ firstDay = fromOrdinalDate year 1+ -- 0-based year day of first monday of the year+ zbFirstMonday = (5 - toModifiedJulianDay firstDay) `mod` 7+ -- 0-based week of year+ zbWeek = w - 1+ -- 0-based day of week+ zbDay = d - 1+ -- 0-based day in year+ zbYearDay = zbFirstMonday + 7 * toInteger zbWeek + toInteger zbDay+ in+ addDays zbYearDay firstDay++fromMondayStartWeekValid ::+ -- | Year.+ Year ->+ -- | Monday-starting week number (as @%W@ in 'Data.Time.Format.formatTime').+ WeekOfYear ->+ -- | Day of week.+ -- Monday is 1, Sunday is 7 (as @%u@ in 'Data.Time.Format.formatTime').+ Int ->+ Maybe Day+fromMondayStartWeekValid year w d = do+ d' <- clipValid 1 7 d+ let+ -- first day of the year+ firstDay = fromOrdinalDate year 1+ -- 0-based week of year+ zbFirstMonday = (5 - toModifiedJulianDay firstDay) `mod` 7+ -- 0-based week number+ zbWeek = w - 1+ -- 0-based day of week+ zbDay = d' - 1+ -- 0-based day in year+ zbYearDay = zbFirstMonday + 7 * toInteger zbWeek + toInteger zbDay+ zbYearDay' <-+ clipValid+ 0+ ( if isLeapYear year+ then 365+ else 364+ )+ zbYearDay+ return $ addDays zbYearDay' firstDay++-- | The inverse of 'sundayStartWeek'. Get a 'Day' given the year and+-- the number of the day of a Sunday-starting week.+-- The first Sunday is the first day of week 1, any earlier days in the+-- year are week 0 (as @%U@ in 'Data.Time.Format.formatTime').+fromSundayStartWeek ::+ -- | Year.+ Year ->+ -- | Sunday-starting week number (as @%U@ in 'Data.Time.Format.formatTime').+ WeekOfYear ->+ -- | Day of week+ -- Sunday is 0, Saturday is 6 (as @%w@ in 'Data.Time.Format.formatTime').+ Int ->+ Day+fromSundayStartWeek year w d =+ let+ -- first day of the year+ firstDay = fromOrdinalDate year 1+ -- 0-based year day of first monday of the year+ zbFirstSunday = (4 - toModifiedJulianDay firstDay) `mod` 7+ -- 0-based week of year+ zbWeek = w - 1+ -- 0-based day of week+ zbDay = d+ -- 0-based day in year+ zbYearDay = zbFirstSunday + 7 * toInteger zbWeek + toInteger zbDay+ in+ addDays zbYearDay firstDay++fromSundayStartWeekValid ::+ -- | Year.+ Year ->+ -- | Sunday-starting week number (as @%U@ in 'Data.Time.Format.formatTime').+ WeekOfYear ->+ -- | Day of week.+ -- Sunday is 0, Saturday is 6 (as @%w@ in 'Data.Time.Format.formatTime').+ Int ->+ Maybe Day+fromSundayStartWeekValid year w d = do+ d' <- clipValid 0 6 d+ let+ -- first day of the year+ firstDay = fromOrdinalDate year 1+ -- 0-based week of year+ zbFirstSunday = (4 - toModifiedJulianDay firstDay) `mod` 7+ -- 0-based week number+ zbWeek = w - 1+ -- 0-based day of week+ zbDay = d'+ -- 0-based day in year+ zbYearDay = zbFirstSunday + 7 * toInteger zbWeek + toInteger zbDay+ zbYearDay' <-+ clipValid+ 0+ ( if isLeapYear year+ then 365+ else 364+ )+ zbYearDay+ return $ addDays zbYearDay' firstDay
+ lib/Data/Time/Calendar/Private.hs view
@@ -0,0 +1,81 @@+{-# LANGUAGE Safe #-}++module Data.Time.Calendar.Private where++import Data.Fixed++data PadOption+ = Pad+ Int+ Char+ | NoPad++showPadded :: PadOption -> String -> String+showPadded NoPad s = s+showPadded (Pad i c) s = replicate (i - length s) c ++ s++class (Num t, Ord t, Show t) => ShowPadded t where+ showPaddedNum :: PadOption -> t -> String++instance ShowPadded Integer where+ showPaddedNum NoPad i = show i+ showPaddedNum pad i+ | i < 0 = '-' : (showPaddedNum pad (negate i))+ showPaddedNum pad i = showPadded pad $ show i++instance ShowPadded Int where+ showPaddedNum NoPad i = show i+ showPaddedNum _pad i+ | i == minBound = show i+ showPaddedNum pad i+ | i < 0 = '-' : (showPaddedNum pad (negate i))+ showPaddedNum pad i = showPadded pad $ show i++show2Fixed :: Pico -> String+show2Fixed x+ | x < 10 = '0' : (showFixed True x)+show2Fixed x = showFixed True x++show2 :: ShowPadded t => t -> String+show2 = showPaddedNum $ Pad 2 '0'++show3 :: ShowPadded t => t -> String+show3 = showPaddedNum $ Pad 3 '0'++show4 :: ShowPadded t => t -> String+show4 = showPaddedNum $ Pad 4 '0'++mod100 :: Integral i => i -> i+mod100 x = mod x 100++div100 :: Integral i => i -> i+div100 x = div x 100++clip :: Ord t => t -> t -> t -> t+clip a _ x+ | x < a = a+clip _ b x+ | x > b = b+clip _ _ x = x++clipValid :: Ord t => t -> t -> t -> Maybe t+clipValid a _ x+ | x < a = Nothing+clipValid _ b x+ | x > b = Nothing+clipValid _ _ x = Just x++quotBy :: (Real a, Integral b) => a -> a -> b+quotBy d n = truncate ((toRational n) / (toRational d))++remBy :: Real a => a -> a -> a+remBy d n = n - (fromInteger f) * d+ where+ f = quotBy d n++quotRemBy :: (Real a, Integral b) => a -> a -> (b, a)+quotRemBy d n =+ let+ f = quotBy d n+ in+ (f, n - (fromIntegral f) * d)
+ lib/Data/Time/Calendar/Quarter.hs view
@@ -0,0 +1,152 @@+{-# LANGUAGE CPP #-}+{-# LANGUAGE Safe #-}++-- | Year quarters.+module Data.Time.Calendar.Quarter (+ QuarterOfYear (..),+ addQuarters,+ diffQuarters,+ Quarter (..),+ pattern YearQuarter,+ monthOfYearQuarter,+ monthQuarter,+ dayQuarter,+ DayOfQuarter,+ pattern QuarterDay,+) where++import Control.DeepSeq+import Data.Data+import Data.Fixed+import Data.Ix+import Data.Time.Calendar.Days+import Data.Time.Calendar.Month+import Data.Time.Calendar.Private+import Data.Time.Calendar.Types+import GHC.Generics+#if __GLASGOW_HASKELL__ >= 914+import qualified Language.Haskell.TH.Lift as TH+#else+import qualified Language.Haskell.TH.Syntax as TH+#endif+import Text.ParserCombinators.ReadP+import Text.Read++-- | Quarters of each year. Each quarter corresponds to three months.+data QuarterOfYear = Q1 | Q2 | Q3 | Q4 deriving (Eq, Ord, Read, Show, Ix, Typeable, Data, Generic, TH.Lift)++-- | maps Q1..Q4 to 1..4+instance Enum QuarterOfYear where+ toEnum i =+ case mod' i 4 of+ 1 -> Q1+ 2 -> Q2+ 3 -> Q3+ _ -> Q4+ fromEnum Q1 = 1+ fromEnum Q2 = 2+ fromEnum Q3 = 3+ fromEnum Q4 = 4++instance Bounded QuarterOfYear where+ minBound = Q1+ maxBound = Q4++instance NFData QuarterOfYear where+ rnf Q1 = ()+ rnf Q2 = ()+ rnf Q3 = ()+ rnf Q4 = ()++-- | An absolute count of year quarters.+-- Number is equal to @(year * 4) + (quarterOfYear - 1)@.+newtype Quarter = MkQuarter Integer deriving (Eq, Ord, Typeable, Data, Generic, TH.Lift)++instance NFData Quarter where+ rnf (MkQuarter m) = rnf m++instance Enum Quarter where+ succ (MkQuarter a) = MkQuarter (succ a)+ pred (MkQuarter a) = MkQuarter (pred a)+ toEnum = MkQuarter . toEnum+ fromEnum (MkQuarter a) = fromEnum a+ enumFrom (MkQuarter a) = fmap MkQuarter (enumFrom a)+ enumFromThen (MkQuarter a) (MkQuarter b) = fmap MkQuarter (enumFromThen a b)+ enumFromTo (MkQuarter a) (MkQuarter b) = fmap MkQuarter (enumFromTo a b)+ enumFromThenTo (MkQuarter a) (MkQuarter b) (MkQuarter c) =+ fmap MkQuarter (enumFromThenTo a b c)++instance Ix Quarter where+ range (MkQuarter a, MkQuarter b) = fmap MkQuarter (range (a, b))+ index (MkQuarter a, MkQuarter b) (MkQuarter c) = index (a, b) c+ inRange (MkQuarter a, MkQuarter b) (MkQuarter c) = inRange (a, b) c+ rangeSize (MkQuarter a, MkQuarter b) = rangeSize (a, b)++-- | Show as @yyyy-Qn@.+instance Show Quarter where+ show (YearQuarter y qy) = show4 y ++ "-" ++ show qy++-- | Read as @yyyy-Qn@.+instance Read Quarter where+ readPrec = do+ y <- readPrec+ _ <- lift $ char '-'+ m <- readPrec+ return $ YearQuarter y m++instance DayPeriod Quarter where+ periodFirstDay (YearQuarter y q) =+ case q of+ Q1 -> periodFirstDay $ YearMonth y January+ Q2 -> periodFirstDay $ YearMonth y April+ Q3 -> periodFirstDay $ YearMonth y July+ Q4 -> periodFirstDay $ YearMonth y October+ periodLastDay (YearQuarter y q) =+ case q of+ Q1 -> periodLastDay $ YearMonth y March+ Q2 -> periodLastDay $ YearMonth y June+ Q3 -> periodLastDay $ YearMonth y September+ Q4 -> periodLastDay $ YearMonth y December+ dayPeriod (MonthDay m _) = monthQuarter m++addQuarters :: Integer -> Quarter -> Quarter+addQuarters n (MkQuarter a) = MkQuarter $ a + n++diffQuarters :: Quarter -> Quarter -> Integer+diffQuarters (MkQuarter a) (MkQuarter b) = a - b++-- | Bidirectional abstract constructor.+pattern YearQuarter :: Year -> QuarterOfYear -> Quarter+pattern YearQuarter y qy <-+ MkQuarter ((\q -> divMod' q 4) -> (y, (toEnum . succ . fromInteger -> qy)))+ where+ YearQuarter y qy = MkQuarter $ (y * 4) + toInteger (pred $ fromEnum qy)++{-# COMPLETE YearQuarter #-}++-- | The 'QuarterOfYear' this 'MonthOfYear' is in.+monthOfYearQuarter :: MonthOfYear -> QuarterOfYear+monthOfYearQuarter my | my <= 3 = Q1+monthOfYearQuarter my | my <= 6 = Q2+monthOfYearQuarter my | my <= 9 = Q3+monthOfYearQuarter _ = Q4++-- | The 'Quarter' this 'Month' is in.+monthQuarter :: Month -> Quarter+monthQuarter (YearMonth y my) = YearQuarter y $ monthOfYearQuarter my++-- | The 'Quarter' this 'Day' is in.+dayQuarter :: Day -> Quarter+dayQuarter = dayPeriod++-- | Bidirectional abstract constructor.+-- Invalid days of quarter will be clipped to the correct range.+--+-- @since 1.12.1+pattern QuarterDay :: Quarter -> DayOfQuarter -> Day+pattern QuarterDay q dq <-+ (periodFromDay -> (q, dq))+ where+ QuarterDay = periodToDayClip++{-# COMPLETE QuarterDay #-}
+ lib/Data/Time/Calendar/Types.hs view
@@ -0,0 +1,79 @@+{-# 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 CommonEra n <-+ ((\y -> if y > 0 then Just y else Nothing) -> Just n)+ where+ CommonEra n = 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 BeforeCommonEra n <-+ ((\y -> if y <= 0 then Just (1 - y) else Nothing) -> Just n)+ where+ BeforeCommonEra n = 1 - n++{-# COMPLETE CommonEra, BeforeCommonEra #-}++-- | Month of year, in range 1 (January) to 12 (December).+type MonthOfYear = Int++pattern January :: MonthOfYear+pattern January = 1++pattern February :: MonthOfYear+pattern February = 2++pattern March :: MonthOfYear+pattern March = 3++pattern April :: MonthOfYear+pattern April = 4++pattern May :: MonthOfYear+pattern May = 5++pattern June :: MonthOfYear+pattern June = 6++pattern July :: MonthOfYear+pattern July = 7++pattern August :: MonthOfYear+pattern August = 8++pattern September :: MonthOfYear+pattern September = 9++pattern October :: MonthOfYear+pattern October = 10++pattern November :: MonthOfYear+pattern November = 11++-- | The twelve 'MonthOfYear' patterns form a @COMPLETE@ set.+pattern December :: MonthOfYear+pattern 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
+ lib/Data/Time/Calendar/Week.hs view
@@ -0,0 +1,124 @@+{-# LANGUAGE CPP #-}+{-# LANGUAGE Safe #-}++module Data.Time.Calendar.Week where++import Control.DeepSeq+import Data.Data+import Data.Fixed+import Data.Ix+import Data.Time.Calendar.Days+import GHC.Generics+#if __GLASGOW_HASKELL__ >= 914+import qualified Language.Haskell.TH.Lift as TH+#else+import qualified Language.Haskell.TH.Syntax as TH+#endif++data DayOfWeek+ = Monday+ | Tuesday+ | Wednesday+ | Thursday+ | Friday+ | Saturday+ | Sunday+ deriving (Eq, Ord, Ix, Show, Read, Typeable, Data, Generic, TH.Lift)++instance NFData DayOfWeek where+ rnf Monday = ()+ rnf Tuesday = ()+ rnf Wednesday = ()+ rnf Thursday = ()+ rnf Friday = ()+ rnf Saturday = ()+ rnf Sunday = ()++-- | \"Circular\", so for example @[Tuesday ..]@ gives an endless sequence.+-- Also: 'fromEnum' gives [1 .. 7] for [Monday .. Sunday], and 'toEnum' performs mod 7 to give a cycle of days.+instance Enum DayOfWeek where+ toEnum i = case mod i 7 of+ 0 -> Sunday+ 1 -> Monday+ 2 -> Tuesday+ 3 -> Wednesday+ 4 -> Thursday+ 5 -> Friday+ _ -> Saturday+ fromEnum Monday = 1+ fromEnum Tuesday = 2+ fromEnum Wednesday = 3+ fromEnum Thursday = 4+ fromEnum Friday = 5+ fromEnum Saturday = 6+ fromEnum Sunday = 7+ enumFromTo wd1 wd2+ | wd1 == wd2 = [wd1]+ enumFromTo wd1 wd2 = wd1 : enumFromTo (succ wd1) wd2+ enumFromThenTo wd1 wd2 wd3+ | wd2 == wd3 = [wd1, wd2]+ enumFromThenTo wd1 wd2 wd3 = wd1 : enumFromThenTo wd2 (toEnum $ (2 * fromEnum wd2) - (fromEnum wd1)) wd3++dayOfWeek :: Day -> DayOfWeek+dayOfWeek (ModifiedJulianDay d) = toEnum $ fromInteger $ d + 3++-- | @dayOfWeekDiff a b = a - b@ in range 0 to 6.+-- The number of days from b to the next a.+dayOfWeekDiff :: DayOfWeek -> DayOfWeek -> Int+dayOfWeekDiff a b = mod' (fromEnum a - fromEnum b) 7++-- | The first day-of-week on or after some day+firstDayOfWeekOnAfter :: DayOfWeek -> Day -> Day+firstDayOfWeekOnAfter dw d = addDays (toInteger $ dayOfWeekDiff dw $ dayOfWeek d) d++-- | Returns a week containing the given 'Day' where the first day is the+-- 'DayOfWeek' specified.+--+-- Examples:+--+-- >>> weekAllDays Sunday (YearMonthDay 2022 02 21)+-- [YearMonthDay 2022 2 20 .. YearMonthDay 2022 2 26]+--+-- >>> weekAllDays Monday (YearMonthDay 2022 02 21)+-- [YearMonthDay 2022 2 21 .. YearMonthDay 2022 2 27]+--+-- >>> weekAllDays Tuesday (YearMonthDay 2022 02 21)+-- [YearMonthDay 2022 2 15 .. YearMonthDay 2022 2 21]+--+-- @since 1.12.2+weekAllDays :: DayOfWeek -> Day -> [Day]+weekAllDays firstDay day = [weekFirstDay firstDay day .. weekLastDay firstDay day]++-- | Returns the first day of a week containing the given 'Day'.+--+-- Examples:+--+-- >>> weekFirstDay Sunday (YearMonthDay 2022 02 21)+-- YearMonthDay 2022 2 20+--+-- >>> weekFirstDay Monday (YearMonthDay 2022 02 21)+-- YearMonthDay 2022 2 21+--+-- >>> weekFirstDay Tuesday (YearMonthDay 2022 02 21)+-- YearMonthDay 2022 2 15+--+-- @since 1.12.2+weekFirstDay :: DayOfWeek -> Day -> Day+weekFirstDay firstDay day = addDays (negate 7) $ firstDayOfWeekOnAfter firstDay $ succ day++-- | Returns the last day of a week containing the given 'Day'.+--+-- Examples:+--+-- >>> weekLastDay Sunday (YearMonthDay 2022 02 21)+-- YearMonthDay 2022 2 26+--+-- >>> weekLastDay Monday (YearMonthDay 2022 02 21)+-- YearMonthDay 2022 2 27+--+-- >>> weekLastDay Tuesday (YearMonthDay 2022 02 21)+-- YearMonthDay 2022 2 21+--+-- @since 1.12.2+weekLastDay :: DayOfWeek -> Day -> Day+weekLastDay firstDay day = pred $ firstDayOfWeekOnAfter firstDay $ succ day
+ lib/Data/Time/Calendar/WeekDate.hs view
@@ -0,0 +1,149 @@+{-# LANGUAGE CPP #-}+{-# LANGUAGE Safe #-}++-- | Week-based calendars+module Data.Time.Calendar.WeekDate (+ Year,+ WeekOfYear,+ DayOfWeek (..),+ dayOfWeek,+ FirstWeekType (..),+ toWeekCalendar,+ fromWeekCalendar,+ fromWeekCalendarValid,++ -- * ISO 8601 Week Date format+ toWeekDate,+ fromWeekDate,+ pattern YearWeekDay,+ fromWeekDateValid,+ showWeekDate,+) where++import Data.Time.Calendar.Days+import Data.Time.Calendar.OrdinalDate+import Data.Time.Calendar.Private+import Data.Time.Calendar.Week+#if __GLASGOW_HASKELL__ >= 914+import qualified Language.Haskell.TH.Lift as TH+#else+import qualified Language.Haskell.TH.Syntax as TH+#endif++data FirstWeekType+ = -- | first week is the first whole week of the year+ FirstWholeWeek+ | -- | first week is the first week with four days in the year+ FirstMostWeek+ deriving (Eq, TH.Lift)++firstDayOfWeekCalendar :: FirstWeekType -> DayOfWeek -> Year -> Day+firstDayOfWeekCalendar wt dow year =+ let+ jan1st = fromOrdinalDate year 1+ in+ case wt of+ FirstWholeWeek -> firstDayOfWeekOnAfter dow jan1st+ FirstMostWeek -> firstDayOfWeekOnAfter dow $ addDays (-3) jan1st++-- | Convert to the given kind of "week calendar".+-- Note that the year number matches the weeks, and so is not always the same as the Gregorian year number.+toWeekCalendar ::+ -- | how to reckon the first week of the year+ FirstWeekType ->+ -- | the first day of each week+ DayOfWeek ->+ Day ->+ (Year, WeekOfYear, DayOfWeek)+toWeekCalendar wt ws d =+ let+ dw = dayOfWeek d+ (y0, _) = toOrdinalDate d+ j1p = firstDayOfWeekCalendar wt ws $ pred y0+ j1 = firstDayOfWeekCalendar wt ws y0+ j1s = firstDayOfWeekCalendar wt ws $ succ y0+ in+ if d < j1+ then (pred y0, succ $ div (fromInteger $ diffDays d j1p) 7, dw)+ else+ if d < j1s+ then (y0, succ $ div (fromInteger $ diffDays d j1) 7, dw)+ else (succ y0, succ $ div (fromInteger $ diffDays d j1s) 7, dw)++-- | Convert from the given kind of "week calendar".+-- Invalid week and day values will be clipped to the correct range.+fromWeekCalendar ::+ -- | how to reckon the first week of the year+ FirstWeekType ->+ -- | the first day of each week+ DayOfWeek ->+ Year ->+ WeekOfYear ->+ DayOfWeek ->+ Day+fromWeekCalendar wt ws y wy dw =+ let+ d1 :: Day+ d1 = firstDayOfWeekCalendar wt ws y+ wy' = clip 1 53 wy+ getday :: WeekOfYear -> Day+ getday wy'' = addDays (toInteger $ (pred wy'' * 7) + (dayOfWeekDiff dw ws)) d1+ d1s = firstDayOfWeekCalendar wt ws $ succ y+ day = getday wy'+ in+ if wy' == 53 then if day >= d1s then getday 52 else day else day++-- | Convert from the given kind of "week calendar".+-- Invalid week and day values will return Nothing.+fromWeekCalendarValid ::+ -- | how to reckon the first week of the year+ FirstWeekType ->+ -- | the first day of each week+ DayOfWeek ->+ Year ->+ WeekOfYear ->+ DayOfWeek ->+ Maybe Day+fromWeekCalendarValid wt ws y wy dw =+ let+ d = fromWeekCalendar wt ws y wy dw+ in+ if toWeekCalendar wt ws d == (y, wy, dw) then Just d else Nothing++-- | Convert to ISO 8601 Week Date format. First element of result is year, second week number (1-53), third day of week (1 for Monday to 7 for Sunday).+-- Note that \"Week\" years are not quite the same as Gregorian years, as the first day of the year is always a Monday.+-- The first week of a year is the first week to contain at least four days in the corresponding Gregorian year.+toWeekDate :: Day -> (Year, WeekOfYear, Int)+toWeekDate d =+ let+ (y, wy, dw) = toWeekCalendar FirstMostWeek Monday d+ in+ (y, wy, fromEnum dw)++-- | Convert from ISO 8601 Week Date format. First argument is year, second week number (1-52 or 53), third day of week (1 for Monday to 7 for Sunday).+-- Invalid week and day values will be clipped to the correct range.+fromWeekDate :: Year -> WeekOfYear -> Int -> Day+fromWeekDate y wy dw = fromWeekCalendar FirstMostWeek Monday y wy (toEnum $ clip 1 7 dw)++-- | Bidirectional abstract constructor for ISO 8601 Week Date format.+-- Invalid week values will be clipped to the correct range.+pattern YearWeekDay :: Year -> WeekOfYear -> DayOfWeek -> Day+pattern YearWeekDay y wy dw <-+ (toWeekDate -> (y, wy, (toEnum -> dw)))+ where+ YearWeekDay y wy dw = fromWeekDate y wy (fromEnum dw)++{-# COMPLETE YearWeekDay #-}++-- | Convert from ISO 8601 Week Date format. First argument is year, second week number (1-52 or 53), third day of week (1 for Monday to 7 for Sunday).+-- Invalid week and day values will return Nothing.+fromWeekDateValid :: Year -> WeekOfYear -> Int -> Maybe Day+fromWeekDateValid y wy dwr = do+ dw <- clipValid 1 7 dwr+ fromWeekCalendarValid FirstMostWeek Monday y wy (toEnum dw)++-- | Show in ISO 8601 Week Date format as yyyy-Www-d (e.g. \"2006-W46-3\").+showWeekDate :: Day -> String+showWeekDate date = (show4 y) ++ "-W" ++ (show2 w) ++ "-" ++ (show d)+ where+ (y, w, d) = toWeekDate date
+ lib/Data/Time/Clock.hs view
@@ -0,0 +1,49 @@+{-# LANGUAGE Safe #-}++-- | Types and functions for UTC and UT1+module Data.Time.Clock (+ -- * Universal Time++ -- | Time as measured by the Earth.+ UniversalTime (..),++ -- * Absolute intervals+ DiffTime,+ pattern Picoseconds,+ pattern Seconds,+ pattern Minutes,+ pattern Hours,+ secondsToDiffTime,+ picosecondsToDiffTime,+ diffTimeToPicoseconds,++ -- * UTC++ -- | UTC is time as measured by a clock, corrected to keep pace with the earth by adding or removing+ -- occasional seconds, known as \"leap seconds\".+ -- These corrections are not predictable and are announced with six month's notice.+ -- No table of these corrections is provided, as any program compiled with it would become+ -- out of date in six months.+ --+ -- If you don't care about leap seconds, use 'UTCTime' and 'NominalDiffTime' for your clock calculations,+ -- and you'll be fine.+ UTCTime (..),+ NominalDiffTime,+ pattern Nominal,+ secondsToNominalDiffTime,+ nominalDiffTimeToSeconds,+ nominalDay,+ module Data.Time.Clock.Internal.UTCDiff,+ getCurrentTime,+ getTime_resolution,+) where++import Data.Time.Clock.Internal.DiffTime+import Data.Time.Clock.Internal.NominalDiffTime+import Data.Time.Clock.Internal.SystemTime+import Data.Time.Clock.Internal.UTCDiff+import Data.Time.Clock.Internal.UTCTime+import Data.Time.Clock.Internal.UniversalTime+import Data.Time.Clock.POSIX+import Data.Time.Format.Parse ()+import Data.Time.LocalTime ()
+ lib/Data/Time/Clock/Internal/AbsoluteTime.hs view
@@ -0,0 +1,38 @@+{-# LANGUAGE CPP #-}+{-# LANGUAGE Safe #-}++-- | TAI and leap-second maps for converting to UTC: most people won't need this module.+module Data.Time.Clock.Internal.AbsoluteTime where++import Control.DeepSeq+import Data.Data+import Data.Time.Calendar.Days+import Data.Time.Clock.Internal.DiffTime+#if __GLASGOW_HASKELL__ >= 914+import qualified Language.Haskell.TH.Lift as TH+#else+import qualified Language.Haskell.TH.Syntax as TH+#endif++-- | AbsoluteTime is TAI, time as measured by a clock.+newtype AbsoluteTime+ = MkAbsoluteTime DiffTime+ deriving (Eq, Ord, Typeable, Data, TH.Lift)++instance NFData AbsoluteTime where+ rnf (MkAbsoluteTime a) = rnf a++-- | The epoch of TAI, which is 1858-11-17 00:00:00 TAI.+taiEpoch :: AbsoluteTime+taiEpoch = MkAbsoluteTime 0++taiNominalDayStart :: Day -> AbsoluteTime+taiNominalDayStart day = MkAbsoluteTime $ realToFrac $ (toModifiedJulianDay day) * 86400++-- | addAbsoluteTime a b = a + b+addAbsoluteTime :: DiffTime -> AbsoluteTime -> AbsoluteTime+addAbsoluteTime t (MkAbsoluteTime a) = MkAbsoluteTime (a + t)++-- | diffAbsoluteTime a b = a - b+diffAbsoluteTime :: AbsoluteTime -> AbsoluteTime -> DiffTime+diffAbsoluteTime (MkAbsoluteTime a) (MkAbsoluteTime b) = a - b
+ lib/Data/Time/Clock/Internal/CTimespec.hsc view
@@ -0,0 +1,107 @@+#if !defined(javascript_HOST_ARCH)+{-# LANGUAGE CApiFFI #-}+#endif++module Data.Time.Clock.Internal.CTimespec where++#include "HsTimeConfig.h"++#if !defined(mingw32_HOST_OS) && HAVE_CLOCK_GETTIME && !defined(__MHS__)++import Foreign+import Foreign.C+import System.IO.Unsafe+import System.Posix.Types++#include <time.h>++type ClockID = CClockId++data CTimespec = MkCTimespec CTime CLong++instance Storable CTimespec where+ sizeOf _ = #{size struct timespec}+ alignment _ = alignment (undefined :: CLong)+ peek p = do+ s <- #{peek struct timespec, tv_sec } p+ ns <- #{peek struct timespec, tv_nsec} p+ return (MkCTimespec s ns)+ poke p (MkCTimespec s ns) = do+ #{poke struct timespec, tv_sec } p s+ #{poke struct timespec, tv_nsec} p ns++#if defined(javascript_HOST_ARCH)++foreign import ccall unsafe "time.h clock_gettime"+ clock_gettime :: ClockID -> Ptr CTimespec -> IO CInt++#else /* defined(javascript_HOST_ARCH) */++foreign import capi unsafe "time.h clock_gettime"+ clock_gettime :: ClockID -> Ptr CTimespec -> IO CInt++#endif /* defined(javascript_HOST_ARCH) */++-- | Get the current time from the given clock.+clockGetTime :: ClockID -> IO CTimespec+clockGetTime clockid = alloca (\ptspec -> do+ throwErrnoIfMinus1_ "clock_gettime" $ clock_gettime clockid ptspec+ peek ptspec+ )++#if defined(javascript_HOST_ARCH)++clockGetRes :: ClockID -> IO (Either Errno CTimespec)+clockGetRes _ = return $ Right $ MkCTimespec 0 0++#else /* defined(javascript_HOST_ARCH) */++foreign import capi unsafe "time.h clock_getres"+ clock_getres :: ClockID -> Ptr CTimespec -> IO CInt++-- | Get the resolution of the given clock.+clockGetRes :: ClockID -> IO (Either Errno CTimespec)+clockGetRes clockid = alloca $ \ptspec -> do+ rc <- clock_getres clockid ptspec+ case rc of+ 0 -> do+ res <- peek ptspec+ return $ Right res+ _ -> do+ errno <- getErrno+ return $ Left errno++#endif /* defined(javascript_HOST_ARCH) */++#if defined(javascript_HOST_ARCH)+-- JS backend doesn't support foreign imports with capi convention+clock_REALTIME :: ClockID+clock_REALTIME = #{const CLOCK_REALTIME}+#else /* defined(javascript_HOST_ARCH) */+foreign import capi unsafe "HsTime.h value HS_CLOCK_REALTIME" clock_REALTIME :: ClockID+#endif /* defined(javascript_HOST_ARCH) */++clock_TAI :: Maybe ClockID+clock_TAI =+#if defined(CLOCK_TAI)+ Just #{const CLOCK_TAI}+#else /* defined(CLOCK_TAI) */+ Nothing+#endif /* defined(CLOCK_TAI) */++realtimeRes :: CTimespec+realtimeRes = unsafePerformIO $ do+ mres <- clockGetRes clock_REALTIME+ case mres of+ Left errno -> ioError (errnoToIOError "clock_getres" errno Nothing Nothing)+ Right res -> return res++clockResolution :: ClockID -> Maybe CTimespec+clockResolution clockid = unsafePerformIO $ do+ mres <- clockGetRes clockid+ case mres of+ Left _ -> return Nothing+ Right res -> return $ Just res++#endif /* !defined(mingw32_HOST_OS) && HAVE_CLOCK_GETTIME */+
+ lib/Data/Time/Clock/Internal/CTimeval.hs view
@@ -0,0 +1,47 @@+{-# LANGUAGE CPP #-}+{-# LANGUAGE Safe #-}+#if !defined(javascript_HOST_ARCH)+{-# LANGUAGE CApiFFI #-}+#endif++module Data.Time.Clock.Internal.CTimeval where++#ifndef mingw32_HOST_OS+-- All Unix-specific, this+import Foreign+import Foreign.C++data CTimeval =+ MkCTimeval CLong+ CLong++instance Storable CTimeval where+ sizeOf _ = (sizeOf (undefined :: CLong)) * 2+ alignment _ = alignment (undefined :: CLong)+ peek p = do+ s <- peekElemOff (castPtr p) 0+ mus <- peekElemOff (castPtr p) 1+ return (MkCTimeval s mus)+ poke p (MkCTimeval s mus) = do+ pokeElemOff (castPtr p) 0 s+ pokeElemOff (castPtr p) 1 mus++#if defined(javascript_HOST_ARCH) || defined(__MHS__)++foreign import ccall unsafe "sys/time.h gettimeofday" gettimeofday :: Ptr CTimeval -> Ptr () -> IO CInt++#else++foreign import capi unsafe "sys/time.h gettimeofday" gettimeofday :: Ptr CTimeval -> Ptr () -> IO CInt++#endif++-- | Get the current POSIX time from the system clock.+getCTimeval :: IO CTimeval+getCTimeval =+ with+ (MkCTimeval 0 0)+ (\ptval -> do+ throwErrnoIfMinus1_ "gettimeofday" $ gettimeofday ptval nullPtr+ peek ptval)+#endif
+ lib/Data/Time/Clock/Internal/DiffTime.hs view
@@ -0,0 +1,120 @@+{-# LANGUAGE CPP #-}+{-# LANGUAGE Trustworthy #-}++module Data.Time.Clock.Internal.DiffTime where++import Control.DeepSeq+import Data.Data+import Data.Fixed+#ifdef __GLASGOW_HASKELL__+import GHC.Read+#endif+#if __GLASGOW_HASKELL__ >= 914+import qualified Language.Haskell.TH.Lift as TH+#else+import qualified Language.Haskell.TH.Syntax as TH+#endif+import Text.ParserCombinators.ReadP+import Text.Read++-- | This is a length of time, as measured by a clock.+-- Conversion functions such as 'fromInteger' and 'realToFrac' will treat it as seconds.+-- For example, @(0.010 :: DiffTime)@ corresponds to 10 milliseconds.+--+-- It has a precision of one picosecond (= 10^-12 s). Enumeration functions will treat it as picoseconds.+newtype DiffTime+ = MkDiffTime Pico+ deriving (Eq, Ord, Typeable, Data, TH.Lift)++instance NFData DiffTime where+ rnf (MkDiffTime t) = rnf t++instance Enum DiffTime where+ succ (MkDiffTime a) = MkDiffTime (succ a)+ pred (MkDiffTime a) = MkDiffTime (pred a)+ toEnum = MkDiffTime . toEnum+ fromEnum (MkDiffTime a) = fromEnum a+ enumFrom (MkDiffTime a) = fmap MkDiffTime (enumFrom a)+ enumFromThen (MkDiffTime a) (MkDiffTime b) = fmap MkDiffTime (enumFromThen a b)+ enumFromTo (MkDiffTime a) (MkDiffTime b) = fmap MkDiffTime (enumFromTo a b)+ enumFromThenTo (MkDiffTime a) (MkDiffTime b) (MkDiffTime c) = fmap MkDiffTime (enumFromThenTo a b c)++instance Show DiffTime where+ show (MkDiffTime t) = (showFixed True t) ++ "s"++instance Read DiffTime where+ readPrec = do+ t <- readPrec+ _ <- lift $ char 's'+ return $ MkDiffTime t++instance Num DiffTime where+ (MkDiffTime a) + (MkDiffTime b) = MkDiffTime (a + b)+ (MkDiffTime a) - (MkDiffTime b) = MkDiffTime (a - b)+ (MkDiffTime a) * (MkDiffTime b) = MkDiffTime (a * b)+ negate (MkDiffTime a) = MkDiffTime (negate a)+ abs (MkDiffTime a) = MkDiffTime (abs a)+ signum (MkDiffTime a) = MkDiffTime (signum a)+ fromInteger i = MkDiffTime (fromInteger i)++instance Real DiffTime where+ toRational (MkDiffTime a) = toRational a++instance Fractional DiffTime where+ (MkDiffTime a) / (MkDiffTime b) = MkDiffTime (a / b)+ recip (MkDiffTime a) = MkDiffTime (recip a)+ fromRational r = MkDiffTime (fromRational r)++instance RealFrac DiffTime where+ properFraction (MkDiffTime a) =+ let+ (b', a') = properFraction a+ in+ (b', MkDiffTime a')+ truncate (MkDiffTime a) = truncate a+ round (MkDiffTime a) = round a+ ceiling (MkDiffTime a) = ceiling a+ floor (MkDiffTime a) = floor a++pattern Picoseconds :: Integer -> DiffTime+pattern Picoseconds a <- (diffTimeToPicoseconds -> a)+ where+ Picoseconds a = picosecondsToDiffTime a++{-# COMPLETE Picoseconds #-}++pattern Seconds :: Pico -> DiffTime+pattern Seconds a = MkDiffTime a++{-# COMPLETE Seconds #-}++pattern Minutes :: Pico -> DiffTime+pattern Minutes a <- Seconds ((/ 60) -> a)+ where+ Minutes a = Seconds $ a * 60++{-# COMPLETE Minutes #-}++pattern Hours :: Pico -> DiffTime+pattern Hours a <- Minutes ((/ 60) -> a)+ where+ Hours a = Minutes $ a * 60++{-# COMPLETE Hours #-}++-- | Create a 'DiffTime' which represents an integral number of seconds.+secondsToDiffTime :: Integer -> DiffTime+secondsToDiffTime = fromInteger++-- | Create a 'DiffTime' from a number of picoseconds.+picosecondsToDiffTime :: Integer -> DiffTime+picosecondsToDiffTime x = MkDiffTime (MkFixed x)++-- | Get the number of picoseconds in a 'DiffTime'.+diffTimeToPicoseconds :: DiffTime -> Integer+diffTimeToPicoseconds (MkDiffTime (MkFixed x)) = x++{-# RULES+"realToFrac/DiffTime->Pico" realToFrac = \(MkDiffTime ps) -> ps+"realToFrac/Pico->DiffTime" realToFrac = MkDiffTime+ #-}
+ lib/Data/Time/Clock/Internal/NominalDiffTime.hs view
@@ -0,0 +1,120 @@+{-# LANGUAGE CPP #-}+{-# LANGUAGE Trustworthy #-}++module Data.Time.Clock.Internal.NominalDiffTime where++import Control.DeepSeq+import Data.Data+import Data.Fixed+#ifdef __GLASGOW_HASKELL__+import GHC.Read+#endif+import Data.Time.Clock.Internal.DiffTime+#if __GLASGOW_HASKELL__ >= 914+import qualified Language.Haskell.TH.Lift as TH+#else+import qualified Language.Haskell.TH.Syntax as TH+#endif+import Text.ParserCombinators.ReadP+import Text.ParserCombinators.ReadPrec++-- | This is a length of time, as measured by UTC.+-- It has a precision of one picosecond (10^-12 s).+--+-- Conversion functions such as 'fromInteger' and 'realToFrac' will treat it as seconds.+-- For example, @(0.010 :: NominalDiffTime)@ corresponds to 10 milliseconds.+--+-- Enumeration functions will treat it as picoseconds.+--+-- It ignores leap-seconds, so it's not necessarily a fixed amount of clock time.+-- For instance, 23:00 UTC + 2 hours of NominalDiffTime = 01:00 UTC (+ 1 day),+-- regardless of whether a leap-second intervened.+newtype NominalDiffTime+ = MkNominalDiffTime Pico+ deriving (Eq, Ord, Typeable, Data, TH.Lift)++-- | convert from DiffTime+pattern Nominal :: DiffTime -> NominalDiffTime+pattern Nominal dt <- MkNominalDiffTime (realToFrac -> dt)+ where+ Nominal dt = MkNominalDiffTime $ realToFrac dt++{-# COMPLETE Nominal #-}++-- | Create a 'NominalDiffTime' from a number of seconds.+--+-- @since 1.9.1+secondsToNominalDiffTime :: Pico -> NominalDiffTime+secondsToNominalDiffTime = MkNominalDiffTime++-- | Get the seconds in a 'NominalDiffTime'.+--+-- @since 1.9.1+nominalDiffTimeToSeconds :: NominalDiffTime -> Pico+nominalDiffTimeToSeconds (MkNominalDiffTime t) = t++instance NFData NominalDiffTime where+ rnf (MkNominalDiffTime t) = rnf t++instance Enum NominalDiffTime where+ succ (MkNominalDiffTime a) = MkNominalDiffTime (succ a)+ pred (MkNominalDiffTime a) = MkNominalDiffTime (pred a)+ toEnum = MkNominalDiffTime . toEnum+ fromEnum (MkNominalDiffTime a) = fromEnum a+ enumFrom (MkNominalDiffTime a) = fmap MkNominalDiffTime (enumFrom a)+ enumFromThen (MkNominalDiffTime a) (MkNominalDiffTime b) = fmap MkNominalDiffTime (enumFromThen a b)+ enumFromTo (MkNominalDiffTime a) (MkNominalDiffTime b) = fmap MkNominalDiffTime (enumFromTo a b)+ enumFromThenTo (MkNominalDiffTime a) (MkNominalDiffTime b) (MkNominalDiffTime c) =+ fmap MkNominalDiffTime (enumFromThenTo a b c)++instance Show NominalDiffTime where+ show (MkNominalDiffTime t) = (showFixed True t) ++ "s"++instance Read NominalDiffTime where+ readPrec = do+ t <- readPrec+ _ <- lift $ char 's'+ return $ MkNominalDiffTime t++instance Num NominalDiffTime where+ (MkNominalDiffTime a) + (MkNominalDiffTime b) = MkNominalDiffTime (a + b)+ (MkNominalDiffTime a) - (MkNominalDiffTime b) = MkNominalDiffTime (a - b)+ (MkNominalDiffTime a) * (MkNominalDiffTime b) = MkNominalDiffTime (a * b)+ negate (MkNominalDiffTime a) = MkNominalDiffTime (negate a)+ abs (MkNominalDiffTime a) = MkNominalDiffTime (abs a)+ signum (MkNominalDiffTime a) = MkNominalDiffTime (signum a)+ fromInteger i = MkNominalDiffTime (fromInteger i)++instance Real NominalDiffTime where+ toRational (MkNominalDiffTime a) = toRational a++instance Fractional NominalDiffTime where+ (MkNominalDiffTime a) / (MkNominalDiffTime b) = MkNominalDiffTime (a / b)+ recip (MkNominalDiffTime a) = MkNominalDiffTime (recip a)+ fromRational r = MkNominalDiffTime (fromRational r)++instance RealFrac NominalDiffTime where+ properFraction (MkNominalDiffTime a) = (i, MkNominalDiffTime f)+ where+ (i, f) = properFraction a+ truncate (MkNominalDiffTime a) = truncate a+ round (MkNominalDiffTime a) = round a+ ceiling (MkNominalDiffTime a) = ceiling a+ floor (MkNominalDiffTime a) = floor a++{-# RULES+"realToFrac/DiffTime->NominalDiffTime"+ realToFrac =+ \dt -> MkNominalDiffTime (realToFrac dt)+"realToFrac/NominalDiffTime->DiffTime"+ realToFrac =+ \(MkNominalDiffTime ps) -> realToFrac ps+"realToFrac/NominalDiffTime->Pico"+ realToFrac =+ \(MkNominalDiffTime ps) -> ps+"realToFrac/Pico->NominalDiffTime" realToFrac = MkNominalDiffTime+ #-}++-- | One day in 'NominalDiffTime'.+nominalDay :: NominalDiffTime+nominalDay = 86400
+ lib/Data/Time/Clock/Internal/POSIXTime.hs view
@@ -0,0 +1,14 @@+{-# LANGUAGE Safe #-}++module Data.Time.Clock.Internal.POSIXTime where++import Data.Time.Clock.Internal.NominalDiffTime++-- | 86400 nominal seconds in every day+posixDayLength :: NominalDiffTime+posixDayLength = nominalDay++-- | POSIX time is the nominal time since 1970-01-01 00:00 UTC+--+-- To convert from a 'Foreign.C.Types.CTime' or @System.Posix.EpochTime@, use 'realToFrac'.+type POSIXTime = NominalDiffTime
+ lib/Data/Time/Clock/Internal/SystemTime.hs view
@@ -0,0 +1,111 @@+{-# LANGUAGE CPP #-}++#if !defined(__MHS__)+#include "HsTimeConfig.h"+#endif++#if defined(mingw32_HOST_OS) || !defined(HAVE_CLOCK_GETTIME)+{-# LANGUAGE Safe #-}+#else+{-# LANGUAGE Trustworthy #-}+#endif++module Data.Time.Clock.Internal.SystemTime (+ SystemTime (..),+ getSystemTime,+ getTime_resolution,+ getTAISystemTime,+) where++import Control.DeepSeq+import Data.Data+import Data.Int (Int64)+import Data.Time.Clock.Internal.DiffTime+import Data.Word+import GHC.Generics+#if __GLASGOW_HASKELL__ >= 914+import qualified Language.Haskell.TH.Lift as TH+#else+import qualified Language.Haskell.TH.Syntax as TH+#endif++#ifdef mingw32_HOST_OS+import qualified System.Win32.Time as Win32+#elif defined(HAVE_CLOCK_GETTIME) && !defined(__MHS__)+import Data.Time.Clock.Internal.CTimespec+import Foreign.C.Types (CLong(..), CTime(..))+#else+import Data.Time.Clock.Internal.CTimeval+import Foreign.C.Types (CLong(..))+#endif+--------------------------------------------------------------------------------++-- | 'SystemTime' is time returned by system clock functions.+-- Its semantics depends on the clock function, but the epoch is typically the beginning of 1970.+-- Note that 'systemNanoseconds' of 1E9 to 2E9-1 can be used to represent leap seconds.+data SystemTime = MkSystemTime+ { systemSeconds :: {-# UNPACK #-} !Int64+ , systemNanoseconds :: {-# UNPACK #-} !Word32+ }+ deriving (Eq, Ord, Show, Typeable, Data, Generic, TH.Lift)++instance NFData SystemTime where+ rnf a = a `seq` ()++-- | Get the system time, epoch start of 1970 UTC, leap-seconds ignored.+-- 'getSystemTime' is typically much faster than 'getCurrentTime'.+getSystemTime :: IO SystemTime++-- | The resolution of 'getSystemTime', 'getCurrentTime', 'getPOSIXTime'.+-- On UNIX systems this uses @clock_getres@, which may be <https://github.com/microsoft/WSL/issues/6029 wrong on WSL2>.+getTime_resolution :: DiffTime++-- | If supported, get TAI time, epoch start of 1970 TAI, with resolution.+-- This is supported only on UNIX systems, and only those with CLOCK_TAI available at run-time.+getTAISystemTime :: Maybe (DiffTime, IO SystemTime)++#ifdef mingw32_HOST_OS+-- On Windows, the equivalent of POSIX time is "file time", defined as+-- the number of 100-nanosecond intervals that have elapsed since+-- 12:00 A.M. January 1, 1601 (UTC). We can convert this into a POSIX+-- time by adjusting the offset to be relative to the POSIX epoch.+getSystemTime = do+ Win32.FILETIME ft <- Win32.getSystemTimeAsFileTime+ let (s, us) = (ft - win32_epoch_adjust) `divMod` 10000000+ return (MkSystemTime (fromIntegral s) (fromIntegral us * 100))+ where+ win32_epoch_adjust :: Word64+ win32_epoch_adjust = 116444736000000000++getTime_resolution = 100E-9 -- 100ns++getTAISystemTime = Nothing+#elif defined(HAVE_CLOCK_GETTIME) && !defined(__MHS__)+-- Use hi-res clock_gettime+timespecToSystemTime :: CTimespec -> SystemTime+timespecToSystemTime (MkCTimespec (CTime s) (CLong ns)) = (MkSystemTime (fromIntegral s) (fromIntegral ns))++timespecToDiffTime :: CTimespec -> DiffTime+timespecToDiffTime (MkCTimespec (CTime s) ns) = (fromIntegral s) + (fromIntegral ns) * 1E-9++clockGetSystemTime :: ClockID -> IO SystemTime+clockGetSystemTime clock = fmap timespecToSystemTime $ clockGetTime clock++getSystemTime = clockGetSystemTime clock_REALTIME++getTime_resolution = timespecToDiffTime realtimeRes++getTAISystemTime = do+ clockID <- clock_TAI+ resolution <- clockResolution clockID+ return $ (timespecToDiffTime resolution, clockGetSystemTime clockID)+#else+-- Use gettimeofday+getSystemTime = do+ MkCTimeval (CLong s) (CLong us) <- getCTimeval+ return (MkSystemTime (fromIntegral s) (fromIntegral us * 1000))++getTime_resolution = 1E-6 -- microsecond++getTAISystemTime = Nothing+#endif
+ lib/Data/Time/Clock/Internal/UTCDiff.hs view
@@ -0,0 +1,15 @@+{-# LANGUAGE Safe #-}++module Data.Time.Clock.Internal.UTCDiff where++import Data.Time.Clock.Internal.NominalDiffTime+import Data.Time.Clock.Internal.UTCTime+import Data.Time.Clock.POSIX++-- | addUTCTime a b = a + b+addUTCTime :: NominalDiffTime -> UTCTime -> UTCTime+addUTCTime x t = posixSecondsToUTCTime (x + (utcTimeToPOSIXSeconds t))++-- | diffUTCTime a b = a - b+diffUTCTime :: UTCTime -> UTCTime -> NominalDiffTime+diffUTCTime a b = (utcTimeToPOSIXSeconds a) - (utcTimeToPOSIXSeconds b)
+ lib/Data/Time/Clock/Internal/UTCTime.hs view
@@ -0,0 +1,29 @@+{-# LANGUAGE CPP #-}+{-# LANGUAGE Safe #-}++module Data.Time.Clock.Internal.UTCTime where++import Control.DeepSeq+import Data.Data+import Data.Time.Calendar.Days+import Data.Time.Clock.Internal.DiffTime+import GHC.Generics+#if __GLASGOW_HASKELL__ >= 914+import qualified Language.Haskell.TH.Lift as TH+#else+import qualified Language.Haskell.TH.Syntax as TH+#endif++-- | This is the simplest representation of UTC.+-- It consists of the day number, and a time offset from midnight.+-- Note that if a day has a leap second added to it, it will have 86401 seconds.+data UTCTime = UTCTime+ { utctDay :: Day+ -- ^ the day+ , utctDayTime :: DiffTime+ -- ^ the time from midnight, 0 <= t < 86401s (because of leap-seconds)+ }+ deriving (Eq, Ord, Typeable, Data, Generic, TH.Lift)++instance NFData UTCTime where+ rnf (UTCTime d t) = rnf d `seq` rnf t `seq` ()
+ lib/Data/Time/Clock/Internal/UniversalTime.hs view
@@ -0,0 +1,23 @@+{-# LANGUAGE CPP #-}+{-# LANGUAGE Safe #-}++module Data.Time.Clock.Internal.UniversalTime where++import Control.DeepSeq+import Data.Data+import GHC.Generics+#if __GLASGOW_HASKELL__ >= 914+import qualified Language.Haskell.TH.Lift as TH+#else+import qualified Language.Haskell.TH.Syntax as TH+#endif++-- | The Modified Julian Date is the day with the fraction of the day, measured from UT midnight.+-- It's used to represent UT1, which is time as measured by the earth's rotation, adjusted for various wobbles.+newtype UniversalTime = ModJulianDate+ { getModJulianDate :: Rational+ }+ deriving (Eq, Ord, Typeable, Data, Generic, TH.Lift)++instance NFData UniversalTime where+ rnf (ModJulianDate a) = rnf a
+ lib/Data/Time/Clock/POSIX.hs view
@@ -0,0 +1,56 @@+{-# LANGUAGE Safe #-}++-- | POSIX time, if you need to deal with timestamps and the like.+-- Most people won't need this module.+--+-- You can use 'POSIXTime' to obtain integer/word timestamps. For example:+--+-- > import Data.Time+-- > import Data.Time.Clock.POSIX+-- > import Data.Int+-- >+-- > nanosSinceEpoch :: UTCTime -> Int64+-- > nanosSinceEpoch =+-- > floor . (1e9 *) . nominalDiffTimeToSeconds . utcTimeToPOSIXSeconds+-- >+-- > main :: IO ()+-- > main = do+-- > u <- getCurrentTime+-- > print $ nanosSinceEpoch u+module Data.Time.Clock.POSIX (+ posixDayLength,+ POSIXTime,+ posixSecondsToUTCTime,+ utcTimeToPOSIXSeconds,+ getPOSIXTime,+ getCurrentTime,+ systemToPOSIXTime,+) where++import Data.Fixed+import Data.Time.Calendar.Days+import Data.Time.Clock.Internal.POSIXTime+import Data.Time.Clock.Internal.UTCTime+import Data.Time.Clock.System++posixSecondsToUTCTime :: POSIXTime -> UTCTime+posixSecondsToUTCTime i =+ let+ (d, t) = divMod' i posixDayLength+ in+ UTCTime (addDays d systemEpochDay) (realToFrac t)++utcTimeToPOSIXSeconds :: UTCTime -> POSIXTime+utcTimeToPOSIXSeconds (UTCTime d t) =+ (fromInteger (diffDays d systemEpochDay) * posixDayLength) + min posixDayLength (realToFrac t)++systemToPOSIXTime :: SystemTime -> POSIXTime+systemToPOSIXTime (MkSystemTime s ns) = (fromIntegral s) + (fromIntegral ns) * 1E-9++-- | Get the current POSIX time from the system clock.+getPOSIXTime :: IO POSIXTime+getPOSIXTime = fmap systemToPOSIXTime getSystemTime++-- | Get the current 'UTCTime' from the system clock.+getCurrentTime :: IO UTCTime+getCurrentTime = systemToUTCTime `fmap` getSystemTime
+ lib/Data/Time/Clock/System.hs view
@@ -0,0 +1,81 @@+{-# LANGUAGE Safe #-}++-- | Fast access to the system clock.+module Data.Time.Clock.System (+ systemEpochDay,+ SystemTime (..),+ truncateSystemTimeLeapSecond,+ getSystemTime,+ systemToUTCTime,+ utcToSystemTime,+ systemToTAITime,+) where++import Data.Int (Int64)+import Data.Time.Calendar.Days+import Data.Time.Clock.Internal.AbsoluteTime+import Data.Time.Clock.Internal.DiffTime+import Data.Time.Clock.Internal.SystemTime+import Data.Time.Clock.Internal.UTCTime++-- | Map leap-second values to the start of the following second.+-- The resulting 'systemNanoseconds' will always be in the range 0 to 1E9-1.+truncateSystemTimeLeapSecond :: SystemTime -> SystemTime+truncateSystemTimeLeapSecond (MkSystemTime seconds nanoseconds)+ | nanoseconds >= 1000000000 = MkSystemTime (succ seconds) 0+truncateSystemTimeLeapSecond t = t++-- | Convert 'SystemTime' to 'UTCTime', matching zero 'SystemTime' to midnight of 'systemEpochDay' UTC.+systemToUTCTime :: SystemTime -> UTCTime+systemToUTCTime (MkSystemTime seconds nanoseconds) =+ let+ days :: Int64+ timeSeconds :: Int64+ (days, timeSeconds) = seconds `divMod` 86400+ day :: Day+ day = addDays (fromIntegral days) systemEpochDay+ timeNanoseconds :: Int64+ timeNanoseconds = timeSeconds * 1000000000 + (fromIntegral nanoseconds)+ timePicoseconds :: Int64+ timePicoseconds = timeNanoseconds * 1000+ time :: DiffTime+ time = picosecondsToDiffTime $ fromIntegral timePicoseconds+ in+ UTCTime day time++-- | Convert 'UTCTime' to 'SystemTime', matching zero 'SystemTime' to midnight of 'systemEpochDay' UTC.+utcToSystemTime :: UTCTime -> SystemTime+utcToSystemTime (UTCTime day time) =+ let+ days :: Int64+ days = fromIntegral $ diffDays day systemEpochDay+ timePicoseconds :: Int64+ timePicoseconds = fromIntegral $ diffTimeToPicoseconds time+ timeNanoseconds :: Int64+ timeNanoseconds = timePicoseconds `div` 1000+ timeSeconds :: Int64+ nanoseconds :: Int64+ (timeSeconds, nanoseconds) =+ if timeNanoseconds >= 86400000000000+ then (86399, timeNanoseconds - 86399000000000)+ else timeNanoseconds `divMod` 1000000000+ seconds :: Int64+ seconds = days * 86400 + timeSeconds+ in+ MkSystemTime seconds $ fromIntegral nanoseconds++systemEpochAbsolute :: AbsoluteTime+systemEpochAbsolute = taiNominalDayStart systemEpochDay++-- | Convert 'SystemTime' to 'AbsoluteTime', matching zero 'SystemTime' to midnight of 'systemEpochDay' TAI.+systemToTAITime :: SystemTime -> AbsoluteTime+systemToTAITime (MkSystemTime s ns) =+ let+ diff :: DiffTime+ diff = (fromIntegral s) + (fromIntegral ns) * 1E-9+ in+ addAbsoluteTime diff systemEpochAbsolute++-- | The day of the epoch of 'SystemTime', 1970-01-01+systemEpochDay :: Day+systemEpochDay = ModifiedJulianDay 40587
+ lib/Data/Time/Clock/TAI.hs view
@@ -0,0 +1,76 @@+{-# LANGUAGE CPP #-}+{-# LANGUAGE Safe #-}++{-# OPTIONS -fno-warn-orphans #-}++-- | TAI and leap-second maps for converting to UTC: most people won't need this module.+module Data.Time.Clock.TAI (+ -- * Absolute Time+ AbsoluteTime,+ taiEpoch,+ addAbsoluteTime,+ diffAbsoluteTime,+ taiNominalDayStart,++ -- * Leap-Second Map+ LeapSecondMap,+ utcDayLength,+ utcToTAITime,+ taiToUTCTime,+ taiClock,+) where++import Data.Fixed+import Data.Maybe+import Data.Time.Calendar.Days+import Data.Time.Clock+import Data.Time.Clock.Internal.AbsoluteTime+import Data.Time.Clock.Internal.SystemTime+import Data.Time.Clock.System+import Data.Time.LocalTime+#ifdef __MHS__+import Data.Tuple.Instances+#endif++instance Show AbsoluteTime where+ show t = show (utcToLocalTime utc (fromJust (taiToUTCTime (const (Just 0)) t))) ++ " TAI" -- ugly, but standard apparently++-- | TAI - UTC during this day.+-- No table is provided, as any program compiled with it would become+-- out of date in six months.+type LeapSecondMap = Day -> Maybe Int++utcDayLength :: LeapSecondMap -> Day -> Maybe DiffTime+utcDayLength lsmap day = do+ i0 <- lsmap day+ i1 <- lsmap $ addDays 1 day+ return $ realToFrac (86400 + i1 - i0)++dayStart :: LeapSecondMap -> Day -> Maybe AbsoluteTime+dayStart lsmap day = do+ i <- lsmap day+ return $ addAbsoluteTime (realToFrac $ (toModifiedJulianDay day) * 86400 + toInteger i) taiEpoch++utcToTAITime :: LeapSecondMap -> UTCTime -> Maybe AbsoluteTime+utcToTAITime lsmap (UTCTime day dtime) = do+ t <- dayStart lsmap day+ return $ addAbsoluteTime dtime t++taiToUTCTime :: LeapSecondMap -> AbsoluteTime -> Maybe UTCTime+taiToUTCTime lsmap abstime =+ let+ stable day = do+ dayt <- dayStart lsmap day+ len <- utcDayLength lsmap day+ let+ dtime = diffAbsoluteTime abstime dayt+ day' = addDays (div' dtime len) day+ if day == day'+ then return (UTCTime day dtime)+ else stable day'+ in+ stable $ ModifiedJulianDay $ div' (diffAbsoluteTime abstime taiEpoch) 86400++-- | TAI clock, if it exists. Note that it is unlikely to be set correctly, without due care and attention.+taiClock :: Maybe (DiffTime, IO AbsoluteTime)+taiClock = fmap (fmap (fmap systemToTAITime)) getTAISystemTime
+ lib/Data/Time/Format.hs view
@@ -0,0 +1,28 @@+{-# LANGUAGE Safe #-}++module Data.Time.Format (+ -- * UNIX-style formatting+ FormatTime (),+ formatTime,++ -- * UNIX-style parsing+ parseTimeM,+ parseTimeMultipleM,+ parseTimeOrError,+ readSTime,+ readPTime,+ ParseTime (),++ -- * Locale+ TimeLocale (..),+ defaultTimeLocale,+ iso8601DateFormat,+ rfc822DateFormat,+) where++import Data.Time.Format.Format.Class+import Data.Time.Format.Format.Instances ()+import Data.Time.Format.ISO8601 ()+import Data.Time.Format.Locale+import Data.Time.Format.Parse+import Data.Time.Format.Parse.Class
+ lib/Data/Time/Format/Format/Class.hs view
@@ -0,0 +1,406 @@+{-# LANGUAGE Safe #-}++module Data.Time.Format.Format.Class (+ -- * Formatting+ formatTime,+ FormatNumericPadding,+ FormatOptions (..),+ FormatTime (..),+ ShowPadded,+ PadOption,+ formatGeneral,+ formatString,+ formatNumber,+ formatNumberStd,+ showPaddedFixed,+ showPaddedFixedFraction,+ quotBy,+ remBy,+) where++import Data.Char+import Data.Fixed+import Data.Maybe+import Data.Time.Calendar.Private+import Data.Time.Format.Locale++type FormatNumericPadding = Maybe Char++data FormatOptions = MkFormatOptions+ { foLocale :: TimeLocale+ , foPadding :: Maybe FormatNumericPadding+ , foWidth :: Maybe Int+ }++-- <http://www.opengroup.org/onlinepubs/007908799/xsh/strftime.html>+class FormatTime t where+ -- | @since 1.9.1+ formatCharacter :: Bool -> Char -> Maybe (FormatOptions -> t -> String)++-- the weird UNIX logic is here+getPadOption :: Bool -> Bool -> Int -> Char -> Maybe FormatNumericPadding -> Maybe Int -> PadOption+getPadOption trunc fdef idef cdef mnpad mi =+ let+ c = case mnpad of+ Just (Just c') -> c'+ Just Nothing -> ' '+ _ -> cdef+ i = case mi of+ Just i' -> case mnpad of+ Just Nothing -> i'+ _ ->+ if trunc+ then i'+ else max i' idef+ Nothing -> idef+ f = case mi of+ Just _ -> True+ Nothing -> case mnpad of+ Nothing -> fdef+ Just Nothing -> False+ Just (Just _) -> True+ in+ if f+ then Pad i c+ else NoPad++formatGeneral ::+ Bool -> Bool -> Int -> Char -> (TimeLocale -> PadOption -> t -> String) -> (FormatOptions -> t -> String)+formatGeneral trunc fdef idef cdef ff fo =+ ff (foLocale fo) $ getPadOption trunc fdef idef cdef (foPadding fo) (foWidth fo)++formatString :: (TimeLocale -> t -> String) -> (FormatOptions -> t -> String)+formatString ff = formatGeneral False False 1 ' ' $ \locale pado -> showPadded pado . ff locale++formatNumber :: ShowPadded i => Bool -> Int -> Char -> (t -> i) -> (FormatOptions -> t -> String)+formatNumber fdef idef cdef ff = formatGeneral False fdef idef cdef $ \_ pado -> showPaddedNum pado . ff++formatNumberStd :: Int -> (t -> Integer) -> (FormatOptions -> t -> String)+formatNumberStd n = formatNumber False n '0'++showPaddedFixed :: HasResolution a => PadOption -> PadOption -> Fixed a -> String+showPaddedFixed padn padf x+ | x < 0 = '-' : showPaddedFixed padn padf (negate x)+showPaddedFixed padn padf x =+ let+ ns = showPaddedNum padn $ (floor x :: Integer)+ fs = showPaddedFixedFraction padf x+ ds =+ if null fs+ then ""+ else "."+ in+ ns ++ ds ++ fs++showPaddedFixedFraction :: HasResolution a => PadOption -> Fixed a -> String+showPaddedFixedFraction pado x =+ let+ digits = dropWhile (== '.') $ dropWhile (/= '.') $ showFixed True x+ n = length digits+ in+ case pado of+ NoPad -> digits+ Pad i c ->+ if i < n+ then take i digits+ else digits ++ replicate (i - n) c++-- | Substitute various time-related information for each %-code in the string, as per 'formatCharacter'.+--+-- The general form is @%\<modifier\>\<width\>\<alternate\>\<specifier\>@, where @\<modifier\>@, @\<width\>@, and @\<alternate\>@ are optional.+--+-- == @\<modifier\>@+-- glibc-style modifiers can be used before the specifier (here marked as @z@):+--+-- [@%-z@] no padding+--+-- [@%_z@] pad with spaces+--+-- [@%0z@] pad with zeros+--+-- [@%^z@] convert to upper case+--+-- [@%#z@] convert to lower case (consistently, unlike glibc)+--+-- == @\<width\>@+-- Width digits can also be used after any modifiers and before the specifier (here marked as @z@), for example:+--+-- [@%4z@] pad to 4 characters (with default padding character)+--+-- [@%_12z@] pad with spaces to 12 characters+--+-- == @\<alternate\>@+-- An optional @E@ character indicates an alternate formatting. Currently this only affects @%Z@ and @%z@.+--+-- [@%Ez@] alternate formatting+--+-- == @\<specifier\>@+--+-- For all types (note these three are done by 'formatTime', not by 'formatCharacter'):+--+-- [@%%@] @%@+--+-- [@%t@] tab+--+-- [@%n@] newline+--+-- === 'TimeZone'+-- For 'TimeZone' (and 'ZonedTime' and 'UTCTime'):+--+-- [@%z@] timezone offset in the format @±HHMM@+--+-- [@%Ez@] timezone offset in the format @±HH:MM@+--+-- [@%Z@] timezone name (or else offset in the format @±HHMM@)+--+-- [@%EZ@] timezone name (or else offset in the format @±HH:MM@)+--+-- === 'LocalTime'+-- For 'LocalTime' (and 'ZonedTime' and 'UTCTime' and 'UniversalTime'):+--+-- [@%c@] as 'dateTimeFmt' @locale@ (e.g. @%a %b %e %H:%M:%S %Z %Y@)+--+-- === 'TimeOfDay'+-- For 'TimeOfDay' (and 'LocalTime' and 'ZonedTime' and 'UTCTime' and 'UniversalTime'):+--+-- [@%R@] same as @%H:%M@+--+-- [@%T@] same as @%H:%M:%S@+--+-- [@%X@] as 'timeFmt' @locale@ (e.g. @%H:%M:%S@)+--+-- [@%r@] as 'time12Fmt' @locale@ (e.g. @%I:%M:%S %p@)+--+-- [@%P@] day-half of day from ('amPm' @locale@), converted to lowercase, @am@, @pm@+--+-- [@%p@] day-half of day from ('amPm' @locale@), @AM@, @PM@+--+-- [@%H@] hour of day (24-hour), 0-padded to two chars, @00@ - @23@+--+-- [@%k@] hour of day (24-hour), space-padded to two chars, @ 0@ - @23@+--+-- [@%I@] hour of day-half (12-hour), 0-padded to two chars, @01@ - @12@+--+-- [@%l@] hour of day-half (12-hour), space-padded to two chars, @ 1@ - @12@+--+-- [@%M@] minute of hour, 0-padded to two chars, @00@ - @59@+--+-- [@%S@] second of minute (without decimal part), 0-padded to two chars, @00@ - @60@+--+-- [@%q@] picosecond of second, 0-padded to twelve chars, @000000000000@ - @999999999999@.+--+-- [@%Q@] decimal point and fraction of second, up to 12 second decimals, without trailing zeros.+-- For a whole number of seconds, @%Q@ omits the decimal point unless padding is specified.+--+-- === 'UTCTime' and 'ZonedTime'+-- For 'UTCTime' and 'ZonedTime':+--+-- [@%s@] number of whole seconds since the Unix epoch. For times before+-- the Unix epoch, this is a negative number. Note that in @%s.%q@ and @%s%Q@+-- the decimals are positive, not negative. For example, 0.9 seconds+-- before the Unix epoch is formatted as @-1.1@ with @%s%Q@.+--+-- === 'DayOfWeek'+-- For 'DayOfWeek' (and 'Day' and 'LocalTime' and 'ZonedTime' and 'UTCTime' and 'UniversalTime'):+--+-- [@%u@] day of week number for Week Date format, @1@ (= Monday) - @7@ (= Sunday)+--+-- [@%w@] day of week number, @0@ (= Sunday) - @6@ (= Saturday)+--+-- [@%a@] day of week, short form ('snd' from 'wDays' @locale@), @Sun@ - @Sat@+--+-- [@%A@] day of week, long form ('fst' from 'wDays' @locale@), @Sunday@ - @Saturday@+--+-- === 'QuarterOfYear'+-- For 'QuarterOfYear' (and 'Quarter' and 'Month' and 'Day' and 'LocalTime' and 'ZonedTime' and 'UTCTime' and 'UniversalTime'):+--+-- [@%v@] quarter number, @1@ - @4@+--+-- === 'Quarter'+-- For 'Quarter' (and 'Month' and 'Day' and 'LocalTime' and 'ZonedTime' and 'UTCTime' and 'UniversalTime'):+--+-- [@%Y@] year, no padding. Note @%0Y@ and @%_Y@ pad to four chars+--+-- [@%y@] year of century, 0-padded to two chars, @00@ - @99@+--+-- [@%C@] century, no padding. Note @%0C@ and @%_C@ pad to two chars+--+-- [@%v@] quarter number, @1@ - @4@+--+--+-- === 'Month'+-- For 'Month' (and 'Day' and 'LocalTime' and 'ZonedTime' and 'UTCTime' and 'UniversalTime'):+--+-- [@%B@] month name, long form ('fst' from 'months' @locale@), @January@ - @December@+--+-- [@%b@, @%h@] month name, short form ('snd' from 'months' @locale@), @Jan@ - @Dec@+--+-- [@%m@] month of year, 0-padded to two chars, @01@ - @12@+--+-- === 'Day'+-- For 'Day' (and 'LocalTime' and 'ZonedTime' and 'UTCTime' and 'UniversalTime'):+--+-- [@%D@] same as @%m\/%d\/%y@+--+-- [@%F@] same as @%Y-%m-%d@+--+-- [@%x@] as 'dateFmt' @locale@ (e.g. @%m\/%d\/%y@)+--+-- [@%d@] day of month, 0-padded to two chars, @01@ - @31@+--+-- [@%e@] day of month, space-padded to two chars, @ 1@ - @31@+--+-- [@%j@] day of year, 0-padded to three chars, @001@ - @366@+--+-- [@%G@] year for ISO 8601 Week Date format. Note @%0G@ and @%_G@ pad to four chars+--+-- [@%g@] year of century for ISO 8601 Week Date format, 0-padded to two chars, @00@ - @99@+--+-- [@%f@] century for ISO 8601 Week Date format, no padding. Note @%0f@ and @%_f@ pad to two chars+--+-- [@%V@] week of year for ISO 8601 Week Date format, 0-padded to two chars, @01@ - @53@+--+-- [@%U@] week of year where weeks start on Sunday (as 'sundayStartWeek'), 0-padded to two chars, @00@ - @53@+--+-- [@%W@] week of year where weeks start on Monday (as 'mondayStartWeek'), 0-padded to two chars, @00@ - @53@+--+-- == Duration types+-- The specifiers for 'DiffTime', 'NominalDiffTime', 'CalendarDiffDays', and 'CalendarDiffTime' are semantically+-- separate from the other types.+-- Specifiers on negative time differences will generally be negative (think 'rem' rather than 'mod').+--+-- === 'NominalDiffTime' and 'DiffTime'+-- Note that a "minute" of 'DiffTime' is simply 60 SI seconds, rather than a minute of civil time.+-- Use 'NominalDiffTime' to work with civil time, ignoring any leap seconds.+--+-- For 'NominalDiffTime' and 'DiffTime':+--+-- [@%w@] total whole weeks+--+-- [@%d@] total whole days+--+-- [@%D@] whole days of week+--+-- [@%h@] total whole hours+--+-- [@%H@] whole hours of day+--+-- [@%m@] total whole minutes+--+-- [@%M@] whole minutes of hour+--+-- [@%s@] total whole seconds+--+-- [@%Es@] total seconds, with decimal point and up to \<width\> (default 12) decimal places, without trailing zeros.+-- For a whole number of seconds, @%Es@ omits the decimal point unless padding is specified.+--+-- [@%0Es@] total seconds, with decimal point and \<width\> (default 12) decimal places.+--+-- [@%S@] whole seconds of minute+--+-- [@%ES@] seconds of minute, with decimal point and up to \<width\> (default 12) decimal places, without trailing zeros.+-- For a whole number of seconds, @%ES@ omits the decimal point unless padding is specified.+--+-- [@%0ES@] seconds of minute as two digits, with decimal point and \<width\> (default 12) decimal places.+--+-- === 'CalendarDiffDays'+-- For 'CalendarDiffDays' (and 'CalendarDiffTime'):+--+-- [@%y@] total years+--+-- [@%b@] total months+--+-- [@%B@] months of year+--+-- [@%w@] total weeks, not including months+--+-- [@%d@] total days, not including months+--+-- [@%D@] days of week+--+-- === 'CalendarDiffTime'+-- For 'CalendarDiffTime':+--+-- [@%h@] total hours, not including months+--+-- [@%H@] hours of day+--+-- [@%m@] total minutes, not including months+--+-- [@%M@] minutes of hour+--+-- [@%s@] total whole seconds, not including months+--+-- [@%Es@] total seconds, not including months, with decimal point and up to \<width\> (default 12) decimal places, without trailing zeros.+-- For a whole number of seconds, @%Es@ omits the decimal point unless padding is specified.+--+-- [@%0Es@] total seconds, not including months, with decimal point and \<width\> (default 12) decimal places.+--+-- [@%S@] whole seconds of minute+--+-- [@%ES@] seconds of minute, with decimal point and up to \<width\> (default 12) decimal places, without trailing zeros.+-- For a whole number of seconds, @%ES@ omits the decimal point unless padding is specified.+--+-- [@%0ES@] seconds of minute as two digits, with decimal point and \<width\> (default 12) decimal places.+formatTime :: FormatTime t => TimeLocale -> String -> t -> String+formatTime _ [] _ = ""+formatTime locale ('%' : cs) t =+ case formatTime1 locale cs t of+ Just result -> result+ Nothing -> '%' : (formatTime locale cs t)+formatTime locale (c : cs) t = c : (formatTime locale cs t)++formatTime1 :: FormatTime t => TimeLocale -> String -> t -> Maybe String+formatTime1 locale ('_' : cs) t = formatTime2 locale id (Just (Just ' ')) cs t+formatTime1 locale ('-' : cs) t = formatTime2 locale id (Just Nothing) cs t+formatTime1 locale ('0' : cs) t = formatTime2 locale id (Just (Just '0')) cs t+formatTime1 locale ('^' : cs) t = formatTime2 locale (fmap toUpper) Nothing cs t+formatTime1 locale ('#' : cs) t = formatTime2 locale (fmap toLower) Nothing cs t+formatTime1 locale cs t = formatTime2 locale id Nothing cs t++getDigit :: Char -> Maybe Int+getDigit c+ | c < '0' = Nothing+getDigit c+ | c > '9' = Nothing+getDigit c = Just $ (ord c) - (ord '0')++pullNumber :: Maybe Int -> String -> (Maybe Int, String)+pullNumber mx [] = (mx, [])+pullNumber mx s@(c : cs) =+ case getDigit c of+ Just i -> pullNumber (Just $ (fromMaybe 0 mx) * 10 + i) cs+ Nothing -> (mx, s)++formatTime2 ::+ FormatTime t => TimeLocale -> (String -> String) -> Maybe FormatNumericPadding -> String -> t -> Maybe String+formatTime2 locale recase mpad cs t =+ let+ (mwidth, rest) = pullNumber Nothing cs+ in+ formatTime3 locale recase mpad mwidth rest t++formatTime3 ::+ FormatTime t =>+ TimeLocale ->+ (String -> String) ->+ Maybe FormatNumericPadding ->+ Maybe Int ->+ String ->+ t ->+ Maybe String+formatTime3 locale recase mpad mwidth ('E' : cs) = formatTime4 True recase (MkFormatOptions locale mpad mwidth) cs+formatTime3 locale recase mpad mwidth cs = formatTime4 False recase (MkFormatOptions locale mpad mwidth) cs++formatTime4 :: FormatTime t => Bool -> (String -> String) -> FormatOptions -> String -> t -> Maybe String+formatTime4 alt recase fo (c : cs) t = Just $ (recase (formatChar alt c fo t)) ++ (formatTime (foLocale fo) cs t)+formatTime4 _alt _recase _fo [] _t = Nothing++formatChar :: FormatTime t => Bool -> Char -> FormatOptions -> t -> String+formatChar _ '%' = formatString $ \_ _ -> "%"+formatChar _ 't' = formatString $ \_ _ -> "\t"+formatChar _ 'n' = formatString $ \_ _ -> "\n"+formatChar alt c =+ case formatCharacter alt c of+ Just f -> f+ _ -> \_ _ -> ""
+ lib/Data/Time/Format/Format/Instances.hs view
@@ -0,0 +1,229 @@+{-# LANGUAGE Safe #-}++{-# OPTIONS -fno-warn-orphans #-}++module Data.Time.Format.Format.Instances (++) where++import Control.Applicative ((<|>))+import Data.Char+import Data.Fixed+import Data.Time.Calendar.CalendarDiffDays+import Data.Time.Calendar.Days+import Data.Time.Calendar.Gregorian+import Data.Time.Calendar.Month+import Data.Time.Calendar.OrdinalDate+import Data.Time.Calendar.Private+import Data.Time.Calendar.Quarter+import Data.Time.Calendar.Week+import Data.Time.Calendar.WeekDate+import Data.Time.Clock.Internal.DiffTime+import Data.Time.Clock.Internal.NominalDiffTime+import Data.Time.Clock.Internal.UTCTime+import Data.Time.Clock.Internal.UniversalTime+import Data.Time.Clock.POSIX+import Data.Time.Format.Format.Class+import Data.Time.Format.Locale+import Data.Time.LocalTime.Internal.CalendarDiffTime+import Data.Time.LocalTime.Internal.LocalTime+import Data.Time.LocalTime.Internal.TimeOfDay+import Data.Time.LocalTime.Internal.TimeZone+import Data.Time.LocalTime.Internal.ZonedTime++mapFormatCharacter :: (b -> a) -> Maybe (FormatOptions -> a -> String) -> Maybe (FormatOptions -> b -> String)+mapFormatCharacter ba = fmap $ fmap $ \as -> as . ba++instance FormatTime LocalTime where+ formatCharacter _ 'c' = Just $ \fo -> formatTime (foLocale fo) $ dateTimeFmt $ foLocale fo+ formatCharacter alt c =+ mapFormatCharacter localDay (formatCharacter alt c)+ <|> mapFormatCharacter localTimeOfDay (formatCharacter alt c)++todAMPM :: TimeLocale -> TimeOfDay -> String+todAMPM locale day =+ let+ (am, pm) = amPm locale+ in+ if (todHour day) < 12+ then am+ else pm++tod12Hour :: TimeOfDay -> Int+tod12Hour day = (mod (todHour day - 1) 12) + 1++instance FormatTime TimeOfDay where+ -- Aggregate+ formatCharacter _ 'R' = Just $ formatString $ \locale -> formatTime locale "%H:%M"+ formatCharacter _ 'T' = Just $ formatString $ \locale -> formatTime locale "%H:%M:%S"+ formatCharacter _ 'X' = Just $ formatString $ \locale -> formatTime locale (timeFmt locale)+ formatCharacter _ 'r' = Just $ formatString $ \locale -> formatTime locale (time12Fmt locale)+ -- AM/PM+ formatCharacter _ 'P' = Just $ formatString $ \locale -> map toLower . todAMPM locale+ formatCharacter _ 'p' = Just $ formatString $ \locale -> todAMPM locale+ -- Hour+ formatCharacter _ 'H' = Just $ formatNumber True 2 '0' todHour+ formatCharacter _ 'I' = Just $ formatNumber True 2 '0' tod12Hour+ formatCharacter _ 'k' = Just $ formatNumber True 2 ' ' todHour+ formatCharacter _ 'l' = Just $ formatNumber True 2 ' ' tod12Hour+ -- Minute+ formatCharacter _ 'M' = Just $ formatNumber True 2 '0' todMin+ -- Second+ formatCharacter _ 'S' = Just $ formatNumber True 2 '0' $ (floor . todSec :: TimeOfDay -> Int)+ formatCharacter _ 'q' = Just $ formatGeneral True True 12 '0' $ \_ pado -> showPaddedFixedFraction pado . todSec+ formatCharacter _ 'Q' =+ Just $ formatGeneral True False 12 '0' $ \_ pado -> dotNonEmpty . showPaddedFixedFraction pado . todSec+ where+ dotNonEmpty "" = ""+ dotNonEmpty s = '.' : s+ -- Default+ formatCharacter _ _ = Nothing++instance FormatTime ZonedTime where+ formatCharacter _ 'c' = Just $ formatString $ \locale -> formatTime locale (dateTimeFmt locale)+ formatCharacter _ 's' =+ Just $ formatNumber True 1 '0' $ (floor . utcTimeToPOSIXSeconds . zonedTimeToUTC :: ZonedTime -> Integer)+ formatCharacter alt c =+ mapFormatCharacter zonedTimeToLocalTime (formatCharacter alt c)+ <|> mapFormatCharacter zonedTimeZone (formatCharacter alt c)++instance FormatTime TimeZone where+ formatCharacter False 'z' = Just $ formatGeneral False True 4 '0' $ \_ -> timeZoneOffsetString'' False+ formatCharacter True 'z' = Just $ formatGeneral False True 5 '0' $ \_ -> timeZoneOffsetString'' True+ formatCharacter alt 'Z' =+ Just $ \fo z ->+ let+ n = timeZoneName z+ idef =+ if alt+ then 5+ else 4+ in+ if null n+ then formatGeneral False True idef '0' (\_ -> timeZoneOffsetString'' alt) fo z+ else formatString (\_ -> timeZoneName) fo z+ formatCharacter _ _ = Nothing++instance FormatTime DayOfWeek where+ formatCharacter _ 'u' = Just $ formatNumber True 1 '0' $ fromEnum+ formatCharacter _ 'w' = Just $ formatNumber True 1 '0' $ \wd -> (mod (fromEnum wd) 7)+ formatCharacter _ 'a' = Just $ formatString $ \locale wd -> snd $ (wDays locale) !! (mod (fromEnum wd) 7)+ formatCharacter _ 'A' = Just $ formatString $ \locale wd -> fst $ (wDays locale) !! (mod (fromEnum wd) 7)+ formatCharacter _ _ = Nothing++instance FormatTime QuarterOfYear where+ -- Quarter of Year+ formatCharacter _ 'v' = Just $ formatNumber False 1 '0' fromEnum+ formatCharacter _ _ = Nothing++instance FormatTime Quarter where+ -- Year Count+ formatCharacter _ 'Y' = Just $ formatNumber False 4 '0' $ \(YearQuarter y _) -> y+ formatCharacter _ 'y' = Just $ formatNumber True 2 '0' $ \(YearQuarter y _) -> mod100 y+ formatCharacter _ 'C' = Just $ formatNumber False 2 '0' $ \(YearQuarter y _) -> div100 y+ -- Default+ formatCharacter alt c = mapFormatCharacter (\(YearQuarter _ q) -> q) $ formatCharacter alt c++instance FormatTime Month where+ -- Month of Year+ formatCharacter _ 'B' =+ Just $ formatString $ \locale (YearMonth _ my) -> fst $ (months locale) !! (my - 1)+ formatCharacter _ 'b' =+ Just $ formatString $ \locale (YearMonth _ my) -> snd $ (months locale) !! (my - 1)+ formatCharacter _ 'h' =+ Just $ formatString $ \locale (YearMonth _ my) -> snd $ (months locale) !! (my - 1)+ formatCharacter _ 'm' = Just $ formatNumber True 2 '0' $ \(YearMonth _ m) -> m+ -- Default+ formatCharacter alt c = mapFormatCharacter monthQuarter $ formatCharacter alt c++instance FormatTime Day where+ -- Aggregate+ formatCharacter _ 'D' = Just $ formatString $ \locale -> formatTime locale "%m/%d/%y"+ formatCharacter _ 'F' = Just $ formatString $ \locale -> formatTime locale "%Y-%m-%d"+ formatCharacter _ 'x' = Just $ formatString $ \locale -> formatTime locale (dateFmt locale)+ -- Day of Month+ formatCharacter _ 'd' = Just $ formatNumber True 2 '0' $ \(YearMonthDay _ _ dm) -> dm+ formatCharacter _ 'e' = Just $ formatNumber True 2 ' ' $ \(YearMonthDay _ _ dm) -> dm+ -- Day of Year+ formatCharacter _ 'j' = Just $ formatNumber True 3 '0' $ \(YearDay _ dy) -> dy+ -- ISO 8601 Week Date+ formatCharacter _ 'G' = Just $ formatNumber False 4 '0' $ \(YearWeekDay y _ _) -> y+ formatCharacter _ 'g' = Just $ formatNumber True 2 '0' $ \(YearWeekDay y _ _) -> mod100 y+ formatCharacter _ 'f' = Just $ formatNumber False 2 '0' $ \(YearWeekDay y _ _) -> div100 y+ formatCharacter _ 'V' = Just $ formatNumber True 2 '0' $ \(YearWeekDay _ wy _) -> wy+ formatCharacter _ 'u' = Just $ formatNumber True 1 '0' $ \(YearWeekDay _ _ dw) -> fromEnum dw+ -- Day of week+ formatCharacter _ 'a' = Just $ formatString $ \locale -> snd . ((wDays locale) !!) . snd . sundayStartWeek+ formatCharacter _ 'A' = Just $ formatString $ \locale -> fst . ((wDays locale) !!) . snd . sundayStartWeek+ formatCharacter _ 'U' = Just $ formatNumber True 2 '0' $ fst . sundayStartWeek+ formatCharacter _ 'w' = Just $ formatNumber True 1 '0' $ snd . sundayStartWeek+ formatCharacter _ 'W' = Just $ formatNumber True 2 '0' $ fst . mondayStartWeek+ -- Default+ formatCharacter alt c = mapFormatCharacter (\(MonthDay m _) -> m) $ formatCharacter alt c++instance FormatTime UTCTime where+ formatCharacter alt c = mapFormatCharacter (utcToZonedTime utc) $ formatCharacter alt c++instance FormatTime UniversalTime where+ formatCharacter alt c = mapFormatCharacter (ut1ToLocalTime 0) $ formatCharacter alt c++instance FormatTime NominalDiffTime where+ formatCharacter _ 'w' = Just $ formatNumberStd 1 $ quotBy $ 7 * 86400+ formatCharacter _ 'd' = Just $ formatNumberStd 1 $ quotBy 86400+ formatCharacter _ 'D' = Just $ formatNumberStd 1 $ remBy 7 . quotBy 86400+ formatCharacter _ 'h' = Just $ formatNumberStd 1 $ quotBy 3600+ formatCharacter _ 'H' = Just $ formatNumberStd 2 $ remBy 24 . quotBy 3600+ formatCharacter _ 'm' = Just $ formatNumberStd 1 $ quotBy 60+ formatCharacter _ 'M' = Just $ formatNumberStd 2 $ remBy 60 . quotBy 60+ formatCharacter False 's' = Just $ formatNumberStd 1 $ quotBy 1+ formatCharacter True 's' =+ Just $ formatGeneral True False 12 '0' $ \_ padf t -> showPaddedFixed NoPad padf (realToFrac t :: Pico)+ formatCharacter False 'S' = Just $ formatNumberStd 2 $ remBy 60 . quotBy 1+ formatCharacter True 'S' =+ Just $+ formatGeneral True False 12 '0' $ \_ padf t ->+ let+ padn = case padf of+ NoPad -> NoPad+ Pad _ c -> Pad 2 c+ in+ showPaddedFixed padn padf (realToFrac $ remBy 60 t :: Pico)+ formatCharacter _ _ = Nothing++instance FormatTime DiffTime where+ formatCharacter _ 'w' = Just $ formatNumberStd 1 $ quotBy $ 7 * 86400+ formatCharacter _ 'd' = Just $ formatNumberStd 1 $ quotBy 86400+ formatCharacter _ 'D' = Just $ formatNumberStd 1 $ remBy 7 . quotBy 86400+ formatCharacter _ 'h' = Just $ formatNumberStd 1 $ quotBy 3600+ formatCharacter _ 'H' = Just $ formatNumberStd 2 $ remBy 24 . quotBy 3600+ formatCharacter _ 'm' = Just $ formatNumberStd 1 $ quotBy 60+ formatCharacter _ 'M' = Just $ formatNumberStd 2 $ remBy 60 . quotBy 60+ formatCharacter False 's' = Just $ formatNumberStd 1 $ quotBy 1+ formatCharacter True 's' =+ Just $ formatGeneral True False 12 '0' $ \_ padf t -> showPaddedFixed NoPad padf (realToFrac t :: Pico)+ formatCharacter False 'S' = Just $ formatNumberStd 2 $ remBy 60 . quotBy 1+ formatCharacter True 'S' =+ Just $+ formatGeneral True False 12 '0' $ \_ padf t ->+ let+ padn = case padf of+ NoPad -> NoPad+ Pad _ c -> Pad 2 c+ in+ showPaddedFixed padn padf (realToFrac $ remBy 60 t :: Pico)+ formatCharacter _ _ = Nothing++instance FormatTime CalendarDiffDays where+ formatCharacter _ 'y' = Just $ formatNumberStd 1 $ quotBy 12 . cdMonths+ formatCharacter _ 'b' = Just $ formatNumberStd 1 $ cdMonths+ formatCharacter _ 'B' = Just $ formatNumberStd 2 $ remBy 12 . cdMonths+ formatCharacter _ 'w' = Just $ formatNumberStd 1 $ quotBy 7 . cdDays+ formatCharacter _ 'd' = Just $ formatNumberStd 1 $ cdDays+ formatCharacter _ 'D' = Just $ formatNumberStd 1 $ remBy 7 . cdDays+ formatCharacter _ _ = Nothing++instance FormatTime CalendarDiffTime where+ formatCharacter _ 'y' = Just $ formatNumberStd 1 $ quotBy 12 . ctMonths+ formatCharacter _ 'b' = Just $ formatNumberStd 1 $ ctMonths+ formatCharacter _ 'B' = Just $ formatNumberStd 2 $ remBy 12 . ctMonths+ formatCharacter alt c = mapFormatCharacter ctTime $ formatCharacter alt c
+ lib/Data/Time/Format/ISO8601.hs view
@@ -0,0 +1,469 @@+{-# LANGUAGE Safe #-}++{-# OPTIONS -fno-warn-orphans #-}++module Data.Time.Format.ISO8601 (+ -- * Format+ Format,+ formatShowM,+ formatShow,+ formatReadP,+ formatParseM,++ -- * Common formats+ ISO8601 (..),+ iso8601Show,+ iso8601ParseM,++ -- * All formats+ FormatExtension (..),+ formatReadPExtension,+ parseFormatExtension,+ calendarFormat,+ yearMonthFormat,+ yearFormat,+ centuryFormat,+ expandedCalendarFormat,+ expandedYearMonthFormat,+ expandedYearFormat,+ expandedCenturyFormat,+ ordinalDateFormat,+ expandedOrdinalDateFormat,+ weekDateFormat,+ yearWeekFormat,+ expandedWeekDateFormat,+ expandedYearWeekFormat,+ timeOfDayFormat,+ hourMinuteFormat,+ hourFormat,+ withTimeDesignator,+ withUTCDesignator,+ timeOffsetFormat,+ timeOfDayAndOffsetFormat,+ localTimeFormat,+ zonedTimeFormat,+ utcTimeFormat,+ dayAndTimeFormat,+ timeAndOffsetFormat,+ durationDaysFormat,+ durationTimeFormat,+ alternativeDurationDaysFormat,+ alternativeDurationTimeFormat,+ intervalFormat,+ recurringIntervalFormat,++ -- * Other+ isoMakeTimeOfDayValid,+) where++import Control.Monad.Fail+import Data.Fixed+import Data.Format+import Data.Ratio+import Data.Time.Calendar.CalendarDiffDays+import Data.Time.Calendar.Days+import Data.Time.Calendar.Gregorian+import Data.Time.Calendar.OrdinalDate+import Data.Time.Calendar.Private+import Data.Time.Calendar.WeekDate+import Data.Time.Clock.Internal.NominalDiffTime+import Data.Time.Clock.Internal.UTCTime+import Data.Time.LocalTime.Internal.CalendarDiffTime+import Data.Time.LocalTime.Internal.LocalTime+import Data.Time.LocalTime.Internal.TimeOfDay+import Data.Time.LocalTime.Internal.TimeZone hiding (timeZoneOffsetString'')+import Data.Time.LocalTime.Internal.ZonedTime+import Text.ParserCombinators.ReadP+import Text.Read (Read (..), lift)+import Prelude hiding (fail)++data FormatExtension+ = -- | Use hyphens and colons. [ISO 8601:2004(E) sec. 2.3.4]+ ExtendedFormat+ | -- | Omit hyphens and colons. "The basic format should be avoided in plain text." [ISO 8601:2004(E) sec. 2.3.3]+ BasicFormat++-- | Read a value in either extended or basic format+formatReadPExtension :: (FormatExtension -> Format t) -> ReadP t+formatReadPExtension ff = formatReadP (ff ExtendedFormat) +++ formatReadP (ff BasicFormat)++-- | Parse a value in either extended or basic format+parseFormatExtension :: MonadFail m => (FormatExtension -> Format t) -> String -> m t+parseFormatExtension ff = parseReader $ formatReadPExtension ff++sepFormat :: String -> Format a -> Format b -> Format (a, b)+sepFormat sep fa fb = (fa <** literalFormat sep) <**> fb++dashFormat :: Format a -> Format b -> Format (a, b)+dashFormat = sepFormat "-"++colnFormat :: Format a -> Format b -> Format (a, b)+colnFormat = sepFormat ":"++extDashFormat :: FormatExtension -> Format a -> Format b -> Format (a, b)+extDashFormat ExtendedFormat = dashFormat+extDashFormat BasicFormat = (<**>)++extColonFormat :: FormatExtension -> Format a -> Format b -> Format (a, b)+extColonFormat ExtendedFormat = colnFormat+extColonFormat BasicFormat = (<**>)++expandedYearFormat' :: Int -> Format Integer+expandedYearFormat' n = integerFormat PosNegSign (Just n)++yearFormat' :: Format Integer+yearFormat' = integerFormat NegSign (Just 4)++monthFormat :: Format Int+monthFormat = integerFormat NoSign (Just 2)++dayOfMonthFormat :: Format Int+dayOfMonthFormat = integerFormat NoSign (Just 2)++dayOfYearFormat :: Format Int+dayOfYearFormat = integerFormat NoSign (Just 3)++weekOfYearFormat :: Format Int+weekOfYearFormat = literalFormat "W" **> integerFormat NoSign (Just 2)++dayOfWeekFormat :: Format Int+dayOfWeekFormat = integerFormat NoSign (Just 1)++hourFormat' :: Format Int+hourFormat' = integerFormat NoSign (Just 2)++data E14++instance HasResolution E14 where+ resolution _ = 100000000000000++data E16++instance HasResolution E16 where+ resolution _ = 10000000000000000++hourDecimalFormat :: Format (Fixed E16) -- need four extra decimal places for hours+hourDecimalFormat = decimalFormat NoSign (Just 2)++minuteFormat :: Format Int+minuteFormat = integerFormat NoSign (Just 2)++minuteDecimalFormat :: Format (Fixed E14) -- need two extra decimal places for minutes+minuteDecimalFormat = decimalFormat NoSign (Just 2)++secondFormat :: Format Pico+secondFormat = decimalFormat NoSign (Just 2)++mapGregorian :: Format (Integer, (Int, Int)) -> Format Day+mapGregorian =+ mapMFormat (\(y, (m, d)) -> fromGregorianValid y m d) (\day -> (\(y, m, d) -> Just (y, (m, d))) $ toGregorian day)++mapOrdinalDate :: Format (Integer, Int) -> Format Day+mapOrdinalDate = mapMFormat (\(y, d) -> fromOrdinalDateValid y d) (Just . toOrdinalDate)++mapWeekDate :: Format (Integer, (Int, Int)) -> Format Day+mapWeekDate =+ mapMFormat (\(y, (w, d)) -> fromWeekDateValid y w d) (\day -> (\(y, w, d) -> Just (y, (w, d))) $ toWeekDate day)++-- | Like 'makeTimeOfDayValid', but accepts @24 0 0@ per ISO 8601:2004(E) sec. 4.2.3+--+-- @since 1.12+isoMakeTimeOfDayValid :: Int -> Int -> Pico -> Maybe TimeOfDay+isoMakeTimeOfDayValid 24 0 0 = return (TimeOfDay 24 0 0)+isoMakeTimeOfDayValid h m s = makeTimeOfDayValid h m s++mapTimeOfDay :: Format (Int, (Int, Pico)) -> Format TimeOfDay+mapTimeOfDay = mapMFormat (\(h, (m, s)) -> isoMakeTimeOfDayValid h m s) (\(TimeOfDay h m s) -> Just (h, (m, s)))++-- | @yyyy-mm-dd@ (extended), @yyyymmdd@ (basic) [ISO 8601:2004(E) sec. 4.1.2.2]+calendarFormat :: FormatExtension -> Format Day+calendarFormat fe = mapGregorian $ extDashFormat fe yearFormat $ extDashFormat fe monthFormat dayOfMonthFormat++-- | @yyyy-mm@ [ISO 8601:2004(E) sec. 4.1.2.3(a)]+yearMonthFormat :: Format (Integer, Int)+yearMonthFormat = yearFormat <**> literalFormat "-" **> monthFormat++-- | @yyyy@ [ISO 8601:2004(E) sec. 4.1.2.3(b)]+yearFormat :: Format Integer+yearFormat = yearFormat'++-- | @yy@ [ISO 8601:2004(E) sec. 4.1.2.3(c)]+centuryFormat :: Format Integer+centuryFormat = integerFormat NegSign (Just 2)++-- | @±__y__yyyy-mm-dd@ (extended), @±__y__yyyymmdd@ (basic) [ISO 8601:2004(E) sec. 4.1.2.4(a)]+expandedCalendarFormat :: Int -> FormatExtension -> Format Day+expandedCalendarFormat n fe =+ mapGregorian $ extDashFormat fe (expandedYearFormat n) $ extDashFormat fe monthFormat dayOfMonthFormat++-- | @±__y__yyyy-mm@ [ISO 8601:2004(E) sec. 4.1.2.4(b)]+expandedYearMonthFormat :: Int -> Format (Integer, Int)+expandedYearMonthFormat n = dashFormat (expandedYearFormat n) monthFormat++-- | @±__y__yyyy@ [ISO 8601:2004(E) sec. 4.1.2.4(c)]+expandedYearFormat :: Int -> Format Integer+expandedYearFormat = expandedYearFormat'++-- | @±__y__yy@ [ISO 8601:2004(E) sec. 4.1.2.4(d)]+expandedCenturyFormat :: Int -> Format Integer+expandedCenturyFormat n = integerFormat PosNegSign (Just n)++-- | @yyyy-ddd@ (extended), @yyyyddd@ (basic) [ISO 8601:2004(E) sec. 4.1.3.2]+ordinalDateFormat :: FormatExtension -> Format Day+ordinalDateFormat fe = mapOrdinalDate $ extDashFormat fe yearFormat dayOfYearFormat++-- | @__y__yyyy-ddd@ (extended), @__y__yyyyddd@ (basic) [ISO 8601:2004(E) sec. 4.1.3.3]+expandedOrdinalDateFormat :: Int -> FormatExtension -> Format Day+expandedOrdinalDateFormat n fe = mapOrdinalDate $ extDashFormat fe (expandedYearFormat n) dayOfYearFormat++-- | @yyyy-Www-D@ (extended), @yyyyWwwd@ (basic) [ISO 8601:2004(E) sec. 4.1.4.2]+weekDateFormat :: FormatExtension -> Format Day+weekDateFormat fe = mapWeekDate $ extDashFormat fe yearFormat $ extDashFormat fe weekOfYearFormat dayOfWeekFormat++-- | @yyyy-Www@ (extended), @yyyyWww@ (basic) [ISO 8601:2004(E) sec. 4.1.4.3]+yearWeekFormat :: FormatExtension -> Format (Integer, Int)+yearWeekFormat fe = extDashFormat fe yearFormat weekOfYearFormat++-- | @±__y__yyyy-Www-d@ (extended), @±__y__yyyyWwwD@ (basic) [ISO 8601:2004(E) sec. 4.1.4.4]+expandedWeekDateFormat :: Int -> FormatExtension -> Format Day+expandedWeekDateFormat n fe =+ mapWeekDate $ extDashFormat fe (expandedYearFormat n) $ extDashFormat fe weekOfYearFormat dayOfWeekFormat++-- | @±__y__yyyy-Www@ (extended), @±__y__yyyyWww@ (basic) [ISO 8601:2004(E) sec. 4.1.4.4]+expandedYearWeekFormat :: Int -> FormatExtension -> Format (Integer, Int)+expandedYearWeekFormat n fe = extDashFormat fe (expandedYearFormat n) weekOfYearFormat++-- | @hh:mm:ss[.s__s__]@ (extended), @hhmmss[.s__s__]@ (basic) [ISO 8601:2004(E) sec. 4.2.2.2, 4.2.2.4(a)]+timeOfDayFormat :: FormatExtension -> Format TimeOfDay+timeOfDayFormat fe = mapTimeOfDay $ extColonFormat fe hourFormat' $ extColonFormat fe minuteFormat secondFormat++-- workaround for the 'fromRational' in 'Fixed', which uses 'floor' instead of 'round'+fromRationalRound :: Rational -> NominalDiffTime+fromRationalRound r = fromRational $ round (r * 1000000000000) % 1000000000000++-- | @hh:mm[.m__m__]@ (extended), @hhmm[.m__m__]@ (basic) [ISO 8601:2004(E) sec. 4.2.2.3(a), 4.2.2.4(b)]+hourMinuteFormat :: FormatExtension -> Format TimeOfDay+hourMinuteFormat fe =+ let+ toTOD (h, m) =+ case timeToDaysAndTimeOfDay $ fromRationalRound $ toRational $ (fromIntegral h) * 3600 + m * 60 of+ (0, tod) -> Just tod+ (1, TimeOfDay 0 0 0) -> Just $ TimeOfDay 24 0 0+ _ -> Nothing+ fromTOD tod =+ let+ mm = (realToFrac $ daysAndTimeOfDayToTime 0 tod) / 60+ in+ Just $ quotRemBy 60 mm+ in+ mapMFormat toTOD fromTOD $ extColonFormat fe hourFormat' $ minuteDecimalFormat++-- | @hh[.h__h__]@ [ISO 8601:2004(E) sec. 4.2.2.3(b), 4.2.2.4(c)]+hourFormat :: Format TimeOfDay+hourFormat =+ let+ toTOD h = case timeToDaysAndTimeOfDay $ fromRationalRound $ toRational $ h * 3600 of+ (0, tod) -> Just tod+ (1, TimeOfDay 0 0 0) -> Just $ TimeOfDay 24 0 0+ _ -> Nothing+ fromTOD tod = Just $ (realToFrac $ daysAndTimeOfDayToTime 0 tod) / 3600+ in+ mapMFormat toTOD fromTOD $ hourDecimalFormat++-- | @Tx@ [ISO 8601:2004(E) sec. 4.2.2.5]+withTimeDesignator :: Format t -> Format t+withTimeDesignator f = literalFormat "T" **> f++-- | @xZ@ [ISO 8601:2004(E) sec. 4.2.4]+withUTCDesignator :: Format t -> Format t+withUTCDesignator f = f <** specialCaseReadFormat ((), "") (literalFormat "Z")++-- | @±hh:mm@ (extended), @±hhmm@ (basic) [ISO 8601:2004(E) sec. 4.2.5.1]+timeOffsetFormat :: FormatExtension -> Format TimeZone+timeOffsetFormat fe =+ let+ toTimeZone (sign, ehm) =+ minutesToTimeZone $+ sign * case ehm of+ Left h -> h * 60+ Right (h, m) -> h * 60 + m+ fromTimeZone tz =+ let+ mm = timeZoneMinutes tz+ (h, m) = quotRem (abs mm) 60+ in+ (signum mm, Right (h, m))+ digits2 = integerFormat NoSign (Just 2)+ in+ specialCaseReadFormat (utc, "") $+ specialCaseReadFormat (utc, "Z") $+ isoMap toTimeZone fromTimeZone $+ mandatorySignFormat <**> (digits2 <++> extColonFormat fe digits2 digits2)++-- | @hh:mm:ss±hh:mm@ (extended), @hhmmss±hhmm@ (basic) [ISO 8601:2004(E) sec. 4.2.5.2]+timeOfDayAndOffsetFormat :: FormatExtension -> Format (TimeOfDay, TimeZone)+timeOfDayAndOffsetFormat fe = timeOfDayFormat fe <**> timeOffsetFormat fe++-- | @xTy@ [ISO 8601:2004(E) sec. 4.3.2]+localTimeFormat :: Format Day -> Format TimeOfDay -> Format LocalTime+localTimeFormat fday ftod =+ isoMap (\(day, tod) -> LocalTime day tod) (\(LocalTime day tod) -> (day, tod)) $ dayAndTimeFormat fday ftod++-- | @xTy±hh:mm@ (extended), @xTy±hhmm@ (basic) [ISO 8601:2004(E) sec. 4.3.2]+zonedTimeFormat :: Format Day -> Format TimeOfDay -> FormatExtension -> Format ZonedTime+zonedTimeFormat fday ftod fe =+ isoMap (\(lt, tz) -> ZonedTime lt tz) (\(ZonedTime lt tz) -> (lt, tz)) $+ timeAndOffsetFormat (localTimeFormat fday ftod) fe++-- | @xTyZ@ [ISO 8601:2004(E) sec. 4.3.2]+utcTimeFormat :: Format Day -> Format TimeOfDay -> Format UTCTime+utcTimeFormat fday ftod =+ isoMap (localTimeToUTC utc) (utcToLocalTime utc) $ withUTCDesignator $ localTimeFormat fday ftod++-- | @xTy@ [ISO 8601:2004(E) sec. 4.3.3]+dayAndTimeFormat :: Format Day -> Format time -> Format (Day, time)+dayAndTimeFormat fday ftod = fday <**> withTimeDesignator ftod++-- | @x±hh:mm@ (extended), @x±hhmm@ (basic) [ISO 8601:2004(E) sec. 4.3.3]+timeAndOffsetFormat :: Format t -> FormatExtension -> Format (t, TimeZone)+timeAndOffsetFormat ft fe = ft <**> timeOffsetFormat fe++intDesignator :: (Eq t, Show t, Read t, Num t) => Char -> Format t+intDesignator c = optionalFormat 0 $ integerFormat NegSign Nothing <** literalFormat [c]++decDesignator :: (Eq t, Show t, Read t, Num t) => Char -> Format t+decDesignator c = optionalFormat 0 $ decimalFormat NegSign Nothing <** literalFormat [c]++daysDesigs :: Format CalendarDiffDays+daysDesigs =+ let+ toCD (y, (m, (w, d))) = CalendarDiffDays (y * 12 + m) (w * 7 + d)+ fromCD (CalendarDiffDays mm d) = (quot mm 12, (rem mm 12, (0, d)))+ in+ isoMap toCD fromCD $ intDesignator 'Y' <**> intDesignator 'M' <**> intDesignator 'W' <**> intDesignator 'D'++-- | @PyyYmmMddD@ [ISO 8601:2004(E) sec. 4.4.3.2]+durationDaysFormat :: Format CalendarDiffDays+durationDaysFormat = (**>) (literalFormat "P") $ specialCaseShowFormat (mempty, "0D") $ daysDesigs++-- | @PyyYmmMddDThhHmmMss[.s__s__]S@ [ISO 8601:2004(E) sec. 4.4.3.2]+durationTimeFormat :: Format CalendarDiffTime+durationTimeFormat =+ let+ toCT (cd, (h, (m, s))) =+ mappend (calendarTimeDays cd) (calendarTimeTime $ daysAndTimeOfDayToTime 0 $ TimeOfDay h m s)+ fromCT (CalendarDiffTime mm t) =+ let+ (d, TimeOfDay h m s) = timeToDaysAndTimeOfDay t+ in+ (CalendarDiffDays mm d, (h, (m, s)))+ in+ (**>) (literalFormat "P") $+ specialCaseShowFormat (mempty, "0D") $+ isoMap toCT fromCT $+ (<**>) daysDesigs $+ optionalFormat (0, (0, 0)) $+ literalFormat "T" **> intDesignator 'H' <**> intDesignator 'M' <**> decDesignator 'S'++-- | @Pyyyy-mm-dd@ (extended), @Pyyyymmdd@ (basic) [ISO 8601:2004(E) sec. 4.4.3.3]+alternativeDurationDaysFormat :: FormatExtension -> Format CalendarDiffDays+alternativeDurationDaysFormat fe =+ let+ toCD (y, (m, d)) = CalendarDiffDays (y * 12 + m) d+ fromCD (CalendarDiffDays mm d) = (quot mm 12, (rem mm 12, d))+ in+ isoMap toCD fromCD $+ (**>) (literalFormat "P") $+ extDashFormat fe (clipFormat (0, 9999) $ integerFormat NegSign $ Just 4) $+ extDashFormat fe (clipFormat (0, 12) $ integerFormat NegSign $ Just 2) $+ (clipFormat (0, 30) $ integerFormat NegSign $ Just 2)++-- | @Pyyyy-mm-ddThh:mm:ss@ (extended), @PyyyymmddThhmmss@ (basic) [ISO 8601:2004(E) sec. 4.4.3.3]+alternativeDurationTimeFormat :: FormatExtension -> Format CalendarDiffTime+alternativeDurationTimeFormat fe =+ let+ toCT (cd, (h, (m, s))) =+ mappend (calendarTimeDays cd) (calendarTimeTime $ daysAndTimeOfDayToTime 0 $ TimeOfDay h m s)+ fromCT (CalendarDiffTime mm t) =+ let+ (d, TimeOfDay h m s) = timeToDaysAndTimeOfDay t+ in+ (CalendarDiffDays mm d, (h, (m, s)))+ in+ isoMap toCT fromCT $+ (<**>) (alternativeDurationDaysFormat fe) $+ withTimeDesignator $+ extColonFormat fe (clipFormat (0, 24) $ integerFormat NegSign (Just 2)) $+ extColonFormat fe (clipFormat (0, 60) $ integerFormat NegSign (Just 2)) $+ (clipFormat (0, 60) $ decimalFormat NegSign (Just 2))++-- | @x\/y@ [ISO 8601:2004(E) sec. 4.4.4.1]+intervalFormat :: Format a -> Format b -> Format (a, b)+intervalFormat = sepFormat "/"++-- | @Rn\/x\/y@ [ISO 8601:2004(E) sec. 4.5]+recurringIntervalFormat :: Format a -> Format b -> Format (Int, a, b)+recurringIntervalFormat fa fb =+ isoMap (\(r, (a, b)) -> (r, a, b)) (\(r, a, b) -> (r, (a, b))) $+ sepFormat "/" (literalFormat "R" **> integerFormat NoSign Nothing) $+ intervalFormat fa fb++class ISO8601 t where+ -- | The most commonly used ISO 8601 format for this type.+ iso8601Format :: Format t++-- | Show in the most commonly used ISO 8601 format.+iso8601Show :: ISO8601 t => t -> String+iso8601Show = formatShow iso8601Format++-- | Parse the most commonly used ISO 8601 format.+iso8601ParseM :: (MonadFail m, ISO8601 t) => String -> m t+iso8601ParseM = formatParseM iso8601Format++-- | @yyyy-mm-dd@ [ISO 8601:2004(E) sec. 4.1.2.2 extended format]+instance ISO8601 Day where+ iso8601Format = calendarFormat ExtendedFormat++-- | @hh:mm:ss[.s__s__]@ [ISO 8601:2004(E) sec. 4.2.2.2, 4.2.2.4(a) extended format]+instance ISO8601 TimeOfDay where+ iso8601Format = timeOfDayFormat ExtendedFormat++-- | @±hh:mm@ [ISO 8601:2004(E) sec. 4.2.5.1 extended format]+instance ISO8601 TimeZone where+ iso8601Format = timeOffsetFormat ExtendedFormat++-- | @yyyy-mm-ddThh:mm:ss[.s__s__]@ [ISO 8601:2004(E) sec. 4.3.2 extended format]+instance ISO8601 LocalTime where+ iso8601Format = localTimeFormat iso8601Format iso8601Format++-- | @yyyy-mm-ddThh:mm:ss[.s__s__]±hh:mm@ [ISO 8601:2004(E) sec. 4.3.2 extended format]+instance ISO8601 ZonedTime where+ iso8601Format = zonedTimeFormat iso8601Format iso8601Format ExtendedFormat++-- | @yyyy-mm-ddThh:mm:ss[.s__s__]Z@ [ISO 8601:2004(E) sec. 4.3.2 extended format]+instance ISO8601 UTCTime where+ iso8601Format = utcTimeFormat iso8601Format iso8601Format++-- | @PyYmMdD@ [ISO 8601:2004(E) sec. 4.4.3.2]+instance ISO8601 CalendarDiffDays where+ iso8601Format = durationDaysFormat++-- | @PyYmMdDThHmMs[.s__s__]S@ [ISO 8601:2004(E) sec. 4.4.3.2]+instance ISO8601 CalendarDiffTime where+ iso8601Format = durationTimeFormat++-- orphan instance+instance Read CalendarDiffDays where+ readPrec = lift $ formatReadP iso8601Format++-- orphan instance+instance Show CalendarDiffDays where+ show = formatShow iso8601Format++-- orphan instance+instance Read CalendarDiffTime where+ readPrec = lift $ formatReadP iso8601Format++-- orphan instance+instance Show CalendarDiffTime where+ show = formatShow iso8601Format
+ lib/Data/Time/Format/Internal.hs view
@@ -0,0 +1,15 @@+{-# LANGUAGE Safe #-}++-- |+-- The contents of this module is liable to change, or disappear entirely.+-- Please <https://github.com/haskell/time/issues/new let me know> if you depend on anything here.+module Data.Time.Format.Internal (+ -- * ISO8601 formatting+ Format (..),+ module Data.Time.Format.Format.Class,+ module Data.Time.Format.Parse.Class,+) where++import Data.Format+import Data.Time.Format.Format.Class+import Data.Time.Format.Parse.Class
+ lib/Data/Time/Format/Locale.hs view
@@ -0,0 +1,92 @@+{-# LANGUAGE Safe #-}++-- Note: this file derives from old-locale:System.Locale.hs, which is copyright (c) The University of Glasgow 2001+module Data.Time.Format.Locale where++import Data.Time.LocalTime.Internal.TimeZone++data TimeLocale = TimeLocale+ { -- | full and abbreviated week days, starting with Sunday+ wDays :: [(String, String)]+ , -- | full and abbreviated months+ months :: [(String, String)]+ , -- | AM\/PM symbols+ amPm :: (String, String)+ , -- | formatting strings+ dateTimeFmt, dateFmt, timeFmt, time12Fmt :: String+ , -- | time zones known by name+ knownTimeZones :: [TimeZone]+ }+ deriving (Eq, Ord, Show)++-- | Locale representing American usage.+--+-- 'knownTimeZones' contains only the ten time-zones mentioned in RFC 822 sec. 5:+-- \"UT\", \"GMT\", \"EST\", \"EDT\", \"CST\", \"CDT\", \"MST\", \"MDT\", \"PST\", \"PDT\".+-- Note that the parsing functions will regardless parse \"UTC\", single-letter military time-zones, and +HHMM format.+defaultTimeLocale :: TimeLocale+defaultTimeLocale =+ TimeLocale+ { wDays =+ [ ("Sunday", "Sun")+ , ("Monday", "Mon")+ , ("Tuesday", "Tue")+ , ("Wednesday", "Wed")+ , ("Thursday", "Thu")+ , ("Friday", "Fri")+ , ("Saturday", "Sat")+ ]+ , months =+ [ ("January", "Jan")+ , ("February", "Feb")+ , ("March", "Mar")+ , ("April", "Apr")+ , ("May", "May")+ , ("June", "Jun")+ , ("July", "Jul")+ , ("August", "Aug")+ , ("September", "Sep")+ , ("October", "Oct")+ , ("November", "Nov")+ , ("December", "Dec")+ ]+ , amPm = ("AM", "PM")+ , dateTimeFmt = "%a %b %e %H:%M:%S %Z %Y"+ , dateFmt = "%m/%d/%y"+ , timeFmt = "%H:%M:%S"+ , time12Fmt = "%I:%M:%S %p"+ , knownTimeZones =+ [ TimeZone 0 False "UT"+ , TimeZone 0 False "GMT"+ , TimeZone (-5 * 60) False "EST"+ , TimeZone (-4 * 60) True "EDT"+ , TimeZone (-6 * 60) False "CST"+ , TimeZone (-5 * 60) True "CDT"+ , TimeZone (-7 * 60) False "MST"+ , TimeZone (-6 * 60) True "MDT"+ , TimeZone (-8 * 60) False "PST"+ , TimeZone (-7 * 60) True "PDT"+ ]+ }++{-# DEPRECATED iso8601DateFormat "use \"Data.Time.Format.ISO8601\" functions instead" #-}++{- | Construct format string according to <http://en.wikipedia.org/wiki/ISO_8601 ISO-8601>.++The @Maybe String@ argument allows to supply an optional time specification. E.g.:++@+'iso8601DateFormat' Nothing == "%Y-%m-%d" -- i.e. @/YYYY-MM-DD/@+'iso8601DateFormat' (Just "%H:%M:%S") == "%Y-%m-%dT%H:%M:%S" -- i.e. @/YYYY-MM-DD/T/HH:MM:SS/@+@+-}+iso8601DateFormat :: Maybe String -> String+iso8601DateFormat mTimeFmt =+ "%Y-%m-%d"+ ++ case mTimeFmt of+ Nothing -> ""+ Just fmt -> 'T' : fmt++-- | Format string according to <http://tools.ietf.org/html/rfc822#section-5 RFC822>.+rfc822DateFormat :: String+rfc822DateFormat = "%a, %_d %b %Y %H:%M:%S %Z"
+ lib/Data/Time/Format/Parse.hs view
@@ -0,0 +1,238 @@+{-# LANGUAGE Safe #-}++{-# OPTIONS -fno-warn-orphans #-}++module Data.Time.Format.Parse where++import Control.Monad.Fail+import Data.Char+import Data.Proxy+import Data.Time.Calendar.Days+import Data.Time.Clock.Internal.UTCTime+import Data.Time.Clock.Internal.UniversalTime+import Data.Time.Format.Locale+import Data.Time.Format.Parse.Class+import Data.Time.Format.Parse.Instances ()+import Data.Time.LocalTime.Internal.LocalTime+import Data.Time.LocalTime.Internal.TimeOfDay+import Data.Time.LocalTime.Internal.TimeZone+import Data.Time.LocalTime.Internal.ZonedTime+import Data.Traversable+import Text.ParserCombinators.ReadP hiding (char, string)+import Prelude hiding (fail)++-- | Parses a time value given a format string.+-- Missing information will be derived from 1970-01-01 00:00 UTC (which was a Thursday).+-- Supports the same %-codes as 'formatTime', including @%-@, @%_@ and @%0@ modifiers, however padding widths are not supported.+-- Case is not significant in the input string.+-- Some variations in the input are accepted:+--+-- [@%z@ @%Ez@] accepts any of @±HHMM@ or @±HH:MM@.+--+-- [@%Z@ @%EZ@] accepts any string of letters, or any of the formats accepted by @%z@.+--+-- [@%0Y@] accepts exactly four digits.+--+-- [@%0G@] accepts exactly four digits.+--+-- [@%0C@] accepts exactly two digits.+--+-- [@%0f@] accepts exactly two digits.+--+-- For example, to parse a date in YYYY-MM-DD format, while allowing the month+-- and date to have optional leading zeros (notice the @-@ modifier used for @%m@+-- and @%d@):+--+-- > Prelude Data.Time> parseTimeM True defaultTimeLocale "%Y-%-m-%-d" "2010-3-04" :: Maybe Day+-- > Just 2010-03-04+parseTimeM ::+ (MonadFail m, ParseTime t) =>+ -- | Accept leading and trailing whitespace?+ Bool ->+ -- | Time locale.+ TimeLocale ->+ -- | Format string.+ String ->+ -- | Input string.+ String ->+ -- | Return the time value, or fail if the input could not be parsed using the given format.+ m t+parseTimeM acceptWS l fmt s = parseTimeMultipleM acceptWS l [(fmt, s)]++-- | Parses a time value given a list of pairs of format and input.+-- Resulting value is constructed from all provided specifiers.+parseTimeMultipleM' ::+ (MonadFail m, ParseTime t) =>+ Proxy t ->+ -- | Accept leading and trailing whitespace?+ Bool ->+ -- | Time locale.+ TimeLocale ->+ -- | Pairs of (format string, input string).+ [(String, String)] ->+ -- | Return the time value, or fail if the input could not be parsed using the given format.+ m t+parseTimeMultipleM' pt acceptWS l fmts = do+ specss <- for fmts $ \(fmt, s) -> parseTimeSpecifiersM pt acceptWS l fmt s+ case buildTime l $ mconcat specss of+ Just t -> return t+ Nothing -> fail "parseTimeM: cannot construct"++-- | Parses a time value given a list of pairs of format and input.+-- Resulting value is constructed from all provided specifiers.+parseTimeMultipleM ::+ (MonadFail m, ParseTime t) =>+ -- | Accept leading and trailing whitespace?+ Bool ->+ -- | Time locale.+ TimeLocale ->+ -- | Pairs of (format string, input string).+ [(String, String)] ->+ -- | Return the time value, or fail if the input could not be parsed using the given format.+ m t+parseTimeMultipleM = parseTimeMultipleM' Proxy++-- | Parse a time value given a format string. Fails if the input could+-- not be parsed using the given format. See 'parseTimeM' for details.+parseTimeOrError ::+ ParseTime t =>+ -- | Accept leading and trailing whitespace?+ Bool ->+ -- | Time locale.+ TimeLocale ->+ -- | Format string.+ String ->+ -- | Input string.+ String ->+ -- | The time value.+ t+parseTimeOrError acceptWS l fmt s =+ case parseTimeM acceptWS l fmt s of+ [t] -> t+ [] -> error $ "parseTimeOrError: no parse of " ++ show s+ _ -> error $ "parseTimeOrError: multiple parses of " ++ show s++parseTimeSpecifiersM ::+ (MonadFail m, ParseTime t) =>+ Proxy t ->+ -- | Accept leading and trailing whitespace?+ Bool ->+ -- | Time locale.+ TimeLocale ->+ -- | Format string+ String ->+ -- | Input string.+ String ->+ m [(Char, String)]+parseTimeSpecifiersM pt acceptWS l fmt s =+ case parseTimeSpecifiers pt acceptWS l fmt s of+ [t] -> return t+ [] -> fail $ "parseTimeM: no parse of " ++ show s+ _ -> fail $ "parseTimeM: multiple parses of " ++ show s++parseTimeSpecifiers ::+ ParseTime t =>+ Proxy t ->+ -- | Accept leading and trailing whitespace?+ Bool ->+ -- | Time locale.+ TimeLocale ->+ -- | Format string+ String ->+ -- | Input string.+ String ->+ [[(Char, String)]]+parseTimeSpecifiers pt False l fmt s = [t | (t, "") <- readP_to_S (readPSpecifiers pt False l fmt) s]+parseTimeSpecifiers pt True l fmt s = [t | (t, r) <- readP_to_S (readPSpecifiers pt True l fmt) s, all isSpace r]++-- | Parse a time value given a format string. See 'parseTimeM' for details.+readSTime ::+ ParseTime t =>+ -- | Accept leading whitespace?+ Bool ->+ -- | Time locale.+ TimeLocale ->+ -- | Format string+ String ->+ ReadS t+readSTime acceptWS l f = readP_to_S $ readPTime acceptWS l f++readPSpecifiers ::+ ParseTime t =>+ Proxy t ->+ -- | Accept leading whitespace?+ Bool ->+ -- | Time locale.+ TimeLocale ->+ -- | Format string+ String ->+ ReadP [(Char, String)]+readPSpecifiers pt False l f = parseSpecifiers pt l f+readPSpecifiers pt True l f = (skipSpaces >> parseSpecifiers pt l f) <++ parseSpecifiers pt l f++-- | Parse a time value given a format string. See 'parseTimeM' for details.+readPTime' ::+ ParseTime t =>+ Proxy t ->+ -- | Accept leading whitespace?+ Bool ->+ -- | Time locale.+ TimeLocale ->+ -- | Format string+ String ->+ ReadP t+readPTime' pt ws l f = do+ pairs <- readPSpecifiers pt ws l f+ case buildTime l pairs of+ Just t -> return t+ Nothing -> pfail++-- | Parse a time value given a format string. See 'parseTimeM' for details.+readPTime ::+ ParseTime t =>+ -- | Accept leading whitespace?+ Bool ->+ -- | Time locale.+ TimeLocale ->+ -- | Format string+ String ->+ ReadP t+readPTime = readPTime' Proxy++-- * Read instances for time package types++instance Read Day where+ readsPrec _ = readParen False $ readSTime True defaultTimeLocale "%Y-%m-%d"++instance Read TimeOfDay where+ readsPrec _ = readParen False $ readSTime True defaultTimeLocale "%H:%M:%S%Q"++instance Read LocalTime where+ readsPrec _ = readParen False $ readSTime True defaultTimeLocale "%Y-%m-%d %H:%M:%S%Q"++-- | This only works for @±HHMM@ format,+-- single-letter military time-zones,+-- and these time-zones: \"UTC\", \"UT\", \"GMT\", \"EST\", \"EDT\", \"CST\", \"CDT\", \"MST\", \"MDT\", \"PST\", \"PDT\",+-- per RFC 822 section 5.+instance Read TimeZone where+ readsPrec _ = readParen False $ readSTime True defaultTimeLocale "%Z"++-- | This only works for a 'zonedTimeZone' in @±HHMM@ format,+-- single-letter military time-zones,+-- and these time-zones: \"UTC\", \"UT\", \"GMT\", \"EST\", \"EDT\", \"CST\", \"CDT\", \"MST\", \"MDT\", \"PST\", \"PDT\",+-- per RFC 822 section 5.+instance Read ZonedTime where+ readsPrec n = readParen False $ \s -> [(ZonedTime t z, r2) | (t, r1) <- readsPrec n s, (z, r2) <- readsPrec n r1]++(<||) :: [a] -> [a] -> [a]+[] <|| b = b+a <|| _ = a++instance Read UTCTime where+ readsPrec n s = do+ (lt, s') <- readsPrec n s+ (tz, s'') <- readsPrec n s' <|| pure (utc, s')+ return (localTimeToUTC tz lt, s'')++instance Read UniversalTime where+ readsPrec n s = [(localTimeToUT1 0 t, r) | (t, r) <- readsPrec n s]
+ lib/Data/Time/Format/Parse/Class.hs view
@@ -0,0 +1,293 @@+{-# LANGUAGE Safe #-}++module Data.Time.Format.Parse.Class (+ ParseNumericPadding (..),+ ParseTime (..),+ parseSpecifiers,+ timeSubstituteTimeSpecifier,+ timeParseTimeSpecifier,+ durationParseTimeSpecifier,+) where++import Control.Monad+import Data.Char+import Data.Foldable+import Data.Maybe+import Data.Proxy+import Data.Time.Format.Locale+import Text.ParserCombinators.ReadP++data ParseNumericPadding+ = NoPadding+ | SpacePadding+ | ZeroPadding++-- | The class of types which can be parsed given a UNIX-style time format+-- string.+class ParseTime t where+ -- | @since 1.9.1+ substituteTimeSpecifier :: Proxy t -> TimeLocale -> Char -> Maybe String+ substituteTimeSpecifier _ _ _ = Nothing++ -- | Get the string corresponding to the given format specifier.+ --+ -- @since 1.9.1+ parseTimeSpecifier :: Proxy t -> TimeLocale -> Maybe ParseNumericPadding -> Char -> ReadP String++ -- | Builds a time value from a parsed input string.+ -- If the input does not include all the information needed to+ -- construct a complete value, any missing parts should be taken+ -- from 1970-01-01 00:00:00 +0000 (which was a Thursday).+ -- In the absence of @%C@ or @%Y@, century is 1969 - 2068.+ --+ -- @since 1.9.1+ buildTime ::+ -- | The time locale.+ TimeLocale ->+ -- | Pairs of format characters and the+ -- corresponding part of the input.+ [(Char, String)] ->+ Maybe t++-- | Case-insensitive version of 'Text.ParserCombinators.ReadP.char'.+charCI :: Char -> ReadP Char+charCI c = satisfy (\x -> toUpper c == toUpper x)++-- | Case-insensitive version of 'Text.ParserCombinators.ReadP.string'.+stringCI :: String -> ReadP String+stringCI this = do+ let+ scan [] _ = return this+ scan (x : xs) (y : ys)+ | toUpper x == toUpper y = do+ _ <- get+ scan xs ys+ scan _ _ = pfail+ s <- look+ scan this s++parseSpecifiers :: ParseTime t => Proxy t -> TimeLocale -> String -> ReadP [(Char, String)]+parseSpecifiers pt locale =+ let+ parse :: String -> ReadP [(Char, String)]+ parse [] = return []+ parse ('%' : cs) = parse1 cs+ parse (c : cs) | isSpace c = do+ _ <- satisfy isSpace+ case cs of+ (c' : _) | isSpace c' -> return ()+ _ -> skipSpaces+ parse cs+ parse (c : cs) = do+ _ <- charCI c+ parse cs+ parse1 :: String -> ReadP [(Char, String)]+ parse1 ('-' : cs) = parse2 (Just NoPadding) cs+ parse1 ('_' : cs) = parse2 (Just SpacePadding) cs+ parse1 ('0' : cs) = parse2 (Just ZeroPadding) cs+ parse1 cs = parse2 Nothing cs+ parse2 :: Maybe ParseNumericPadding -> String -> ReadP [(Char, String)]+ parse2 mpad ('E' : cs) = parse3 mpad True cs+ parse2 mpad cs = parse3 mpad False cs+ parse3 :: Maybe ParseNumericPadding -> Bool -> String -> ReadP [(Char, String)]+ parse3 _ _ ('%' : cs) = do+ _ <- char '%'+ parse cs+ parse3 _ _ (c : cs) | Just s <- substituteTimeSpecifier pt locale c = parse $ s ++ cs+ parse3 mpad _alt (c : cs) = do+ str <- parseTimeSpecifier pt locale mpad c+ specs <- parse cs+ return $ (c, str) : specs+ parse3 _ _ [] = return []+ in+ parse++data PaddingSide+ = PrePadding+ | PostPadding++data EmptyOption = AllowEmptyOption | ForbidEmptyOption++checkEmptyOption :: EmptyOption -> String -> ReadP ()+checkEmptyOption ForbidEmptyOption "" = mzero+checkEmptyOption _ _ = return ()++data MunchType = AmbiguousMunchType | MaximalMunchType++data Munch = InexactMunch MunchType | ExactMunch Int++munchDigits :: MunchType -> ReadP String+munchDigits AmbiguousMunchType = many $ satisfy isDigit+munchDigits MaximalMunchType = munch isDigit++checkAll :: (a -> Bool) -> [a] -> ReadP ()+checkAll f l = for_ l $ \c -> if f c then return () else mzero++parseAnyPaddedDigits :: Maybe PaddingSide -> Munch -> ReadP String+parseAnyPaddedDigits mpad (ExactMunch n) = do+ chars <- count n get+ case mpad of+ Nothing -> do+ checkAll isDigit chars+ return chars+ Just PrePadding -> do+ let+ digits = dropWhile isSpace chars+ checkAll isDigit digits+ return digits+ Just PostPadding -> do+ let+ (digits, spaces) = span isDigit chars+ checkAll isSpace spaces+ return digits+parseAnyPaddedDigits Nothing (InexactMunch munchtype) = munchDigits munchtype+parseAnyPaddedDigits (Just PrePadding) (InexactMunch munchtype) = do+ skipSpaces+ munchDigits munchtype+parseAnyPaddedDigits (Just PostPadding) (InexactMunch munchtype) = do+ r <- munchDigits munchtype+ skipSpaces+ return r++parsePaddedDigits :: Maybe PaddingSide -> Munch -> EmptyOption -> ReadP String+parsePaddedDigits mps mn eo = do+ digits <- parseAnyPaddedDigits mps mn+ checkEmptyOption eo digits+ return digits++parsePaddingDigits :: PaddingSide -> ParseNumericPadding -> EmptyOption -> MunchType -> Int -> ReadP String+parsePaddingDigits _ps NoPadding eo mt _n = parsePaddedDigits Nothing (InexactMunch mt) eo+parsePaddingDigits _ps ZeroPadding eo _mt n = parsePaddedDigits Nothing (ExactMunch n) eo+parsePaddingDigits ps SpacePadding eo mt _n = parsePaddedDigits (Just ps) (InexactMunch mt) eo++allowNegative :: ReadP String -> ReadP String+allowNegative p = do+ sign <- option "" $ fmap pure $ char '-'+ val <- p+ return $ sign ++ val++timeParseTimeSpecifier :: TimeLocale -> Maybe ParseNumericPadding -> Char -> ReadP String+timeParseTimeSpecifier l mpad c =+ let+ parseDigits :: PaddingSide -> ParseNumericPadding -> EmptyOption -> MunchType -> Int -> ReadP String+ parseDigits ps pad = parsePaddingDigits ps $ fromMaybe pad mpad++ parseDigitsUsual :: ParseNumericPadding -> Int -> ReadP String+ parseDigitsUsual pad = parseDigits PrePadding pad ForbidEmptyOption AmbiguousMunchType++ oneOf = choice . map stringCI+ numericTZ = do+ s <- choice [char '+', char '-']+ h <- parseDigitsUsual ZeroPadding 2+ optional (char ':')+ m <- parseDigitsUsual ZeroPadding 2+ return (s : h ++ m)+ in+ case c of+ -- century+ 'C' -> allowNegative $ parseDigitsUsual SpacePadding 2+ 'f' -> allowNegative $ parseDigitsUsual SpacePadding 2+ -- year+ 'Y' -> allowNegative $ parseDigitsUsual SpacePadding 4+ 'G' -> allowNegative $ parseDigitsUsual SpacePadding 4+ -- year of century+ 'y' -> parseDigitsUsual ZeroPadding 2+ 'g' -> parseDigitsUsual ZeroPadding 2+ -- quarter of year+ 'v' -> parseDigitsUsual ZeroPadding 1+ -- month of year+ 'B' -> oneOf (map fst (months l))+ 'b' -> oneOf (map snd (months l))+ 'm' -> parseDigitsUsual ZeroPadding 2+ -- day of month+ 'd' -> parseDigitsUsual ZeroPadding 2+ 'e' -> parseDigitsUsual SpacePadding 2+ -- week of year+ 'V' -> parseDigitsUsual ZeroPadding 2+ 'U' -> parseDigitsUsual ZeroPadding 2+ 'W' -> parseDigitsUsual ZeroPadding 2+ -- day of week+ 'u' -> oneOf $ map (: []) ['1' .. '7']+ 'a' -> oneOf (map snd (wDays l))+ 'A' -> oneOf (map fst (wDays l))+ 'w' -> oneOf $ map (: []) ['0' .. '6']+ -- day of year+ 'j' -> parseDigitsUsual ZeroPadding 3+ -- dayhalf of day (i.e. AM or PM)+ 'P' ->+ oneOf+ ( let+ (am, pm) = amPm l+ in+ [am, pm]+ )+ 'p' ->+ oneOf+ ( let+ (am, pm) = amPm l+ in+ [am, pm]+ )+ -- hour of day (i.e. 24h)+ 'H' -> parseDigitsUsual ZeroPadding 2+ 'k' -> parseDigitsUsual SpacePadding 2+ -- hour of dayhalf (i.e. 12h)+ 'I' -> parseDigitsUsual ZeroPadding 2+ 'l' -> parseDigitsUsual SpacePadding 2+ -- minute of hour+ 'M' -> parseDigitsUsual ZeroPadding 2+ -- second of minute+ 'S' -> parseDigitsUsual ZeroPadding 2+ -- picosecond of second+ 'q' -> parseDigits PostPadding NoPadding AllowEmptyOption MaximalMunchType 12+ 'Q' -> (char '.' >> parseDigits PostPadding NoPadding AllowEmptyOption MaximalMunchType 12) <++ return ""+ -- time zone+ 'z' -> numericTZ+ 'Z' -> munch1 isAlpha <++ numericTZ+ -- seconds since epoch+ 's' -> (char '-' >> fmap ('-' :) (munch1 isDigit)) <++ munch1 isDigit+ _ -> fail $ "Unknown format character: " ++ show c++timeSubstituteTimeSpecifier :: TimeLocale -> Char -> Maybe String+timeSubstituteTimeSpecifier l 'c' = Just $ dateTimeFmt l+timeSubstituteTimeSpecifier _ 'R' = Just "%H:%M"+timeSubstituteTimeSpecifier _ 'T' = Just "%H:%M:%S"+timeSubstituteTimeSpecifier l 'X' = Just $ timeFmt l+timeSubstituteTimeSpecifier l 'r' = Just $ time12Fmt l+timeSubstituteTimeSpecifier _ 'D' = Just "%m/%d/%y"+timeSubstituteTimeSpecifier _ 'F' = Just "%Y-%m-%d"+timeSubstituteTimeSpecifier l 'x' = Just $ dateFmt l+timeSubstituteTimeSpecifier _ 'h' = Just "%b"+timeSubstituteTimeSpecifier _ _ = Nothing++durationParseTimeSpecifier :: TimeLocale -> Maybe ParseNumericPadding -> Char -> ReadP String+durationParseTimeSpecifier _ mpad c =+ let+ parsePaddedSignedDigits :: Int -> ReadP String+ parsePaddedSignedDigits n = allowNegative $ do+ parsePaddingDigits PrePadding (fromMaybe NoPadding mpad) ForbidEmptyOption MaximalMunchType n++ parseSignedDecimal :: ReadP String+ parseSignedDecimal = allowNegative $ do+ digits <- munch1 isDigit+ decimaldigits <-+ option "" $ do+ _ <- char '.'+ dd <- munch isDigit+ return $ '.' : dd+ return $ digits ++ decimaldigits+ in+ case c of+ 'y' -> parsePaddedSignedDigits 1+ 'b' -> parsePaddedSignedDigits 1+ 'B' -> parsePaddedSignedDigits 2+ 'w' -> parsePaddedSignedDigits 1+ 'd' -> parsePaddedSignedDigits 1+ 'D' -> parsePaddedSignedDigits 1+ 'h' -> parsePaddedSignedDigits 1+ 'H' -> parsePaddedSignedDigits 2+ 'm' -> parsePaddedSignedDigits 1+ 'M' -> parsePaddedSignedDigits 2+ 's' -> parseSignedDecimal+ 'S' -> parseSignedDecimal+ _ -> fail $ "Unknown format character: " ++ show c
+ lib/Data/Time/Format/Parse/Instances.hs view
@@ -0,0 +1,672 @@+{-# LANGUAGE Safe #-}++{-# OPTIONS -fno-warn-orphans #-}++module Data.Time.Format.Parse.Instances (++) where++import Control.Applicative ((<|>))+import Data.Char+import Data.Fixed+import Data.List (elemIndex, find)+import Data.Maybe+import Data.Ratio+import Data.Time.Calendar.CalendarDiffDays+import Data.Time.Calendar.Days+import Data.Time.Calendar.Gregorian+import Data.Time.Calendar.Month+import Data.Time.Calendar.OrdinalDate+import Data.Time.Calendar.Private (clipValid)+import Data.Time.Calendar.Quarter+import Data.Time.Calendar.Types+import Data.Time.Calendar.WeekDate+import Data.Time.Clock.Internal.DiffTime+import Data.Time.Clock.Internal.NominalDiffTime+import Data.Time.Clock.Internal.UTCTime+import Data.Time.Clock.Internal.UniversalTime+import Data.Time.Clock.POSIX+import Data.Time.Format.Locale+import Data.Time.Format.Parse.Class+import Data.Time.LocalTime.Internal.CalendarDiffTime+import Data.Time.LocalTime.Internal.LocalTime+import Data.Time.LocalTime.Internal.TimeOfDay+import Data.Time.LocalTime.Internal.TimeZone+import Data.Time.LocalTime.Internal.ZonedTime+import Data.Traversable+import Text.Read (readMaybe)++data WeekType+ = ISOWeek+ | SundayWeek+ | MondayWeek+ deriving Eq++mkDayFromWeekType :: WeekType -> Year -> WeekOfYear -> DayOfWeek -> Maybe Day+mkDayFromWeekType wt y woy dow =+ case wt of+ ISOWeek -> fromWeekDateValid y woy $ fromEnum dow+ SundayWeek -> fromSundayStartWeekValid y woy $ mod (fromEnum dow) 7+ MondayWeek -> fromMondayStartWeekValid y woy $ fromEnum dow++data DayFact+ = CenturyDayFact Integer -- century of all years+ | YearOfCenturyDayFact Integer -- 0-99, last two digits of both real years and week years+ | QuarterOfYearDayFact QuarterOfYear+ | MonthOfYearDayFact MonthOfYear -- 1-12+ | DayOfMonthDayFact DayOfMonth -- 1-31+ | DayOfYearDayFact DayOfYear -- 1-366+ | DayOfWeekDayFact DayOfWeek+ | WeekOfYearDayFact+ WeekType+ WeekOfYear -- 1-53 or 0-53+ | UTCTimeDayFact UTCTime+ | TimeZoneDayFact TimeZone++lastMatch :: (a -> Maybe b) -> [a] -> Maybe b+lastMatch f aa = listToMaybe $ reverse $ catMaybes $ fmap f aa++dayFactGetCentury :: [DayFact] -> Maybe Integer+dayFactGetCentury = lastMatch $ \case+ CenturyDayFact x -> Just x+ _ -> Nothing++dayFactGetYearOfCentury :: [DayFact] -> Maybe Integer+dayFactGetYearOfCentury = lastMatch $ \case+ YearOfCenturyDayFact x -> Just x+ _ -> Nothing++dayFactGetQuarterOfYear :: [DayFact] -> Maybe QuarterOfYear+dayFactGetQuarterOfYear = lastMatch $ \case+ QuarterOfYearDayFact x -> Just x+ _ -> Nothing++dayFactGetMonthOfYear :: [DayFact] -> Maybe MonthOfYear+dayFactGetMonthOfYear = lastMatch $ \case+ MonthOfYearDayFact x -> Just x+ _ -> Nothing++dayFactGetDayOfMonth :: [DayFact] -> Maybe DayOfMonth+dayFactGetDayOfMonth = lastMatch $ \case+ DayOfMonthDayFact x -> Just x+ _ -> Nothing++dayFactGetDayOfYear :: [DayFact] -> Maybe DayOfYear+dayFactGetDayOfYear = lastMatch $ \case+ DayOfYearDayFact x -> Just x+ _ -> Nothing++dayFactGetDayOfWeek :: [DayFact] -> Maybe DayOfWeek+dayFactGetDayOfWeek = lastMatch $ \case+ DayOfWeekDayFact x -> Just x+ _ -> Nothing++dayFactGetWeekOfYear :: [DayFact] -> Maybe (WeekType, WeekOfYear)+dayFactGetWeekOfYear = lastMatch $ \case+ WeekOfYearDayFact wt x -> Just (wt, x)+ _ -> Nothing++dayFactGetUTCTime :: [DayFact] -> Maybe UTCTime+dayFactGetUTCTime = lastMatch $ \case+ UTCTimeDayFact x -> Just x+ _ -> Nothing++dayFactGetTimeZone :: [DayFact] -> Maybe TimeZone+dayFactGetTimeZone = lastMatch $ \case+ TimeZoneDayFact x -> Just x+ _ -> Nothing++readSpec_z :: String -> Maybe Int+readSpec_z = readTzOffset++readSpec_Z :: TimeLocale -> String -> Maybe TimeZone+readSpec_Z _ str | Just offset <- readTzOffset str = Just $ TimeZone offset False ""+readSpec_Z l str | Just zone <- getKnownTimeZone l str = Just zone+readSpec_Z _ "UTC" = Just utc+readSpec_Z _ [c] | Just zone <- getMilZone c = Just zone+readSpec_Z _ _ = Nothing++makeDayFact :: TimeLocale -> Char -> String -> Maybe [DayFact]+makeDayFact l c x =+ let+ ra :: Read a => Maybe a+ ra = readMaybe x+ zeroBasedListIndex :: [String] -> Maybe Int+ zeroBasedListIndex ss = elemIndex (map toUpper x) $ fmap (map toUpper) ss+ oneBasedListIndex :: [String] -> Maybe Int+ oneBasedListIndex ss = do+ index <- zeroBasedListIndex ss+ return $ 1 + index+ in+ case c of+ -- %C: century (all but the last two digits of the year), 00 - 99+ 'C' -> do+ a <- ra+ return [CenturyDayFact a]+ -- %f century (all but the last two digits of the year), 00 - 99+ 'f' -> do+ a <- ra+ return [CenturyDayFact a]+ -- %Y: year+ 'Y' -> do+ a <- ra+ return [CenturyDayFact (a `div` 100), YearOfCenturyDayFact (a `mod` 100)]+ -- %G: year for Week Date format+ 'G' -> do+ a <- ra+ return [CenturyDayFact (a `div` 100), YearOfCenturyDayFact (a `mod` 100)]+ -- %y: last two digits of year, 00 - 99+ 'y' -> do+ a <- ra+ return [YearOfCenturyDayFact a]+ -- %g: last two digits of year for Week Date format, 00 - 99+ 'g' -> do+ a <- ra+ return [YearOfCenturyDayFact a]+ -- %v: quarter of year, 1 - 4+ 'v' -> do+ raw <- ra+ a <- clipValid 1 4 raw+ return [QuarterOfYearDayFact $ toEnum a]+ -- %B: month name, long form (fst from months locale), January - December+ 'B' -> do+ a <- oneBasedListIndex $ fmap fst $ months l+ return [MonthOfYearDayFact a]+ -- %b: month name, short form (snd from months locale), Jan - Dec+ 'b' -> do+ a <- oneBasedListIndex $ fmap snd $ months l+ return [MonthOfYearDayFact a]+ -- %m: month of year, leading 0 as needed, 01 - 12+ 'm' -> do+ raw <- ra+ a <- clipValid 1 12 raw+ return [MonthOfYearDayFact a]+ -- %d: day of month, leading 0 as needed, 01 - 31+ 'd' -> do+ raw <- ra+ a <- clipValid 1 31 raw+ return [DayOfMonthDayFact a]+ -- %e: day of month, leading space as needed, 1 - 31+ 'e' -> do+ raw <- ra+ a <- clipValid 1 31 raw+ return [DayOfMonthDayFact a]+ -- %V: week for Week Date format, 01 - 53+ 'V' -> do+ raw <- ra+ a <- clipValid 1 53 raw+ return [WeekOfYearDayFact ISOWeek a]+ -- %U: week number of year, where weeks start on Sunday (as sundayStartWeek), 00 - 53+ 'U' -> do+ raw <- ra+ a <- clipValid 0 53 raw+ return [WeekOfYearDayFact SundayWeek a]+ -- %W: week number of year, where weeks start on Monday (as mondayStartWeek), 00 - 53+ 'W' -> do+ raw <- ra+ a <- clipValid 0 53 raw+ return [WeekOfYearDayFact MondayWeek a]+ -- %u: day for Week Date format, 1 - 7+ 'u' -> do+ raw <- ra+ a <- clipValid 1 7 raw+ return [DayOfWeekDayFact $ toEnum a]+ -- %a: day of week, short form (snd from wDays locale), Sun - Sat+ 'a' -> do+ a <- zeroBasedListIndex $ fmap snd $ wDays l+ return [DayOfWeekDayFact $ toEnum a]+ -- %A: day of week, long form (fst from wDays locale), Sunday - Saturday+ 'A' -> do+ a <- zeroBasedListIndex $ fmap fst $ wDays l+ return [DayOfWeekDayFact $ toEnum a]+ -- %w: day of week number, 0 (= Sunday) - 6 (= Saturday)+ 'w' -> do+ raw <- ra+ a <- clipValid 0 6 raw+ return [DayOfWeekDayFact $ toEnum a]+ -- %j: day of year for Ordinal Date format, 001 - 366+ 'j' -> do+ raw <- ra+ a <- clipValid 1 366 raw+ return [DayOfYearDayFact a]+ -- %s: number of whole seconds since the Unix epoch.+ 's' -> do+ raw <- ra+ return [UTCTimeDayFact $ posixSecondsToUTCTime $ fromInteger raw]+ 'z' -> do+ a <- readSpec_z x+ return [TimeZoneDayFact $ TimeZone a False ""]+ 'Z' -> do+ a <- readSpec_Z l x+ return [TimeZoneDayFact a]+ -- unrecognised, pass on to other parsers+ _ -> return []++makeDayFacts :: TimeLocale -> [(Char, String)] -> Maybe [DayFact]+makeDayFacts l pairs = do+ factss <- for pairs $ \(c, x) -> makeDayFact l c x+ return $ mconcat factss++dayFactYear :: [DayFact] -> Integer+dayFactYear facts =+ let+ d = fromMaybe 70 $ dayFactGetYearOfCentury facts+ c =+ fromMaybe+ ( if d >= 69+ then 19+ else 20+ )+ $ dayFactGetCentury facts+ in+ 100 * c + d++dayFactDay :: [DayFact] -> Maybe Day+dayFactDay facts =+ case dayFactYear facts of+ y | Just doy <- dayFactGetDayOfYear facts -> fromOrdinalDateValid y doy+ y+ | Just moy <- dayFactGetMonthOfYear facts ->+ let+ dom = fromMaybe 1 $ dayFactGetDayOfMonth facts+ in+ fromGregorianValid y moy dom+ y+ | Just (wt, woy) <- dayFactGetWeekOfYear facts ->+ let+ dow = fromMaybe Thursday $ dayFactGetDayOfWeek facts+ in+ mkDayFromWeekType wt y woy dow+ y+ | Just qoy <- dayFactGetQuarterOfYear facts ->+ let+ moy = case qoy of+ Q1 -> 1+ Q2 -> 4+ Q3 -> 7+ Q4 -> 10+ dom = fromMaybe 1 $ dayFactGetDayOfMonth facts+ in+ fromGregorianValid y moy dom+ _+ | Just ut <- dayFactGetUTCTime facts ->+ let+ tz = fromMaybe utc $ dayFactGetTimeZone facts+ in+ Just $ localDay $ utcToLocalTime tz ut+ y | Just dom <- dayFactGetDayOfMonth facts -> fromGregorianValid y 1 dom+ y | Just dow <- dayFactGetDayOfWeek facts -> fromWeekDateValid y 1 $ fromEnum dow+ y -> fromOrdinalDateValid y 1++instance ParseTime Day where+ substituteTimeSpecifier _ = timeSubstituteTimeSpecifier+ parseTimeSpecifier _ = timeParseTimeSpecifier+ buildTime l pairs = do+ facts <- makeDayFacts l pairs+ dayFactDay facts++instance ParseTime DayOfWeek where+ substituteTimeSpecifier _ = timeSubstituteTimeSpecifier+ parseTimeSpecifier _ = timeParseTimeSpecifier+ buildTime l pairs = do+ facts <- makeDayFacts l pairs+ dayFactGetDayOfWeek facts+ <|> (fmap dayOfWeek $ dayFactDay facts)++instance ParseTime Month where+ substituteTimeSpecifier _ = timeSubstituteTimeSpecifier+ parseTimeSpecifier _ = timeParseTimeSpecifier+ buildTime l pairs = do+ facts <- makeDayFacts l pairs+ case dayFactGetMonthOfYear facts of+ Just moy ->+ let+ y = dayFactYear facts+ in+ Just $ YearMonth y moy+ Nothing -> fmap dayPeriod $ dayFactDay facts++instance ParseTime QuarterOfYear where+ substituteTimeSpecifier _ = timeSubstituteTimeSpecifier+ parseTimeSpecifier _ = timeParseTimeSpecifier+ buildTime l pairs = do+ facts <- makeDayFacts l pairs+ case dayFactGetQuarterOfYear facts of+ Just qoy -> Just qoy+ Nothing -> do+ QuarterDay (YearQuarter _ qoy) _ <- dayFactDay facts+ return qoy++instance ParseTime Quarter where+ substituteTimeSpecifier _ = timeSubstituteTimeSpecifier+ parseTimeSpecifier _ = timeParseTimeSpecifier+ buildTime l pairs = do+ facts <- makeDayFacts l pairs+ case dayFactGetQuarterOfYear facts of+ Just qoy ->+ let+ y = dayFactYear facts+ in+ Just $ YearQuarter y qoy+ Nothing -> fmap dayPeriod $ dayFactDay facts++mfoldl :: Monad m => (a -> b -> m a) -> m a -> [b] -> m a+mfoldl f =+ let+ mf ma b = do+ a <- ma+ f a b+ in+ foldl mf++data AMPM = AM | PM++data TimeFact+ = AMAPMTimeFact AMPM+ | HourTimeFact Int+ | MinuteTimeFact Int+ | WholeSecondTimeFact Int+ | FractSecondTimeFact Pico+ | UTCTimeFact UTCTime+ | ZoneTimeFact TimeZone++timeFactGetAMPM :: [TimeFact] -> Maybe AMPM+timeFactGetAMPM = lastMatch $ \case+ AMAPMTimeFact x -> Just x+ _ -> Nothing++timeFactGetHour :: [TimeFact] -> Maybe Int+timeFactGetHour = lastMatch $ \case+ HourTimeFact x -> Just x+ _ -> Nothing++timeFactGetMinute :: [TimeFact] -> Maybe Int+timeFactGetMinute = lastMatch $ \case+ MinuteTimeFact x -> Just x+ _ -> Nothing++timeFactGetWholeSecond :: [TimeFact] -> Maybe Int+timeFactGetWholeSecond = lastMatch $ \case+ WholeSecondTimeFact x -> Just x+ _ -> Nothing++timeFactGetFractSecond :: [TimeFact] -> Maybe Pico+timeFactGetFractSecond = lastMatch $ \case+ FractSecondTimeFact x -> Just x+ _ -> Nothing++timeFactGetUTC :: [TimeFact] -> Maybe UTCTime+timeFactGetUTC = lastMatch $ \case+ UTCTimeFact x -> Just x+ _ -> Nothing++timeFactGetZone :: [TimeFact] -> Maybe TimeZone+timeFactGetZone = lastMatch $ \case+ ZoneTimeFact x -> Just x+ _ -> Nothing++makeTimeFact :: TimeLocale -> Char -> String -> Maybe [TimeFact]+makeTimeFact l c x =+ let+ ra :: Read a => Maybe a+ ra = readMaybe x+ getAmPm =+ let+ upx = map toUpper x+ (amStr, pmStr) = amPm l+ in+ if upx == amStr+ then Just [AMAPMTimeFact AM]+ else+ if upx == pmStr+ then Just [AMAPMTimeFact PM]+ else Nothing+ in+ case c of+ 'P' -> getAmPm+ 'p' -> getAmPm+ 'H' -> do+ raw <- ra+ a <- clipValid 0 23 raw+ return [HourTimeFact a]+ 'I' -> do+ raw <- ra+ a <- clipValid 1 12 raw+ return [HourTimeFact a]+ 'k' -> do+ raw <- ra+ a <- clipValid 0 23 raw+ return [HourTimeFact a]+ 'l' -> do+ raw <- ra+ a <- clipValid 1 12 raw+ return [HourTimeFact a]+ 'M' -> do+ raw <- ra+ a <- clipValid 0 59 raw+ return [MinuteTimeFact a]+ 'S' -> do+ raw <- ra+ a <- clipValid 0 60 raw+ return [WholeSecondTimeFact $ fromInteger a]+ 'q' -> do+ ps <- (readMaybe $ take 12 $ rpad 12 '0' x) <|> return 0+ return [FractSecondTimeFact $ mkPico 0 ps]+ 'Q' ->+ if null x+ then return []+ else do+ ps <- (readMaybe $ take 12 $ rpad 12 '0' x) <|> return 0+ return [FractSecondTimeFact $ mkPico 0 ps]+ 's' -> do+ raw <- ra+ return [UTCTimeFact $ posixSecondsToUTCTime $ fromInteger raw]+ 'z' -> do+ a <- readSpec_z x+ return [ZoneTimeFact $ TimeZone a False ""]+ 'Z' -> do+ a <- readSpec_Z l x+ return [ZoneTimeFact a]+ _ -> return []++makeTimeFacts :: TimeLocale -> [(Char, String)] -> Maybe [TimeFact]+makeTimeFacts l pairs = do+ factss <- for pairs $ \(c, x) -> makeTimeFact l c x+ return $ mconcat factss++instance ParseTime TimeOfDay where+ substituteTimeSpecifier _ = timeSubstituteTimeSpecifier+ parseTimeSpecifier _ = timeParseTimeSpecifier+ buildTime l pairs = do+ facts <- makeTimeFacts l pairs+ -- 'Nothing' indicates a parse failure,+ -- while 'Just []' means no information+ case timeFactGetUTC facts of+ Just t ->+ let+ zone = fromMaybe utc $ timeFactGetZone facts+ sf = fromMaybe 0 $ timeFactGetFractSecond facts+ TimeOfDay h m s = localTimeOfDay $ utcToLocalTime zone t+ in+ return $ TimeOfDay h m $ s + sf+ Nothing ->+ let+ h = fromMaybe 0 $ timeFactGetHour facts+ m = fromMaybe 0 $ timeFactGetMinute facts+ si = fromMaybe 0 $ timeFactGetWholeSecond facts+ sf = fromMaybe 0 $ timeFactGetFractSecond facts+ s :: Pico+ s = fromIntegral si + sf+ h' = case timeFactGetAMPM facts of+ Nothing -> h+ Just AM -> mod h 12+ Just PM -> if h < 12 then h + 12 else h+ in+ return $ TimeOfDay h' m s++rpad :: Int -> a -> [a] -> [a]+rpad n c xs = xs ++ replicate (n - length xs) c++mkPico :: Integer -> Integer -> Pico+mkPico i f = fromInteger i + fromRational (f % 1000000000000)++instance ParseTime LocalTime where+ substituteTimeSpecifier _ = timeSubstituteTimeSpecifier+ parseTimeSpecifier _ = timeParseTimeSpecifier+ buildTime l xs = LocalTime <$> (buildTime l xs) <*> (buildTime l xs)++enumDiff :: Enum a => a -> a -> Int+enumDiff a b = (fromEnum a) - (fromEnum b)++getMilZoneHours :: Char -> Maybe Int+getMilZoneHours c+ | c < 'A' = Nothing+getMilZoneHours c+ | c <= 'I' = Just $ 1 + enumDiff c 'A'+getMilZoneHours 'J' = Nothing+getMilZoneHours c+ | c <= 'M' = Just $ 10 + enumDiff c 'K'+getMilZoneHours c+ | c <= 'Y' = Just $ (enumDiff 'N' c) - 1+getMilZoneHours 'Z' = Just 0+getMilZoneHours _ = Nothing++getMilZone :: Char -> Maybe TimeZone+getMilZone c =+ let+ yc = toUpper c+ in+ do+ hours <- getMilZoneHours yc+ return $ TimeZone (hours * 60) False [yc]++getKnownTimeZone :: TimeLocale -> String -> Maybe TimeZone+getKnownTimeZone locale x = find (\tz -> map toUpper x == timeZoneName tz) (knownTimeZones locale)++instance ParseTime TimeZone where+ substituteTimeSpecifier _ = timeSubstituteTimeSpecifier+ parseTimeSpecifier _ = timeParseTimeSpecifier+ buildTime l =+ let+ f :: Char -> String -> TimeZone -> Maybe TimeZone+ f 'z' str (TimeZone _ dst name) = do+ offset <- readSpec_z str+ return $ TimeZone offset dst name+ f 'Z' str _ = readSpec_Z l str+ f _ _ tz = Just tz+ in+ foldl (\mt (c, s) -> mt >>= f c s) (Just $ minutesToTimeZone 0)++readTzOffset :: String -> Maybe Int+readTzOffset str =+ let+ getSign '+' = Just 1+ getSign '-' = Just (-1)+ getSign _ = Nothing+ calc s h1 h2 m1 m2 = do+ sign <- getSign s+ h <- readMaybe [h1, h2]+ m <- readMaybe [m1, m2]+ return $ sign * (60 * h + m)+ in+ case str of+ (s : h1 : h2 : ':' : m1 : m2 : []) -> calc s h1 h2 m1 m2+ (s : h1 : h2 : m1 : m2 : []) -> calc s h1 h2 m1 m2+ _ -> Nothing++instance ParseTime ZonedTime where+ substituteTimeSpecifier _ = timeSubstituteTimeSpecifier+ parseTimeSpecifier _ = timeParseTimeSpecifier+ buildTime l xs =+ let+ f (ZonedTime (LocalTime _ tod) z) ('s', x) = do+ a <- readMaybe x+ let+ s = fromInteger a+ (_, ps) = properFraction (todSec tod) :: (Integer, Pico)+ s' = s + fromRational (toRational ps)+ return $ utcToZonedTime z (posixSecondsToUTCTime s')+ f t _ = Just t+ in+ mfoldl f (ZonedTime <$> (buildTime l xs) <*> (buildTime l xs)) xs++instance ParseTime UTCTime where+ substituteTimeSpecifier _ = timeSubstituteTimeSpecifier+ parseTimeSpecifier _ = timeParseTimeSpecifier+ buildTime l xs = zonedTimeToUTC <$> buildTime l xs++instance ParseTime UniversalTime where+ substituteTimeSpecifier _ = timeSubstituteTimeSpecifier+ parseTimeSpecifier _ = timeParseTimeSpecifier+ buildTime l xs = localTimeToUT1 0 <$> buildTime l xs++--- Duration++buildTimeMonths :: [(Char, String)] -> Maybe Integer+buildTimeMonths xs = do+ tt <-+ for xs $ \(c, s) ->+ case c of+ 'y' -> fmap ((*) 12) $ readMaybe s+ 'b' -> readMaybe s+ 'B' -> readMaybe s+ _ -> return 0+ return $ sum tt++buildTimeDays :: [(Char, String)] -> Maybe Integer+buildTimeDays xs = do+ tt <-+ for xs $ \(c, s) ->+ case c of+ 'w' -> fmap ((*) 7) $ readMaybe s+ 'd' -> readMaybe s+ 'D' -> readMaybe s+ _ -> return 0+ return $ sum tt++buildTimeSeconds :: [(Char, String)] -> Maybe Pico+buildTimeSeconds xs = do+ tt <- for xs $ \(c, s) ->+ let+ readInt :: Integer -> Maybe Pico+ readInt t = do+ i <- readMaybe s+ return $ fromInteger $ i * t+ in+ case c of+ 'h' -> readInt 3600+ 'H' -> readInt 3600+ 'm' -> readInt 60+ 'M' -> readInt 60+ 's' -> readMaybe s+ 'S' -> readMaybe s+ _ -> return 0+ return $ sum tt++instance ParseTime NominalDiffTime where+ parseTimeSpecifier _ = durationParseTimeSpecifier+ buildTime _ xs = do+ dd <- buildTimeDays xs+ tt <- buildTimeSeconds xs+ return $ (fromInteger dd * 86400) + realToFrac tt++instance ParseTime DiffTime where+ parseTimeSpecifier _ = durationParseTimeSpecifier+ buildTime _ xs = do+ dd <- buildTimeDays xs+ tt <- buildTimeSeconds xs+ return $ (fromInteger dd * 86400) + realToFrac tt++instance ParseTime CalendarDiffDays where+ parseTimeSpecifier _ = durationParseTimeSpecifier+ buildTime _ xs = do+ mm <- buildTimeMonths xs+ dd <- buildTimeDays xs+ return $ CalendarDiffDays mm dd++instance ParseTime CalendarDiffTime where+ parseTimeSpecifier _ = durationParseTimeSpecifier+ buildTime locale xs = do+ mm <- buildTimeMonths xs+ tt <- buildTime locale xs+ return $ CalendarDiffTime mm tt
+ lib/Data/Time/LocalTime.hs view
@@ -0,0 +1,64 @@+{-# LANGUAGE Safe #-}++module Data.Time.LocalTime (+ -- * Time zones+ TimeZone (..),+ timeZoneOffsetString,+ timeZoneOffsetString',+ minutesToTimeZone,+ hoursToTimeZone,+ utc,+ -- getting the locale time zone+ getTimeZone,+ getCurrentTimeZone,++ -- * Time of day+ TimeOfDay (..),+ midnight,+ midday,+ makeTimeOfDayValid,+ timeToDaysAndTimeOfDay,+ daysAndTimeOfDayToTime,+ utcToLocalTimeOfDay,+ localToUTCTimeOfDay,+ timeToTimeOfDay,+ pastMidnight,+ timeOfDayToTime,+ sinceMidnight,+ diffTimeOfDay,+ dayFractionToTimeOfDay,+ timeOfDayToDayFraction,++ -- * Calendar Duration+ module Data.Time.LocalTime.Internal.CalendarDiffTime,++ -- * Local Time+ LocalTime (..),+ addLocalTime,+ diffLocalTime,+ -- converting UTC and UT1 times to LocalTime+ utcToLocalTime,+ localTimeToUTC,+ ut1ToLocalTime,+ localTimeToUT1,+ -- using CalendarDiffTime+ addLocalDurationClip,+ addLocalDurationRollOver,+ diffLocalDurationClip,+ diffLocalDurationRollOver,++ -- * Zoned Time+ ZonedTime (..),+ utcToZonedTime,+ zonedTimeToUTC,+ getZonedTime,+ utcToLocalZonedTime,+) where++import Data.Time.Format ()+import Data.Time.LocalTime.Internal.CalendarDiffTime+import Data.Time.LocalTime.Internal.Foreign+import Data.Time.LocalTime.Internal.LocalTime+import Data.Time.LocalTime.Internal.TimeOfDay+import Data.Time.LocalTime.Internal.TimeZone hiding (timeZoneOffsetString'')+import Data.Time.LocalTime.Internal.ZonedTime
+ lib/Data/Time/LocalTime/Internal/CalendarDiffTime.hs view
@@ -0,0 +1,68 @@+{-# LANGUAGE CPP #-}+{-# LANGUAGE Safe #-}++module Data.Time.LocalTime.Internal.CalendarDiffTime where++import Control.DeepSeq+import Data.Data+import Data.Time.Calendar.CalendarDiffDays+import Data.Time.Calendar.Gregorian+import Data.Time.Clock.Internal.NominalDiffTime+import Data.Time.Clock.Internal.UTCDiff+import Data.Time.Clock.Internal.UTCTime+import GHC.Generics+#if __GLASGOW_HASKELL__ >= 914+import qualified Language.Haskell.TH.Lift as TH+#else+import qualified Language.Haskell.TH.Syntax as TH+#endif++data CalendarDiffTime = CalendarDiffTime+ { ctMonths :: Integer+ , ctTime :: NominalDiffTime+ }+ deriving (Eq, Typeable, Data, Generic, TH.Lift)++instance NFData CalendarDiffTime where+ rnf (CalendarDiffTime m t) = rnf m `seq` rnf t `seq` ()++-- | Additive+instance Semigroup CalendarDiffTime where+ CalendarDiffTime m1 d1 <> CalendarDiffTime m2 d2 = CalendarDiffTime (m1 + m2) (d1 + d2)++-- | Additive+instance Monoid CalendarDiffTime where+ mempty = CalendarDiffTime 0 0+ mappend = (<>)++calendarTimeDays :: CalendarDiffDays -> CalendarDiffTime+calendarTimeDays (CalendarDiffDays m d) = CalendarDiffTime m $ fromInteger d * nominalDay++calendarTimeTime :: NominalDiffTime -> CalendarDiffTime+calendarTimeTime dt = CalendarDiffTime 0 dt++-- | Scale by a factor. Note that @scaleCalendarDiffTime (-1)@ will not perfectly invert a duration, due to variable month lengths.+scaleCalendarDiffTime :: Integer -> CalendarDiffTime -> CalendarDiffTime+scaleCalendarDiffTime k (CalendarDiffTime m d) = CalendarDiffTime (k * m) (fromInteger k * d)++addUTCDurationClip :: CalendarDiffTime -> UTCTime -> UTCTime+addUTCDurationClip (CalendarDiffTime m d) (UTCTime day t) =+ addUTCTime d $ UTCTime (addGregorianMonthsClip m day) t++addUTCDurationRollOver :: CalendarDiffTime -> UTCTime -> UTCTime+addUTCDurationRollOver (CalendarDiffTime m d) (UTCTime day t) =+ addUTCTime d $ UTCTime (addGregorianMonthsRollOver m day) t++diffUTCDurationClip :: UTCTime -> UTCTime -> CalendarDiffTime+diffUTCDurationClip (UTCTime day1 t1) (UTCTime day2 t2) =+ let+ CalendarDiffTime m t = calendarTimeDays $ diffGregorianDurationClip day1 day2+ in+ CalendarDiffTime m $ t + realToFrac (t1 - t2)++diffUTCDurationRollOver :: UTCTime -> UTCTime -> CalendarDiffTime+diffUTCDurationRollOver (UTCTime day1 t1) (UTCTime day2 t2) =+ let+ CalendarDiffTime m t = calendarTimeDays $ diffGregorianDurationRollOver day1 day2+ in+ CalendarDiffTime m $ t + realToFrac (t1 - t2)
+ lib/Data/Time/LocalTime/Internal/Foreign.hs view
@@ -0,0 +1,119 @@+{-# LANGUAGE CPP #-}+{-# LANGUAGE ForeignFunctionInterface #-}+{-# LANGUAGE Safe #-}++module Data.Time.LocalTime.Internal.Foreign (+ getTimeZone,+ getCurrentTimeZone,+) where++import Data.Time.Clock.Internal.UTCTime+import Data.Time.Clock.POSIX+import Data.Time.Clock.System+import Data.Time.LocalTime.Internal.TimeZone+import Foreign+import Foreign.C+#if defined(javascript_HOST_ARCH)+import Data.Time.Calendar.Gregorian+import Data.Time.Clock.Internal.NominalDiffTime+import Data.Time.LocalTime.Internal.LocalTime+import Data.Time.LocalTime.Internal.TimeOfDay+#endif++#if defined(javascript_HOST_ARCH)++foreign import javascript "((dy,dm,dd,th,tm,ts) => { return new Date(dy,dm,dd,th,tm,ts).getTimezoneOffset(); })"+ js_get_timezone_minutes :: Int -> Int -> Int -> Int -> Int -> Int -> IO Int++get_timezone_minutes :: UTCTime -> IO Int+get_timezone_minutes ut = let+ lt :: LocalTime+ lt = utcToLocalTime utc ut+ in case lt of+ LocalTime (YearMonthDay dy dm dd) (TimeOfDay th tm ts) ->+ js_get_timezone_minutes (fromInteger dy) (pred dm) dd th tm (floor ts)++getTimeZoneCTime :: CTime -> IO TimeZone+getTimeZoneCTime ct = do+ let+ ut :: UTCTime+ ut = posixSecondsToUTCTime $ secondsToNominalDiffTime $ fromIntegral $ fromCTime ct+ mins <- get_timezone_minutes ut+ return $ TimeZone mins False ""++fromCTime :: CTime -> Int64+fromCTime (CTime tt) = fromIntegral tt++#else+{-# CFILES cbits/HsTime.c #-}+foreign import ccall unsafe "HsTime.h get_current_timezone_seconds"+ get_current_timezone_seconds ::+ CTime -> Ptr CInt -> Ptr CString -> IO CLong++getTimeZoneCTime :: CTime -> IO TimeZone+getTimeZoneCTime ctime =+ with 0 $ \pdst ->+ with nullPtr $ \pcname -> do+ secs <- get_current_timezone_seconds ctime pdst pcname+ case secs of+ 0x80000000 -> fail "localtime_r failed"+ _ -> do+ dst <- peek pdst+ cname <- peek pcname+ name <- peekCString cname+ return (TimeZone (div (fromIntegral secs) 60) (dst == 1) name)+#endif++-- there's no instance Bounded CTime, so this is the easiest way to check for overflow+toCTime :: Int64 -> IO CTime+toCTime t =+ let+ tt = fromIntegral t+ t' = fromIntegral tt+ in+ if t' == t+ then return $ CTime tt+ else fail "Data.Time.LocalTime.Internal.TimeZone.toCTime: Overflow"++-- | Get the configured time-zone for a given time (varying as per summertime adjustments).+getTimeZoneSystem :: SystemTime -> IO TimeZone+getTimeZoneSystem t = do+ ctime <- toCTime $ systemSeconds t+ getTimeZoneCTime ctime++-- | Get the configured time-zone for a given time (varying as per summertime adjustments).+--+-- On Unix systems the output of this function depends on:+--+-- 1. The value of @TZ@ environment variable (if set)+--+-- 2. The system time zone (usually configured by @\/etc\/localtime@ symlink)+--+-- For details see tzset(3) and localtime(3).+--+-- Example:+--+-- @+-- > let t = `UTCTime` (`Data.Time.Calendar.fromGregorian` 2021 7 1) 0+-- > `getTimeZone` t+-- CEST+-- > `System.Environment.setEnv` \"TZ\" \"America/New_York\" >> `getTimeZone` t+-- EDT+-- > `System.Environment.setEnv` \"TZ\" \"Europe/Berlin\" >> `getTimeZone` t+-- CEST+-- @+--+-- On Windows systems the output of this function depends on:+--+-- 1. The value of @TZ@ environment variable (if set).+-- See [here](https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/tzset) for how Windows interprets this variable.+--+-- 2. The system time zone, configured in Settings+getTimeZone :: UTCTime -> IO TimeZone+getTimeZone t = do+ ctime <- toCTime $ floor $ utcTimeToPOSIXSeconds t+ getTimeZoneCTime ctime++-- | Get the configured time-zone for the current time.+getCurrentTimeZone :: IO TimeZone+getCurrentTimeZone = getSystemTime >>= getTimeZoneSystem
+ lib/Data/Time/LocalTime/Internal/LocalTime.hs view
@@ -0,0 +1,100 @@+{-# LANGUAGE CPP #-}+{-# LANGUAGE Safe #-}++{-# OPTIONS -fno-warn-orphans #-}++module Data.Time.LocalTime.Internal.LocalTime where++import Control.DeepSeq+import Data.Data+import Data.Time.Calendar.Days+import Data.Time.Calendar.Gregorian+import Data.Time.Clock.Internal.NominalDiffTime+import Data.Time.Clock.Internal.UTCDiff+import Data.Time.Clock.Internal.UTCTime+import Data.Time.Clock.Internal.UniversalTime+import Data.Time.LocalTime.Internal.CalendarDiffTime+import Data.Time.LocalTime.Internal.TimeOfDay+import Data.Time.LocalTime.Internal.TimeZone+import GHC.Generics+#if __GLASGOW_HASKELL__ >= 914+import qualified Language.Haskell.TH.Lift as TH+#else+import qualified Language.Haskell.TH.Syntax as TH+#endif++-- | A simple day and time aggregate, where the day is of the specified parameter,+-- and the time is a TimeOfDay.+-- Conversion of this (as local civil time) to UTC depends on the time zone.+-- Conversion of this (as local mean time) to UT1 depends on the longitude.+data LocalTime = LocalTime+ { localDay :: Day+ , localTimeOfDay :: TimeOfDay+ }+ deriving (Eq, Ord, Typeable, Data, Generic, TH.Lift)++instance NFData LocalTime where+ rnf (LocalTime d t) = rnf d `seq` rnf t `seq` ()++instance Show LocalTime where+ show (LocalTime d t) = (showGregorian d) ++ " " ++ (show t)++-- | addLocalTime a b = a + b+addLocalTime :: NominalDiffTime -> LocalTime -> LocalTime+addLocalTime x = utcToLocalTime utc . addUTCTime x . localTimeToUTC utc++-- | diffLocalTime a b = a - b+diffLocalTime :: LocalTime -> LocalTime -> NominalDiffTime+diffLocalTime a b = diffUTCTime (localTimeToUTC utc a) (localTimeToUTC utc b)++-- | Get the local time of a UTC time in a time zone.+utcToLocalTime :: TimeZone -> UTCTime -> LocalTime+utcToLocalTime tz (UTCTime day dt) = LocalTime (addDays i day) tod+ where+ (i, tod) = utcToLocalTimeOfDay tz (timeToTimeOfDay dt)++-- | Get the UTC time of a local time in a time zone.+localTimeToUTC :: TimeZone -> LocalTime -> UTCTime+localTimeToUTC tz (LocalTime day tod) = UTCTime (addDays i day) (timeOfDayToTime todUTC)+ where+ (i, todUTC) = localToUTCTimeOfDay tz tod++-- | Get the local time of a UT1 time on a particular meridian (in degrees, positive is East).+ut1ToLocalTime :: Rational -> UniversalTime -> LocalTime+ut1ToLocalTime long (ModJulianDate date) =+ LocalTime (ModifiedJulianDay localMJD) (dayFractionToTimeOfDay localToDOffset)+ where+ localTime = date + long / 360 :: Rational+ localMJD = floor localTime+ localToDOffset = localTime - (fromIntegral localMJD)++-- | Get the UT1 time of a local time on a particular meridian (in degrees, positive is East).+localTimeToUT1 :: Rational -> LocalTime -> UniversalTime+localTimeToUT1 long (LocalTime (ModifiedJulianDay localMJD) tod) =+ ModJulianDate ((fromIntegral localMJD) + (timeOfDayToDayFraction tod) - (long / 360))++-- orphan instance+instance Show UniversalTime where+ show t = show (ut1ToLocalTime 0 t)++addLocalDurationClip :: CalendarDiffTime -> LocalTime -> LocalTime+addLocalDurationClip (CalendarDiffTime m d) (LocalTime day t) =+ addLocalTime d $ LocalTime (addGregorianMonthsClip m day) t++addLocalDurationRollOver :: CalendarDiffTime -> LocalTime -> LocalTime+addLocalDurationRollOver (CalendarDiffTime m d) (LocalTime day t) =+ addLocalTime d $ LocalTime (addGregorianMonthsRollOver m day) t++diffLocalDurationClip :: LocalTime -> LocalTime -> CalendarDiffTime+diffLocalDurationClip (LocalTime day1 t1) (LocalTime day2 t2) =+ let+ CalendarDiffTime m t = calendarTimeDays $ diffGregorianDurationClip day1 day2+ in+ CalendarDiffTime m $ t + diffTimeOfDay t1 t2++diffLocalDurationRollOver :: LocalTime -> LocalTime -> CalendarDiffTime+diffLocalDurationRollOver (LocalTime day1 t1) (LocalTime day2 t2) =+ let+ CalendarDiffTime m t = calendarTimeDays $ diffGregorianDurationRollOver day1 day2+ in+ CalendarDiffTime m $ t + diffTimeOfDay t1 t2
+ lib/Data/Time/LocalTime/Internal/TimeOfDay.hs view
@@ -0,0 +1,121 @@+{-# LANGUAGE CPP #-}+{-# LANGUAGE Safe #-}++module Data.Time.LocalTime.Internal.TimeOfDay where++import Control.DeepSeq+import Data.Data+import Data.Fixed+import Data.Time.Calendar.Private+import Data.Time.Clock.Internal.DiffTime+import Data.Time.Clock.Internal.NominalDiffTime+import Data.Time.LocalTime.Internal.TimeZone+import GHC.Generics+#if __GLASGOW_HASKELL__ >= 914+import qualified Language.Haskell.TH.Lift as TH+#else+import qualified Language.Haskell.TH.Syntax as TH+#endif++-- | Time of day as represented in hour, minute and second (with picoseconds), typically used to express local time of day.+--+-- @TimeOfDay 24 0 0@ is considered invalid for the purposes of 'makeTimeOfDayValid', as well as reading and parsing,+-- but valid for ISO 8601 parsing in "Data.Time.Format.ISO8601".+data TimeOfDay = TimeOfDay+ { todHour :: Int+ -- ^ range 0 - 23+ , todMin :: Int+ -- ^ range 0 - 59+ , todSec :: Pico+ -- ^ Note that 0 <= 'todSec' < 61, accommodating leap seconds.+ -- Any local minute may have a leap second, since leap seconds happen in all zones simultaneously+ }+ deriving (Eq, Ord, Typeable, Data, Generic, TH.Lift)++instance NFData TimeOfDay where+ rnf (TimeOfDay h m s) = rnf h `seq` rnf m `seq` rnf s `seq` ()++-- | Hour zero+midnight :: TimeOfDay+midnight = TimeOfDay 0 0 0++-- | Hour twelve+midday :: TimeOfDay+midday = TimeOfDay 12 0 0++instance Show TimeOfDay where+ show (TimeOfDay h m s) = (show2 h) ++ ":" ++ (show2 m) ++ ":" ++ (show2Fixed s)++makeTimeOfDayValid :: Int -> Int -> Pico -> Maybe TimeOfDay+makeTimeOfDayValid h m s = do+ _ <- clipValid 0 23 h+ _ <- clipValid 0 59 m+ _ <- clipValid 0 60.999999999999 s+ return (TimeOfDay h m s)++-- | Convert a period of time into a count of days and a time of day since midnight.+-- The time of day will never have a leap second.+timeToDaysAndTimeOfDay :: NominalDiffTime -> (Integer, TimeOfDay)+timeToDaysAndTimeOfDay dt =+ let+ s = realToFrac dt+ (m, ms) = divMod' s 60+ (h, hm) = divMod' m 60+ (d, dh) = divMod' h 24+ in+ (d, TimeOfDay dh hm ms)++-- | Convert a count of days and a time of day since midnight into a period of time.+daysAndTimeOfDayToTime :: Integer -> TimeOfDay -> NominalDiffTime+daysAndTimeOfDayToTime d (TimeOfDay dh hm ms) =+ (+) (realToFrac ms) $ (*) 60 $ (+) (realToFrac hm) $ (*) 60 $ (+) (realToFrac dh) $ (*) 24 $ realToFrac d++-- | Convert a time of day in UTC to a time of day in some timezone, together with a day adjustment.+utcToLocalTimeOfDay :: TimeZone -> TimeOfDay -> (Integer, TimeOfDay)+utcToLocalTimeOfDay zone (TimeOfDay h m s) = (fromIntegral (div h' 24), TimeOfDay (mod h' 24) (mod m' 60) s)+ where+ m' = m + timeZoneMinutes zone+ h' = h + (div m' 60)++-- | Convert a time of day in some timezone to a time of day in UTC, together with a day adjustment.+localToUTCTimeOfDay :: TimeZone -> TimeOfDay -> (Integer, TimeOfDay)+localToUTCTimeOfDay zone = utcToLocalTimeOfDay (minutesToTimeZone (negate (timeZoneMinutes zone)))++posixDayLength :: DiffTime+posixDayLength = fromInteger 86400++-- | Get the time of day given a time since midnight.+-- Time more than 24h will be converted to leap-seconds.+timeToTimeOfDay :: DiffTime -> TimeOfDay+timeToTimeOfDay dt+ | dt >= posixDayLength = TimeOfDay 23 59 (60 + (realToFrac (dt - posixDayLength)))+timeToTimeOfDay dt = TimeOfDay (fromInteger h) (fromInteger m) s+ where+ s' = realToFrac dt+ s = mod' s' 60+ m' = div' s' 60+ m = mod' m' 60+ h = div' m' 60++-- | Same as 'timeToTimeOfDay'.+pastMidnight :: DiffTime -> TimeOfDay+pastMidnight = timeToTimeOfDay++-- | Get the time since midnight for a given time of day.+timeOfDayToTime :: TimeOfDay -> DiffTime+timeOfDayToTime (TimeOfDay h m s) = ((fromIntegral h) * 60 + (fromIntegral m)) * 60 + (realToFrac s)++-- | Same as 'timeOfDayToTime'.+sinceMidnight :: TimeOfDay -> DiffTime+sinceMidnight = timeOfDayToTime++-- | Get the time of day given the fraction of a day since midnight.+dayFractionToTimeOfDay :: Rational -> TimeOfDay+dayFractionToTimeOfDay df = timeToTimeOfDay (realToFrac (df * 86400))++-- | Get the fraction of a day since midnight given a time of day.+timeOfDayToDayFraction :: TimeOfDay -> Rational+timeOfDayToDayFraction tod = realToFrac (timeOfDayToTime tod) / realToFrac posixDayLength++diffTimeOfDay :: TimeOfDay -> TimeOfDay -> NominalDiffTime+diffTimeOfDay t1 t2 = realToFrac $ daysAndTimeOfDayToTime 0 t1 - daysAndTimeOfDayToTime 0 t2
+ lib/Data/Time/LocalTime/Internal/TimeZone.hs view
@@ -0,0 +1,78 @@+{-# LANGUAGE CPP #-}+{-# LANGUAGE Safe #-}++module Data.Time.LocalTime.Internal.TimeZone (+ -- * Time zones+ TimeZone (..),+ timeZoneOffsetString,+ timeZoneOffsetString',+ timeZoneOffsetString'',+ minutesToTimeZone,+ hoursToTimeZone,+ utc,+) where++import Control.DeepSeq+import Data.Data+import Data.Time.Calendar.Private+import GHC.Generics+#if __GLASGOW_HASKELL__ >= 914+import qualified Language.Haskell.TH.Lift as TH+#else+import qualified Language.Haskell.TH.Syntax as TH+#endif++-- | A TimeZone is a whole number of minutes offset from UTC, together with a name and a \"just for summer\" flag.+data TimeZone = TimeZone+ { timeZoneMinutes :: Int+ -- ^ The number of minutes offset from UTC. Positive means local time will be later in the day than UTC.+ , timeZoneSummerOnly :: Bool+ -- ^ Is this time zone just persisting for the summer?+ , timeZoneName :: String+ -- ^ The name of the zone, typically a three- or four-letter acronym.+ }+ deriving (Eq, Ord, Typeable, Data, Generic, TH.Lift)++instance NFData TimeZone where+ rnf (TimeZone m so n) = rnf m `seq` rnf so `seq` rnf n `seq` ()++-- | Create a nameless non-summer timezone for this number of minutes.+minutesToTimeZone :: Int -> TimeZone+minutesToTimeZone m = TimeZone m False ""++-- | Create a nameless non-summer timezone for this number of hours.+hoursToTimeZone :: Int -> TimeZone+hoursToTimeZone i = minutesToTimeZone (60 * i)++showT :: Bool -> PadOption -> Int -> String+showT False opt t = showPaddedNum opt ((div t 60) * 100 + (mod t 60))+showT True opt t =+ let+ opt' = case opt of+ NoPad -> NoPad+ Pad i c -> Pad (max 0 $ i - 3) c+ in+ showPaddedNum opt' (div t 60) ++ ":" ++ show2 (mod t 60)++timeZoneOffsetString'' :: Bool -> PadOption -> TimeZone -> String+timeZoneOffsetString'' colon opt (TimeZone t _ _)+ | t < 0 = '-' : (showT colon opt (negate t))+timeZoneOffsetString'' colon opt (TimeZone t _ _) = '+' : (showT colon opt t)++-- | Text representing the offset of this timezone, such as \"-0800\" or \"+0400\" (like @%z@ in formatTime), with arbitrary padding.+timeZoneOffsetString' :: Maybe Char -> TimeZone -> String+timeZoneOffsetString' Nothing = timeZoneOffsetString'' False NoPad+timeZoneOffsetString' (Just c) = timeZoneOffsetString'' False $ Pad 4 c++-- | Text representing the offset of this timezone, such as \"-0800\" or \"+0400\" (like @%z@ in formatTime).+timeZoneOffsetString :: TimeZone -> String+timeZoneOffsetString = timeZoneOffsetString'' False (Pad 4 '0')++-- | This only shows the time zone name, or offset if the name is empty.+instance Show TimeZone where+ show zone@(TimeZone _ _ "") = timeZoneOffsetString zone+ show (TimeZone _ _ name) = name++-- | The UTC time zone.+utc :: TimeZone+utc = TimeZone 0 False "UTC"
+ lib/Data/Time/LocalTime/Internal/ZonedTime.hs view
@@ -0,0 +1,59 @@+{-# LANGUAGE CPP #-}+{-# LANGUAGE Safe #-}++{-# OPTIONS -fno-warn-orphans #-}++module Data.Time.LocalTime.Internal.ZonedTime where++import Control.DeepSeq+import Data.Data+import Data.Time.Clock.Internal.UTCTime+import Data.Time.Clock.POSIX+import Data.Time.LocalTime.Internal.Foreign+import Data.Time.LocalTime.Internal.LocalTime+import Data.Time.LocalTime.Internal.TimeZone+import GHC.Generics+#if __GLASGOW_HASKELL__ >= 914+import qualified Language.Haskell.TH.Lift as TH+#else+import qualified Language.Haskell.TH.Syntax as TH+#endif++-- | A local time together with a time zone.+--+-- There is no 'Eq' instance for @ZonedTime@.+-- If you want to compare local times, use 'zonedTimeToLocalTime'.+-- If you want to compare absolute times, use 'zonedTimeToUTC'.+data ZonedTime = ZonedTime+ { zonedTimeToLocalTime :: LocalTime+ , zonedTimeZone :: TimeZone+ }+ deriving (Typeable, Data, Generic, TH.Lift)++instance NFData ZonedTime where+ rnf (ZonedTime lt z) = rnf lt `seq` rnf z `seq` ()++utcToZonedTime :: TimeZone -> UTCTime -> ZonedTime+utcToZonedTime zone time = ZonedTime (utcToLocalTime zone time) zone++zonedTimeToUTC :: ZonedTime -> UTCTime+zonedTimeToUTC (ZonedTime t zone) = localTimeToUTC zone t++-- | For the time zone, this only shows the name, or offset if the name is empty.+instance Show ZonedTime where+ show (ZonedTime t zone) = show t ++ " " ++ show zone++-- orphan instance+instance Show UTCTime where+ show t = show (utcToZonedTime utc t)++getZonedTime :: IO ZonedTime+getZonedTime = do+ t <- getCurrentTime+ zone <- getTimeZone t+ return (utcToZonedTime zone t)++utcToLocalZonedTime :: UTCTime -> IO ZonedTime+utcToLocalZonedTime t = do+ zone <- getTimeZone t+ return (utcToZonedTime zone t)
+ lib/cbits/HsTime.c view
@@ -0,0 +1,51 @@+#include "HsTime.h"+#include <stdio.h>++long int get_current_timezone_seconds (time_t t,int* pdst,char const* * pname)+{+#if defined(_MSC_VER) || defined(__MINGW32__) || defined(_WIN32)+ // When compiling with MinGW (which does not provide a full POSIX+ // layer as opposed to Cygwin) it's better to use the CRT's+ // underscore-prefixed `_tzset()` variant to avoid linker issues+ // as Microsoft considers the POSIX named `tzset()` function+ // deprecated (see http://msdn.microsoft.com/en-us/library/ms235384.aspx)+ _tzset();+#elif defined(HAVE_TZSET)+ tzset();+#endif++#if HAVE_LOCALTIME_R+ struct tm tmd;+ struct tm* ptm = localtime_r(&t,&tmd);+#else+ struct tm* ptm = localtime(&t);+#endif+ if (ptm)+ {+ int dst = ptm -> tm_isdst;+ *pdst = dst;+#if HAVE_TM_ZONE+ *pname = ptm -> tm_zone;+ return ptm -> tm_gmtoff;+#elif defined(_MSC_VER) || defined(__MINGW32__) || defined(_WIN32)+ // We don't have a better API to use on Windows, the logic to+ // decide whether a given date/time falls within DST is+ // implemented as part of localtime() in the CRT. This is_dst+ // flag is all we need here.+ *pname = dst ? _tzname[1] : _tzname[0];+ return - (dst ? _timezone - 3600 : _timezone);+#else+# if HAVE_TZNAME || defined(__MHS__)+ *pname = *tzname;+# else+# error "Don't know how to get timezone name on your OS"+# endif+# if HAVE_DECL_ALTZONE+ return dst ? altzone : timezone;+# else+ return dst ? timezone - 3600 : timezone;+# endif+#endif // HAVE_TM_ZONE+ }+ else return 0x80000000;+}
+ lib/include/HsTime.h view
@@ -0,0 +1,25 @@+#ifndef __HSTIME_H__+#define __HSTIME_H__++#if defined(_MSC_VER) || defined(__MINGW32__) || defined(_WIN32) || defined(__MHS__)+#define HAVE_TIME_H 1+#else++#include "HsTimeConfig.h"+// Otherwise these clash with similar definitions from other packages:+#undef PACKAGE_BUGREPORT+#undef PACKAGE_NAME+#undef PACKAGE_STRING+#undef PACKAGE_TARNAME+#undef PACKAGE_VERSION+#endif++#if HAVE_TIME_H+#include <time.h>+#endif++#define HS_CLOCK_REALTIME (uintptr_t)(CLOCK_REALTIME)++long int get_current_timezone_seconds (time_t,int* pdst,char const* * pname);++#endif
+ lib/include/HsTimeConfig.h.in view
@@ -0,0 +1,185 @@+/* lib/include/HsTimeConfig.h.in. Generated from configure.ac by autoheader. */++/* Define to 1 if you have the `clock_gettime' function. */+#undef HAVE_CLOCK_GETTIME++/* Define to 1 if you have the declaration of `altzone', and to 0 if you+ don't. */+#undef HAVE_DECL_ALTZONE++/* Define to 1 if you have the declaration of `tzname', and to 0 if you don't.+ */+#undef HAVE_DECL_TZNAME++/* Define to 1 if you have the `gmtime_r' function. */+#undef HAVE_GMTIME_R++/* Define to 1 if you have the <inttypes.h> header file. */+#undef HAVE_INTTYPES_H++/* Define to 1 if you have the `localtime_r' function. */+#undef HAVE_LOCALTIME_R++/* Define to 1 if you have the <minix/config.h> header file. */+#undef HAVE_MINIX_CONFIG_H++/* Define to 1 if you have the <stdint.h> header file. */+#undef HAVE_STDINT_H++/* Define to 1 if you have the <stdio.h> header file. */+#undef HAVE_STDIO_H++/* Define to 1 if you have the <stdlib.h> header file. */+#undef HAVE_STDLIB_H++/* Define to 1 if you have the <strings.h> header file. */+#undef HAVE_STRINGS_H++/* Define to 1 if you have the <string.h> header file. */+#undef HAVE_STRING_H++/* Define to 1 if `tm_zone' is a member of `struct tm'. */+#undef HAVE_STRUCT_TM_TM_ZONE++/* Define to 1 if you have the <sys/stat.h> header file. */+#undef HAVE_SYS_STAT_H++/* Define to 1 if you have the <sys/time.h> header file. */+#undef HAVE_SYS_TIME_H++/* Define to 1 if you have the <sys/types.h> header file. */+#undef HAVE_SYS_TYPES_H++/* Define to 1 if you have the <time.h> header file. */+#undef HAVE_TIME_H++/* Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use+ `HAVE_STRUCT_TM_TM_ZONE' instead. */+#undef HAVE_TM_ZONE++/* Define to 1 if you don't have `tm_zone' but do have the external array+ `tzname'. */+#undef HAVE_TZNAME++/* Define to 1 if you have the `tzset' function. */+#undef HAVE_TZSET++/* Define to 1 if you have the <unistd.h> header file. */+#undef HAVE_UNISTD_H++/* Define to 1 if you have the <wchar.h> header file. */+#undef HAVE_WCHAR_H++/* Define to the address where bug reports for this package should be sent. */+#undef PACKAGE_BUGREPORT++/* Define to the full name of this package. */+#undef PACKAGE_NAME++/* Define to the full name and version of this package. */+#undef PACKAGE_STRING++/* Define to the one symbol short name of this package. */+#undef PACKAGE_TARNAME++/* Define to the home page for this package. */+#undef PACKAGE_URL++/* Define to the version of this package. */+#undef PACKAGE_VERSION++/* Define to 1 if all of the C90 standard headers exist (not just the ones+ required in a freestanding environment). This macro is provided for+ backward compatibility; new code need not use it. */+#undef STDC_HEADERS++/* Define to 1 if your <sys/time.h> declares `struct tm'. */+#undef TM_IN_SYS_TIME++/* Enable extensions on AIX 3, Interix. */+#ifndef _ALL_SOURCE+# undef _ALL_SOURCE+#endif+/* Enable general extensions on macOS. */+#ifndef _DARWIN_C_SOURCE+# undef _DARWIN_C_SOURCE+#endif+/* Enable general extensions on Solaris. */+#ifndef __EXTENSIONS__+# undef __EXTENSIONS__+#endif+/* Enable GNU extensions on systems that have them. */+#ifndef _GNU_SOURCE+# undef _GNU_SOURCE+#endif+/* Enable X/Open compliant socket functions that do not require linking+ with -lxnet on HP-UX 11.11. */+#ifndef _HPUX_ALT_XOPEN_SOCKET_API+# undef _HPUX_ALT_XOPEN_SOCKET_API+#endif+/* Identify the host operating system as Minix.+ This macro does not affect the system headers' behavior.+ A future release of Autoconf may stop defining this macro. */+#ifndef _MINIX+# undef _MINIX+#endif+/* Enable general extensions on NetBSD.+ Enable NetBSD compatibility extensions on Minix. */+#ifndef _NETBSD_SOURCE+# undef _NETBSD_SOURCE+#endif+/* Enable OpenBSD compatibility extensions on NetBSD.+ Oddly enough, this does nothing on OpenBSD. */+#ifndef _OPENBSD_SOURCE+# undef _OPENBSD_SOURCE+#endif+/* Define to 1 if needed for POSIX-compatible behavior. */+#ifndef _POSIX_SOURCE+# undef _POSIX_SOURCE+#endif+/* Define to 2 if needed for POSIX-compatible behavior. */+#ifndef _POSIX_1_SOURCE+# undef _POSIX_1_SOURCE+#endif+/* Enable POSIX-compatible threading on Solaris. */+#ifndef _POSIX_PTHREAD_SEMANTICS+# undef _POSIX_PTHREAD_SEMANTICS+#endif+/* Enable extensions specified by ISO/IEC TS 18661-5:2014. */+#ifndef __STDC_WANT_IEC_60559_ATTRIBS_EXT__+# undef __STDC_WANT_IEC_60559_ATTRIBS_EXT__+#endif+/* Enable extensions specified by ISO/IEC TS 18661-1:2014. */+#ifndef __STDC_WANT_IEC_60559_BFP_EXT__+# undef __STDC_WANT_IEC_60559_BFP_EXT__+#endif+/* Enable extensions specified by ISO/IEC TS 18661-2:2015. */+#ifndef __STDC_WANT_IEC_60559_DFP_EXT__+# undef __STDC_WANT_IEC_60559_DFP_EXT__+#endif+/* Enable extensions specified by ISO/IEC TS 18661-4:2015. */+#ifndef __STDC_WANT_IEC_60559_FUNCS_EXT__+# undef __STDC_WANT_IEC_60559_FUNCS_EXT__+#endif+/* Enable extensions specified by ISO/IEC TS 18661-3:2015. */+#ifndef __STDC_WANT_IEC_60559_TYPES_EXT__+# undef __STDC_WANT_IEC_60559_TYPES_EXT__+#endif+/* Enable extensions specified by ISO/IEC TR 24731-2:2010. */+#ifndef __STDC_WANT_LIB_EXT2__+# undef __STDC_WANT_LIB_EXT2__+#endif+/* Enable extensions specified by ISO/IEC 24747:2009. */+#ifndef __STDC_WANT_MATH_SPEC_FUNCS__+# undef __STDC_WANT_MATH_SPEC_FUNCS__+#endif+/* Enable extensions on HP NonStop. */+#ifndef _TANDEM_SOURCE+# undef _TANDEM_SOURCE+#endif+/* Enable X/Open extensions. Define to 500 only if necessary+ to make mbstate_t available. */+#ifndef _XOPEN_SOURCE+# undef _XOPEN_SOURCE+#endif+
+ test/ForeignCalls.hs view
@@ -0,0 +1,50 @@+module Main (main) where++import Control.Exception+import Control.Monad+import Data.Foldable+import Data.Monoid+import Data.Time+import Data.Time.Clock.POSIX+import Data.Time.Clock.System+import Data.Time.Clock.TAI+import Data.Traversable+import System.Exit+import System.IO++data Test = MkTest String (IO ())++tests :: [Test]+tests =+ [ MkTest "getCurrentTime" $ void $ getCurrentTime+ , MkTest "getZonedTime" $ void $ getZonedTime+ , MkTest "getCurrentTimeZone" $ void $ getCurrentTimeZone+ , MkTest "getTimeZone" $ void $ getCurrentTime >>= getTimeZone+ , MkTest "getPOSIXTime" $ void $ getPOSIXTime+ , MkTest "getSystemTime" $ void $ getSystemTime+ , MkTest "getTime_resolution" $ void $ evaluate getTime_resolution+ , MkTest "taiClock time" $ for_ taiClock $ \(_, getTime) -> void $ getTime+ , MkTest "taiClock resolution" $ for_ taiClock $ \(res, _) -> void $ evaluate res+ ]++runTest :: Test -> IO Bool+runTest (MkTest name action) = do+ hPutStr stderr $ name <> ": "+ result <- try action+ case result of+ Left err -> do+ hPutStrLn stderr $ "FAILED: " <> show (err :: SomeException)+ return False+ Right () -> do+ hPutStrLn stderr "PASSED"+ return True++main :: IO ()+main = do+ results <- for tests $ \test -> do+ passed <- runTest test+ return (Sum $ if passed then 1 else 0 :: Int, Sum 1)+ let+ (Sum i, Sum n) = mconcat results+ hPutStrLn stderr $ show i <> " out of " <> show n <> " tests passed"+ exitWith $ if i == n then ExitSuccess else ExitFailure 1
+ test/ShowDefaultTZAbbreviations.hs view
@@ -0,0 +1,14 @@+module Main where++import Data.Time++showTZ :: TimeZone -> String+showTZ tz =+ (formatTime defaultTimeLocale "%Z %z" tz)+ ++ ( if timeZoneSummerOnly tz+ then " DST"+ else ""+ )++main :: IO ()+main = mapM_ (\tz -> putStrLn (showTZ tz)) (knownTimeZones defaultTimeLocale)
+ test/ShowTime.hs view
@@ -0,0 +1,8 @@+module Main (main) where++import Data.Time++main :: IO ()+main = do+ now <- getZonedTime+ putStrLn $ show now
+ test/main/Main.hs view
@@ -0,0 +1,58 @@+module Main where++import Test.Calendar.AddDays+import Test.Calendar.CalendarProps+import Test.Calendar.Calendars+import Test.Calendar.ClipDates+import Test.Calendar.ConvertBack+import Test.Calendar.DayPeriod+import Test.Calendar.Duration+import Test.Calendar.Easter+import Test.Calendar.LongWeekYears+import Test.Calendar.MonthDay+import Test.Calendar.MonthOfYear+import Test.Calendar.Valid+import Test.Calendar.Week+import Test.Calendar.Year+import Test.Clock.Conversion+import Test.Clock.Pattern+import Test.Clock.Resolution+import Test.Clock.TAI+import Test.Format.Compile ()+import Test.Format.Format+import Test.Format.ISO8601+import Test.Format.ParseTime+import Test.LocalTime.CalendarDiffTime+import Test.LocalTime.Time+import Test.LocalTime.TimeOfDay+import Test.Tasty+import Test.Types ()++tests :: TestTree+tests =+ testGroup+ "Time"+ [ testGroup+ "Calendar"+ [ addDaysTest+ , testCalendarProps+ , testCalendars+ , clipDates+ , convertBack+ , longWeekYears+ , testDayPeriod+ , testMonthDay+ , testMonthOfYear+ , testEaster+ , testValid+ , testWeek+ , testYear+ , testDuration+ ]+ , testGroup "Clock" [testClockPatterns, testClockConversion, testResolutions, testTAI]+ , testGroup "Format" [testFormat, testParseTime, testISO8601]+ , testGroup "LocalTime" [testTime, testTimeOfDay, testCalendarDiffTime]+ ]++main :: IO ()+main = defaultMain tests
+ test/main/Test/AddDiff.hs view
@@ -0,0 +1,20 @@+module Test.AddDiff (+ AddDiff (..),+ testAddDiff,+) where++import Test.Arbitrary+import Test.Tasty+import Test.Tasty.QuickCheck hiding (reason)++data AddDiff duration time = MkAddDiff+ { adName :: String+ , adAdd :: duration -> time -> time+ , adDifference :: time -> time -> duration+ }++testAddDiff :: (Arbitrary (NoLeapSeconds time), Eq time, Show time) => AddDiff duration time -> TestTree+testAddDiff MkAddDiff{..} =+ testProperty adName $+ \(MkNoLeapSeconds time1) (MkNoLeapSeconds time2) ->+ adAdd (adDifference time2 time1) time1 == time2
+ test/main/Test/Arbitrary.hs view
@@ -0,0 +1,238 @@+{-# OPTIONS -fno-warn-orphans #-}++module Test.Arbitrary (+ supportedDayRange,+ NoLeapSeconds (..),+) where++import Control.Monad+import Data.Fixed+import Data.Ratio+import Data.Time+import Data.Time.Calendar.Month+import Data.Time.Calendar.Quarter+import Data.Time.Calendar.WeekDate+import Data.Time.Clock.POSIX+import System.Random+import Test.Tasty.QuickCheck hiding (reason)++instance Arbitrary DayOfWeek where+ arbitrary = fmap toEnum $ choose (1, 7)++instance Arbitrary FirstWeekType where+ arbitrary = do+ b <- arbitrary+ return $ if b then FirstWholeWeek else FirstMostWeek++deriving instance Show FirstWeekType++deriving instance Random Month++supportedMonthRange :: (Month, Month)+supportedMonthRange = (YearMonth (-9899) 1, YearMonth 9999 12)++shrinkYear :: Integer -> [Integer]+shrinkYear y =+ let+ yearShrink =+ if y > 2000+ then [pred y]+ else+ if y < 2000+ then [succ y]+ else []+ year10Shrink =+ if y > 2010+ then fmap (\i -> y - i) [1 .. 10]+ else+ if y < 1990+ then fmap (\i -> y + i) [1 .. 10]+ else []+ year100Shrink =+ if y > 2100+ then [y - 100]+ else+ if y < 1900+ then [y + 100]+ else []+ in+ year100Shrink <> year10Shrink <> yearShrink++instance Arbitrary Month where+ arbitrary = choose supportedMonthRange++instance Arbitrary Quarter where+ arbitrary = fmap monthQuarter arbitrary+ shrink (YearQuarter y qoy) =+ fmap (\y' -> YearQuarter y' qoy) (shrinkYear y)+ <> fmap (YearQuarter y) (shrink qoy)++instance Arbitrary QuarterOfYear where+ arbitrary = liftM toEnum $ choose (1, 4)+ shrink Q1 = []+ shrink _ = [Q1]++deriving instance Random Day++supportedDayRange :: (Day, Day)+supportedDayRange = (fromGregorian (-9899) 1 1, fromGregorian 9999 12 31)++instance Arbitrary Day where+ arbitrary = choose supportedDayRange+ shrink day =+ let+ (y, m, d) = toGregorian day+ dayShrink =+ if d > 1+ then [fromGregorian y m (d - 1)]+ else []+ monthShrink =+ if m > 1+ then [fromGregorian y (m - 1) d]+ else []+ in+ dayShrink <> monthShrink <> fmap (\y' -> fromGregorian y' m d) (shrinkYear y)++instance CoArbitrary Day where+ coarbitrary (ModifiedJulianDay d) = coarbitrary d++instance Arbitrary CalendarDiffDays where+ arbitrary = liftM2 CalendarDiffDays arbitrary arbitrary++newtype NoLeapSeconds a = MkNoLeapSeconds {unNoLeapSeconds :: a}+ deriving newtype (Eq, Ord, Show)++arbitraryNoLeapSeconds :: Arbitrary (NoLeapSeconds a) => Gen a+arbitraryNoLeapSeconds = fmap unNoLeapSeconds arbitrary++instance {-# OVERLAPPABLE #-} Arbitrary t => Arbitrary (NoLeapSeconds t) where+ arbitrary = fmap MkNoLeapSeconds arbitrary+ shrink (MkNoLeapSeconds t) = fmap MkNoLeapSeconds $ shrink t++instance Arbitrary DiffTime where+ arbitrary = oneof [intSecs, fracSecs] -- up to 1 leap second+ where+ intSecs = liftM secondsToDiffTime' $ choose (0, 86400)+ fracSecs = liftM picosecondsToDiffTime' $ choose (0, 86400 * 10 ^ (12 :: Int))+ secondsToDiffTime' :: Integer -> DiffTime+ secondsToDiffTime' = fromInteger+ picosecondsToDiffTime' :: Integer -> DiffTime+ picosecondsToDiffTime' x = fromRational (x % 10 ^ (12 :: Int))++instance CoArbitrary DiffTime where+ coarbitrary t = coarbitrary (fromEnum t)++instance Arbitrary (NoLeapSeconds DiffTime) where+ arbitrary = fmap MkNoLeapSeconds $ oneof [intSecs, fracSecs] -- no leap second+ where+ intSecs = liftM secondsToDiffTime' $ choose (0, 86399)+ fracSecs = liftM picosecondsToDiffTime' $ choose (0, 86399 * 10 ^ (12 :: Int))+ secondsToDiffTime' :: Integer -> DiffTime+ secondsToDiffTime' = fromInteger+ picosecondsToDiffTime' :: Integer -> DiffTime+ picosecondsToDiffTime' x = fromRational (x % 10 ^ (12 :: Int))+ shrink (MkNoLeapSeconds t) = fmap MkNoLeapSeconds $ shrink t++instance Arbitrary NominalDiffTime where+ arbitrary = oneof [intSecs, fracSecs]+ where+ limit = 1000 * 86400+ picofactor = 10 ^ (12 :: Int)+ intSecs = liftM secondsToDiffTime' $ choose (negate limit, limit)+ fracSecs = liftM picosecondsToDiffTime' $ choose (negate limit * picofactor, limit * picofactor)+ secondsToDiffTime' :: Integer -> NominalDiffTime+ secondsToDiffTime' = fromInteger+ picosecondsToDiffTime' :: Integer -> NominalDiffTime+ picosecondsToDiffTime' x = fromRational (x % 10 ^ (12 :: Int))++instance CoArbitrary NominalDiffTime where+ coarbitrary t = coarbitrary (fromEnum t)++instance Arbitrary CalendarDiffTime where+ arbitrary = liftM2 CalendarDiffTime arbitrary arbitrary++reduceDigits :: Int -> Pico -> Maybe Pico+reduceDigits (-1) _ = Nothing+reduceDigits n x =+ let+ d :: Pico+ d = 10 ^^ (negate n)+ r = mod' x d+ in+ case r of+ 0 -> reduceDigits (n - 1) x+ _ -> Just $ x - r++instance Arbitrary TimeOfDay where+ arbitrary = liftM timeToTimeOfDay arbitrary+ shrink (TimeOfDay h m s) =+ let+ shrinkInt 0 = []+ shrinkInt 1 = [0]+ shrinkInt _ = [0, 1]+ shrinkPico 0 = []+ shrinkPico 1 = [0]+ shrinkPico p = case reduceDigits 12 p of+ Just p' -> [0, 1, p']+ Nothing -> [0, 1]+ in+ [TimeOfDay h' m s | h' <- shrinkInt h]+ ++ [TimeOfDay h m' s | m' <- shrinkInt m]+ ++ [TimeOfDay h m s' | s' <- shrinkPico s]++instance Arbitrary (NoLeapSeconds TimeOfDay) where+ arbitrary = fmap (MkNoLeapSeconds . timeToTimeOfDay) arbitraryNoLeapSeconds+ shrink (MkNoLeapSeconds t) = fmap MkNoLeapSeconds $ shrink t++instance CoArbitrary TimeOfDay where+ coarbitrary t = coarbitrary (timeOfDayToTime t)++instance Arbitrary LocalTime where+ arbitrary = liftM2 LocalTime arbitrary arbitrary+ shrink (LocalTime d tod) = [LocalTime d' tod | d' <- shrink d] ++ [LocalTime d tod' | tod' <- shrink tod]++instance CoArbitrary LocalTime where+ coarbitrary t = coarbitrary (floor (utcTimeToPOSIXSeconds (localTimeToUTC utc t)) :: Integer)++instance Arbitrary (NoLeapSeconds LocalTime) where+ arbitrary = fmap MkNoLeapSeconds $ liftM2 LocalTime arbitraryNoLeapSeconds arbitraryNoLeapSeconds+ shrink (MkNoLeapSeconds t) = fmap MkNoLeapSeconds $ shrink t++instance Arbitrary TimeZone where+ arbitrary = liftM minutesToTimeZone $ choose (-720, 720)+ shrink (TimeZone 0 _ _) = []+ shrink (TimeZone _ s n) = [TimeZone 0 s n]++instance CoArbitrary TimeZone where+ coarbitrary tz = coarbitrary (timeZoneMinutes tz)++instance Arbitrary ZonedTime where+ arbitrary = liftM2 ZonedTime arbitrary arbitrary+ shrink (ZonedTime d tz) = [ZonedTime d' tz | d' <- shrink d] ++ [ZonedTime d tz' | tz' <- shrink tz]++instance CoArbitrary ZonedTime where+ coarbitrary t = coarbitrary (floor (utcTimeToPOSIXSeconds (zonedTimeToUTC t)) :: Integer)++instance Arbitrary (NoLeapSeconds ZonedTime) where+ arbitrary = fmap MkNoLeapSeconds $ liftM2 ZonedTime arbitraryNoLeapSeconds arbitraryNoLeapSeconds+ shrink (MkNoLeapSeconds t) = fmap MkNoLeapSeconds $ shrink t++instance Arbitrary UTCTime where+ arbitrary = liftM2 UTCTime arbitrary arbitrary+ shrink t = fmap (localTimeToUTC utc) $ shrink $ utcToLocalTime utc t++instance CoArbitrary UTCTime where+ coarbitrary t = coarbitrary (floor (utcTimeToPOSIXSeconds t) :: Integer)++instance Arbitrary (NoLeapSeconds UTCTime) where+ arbitrary = fmap MkNoLeapSeconds $ liftM2 UTCTime arbitraryNoLeapSeconds arbitraryNoLeapSeconds+ shrink (MkNoLeapSeconds t) = fmap MkNoLeapSeconds $ shrink t++instance Arbitrary UniversalTime where+ arbitrary = liftM (\n -> ModJulianDate $ n % k) $ choose (-313698 * k, 2973483 * k) -- 1000-01-1 to 9999-12-31+ where+ k = 86400+ shrink t = fmap (localTimeToUT1 0) $ shrink $ ut1ToLocalTime 0 t++instance CoArbitrary UniversalTime where+ coarbitrary (ModJulianDate d) = coarbitrary d
+ test/main/Test/Calendar/AddDays.hs view
@@ -0,0 +1,49 @@+module Test.Calendar.AddDays (+ addDaysTest,+) where++import Data.Time.Calendar+import Test.Calendar.AddDaysRef+import Test.Tasty+import Test.Tasty.HUnit++days :: [Day]+days =+ [ fromGregorian 2005 2 28+ , fromGregorian 2004 2 29+ , fromGregorian 2004 1 31+ , fromGregorian 2004 12 31+ , fromGregorian 2005 7 1+ , fromGregorian 2005 4 21+ , fromGregorian 2005 6 30+ ]++increments :: [Integer]+increments = [-10, -4, -1, 0, 1, 7, 83]++adders :: [(String, Integer -> Day -> Day)]+adders =+ [ ("day", addDays)+ , ("month (clip)", addGregorianMonthsClip)+ , ("month (roll over)", addGregorianMonthsRollOver)+ , ("year (clip)", addGregorianYearsClip)+ , ("year (roll over)", addGregorianYearsRollOver)+ ]++resultDays :: [String]+resultDays = do+ (aname, adder) <- adders+ increment <- increments+ day <- days+ return+ ( (showGregorian day)+ ++ " + "+ ++ (show increment)+ ++ " * "+ ++ aname+ ++ " = "+ ++ showGregorian (adder increment day)+ )++addDaysTest :: TestTree+addDaysTest = testCase "addDays" $ assertEqual "" addDaysRef $ unlines resultDays
+ test/main/Test/Calendar/AddDaysRef.hs view
@@ -0,0 +1,251 @@+module Test.Calendar.AddDaysRef where++addDaysRef :: String+addDaysRef =+ unlines+ [ "2005-02-28 + -10 * day = 2005-02-18"+ , "2004-02-29 + -10 * day = 2004-02-19"+ , "2004-01-31 + -10 * day = 2004-01-21"+ , "2004-12-31 + -10 * day = 2004-12-21"+ , "2005-07-01 + -10 * day = 2005-06-21"+ , "2005-04-21 + -10 * day = 2005-04-11"+ , "2005-06-30 + -10 * day = 2005-06-20"+ , "2005-02-28 + -4 * day = 2005-02-24"+ , "2004-02-29 + -4 * day = 2004-02-25"+ , "2004-01-31 + -4 * day = 2004-01-27"+ , "2004-12-31 + -4 * day = 2004-12-27"+ , "2005-07-01 + -4 * day = 2005-06-27"+ , "2005-04-21 + -4 * day = 2005-04-17"+ , "2005-06-30 + -4 * day = 2005-06-26"+ , "2005-02-28 + -1 * day = 2005-02-27"+ , "2004-02-29 + -1 * day = 2004-02-28"+ , "2004-01-31 + -1 * day = 2004-01-30"+ , "2004-12-31 + -1 * day = 2004-12-30"+ , "2005-07-01 + -1 * day = 2005-06-30"+ , "2005-04-21 + -1 * day = 2005-04-20"+ , "2005-06-30 + -1 * day = 2005-06-29"+ , "2005-02-28 + 0 * day = 2005-02-28"+ , "2004-02-29 + 0 * day = 2004-02-29"+ , "2004-01-31 + 0 * day = 2004-01-31"+ , "2004-12-31 + 0 * day = 2004-12-31"+ , "2005-07-01 + 0 * day = 2005-07-01"+ , "2005-04-21 + 0 * day = 2005-04-21"+ , "2005-06-30 + 0 * day = 2005-06-30"+ , "2005-02-28 + 1 * day = 2005-03-01"+ , "2004-02-29 + 1 * day = 2004-03-01"+ , "2004-01-31 + 1 * day = 2004-02-01"+ , "2004-12-31 + 1 * day = 2005-01-01"+ , "2005-07-01 + 1 * day = 2005-07-02"+ , "2005-04-21 + 1 * day = 2005-04-22"+ , "2005-06-30 + 1 * day = 2005-07-01"+ , "2005-02-28 + 7 * day = 2005-03-07"+ , "2004-02-29 + 7 * day = 2004-03-07"+ , "2004-01-31 + 7 * day = 2004-02-07"+ , "2004-12-31 + 7 * day = 2005-01-07"+ , "2005-07-01 + 7 * day = 2005-07-08"+ , "2005-04-21 + 7 * day = 2005-04-28"+ , "2005-06-30 + 7 * day = 2005-07-07"+ , "2005-02-28 + 83 * day = 2005-05-22"+ , "2004-02-29 + 83 * day = 2004-05-22"+ , "2004-01-31 + 83 * day = 2004-04-23"+ , "2004-12-31 + 83 * day = 2005-03-24"+ , "2005-07-01 + 83 * day = 2005-09-22"+ , "2005-04-21 + 83 * day = 2005-07-13"+ , "2005-06-30 + 83 * day = 2005-09-21"+ , "2005-02-28 + -10 * month (clip) = 2004-04-28"+ , "2004-02-29 + -10 * month (clip) = 2003-04-29"+ , "2004-01-31 + -10 * month (clip) = 2003-03-31"+ , "2004-12-31 + -10 * month (clip) = 2004-02-29"+ , "2005-07-01 + -10 * month (clip) = 2004-09-01"+ , "2005-04-21 + -10 * month (clip) = 2004-06-21"+ , "2005-06-30 + -10 * month (clip) = 2004-08-30"+ , "2005-02-28 + -4 * month (clip) = 2004-10-28"+ , "2004-02-29 + -4 * month (clip) = 2003-10-29"+ , "2004-01-31 + -4 * month (clip) = 2003-09-30"+ , "2004-12-31 + -4 * month (clip) = 2004-08-31"+ , "2005-07-01 + -4 * month (clip) = 2005-03-01"+ , "2005-04-21 + -4 * month (clip) = 2004-12-21"+ , "2005-06-30 + -4 * month (clip) = 2005-02-28"+ , "2005-02-28 + -1 * month (clip) = 2005-01-28"+ , "2004-02-29 + -1 * month (clip) = 2004-01-29"+ , "2004-01-31 + -1 * month (clip) = 2003-12-31"+ , "2004-12-31 + -1 * month (clip) = 2004-11-30"+ , "2005-07-01 + -1 * month (clip) = 2005-06-01"+ , "2005-04-21 + -1 * month (clip) = 2005-03-21"+ , "2005-06-30 + -1 * month (clip) = 2005-05-30"+ , "2005-02-28 + 0 * month (clip) = 2005-02-28"+ , "2004-02-29 + 0 * month (clip) = 2004-02-29"+ , "2004-01-31 + 0 * month (clip) = 2004-01-31"+ , "2004-12-31 + 0 * month (clip) = 2004-12-31"+ , "2005-07-01 + 0 * month (clip) = 2005-07-01"+ , "2005-04-21 + 0 * month (clip) = 2005-04-21"+ , "2005-06-30 + 0 * month (clip) = 2005-06-30"+ , "2005-02-28 + 1 * month (clip) = 2005-03-28"+ , "2004-02-29 + 1 * month (clip) = 2004-03-29"+ , "2004-01-31 + 1 * month (clip) = 2004-02-29"+ , "2004-12-31 + 1 * month (clip) = 2005-01-31"+ , "2005-07-01 + 1 * month (clip) = 2005-08-01"+ , "2005-04-21 + 1 * month (clip) = 2005-05-21"+ , "2005-06-30 + 1 * month (clip) = 2005-07-30"+ , "2005-02-28 + 7 * month (clip) = 2005-09-28"+ , "2004-02-29 + 7 * month (clip) = 2004-09-29"+ , "2004-01-31 + 7 * month (clip) = 2004-08-31"+ , "2004-12-31 + 7 * month (clip) = 2005-07-31"+ , "2005-07-01 + 7 * month (clip) = 2006-02-01"+ , "2005-04-21 + 7 * month (clip) = 2005-11-21"+ , "2005-06-30 + 7 * month (clip) = 2006-01-30"+ , "2005-02-28 + 83 * month (clip) = 2012-01-28"+ , "2004-02-29 + 83 * month (clip) = 2011-01-29"+ , "2004-01-31 + 83 * month (clip) = 2010-12-31"+ , "2004-12-31 + 83 * month (clip) = 2011-11-30"+ , "2005-07-01 + 83 * month (clip) = 2012-06-01"+ , "2005-04-21 + 83 * month (clip) = 2012-03-21"+ , "2005-06-30 + 83 * month (clip) = 2012-05-30"+ , "2005-02-28 + -10 * month (roll over) = 2004-04-28"+ , "2004-02-29 + -10 * month (roll over) = 2003-04-29"+ , "2004-01-31 + -10 * month (roll over) = 2003-03-31"+ , "2004-12-31 + -10 * month (roll over) = 2004-03-02"+ , "2005-07-01 + -10 * month (roll over) = 2004-09-01"+ , "2005-04-21 + -10 * month (roll over) = 2004-06-21"+ , "2005-06-30 + -10 * month (roll over) = 2004-08-30"+ , "2005-02-28 + -4 * month (roll over) = 2004-10-28"+ , "2004-02-29 + -4 * month (roll over) = 2003-10-29"+ , "2004-01-31 + -4 * month (roll over) = 2003-10-01"+ , "2004-12-31 + -4 * month (roll over) = 2004-08-31"+ , "2005-07-01 + -4 * month (roll over) = 2005-03-01"+ , "2005-04-21 + -4 * month (roll over) = 2004-12-21"+ , "2005-06-30 + -4 * month (roll over) = 2005-03-02"+ , "2005-02-28 + -1 * month (roll over) = 2005-01-28"+ , "2004-02-29 + -1 * month (roll over) = 2004-01-29"+ , "2004-01-31 + -1 * month (roll over) = 2003-12-31"+ , "2004-12-31 + -1 * month (roll over) = 2004-12-01"+ , "2005-07-01 + -1 * month (roll over) = 2005-06-01"+ , "2005-04-21 + -1 * month (roll over) = 2005-03-21"+ , "2005-06-30 + -1 * month (roll over) = 2005-05-30"+ , "2005-02-28 + 0 * month (roll over) = 2005-02-28"+ , "2004-02-29 + 0 * month (roll over) = 2004-02-29"+ , "2004-01-31 + 0 * month (roll over) = 2004-01-31"+ , "2004-12-31 + 0 * month (roll over) = 2004-12-31"+ , "2005-07-01 + 0 * month (roll over) = 2005-07-01"+ , "2005-04-21 + 0 * month (roll over) = 2005-04-21"+ , "2005-06-30 + 0 * month (roll over) = 2005-06-30"+ , "2005-02-28 + 1 * month (roll over) = 2005-03-28"+ , "2004-02-29 + 1 * month (roll over) = 2004-03-29"+ , "2004-01-31 + 1 * month (roll over) = 2004-03-02"+ , "2004-12-31 + 1 * month (roll over) = 2005-01-31"+ , "2005-07-01 + 1 * month (roll over) = 2005-08-01"+ , "2005-04-21 + 1 * month (roll over) = 2005-05-21"+ , "2005-06-30 + 1 * month (roll over) = 2005-07-30"+ , "2005-02-28 + 7 * month (roll over) = 2005-09-28"+ , "2004-02-29 + 7 * month (roll over) = 2004-09-29"+ , "2004-01-31 + 7 * month (roll over) = 2004-08-31"+ , "2004-12-31 + 7 * month (roll over) = 2005-07-31"+ , "2005-07-01 + 7 * month (roll over) = 2006-02-01"+ , "2005-04-21 + 7 * month (roll over) = 2005-11-21"+ , "2005-06-30 + 7 * month (roll over) = 2006-01-30"+ , "2005-02-28 + 83 * month (roll over) = 2012-01-28"+ , "2004-02-29 + 83 * month (roll over) = 2011-01-29"+ , "2004-01-31 + 83 * month (roll over) = 2010-12-31"+ , "2004-12-31 + 83 * month (roll over) = 2011-12-01"+ , "2005-07-01 + 83 * month (roll over) = 2012-06-01"+ , "2005-04-21 + 83 * month (roll over) = 2012-03-21"+ , "2005-06-30 + 83 * month (roll over) = 2012-05-30"+ , "2005-02-28 + -10 * year (clip) = 1995-02-28"+ , "2004-02-29 + -10 * year (clip) = 1994-02-28"+ , "2004-01-31 + -10 * year (clip) = 1994-01-31"+ , "2004-12-31 + -10 * year (clip) = 1994-12-31"+ , "2005-07-01 + -10 * year (clip) = 1995-07-01"+ , "2005-04-21 + -10 * year (clip) = 1995-04-21"+ , "2005-06-30 + -10 * year (clip) = 1995-06-30"+ , "2005-02-28 + -4 * year (clip) = 2001-02-28"+ , "2004-02-29 + -4 * year (clip) = 2000-02-29"+ , "2004-01-31 + -4 * year (clip) = 2000-01-31"+ , "2004-12-31 + -4 * year (clip) = 2000-12-31"+ , "2005-07-01 + -4 * year (clip) = 2001-07-01"+ , "2005-04-21 + -4 * year (clip) = 2001-04-21"+ , "2005-06-30 + -4 * year (clip) = 2001-06-30"+ , "2005-02-28 + -1 * year (clip) = 2004-02-28"+ , "2004-02-29 + -1 * year (clip) = 2003-02-28"+ , "2004-01-31 + -1 * year (clip) = 2003-01-31"+ , "2004-12-31 + -1 * year (clip) = 2003-12-31"+ , "2005-07-01 + -1 * year (clip) = 2004-07-01"+ , "2005-04-21 + -1 * year (clip) = 2004-04-21"+ , "2005-06-30 + -1 * year (clip) = 2004-06-30"+ , "2005-02-28 + 0 * year (clip) = 2005-02-28"+ , "2004-02-29 + 0 * year (clip) = 2004-02-29"+ , "2004-01-31 + 0 * year (clip) = 2004-01-31"+ , "2004-12-31 + 0 * year (clip) = 2004-12-31"+ , "2005-07-01 + 0 * year (clip) = 2005-07-01"+ , "2005-04-21 + 0 * year (clip) = 2005-04-21"+ , "2005-06-30 + 0 * year (clip) = 2005-06-30"+ , "2005-02-28 + 1 * year (clip) = 2006-02-28"+ , "2004-02-29 + 1 * year (clip) = 2005-02-28"+ , "2004-01-31 + 1 * year (clip) = 2005-01-31"+ , "2004-12-31 + 1 * year (clip) = 2005-12-31"+ , "2005-07-01 + 1 * year (clip) = 2006-07-01"+ , "2005-04-21 + 1 * year (clip) = 2006-04-21"+ , "2005-06-30 + 1 * year (clip) = 2006-06-30"+ , "2005-02-28 + 7 * year (clip) = 2012-02-28"+ , "2004-02-29 + 7 * year (clip) = 2011-02-28"+ , "2004-01-31 + 7 * year (clip) = 2011-01-31"+ , "2004-12-31 + 7 * year (clip) = 2011-12-31"+ , "2005-07-01 + 7 * year (clip) = 2012-07-01"+ , "2005-04-21 + 7 * year (clip) = 2012-04-21"+ , "2005-06-30 + 7 * year (clip) = 2012-06-30"+ , "2005-02-28 + 83 * year (clip) = 2088-02-28"+ , "2004-02-29 + 83 * year (clip) = 2087-02-28"+ , "2004-01-31 + 83 * year (clip) = 2087-01-31"+ , "2004-12-31 + 83 * year (clip) = 2087-12-31"+ , "2005-07-01 + 83 * year (clip) = 2088-07-01"+ , "2005-04-21 + 83 * year (clip) = 2088-04-21"+ , "2005-06-30 + 83 * year (clip) = 2088-06-30"+ , "2005-02-28 + -10 * year (roll over) = 1995-02-28"+ , "2004-02-29 + -10 * year (roll over) = 1994-03-01"+ , "2004-01-31 + -10 * year (roll over) = 1994-01-31"+ , "2004-12-31 + -10 * year (roll over) = 1994-12-31"+ , "2005-07-01 + -10 * year (roll over) = 1995-07-01"+ , "2005-04-21 + -10 * year (roll over) = 1995-04-21"+ , "2005-06-30 + -10 * year (roll over) = 1995-06-30"+ , "2005-02-28 + -4 * year (roll over) = 2001-02-28"+ , "2004-02-29 + -4 * year (roll over) = 2000-02-29"+ , "2004-01-31 + -4 * year (roll over) = 2000-01-31"+ , "2004-12-31 + -4 * year (roll over) = 2000-12-31"+ , "2005-07-01 + -4 * year (roll over) = 2001-07-01"+ , "2005-04-21 + -4 * year (roll over) = 2001-04-21"+ , "2005-06-30 + -4 * year (roll over) = 2001-06-30"+ , "2005-02-28 + -1 * year (roll over) = 2004-02-28"+ , "2004-02-29 + -1 * year (roll over) = 2003-03-01"+ , "2004-01-31 + -1 * year (roll over) = 2003-01-31"+ , "2004-12-31 + -1 * year (roll over) = 2003-12-31"+ , "2005-07-01 + -1 * year (roll over) = 2004-07-01"+ , "2005-04-21 + -1 * year (roll over) = 2004-04-21"+ , "2005-06-30 + -1 * year (roll over) = 2004-06-30"+ , "2005-02-28 + 0 * year (roll over) = 2005-02-28"+ , "2004-02-29 + 0 * year (roll over) = 2004-02-29"+ , "2004-01-31 + 0 * year (roll over) = 2004-01-31"+ , "2004-12-31 + 0 * year (roll over) = 2004-12-31"+ , "2005-07-01 + 0 * year (roll over) = 2005-07-01"+ , "2005-04-21 + 0 * year (roll over) = 2005-04-21"+ , "2005-06-30 + 0 * year (roll over) = 2005-06-30"+ , "2005-02-28 + 1 * year (roll over) = 2006-02-28"+ , "2004-02-29 + 1 * year (roll over) = 2005-03-01"+ , "2004-01-31 + 1 * year (roll over) = 2005-01-31"+ , "2004-12-31 + 1 * year (roll over) = 2005-12-31"+ , "2005-07-01 + 1 * year (roll over) = 2006-07-01"+ , "2005-04-21 + 1 * year (roll over) = 2006-04-21"+ , "2005-06-30 + 1 * year (roll over) = 2006-06-30"+ , "2005-02-28 + 7 * year (roll over) = 2012-02-28"+ , "2004-02-29 + 7 * year (roll over) = 2011-03-01"+ , "2004-01-31 + 7 * year (roll over) = 2011-01-31"+ , "2004-12-31 + 7 * year (roll over) = 2011-12-31"+ , "2005-07-01 + 7 * year (roll over) = 2012-07-01"+ , "2005-04-21 + 7 * year (roll over) = 2012-04-21"+ , "2005-06-30 + 7 * year (roll over) = 2012-06-30"+ , "2005-02-28 + 83 * year (roll over) = 2088-02-28"+ , "2004-02-29 + 83 * year (roll over) = 2087-03-01"+ , "2004-01-31 + 83 * year (roll over) = 2087-01-31"+ , "2004-12-31 + 83 * year (roll over) = 2087-12-31"+ , "2005-07-01 + 83 * year (roll over) = 2088-07-01"+ , "2005-04-21 + 83 * year (roll over) = 2088-04-21"+ , "2005-06-30 + 83 * year (roll over) = 2088-06-30"+ ]
+ test/main/Test/Calendar/CalendarProps.hs view
@@ -0,0 +1,24 @@+module Test.Calendar.CalendarProps (+ testCalendarProps,+) where++import Data.Time.Calendar.Month+import Data.Time.Calendar.Quarter+import Test.Arbitrary ()+import Test.Tasty+import Test.TestUtil++testYearMonth :: TestTree+testYearMonth = nameTest "YearMonth" $ \m -> case m of+ YearMonth y my -> m == YearMonth y my++testMonthDay :: TestTree+testMonthDay = nameTest "MonthDay" $ \d -> case d of+ MonthDay m dm -> d == MonthDay m dm++testYearQuarter :: TestTree+testYearQuarter = nameTest "YearQuarter" $ \q -> case q of+ YearQuarter y qy -> q == YearQuarter y qy++testCalendarProps :: TestTree+testCalendarProps = nameTest "calendar-props" [testYearMonth, testMonthDay, testYearQuarter]
+ test/main/Test/Calendar/Calendars.hs view
@@ -0,0 +1,26 @@+module Test.Calendar.Calendars (+ testCalendars,+) where++import Data.Time.Calendar+import Data.Time.Calendar.Julian+import Data.Time.Calendar.WeekDate+import Test.Calendar.CalendarsRef+import Test.Tasty+import Test.Tasty.HUnit++showers :: [(String, Day -> String)]+showers =+ [ ("MJD", show . toModifiedJulianDay)+ , ("Gregorian", showGregorian)+ , ("Julian", showJulian)+ , ("ISO 8601", showWeekDate)+ ]++days :: [Day]+days = [fromGregorian 0 12 31, fromJulian 1752 9 2, fromGregorian 1752 9 14, fromGregorian 2005 1 23]++testCalendars :: TestTree+testCalendars = testCase "testCalendars" $ assertEqual "" testCalendarsRef $ unlines $ map (\d -> showShowers d) days+ where+ showShowers day = concatMap (\(nm, shower) -> unwords [" ==", nm, shower day]) showers
+ test/main/Test/Calendar/CalendarsRef.hs view
@@ -0,0 +1,10 @@+module Test.Calendar.CalendarsRef where++testCalendarsRef :: String+testCalendarsRef =+ unlines+ [ " == MJD -678576 == Gregorian 0000-12-31 == Julian 0001-01-02 == ISO 8601 0000-W52-7"+ , " == MJD -38780 == Gregorian 1752-09-13 == Julian 1752-09-02 == ISO 8601 1752-W37-3"+ , " == MJD -38779 == Gregorian 1752-09-14 == Julian 1752-09-03 == ISO 8601 1752-W37-4"+ , " == MJD 53393 == Gregorian 2005-01-23 == Julian 2005-01-10 == ISO 8601 2005-W03-7"+ ]
+ test/main/Test/Calendar/ClipDates.hs view
@@ -0,0 +1,47 @@+module Test.Calendar.ClipDates (+ clipDates,+) where++import Data.Time.Calendar+import Data.Time.Calendar.OrdinalDate+import Data.Time.Calendar.WeekDate+import Test.Calendar.ClipDatesRef+import Test.Tasty+import Test.Tasty.HUnit++yearAndDay :: (Integer, Int) -> String+yearAndDay (y, d) = (show y) ++ "-" ++ (show d) ++ " = " ++ (showOrdinalDate (fromOrdinalDate y d))++gregorian :: (Integer, Int, Int) -> String+gregorian (y, m, d) = (show y) ++ "-" ++ (show m) ++ "-" ++ (show d) ++ " = " ++ (showGregorian (fromGregorian y m d))++iSOWeekDay :: (Integer, Int, Int) -> String+iSOWeekDay (y, w, d) = (show y) ++ "-W" ++ (show w) ++ "-" ++ (show d) ++ " = " ++ (showWeekDate (fromWeekDate y w d))++--+tupleUp2 :: [a] -> [b] -> [(a, b)]+tupleUp2 l1 l2 = concatMap (\e -> map (e,) l2) l1++tupleUp3 :: [a] -> [b] -> [c] -> [(a, b, c)]+tupleUp3 l1 l2 l3 =+ let+ ts = tupleUp2 l2 l3+ in+ concatMap (\e -> map (\(f, g) -> (e, f, g)) ts) l1++testPairs :: String -> [String] -> [String] -> TestTree+testPairs name expected found = testGroup name $ fmap (\(e, f) -> testCase e $ assertEqual "" e f) $ zip expected found++--+clipDates :: TestTree+clipDates =+ testGroup+ "clipDates"+ [ testPairs "YearAndDay" clipDatesYearAndDayRef $ map yearAndDay $ tupleUp2 [1968, 1969, 1971] [-4, 0, 1, 200, 364, 365, 366, 367, 700]+ , testPairs "Gregorian" clipDatesGregorianDayRef $+ map gregorian $+ tupleUp3 [1968, 1969, 1971] [-20, -1, 0, 1, 2, 12, 13, 17] [-7, -1, 0, 1, 2, 27, 28, 29, 30, 31, 32, 40]+ , testPairs "ISOWeekDay" clipDatesISOWeekDayRef $+ map iSOWeekDay $+ tupleUp3 [1968, 1969, 2004] [-20, -1, 0, 1, 20, 51, 52, 53, 54] [-2, -1, 0, 1, 4, 6, 7, 8, 9]+ ]
+ test/main/Test/Calendar/ClipDatesRef.hs view
@@ -0,0 +1,571 @@+module Test.Calendar.ClipDatesRef where++clipDatesYearAndDayRef :: [String]+clipDatesYearAndDayRef =+ [ "1968--4 = 1968-001"+ , "1968-0 = 1968-001"+ , "1968-1 = 1968-001"+ , "1968-200 = 1968-200"+ , "1968-364 = 1968-364"+ , "1968-365 = 1968-365"+ , "1968-366 = 1968-366"+ , "1968-367 = 1968-366"+ , "1968-700 = 1968-366"+ , "1969--4 = 1969-001"+ , "1969-0 = 1969-001"+ , "1969-1 = 1969-001"+ , "1969-200 = 1969-200"+ , "1969-364 = 1969-364"+ , "1969-365 = 1969-365"+ , "1969-366 = 1969-365"+ , "1969-367 = 1969-365"+ , "1969-700 = 1969-365"+ , "1971--4 = 1971-001"+ , "1971-0 = 1971-001"+ , "1971-1 = 1971-001"+ , "1971-200 = 1971-200"+ , "1971-364 = 1971-364"+ , "1971-365 = 1971-365"+ , "1971-366 = 1971-365"+ , "1971-367 = 1971-365"+ , "1971-700 = 1971-365"+ ]++clipDatesGregorianDayRef :: [String]+clipDatesGregorianDayRef =+ [ "1968--20--7 = 1968-01-01"+ , "1968--20--1 = 1968-01-01"+ , "1968--20-0 = 1968-01-01"+ , "1968--20-1 = 1968-01-01"+ , "1968--20-2 = 1968-01-02"+ , "1968--20-27 = 1968-01-27"+ , "1968--20-28 = 1968-01-28"+ , "1968--20-29 = 1968-01-29"+ , "1968--20-30 = 1968-01-30"+ , "1968--20-31 = 1968-01-31"+ , "1968--20-32 = 1968-01-31"+ , "1968--20-40 = 1968-01-31"+ , "1968--1--7 = 1968-01-01"+ , "1968--1--1 = 1968-01-01"+ , "1968--1-0 = 1968-01-01"+ , "1968--1-1 = 1968-01-01"+ , "1968--1-2 = 1968-01-02"+ , "1968--1-27 = 1968-01-27"+ , "1968--1-28 = 1968-01-28"+ , "1968--1-29 = 1968-01-29"+ , "1968--1-30 = 1968-01-30"+ , "1968--1-31 = 1968-01-31"+ , "1968--1-32 = 1968-01-31"+ , "1968--1-40 = 1968-01-31"+ , "1968-0--7 = 1968-01-01"+ , "1968-0--1 = 1968-01-01"+ , "1968-0-0 = 1968-01-01"+ , "1968-0-1 = 1968-01-01"+ , "1968-0-2 = 1968-01-02"+ , "1968-0-27 = 1968-01-27"+ , "1968-0-28 = 1968-01-28"+ , "1968-0-29 = 1968-01-29"+ , "1968-0-30 = 1968-01-30"+ , "1968-0-31 = 1968-01-31"+ , "1968-0-32 = 1968-01-31"+ , "1968-0-40 = 1968-01-31"+ , "1968-1--7 = 1968-01-01"+ , "1968-1--1 = 1968-01-01"+ , "1968-1-0 = 1968-01-01"+ , "1968-1-1 = 1968-01-01"+ , "1968-1-2 = 1968-01-02"+ , "1968-1-27 = 1968-01-27"+ , "1968-1-28 = 1968-01-28"+ , "1968-1-29 = 1968-01-29"+ , "1968-1-30 = 1968-01-30"+ , "1968-1-31 = 1968-01-31"+ , "1968-1-32 = 1968-01-31"+ , "1968-1-40 = 1968-01-31"+ , "1968-2--7 = 1968-02-01"+ , "1968-2--1 = 1968-02-01"+ , "1968-2-0 = 1968-02-01"+ , "1968-2-1 = 1968-02-01"+ , "1968-2-2 = 1968-02-02"+ , "1968-2-27 = 1968-02-27"+ , "1968-2-28 = 1968-02-28"+ , "1968-2-29 = 1968-02-29"+ , "1968-2-30 = 1968-02-29"+ , "1968-2-31 = 1968-02-29"+ , "1968-2-32 = 1968-02-29"+ , "1968-2-40 = 1968-02-29"+ , "1968-12--7 = 1968-12-01"+ , "1968-12--1 = 1968-12-01"+ , "1968-12-0 = 1968-12-01"+ , "1968-12-1 = 1968-12-01"+ , "1968-12-2 = 1968-12-02"+ , "1968-12-27 = 1968-12-27"+ , "1968-12-28 = 1968-12-28"+ , "1968-12-29 = 1968-12-29"+ , "1968-12-30 = 1968-12-30"+ , "1968-12-31 = 1968-12-31"+ , "1968-12-32 = 1968-12-31"+ , "1968-12-40 = 1968-12-31"+ , "1968-13--7 = 1968-12-01"+ , "1968-13--1 = 1968-12-01"+ , "1968-13-0 = 1968-12-01"+ , "1968-13-1 = 1968-12-01"+ , "1968-13-2 = 1968-12-02"+ , "1968-13-27 = 1968-12-27"+ , "1968-13-28 = 1968-12-28"+ , "1968-13-29 = 1968-12-29"+ , "1968-13-30 = 1968-12-30"+ , "1968-13-31 = 1968-12-31"+ , "1968-13-32 = 1968-12-31"+ , "1968-13-40 = 1968-12-31"+ , "1968-17--7 = 1968-12-01"+ , "1968-17--1 = 1968-12-01"+ , "1968-17-0 = 1968-12-01"+ , "1968-17-1 = 1968-12-01"+ , "1968-17-2 = 1968-12-02"+ , "1968-17-27 = 1968-12-27"+ , "1968-17-28 = 1968-12-28"+ , "1968-17-29 = 1968-12-29"+ , "1968-17-30 = 1968-12-30"+ , "1968-17-31 = 1968-12-31"+ , "1968-17-32 = 1968-12-31"+ , "1968-17-40 = 1968-12-31"+ , "1969--20--7 = 1969-01-01"+ , "1969--20--1 = 1969-01-01"+ , "1969--20-0 = 1969-01-01"+ , "1969--20-1 = 1969-01-01"+ , "1969--20-2 = 1969-01-02"+ , "1969--20-27 = 1969-01-27"+ , "1969--20-28 = 1969-01-28"+ , "1969--20-29 = 1969-01-29"+ , "1969--20-30 = 1969-01-30"+ , "1969--20-31 = 1969-01-31"+ , "1969--20-32 = 1969-01-31"+ , "1969--20-40 = 1969-01-31"+ , "1969--1--7 = 1969-01-01"+ , "1969--1--1 = 1969-01-01"+ , "1969--1-0 = 1969-01-01"+ , "1969--1-1 = 1969-01-01"+ , "1969--1-2 = 1969-01-02"+ , "1969--1-27 = 1969-01-27"+ , "1969--1-28 = 1969-01-28"+ , "1969--1-29 = 1969-01-29"+ , "1969--1-30 = 1969-01-30"+ , "1969--1-31 = 1969-01-31"+ , "1969--1-32 = 1969-01-31"+ , "1969--1-40 = 1969-01-31"+ , "1969-0--7 = 1969-01-01"+ , "1969-0--1 = 1969-01-01"+ , "1969-0-0 = 1969-01-01"+ , "1969-0-1 = 1969-01-01"+ , "1969-0-2 = 1969-01-02"+ , "1969-0-27 = 1969-01-27"+ , "1969-0-28 = 1969-01-28"+ , "1969-0-29 = 1969-01-29"+ , "1969-0-30 = 1969-01-30"+ , "1969-0-31 = 1969-01-31"+ , "1969-0-32 = 1969-01-31"+ , "1969-0-40 = 1969-01-31"+ , "1969-1--7 = 1969-01-01"+ , "1969-1--1 = 1969-01-01"+ , "1969-1-0 = 1969-01-01"+ , "1969-1-1 = 1969-01-01"+ , "1969-1-2 = 1969-01-02"+ , "1969-1-27 = 1969-01-27"+ , "1969-1-28 = 1969-01-28"+ , "1969-1-29 = 1969-01-29"+ , "1969-1-30 = 1969-01-30"+ , "1969-1-31 = 1969-01-31"+ , "1969-1-32 = 1969-01-31"+ , "1969-1-40 = 1969-01-31"+ , "1969-2--7 = 1969-02-01"+ , "1969-2--1 = 1969-02-01"+ , "1969-2-0 = 1969-02-01"+ , "1969-2-1 = 1969-02-01"+ , "1969-2-2 = 1969-02-02"+ , "1969-2-27 = 1969-02-27"+ , "1969-2-28 = 1969-02-28"+ , "1969-2-29 = 1969-02-28"+ , "1969-2-30 = 1969-02-28"+ , "1969-2-31 = 1969-02-28"+ , "1969-2-32 = 1969-02-28"+ , "1969-2-40 = 1969-02-28"+ , "1969-12--7 = 1969-12-01"+ , "1969-12--1 = 1969-12-01"+ , "1969-12-0 = 1969-12-01"+ , "1969-12-1 = 1969-12-01"+ , "1969-12-2 = 1969-12-02"+ , "1969-12-27 = 1969-12-27"+ , "1969-12-28 = 1969-12-28"+ , "1969-12-29 = 1969-12-29"+ , "1969-12-30 = 1969-12-30"+ , "1969-12-31 = 1969-12-31"+ , "1969-12-32 = 1969-12-31"+ , "1969-12-40 = 1969-12-31"+ , "1969-13--7 = 1969-12-01"+ , "1969-13--1 = 1969-12-01"+ , "1969-13-0 = 1969-12-01"+ , "1969-13-1 = 1969-12-01"+ , "1969-13-2 = 1969-12-02"+ , "1969-13-27 = 1969-12-27"+ , "1969-13-28 = 1969-12-28"+ , "1969-13-29 = 1969-12-29"+ , "1969-13-30 = 1969-12-30"+ , "1969-13-31 = 1969-12-31"+ , "1969-13-32 = 1969-12-31"+ , "1969-13-40 = 1969-12-31"+ , "1969-17--7 = 1969-12-01"+ , "1969-17--1 = 1969-12-01"+ , "1969-17-0 = 1969-12-01"+ , "1969-17-1 = 1969-12-01"+ , "1969-17-2 = 1969-12-02"+ , "1969-17-27 = 1969-12-27"+ , "1969-17-28 = 1969-12-28"+ , "1969-17-29 = 1969-12-29"+ , "1969-17-30 = 1969-12-30"+ , "1969-17-31 = 1969-12-31"+ , "1969-17-32 = 1969-12-31"+ , "1969-17-40 = 1969-12-31"+ , "1971--20--7 = 1971-01-01"+ , "1971--20--1 = 1971-01-01"+ , "1971--20-0 = 1971-01-01"+ , "1971--20-1 = 1971-01-01"+ , "1971--20-2 = 1971-01-02"+ , "1971--20-27 = 1971-01-27"+ , "1971--20-28 = 1971-01-28"+ , "1971--20-29 = 1971-01-29"+ , "1971--20-30 = 1971-01-30"+ , "1971--20-31 = 1971-01-31"+ , "1971--20-32 = 1971-01-31"+ , "1971--20-40 = 1971-01-31"+ , "1971--1--7 = 1971-01-01"+ , "1971--1--1 = 1971-01-01"+ , "1971--1-0 = 1971-01-01"+ , "1971--1-1 = 1971-01-01"+ , "1971--1-2 = 1971-01-02"+ , "1971--1-27 = 1971-01-27"+ , "1971--1-28 = 1971-01-28"+ , "1971--1-29 = 1971-01-29"+ , "1971--1-30 = 1971-01-30"+ , "1971--1-31 = 1971-01-31"+ , "1971--1-32 = 1971-01-31"+ , "1971--1-40 = 1971-01-31"+ , "1971-0--7 = 1971-01-01"+ , "1971-0--1 = 1971-01-01"+ , "1971-0-0 = 1971-01-01"+ , "1971-0-1 = 1971-01-01"+ , "1971-0-2 = 1971-01-02"+ , "1971-0-27 = 1971-01-27"+ , "1971-0-28 = 1971-01-28"+ , "1971-0-29 = 1971-01-29"+ , "1971-0-30 = 1971-01-30"+ , "1971-0-31 = 1971-01-31"+ , "1971-0-32 = 1971-01-31"+ , "1971-0-40 = 1971-01-31"+ , "1971-1--7 = 1971-01-01"+ , "1971-1--1 = 1971-01-01"+ , "1971-1-0 = 1971-01-01"+ , "1971-1-1 = 1971-01-01"+ , "1971-1-2 = 1971-01-02"+ , "1971-1-27 = 1971-01-27"+ , "1971-1-28 = 1971-01-28"+ , "1971-1-29 = 1971-01-29"+ , "1971-1-30 = 1971-01-30"+ , "1971-1-31 = 1971-01-31"+ , "1971-1-32 = 1971-01-31"+ , "1971-1-40 = 1971-01-31"+ , "1971-2--7 = 1971-02-01"+ , "1971-2--1 = 1971-02-01"+ , "1971-2-0 = 1971-02-01"+ , "1971-2-1 = 1971-02-01"+ , "1971-2-2 = 1971-02-02"+ , "1971-2-27 = 1971-02-27"+ , "1971-2-28 = 1971-02-28"+ , "1971-2-29 = 1971-02-28"+ , "1971-2-30 = 1971-02-28"+ , "1971-2-31 = 1971-02-28"+ , "1971-2-32 = 1971-02-28"+ , "1971-2-40 = 1971-02-28"+ , "1971-12--7 = 1971-12-01"+ , "1971-12--1 = 1971-12-01"+ , "1971-12-0 = 1971-12-01"+ , "1971-12-1 = 1971-12-01"+ , "1971-12-2 = 1971-12-02"+ , "1971-12-27 = 1971-12-27"+ , "1971-12-28 = 1971-12-28"+ , "1971-12-29 = 1971-12-29"+ , "1971-12-30 = 1971-12-30"+ , "1971-12-31 = 1971-12-31"+ , "1971-12-32 = 1971-12-31"+ , "1971-12-40 = 1971-12-31"+ , "1971-13--7 = 1971-12-01"+ , "1971-13--1 = 1971-12-01"+ , "1971-13-0 = 1971-12-01"+ , "1971-13-1 = 1971-12-01"+ , "1971-13-2 = 1971-12-02"+ , "1971-13-27 = 1971-12-27"+ , "1971-13-28 = 1971-12-28"+ , "1971-13-29 = 1971-12-29"+ , "1971-13-30 = 1971-12-30"+ , "1971-13-31 = 1971-12-31"+ , "1971-13-32 = 1971-12-31"+ , "1971-13-40 = 1971-12-31"+ , "1971-17--7 = 1971-12-01"+ , "1971-17--1 = 1971-12-01"+ , "1971-17-0 = 1971-12-01"+ , "1971-17-1 = 1971-12-01"+ , "1971-17-2 = 1971-12-02"+ , "1971-17-27 = 1971-12-27"+ , "1971-17-28 = 1971-12-28"+ , "1971-17-29 = 1971-12-29"+ , "1971-17-30 = 1971-12-30"+ , "1971-17-31 = 1971-12-31"+ , "1971-17-32 = 1971-12-31"+ , "1971-17-40 = 1971-12-31"+ ]++clipDatesISOWeekDayRef :: [String]+clipDatesISOWeekDayRef =+ [ "1968-W-20--2 = 1968-W01-1"+ , "1968-W-20--1 = 1968-W01-1"+ , "1968-W-20-0 = 1968-W01-1"+ , "1968-W-20-1 = 1968-W01-1"+ , "1968-W-20-4 = 1968-W01-4"+ , "1968-W-20-6 = 1968-W01-6"+ , "1968-W-20-7 = 1968-W01-7"+ , "1968-W-20-8 = 1968-W01-7"+ , "1968-W-20-9 = 1968-W01-7"+ , "1968-W-1--2 = 1968-W01-1"+ , "1968-W-1--1 = 1968-W01-1"+ , "1968-W-1-0 = 1968-W01-1"+ , "1968-W-1-1 = 1968-W01-1"+ , "1968-W-1-4 = 1968-W01-4"+ , "1968-W-1-6 = 1968-W01-6"+ , "1968-W-1-7 = 1968-W01-7"+ , "1968-W-1-8 = 1968-W01-7"+ , "1968-W-1-9 = 1968-W01-7"+ , "1968-W0--2 = 1968-W01-1"+ , "1968-W0--1 = 1968-W01-1"+ , "1968-W0-0 = 1968-W01-1"+ , "1968-W0-1 = 1968-W01-1"+ , "1968-W0-4 = 1968-W01-4"+ , "1968-W0-6 = 1968-W01-6"+ , "1968-W0-7 = 1968-W01-7"+ , "1968-W0-8 = 1968-W01-7"+ , "1968-W0-9 = 1968-W01-7"+ , "1968-W1--2 = 1968-W01-1"+ , "1968-W1--1 = 1968-W01-1"+ , "1968-W1-0 = 1968-W01-1"+ , "1968-W1-1 = 1968-W01-1"+ , "1968-W1-4 = 1968-W01-4"+ , "1968-W1-6 = 1968-W01-6"+ , "1968-W1-7 = 1968-W01-7"+ , "1968-W1-8 = 1968-W01-7"+ , "1968-W1-9 = 1968-W01-7"+ , "1968-W20--2 = 1968-W20-1"+ , "1968-W20--1 = 1968-W20-1"+ , "1968-W20-0 = 1968-W20-1"+ , "1968-W20-1 = 1968-W20-1"+ , "1968-W20-4 = 1968-W20-4"+ , "1968-W20-6 = 1968-W20-6"+ , "1968-W20-7 = 1968-W20-7"+ , "1968-W20-8 = 1968-W20-7"+ , "1968-W20-9 = 1968-W20-7"+ , "1968-W51--2 = 1968-W51-1"+ , "1968-W51--1 = 1968-W51-1"+ , "1968-W51-0 = 1968-W51-1"+ , "1968-W51-1 = 1968-W51-1"+ , "1968-W51-4 = 1968-W51-4"+ , "1968-W51-6 = 1968-W51-6"+ , "1968-W51-7 = 1968-W51-7"+ , "1968-W51-8 = 1968-W51-7"+ , "1968-W51-9 = 1968-W51-7"+ , "1968-W52--2 = 1968-W52-1"+ , "1968-W52--1 = 1968-W52-1"+ , "1968-W52-0 = 1968-W52-1"+ , "1968-W52-1 = 1968-W52-1"+ , "1968-W52-4 = 1968-W52-4"+ , "1968-W52-6 = 1968-W52-6"+ , "1968-W52-7 = 1968-W52-7"+ , "1968-W52-8 = 1968-W52-7"+ , "1968-W52-9 = 1968-W52-7"+ , "1968-W53--2 = 1968-W52-1"+ , "1968-W53--1 = 1968-W52-1"+ , "1968-W53-0 = 1968-W52-1"+ , "1968-W53-1 = 1968-W52-1"+ , "1968-W53-4 = 1968-W52-4"+ , "1968-W53-6 = 1968-W52-6"+ , "1968-W53-7 = 1968-W52-7"+ , "1968-W53-8 = 1968-W52-7"+ , "1968-W53-9 = 1968-W52-7"+ , "1968-W54--2 = 1968-W52-1"+ , "1968-W54--1 = 1968-W52-1"+ , "1968-W54-0 = 1968-W52-1"+ , "1968-W54-1 = 1968-W52-1"+ , "1968-W54-4 = 1968-W52-4"+ , "1968-W54-6 = 1968-W52-6"+ , "1968-W54-7 = 1968-W52-7"+ , "1968-W54-8 = 1968-W52-7"+ , "1968-W54-9 = 1968-W52-7"+ , "1969-W-20--2 = 1969-W01-1"+ , "1969-W-20--1 = 1969-W01-1"+ , "1969-W-20-0 = 1969-W01-1"+ , "1969-W-20-1 = 1969-W01-1"+ , "1969-W-20-4 = 1969-W01-4"+ , "1969-W-20-6 = 1969-W01-6"+ , "1969-W-20-7 = 1969-W01-7"+ , "1969-W-20-8 = 1969-W01-7"+ , "1969-W-20-9 = 1969-W01-7"+ , "1969-W-1--2 = 1969-W01-1"+ , "1969-W-1--1 = 1969-W01-1"+ , "1969-W-1-0 = 1969-W01-1"+ , "1969-W-1-1 = 1969-W01-1"+ , "1969-W-1-4 = 1969-W01-4"+ , "1969-W-1-6 = 1969-W01-6"+ , "1969-W-1-7 = 1969-W01-7"+ , "1969-W-1-8 = 1969-W01-7"+ , "1969-W-1-9 = 1969-W01-7"+ , "1969-W0--2 = 1969-W01-1"+ , "1969-W0--1 = 1969-W01-1"+ , "1969-W0-0 = 1969-W01-1"+ , "1969-W0-1 = 1969-W01-1"+ , "1969-W0-4 = 1969-W01-4"+ , "1969-W0-6 = 1969-W01-6"+ , "1969-W0-7 = 1969-W01-7"+ , "1969-W0-8 = 1969-W01-7"+ , "1969-W0-9 = 1969-W01-7"+ , "1969-W1--2 = 1969-W01-1"+ , "1969-W1--1 = 1969-W01-1"+ , "1969-W1-0 = 1969-W01-1"+ , "1969-W1-1 = 1969-W01-1"+ , "1969-W1-4 = 1969-W01-4"+ , "1969-W1-6 = 1969-W01-6"+ , "1969-W1-7 = 1969-W01-7"+ , "1969-W1-8 = 1969-W01-7"+ , "1969-W1-9 = 1969-W01-7"+ , "1969-W20--2 = 1969-W20-1"+ , "1969-W20--1 = 1969-W20-1"+ , "1969-W20-0 = 1969-W20-1"+ , "1969-W20-1 = 1969-W20-1"+ , "1969-W20-4 = 1969-W20-4"+ , "1969-W20-6 = 1969-W20-6"+ , "1969-W20-7 = 1969-W20-7"+ , "1969-W20-8 = 1969-W20-7"+ , "1969-W20-9 = 1969-W20-7"+ , "1969-W51--2 = 1969-W51-1"+ , "1969-W51--1 = 1969-W51-1"+ , "1969-W51-0 = 1969-W51-1"+ , "1969-W51-1 = 1969-W51-1"+ , "1969-W51-4 = 1969-W51-4"+ , "1969-W51-6 = 1969-W51-6"+ , "1969-W51-7 = 1969-W51-7"+ , "1969-W51-8 = 1969-W51-7"+ , "1969-W51-9 = 1969-W51-7"+ , "1969-W52--2 = 1969-W52-1"+ , "1969-W52--1 = 1969-W52-1"+ , "1969-W52-0 = 1969-W52-1"+ , "1969-W52-1 = 1969-W52-1"+ , "1969-W52-4 = 1969-W52-4"+ , "1969-W52-6 = 1969-W52-6"+ , "1969-W52-7 = 1969-W52-7"+ , "1969-W52-8 = 1969-W52-7"+ , "1969-W52-9 = 1969-W52-7"+ , "1969-W53--2 = 1969-W52-1"+ , "1969-W53--1 = 1969-W52-1"+ , "1969-W53-0 = 1969-W52-1"+ , "1969-W53-1 = 1969-W52-1"+ , "1969-W53-4 = 1969-W52-4"+ , "1969-W53-6 = 1969-W52-6"+ , "1969-W53-7 = 1969-W52-7"+ , "1969-W53-8 = 1969-W52-7"+ , "1969-W53-9 = 1969-W52-7"+ , "1969-W54--2 = 1969-W52-1"+ , "1969-W54--1 = 1969-W52-1"+ , "1969-W54-0 = 1969-W52-1"+ , "1969-W54-1 = 1969-W52-1"+ , "1969-W54-4 = 1969-W52-4"+ , "1969-W54-6 = 1969-W52-6"+ , "1969-W54-7 = 1969-W52-7"+ , "1969-W54-8 = 1969-W52-7"+ , "1969-W54-9 = 1969-W52-7"+ , "2004-W-20--2 = 2004-W01-1"+ , "2004-W-20--1 = 2004-W01-1"+ , "2004-W-20-0 = 2004-W01-1"+ , "2004-W-20-1 = 2004-W01-1"+ , "2004-W-20-4 = 2004-W01-4"+ , "2004-W-20-6 = 2004-W01-6"+ , "2004-W-20-7 = 2004-W01-7"+ , "2004-W-20-8 = 2004-W01-7"+ , "2004-W-20-9 = 2004-W01-7"+ , "2004-W-1--2 = 2004-W01-1"+ , "2004-W-1--1 = 2004-W01-1"+ , "2004-W-1-0 = 2004-W01-1"+ , "2004-W-1-1 = 2004-W01-1"+ , "2004-W-1-4 = 2004-W01-4"+ , "2004-W-1-6 = 2004-W01-6"+ , "2004-W-1-7 = 2004-W01-7"+ , "2004-W-1-8 = 2004-W01-7"+ , "2004-W-1-9 = 2004-W01-7"+ , "2004-W0--2 = 2004-W01-1"+ , "2004-W0--1 = 2004-W01-1"+ , "2004-W0-0 = 2004-W01-1"+ , "2004-W0-1 = 2004-W01-1"+ , "2004-W0-4 = 2004-W01-4"+ , "2004-W0-6 = 2004-W01-6"+ , "2004-W0-7 = 2004-W01-7"+ , "2004-W0-8 = 2004-W01-7"+ , "2004-W0-9 = 2004-W01-7"+ , "2004-W1--2 = 2004-W01-1"+ , "2004-W1--1 = 2004-W01-1"+ , "2004-W1-0 = 2004-W01-1"+ , "2004-W1-1 = 2004-W01-1"+ , "2004-W1-4 = 2004-W01-4"+ , "2004-W1-6 = 2004-W01-6"+ , "2004-W1-7 = 2004-W01-7"+ , "2004-W1-8 = 2004-W01-7"+ , "2004-W1-9 = 2004-W01-7"+ , "2004-W20--2 = 2004-W20-1"+ , "2004-W20--1 = 2004-W20-1"+ , "2004-W20-0 = 2004-W20-1"+ , "2004-W20-1 = 2004-W20-1"+ , "2004-W20-4 = 2004-W20-4"+ , "2004-W20-6 = 2004-W20-6"+ , "2004-W20-7 = 2004-W20-7"+ , "2004-W20-8 = 2004-W20-7"+ , "2004-W20-9 = 2004-W20-7"+ , "2004-W51--2 = 2004-W51-1"+ , "2004-W51--1 = 2004-W51-1"+ , "2004-W51-0 = 2004-W51-1"+ , "2004-W51-1 = 2004-W51-1"+ , "2004-W51-4 = 2004-W51-4"+ , "2004-W51-6 = 2004-W51-6"+ , "2004-W51-7 = 2004-W51-7"+ , "2004-W51-8 = 2004-W51-7"+ , "2004-W51-9 = 2004-W51-7"+ , "2004-W52--2 = 2004-W52-1"+ , "2004-W52--1 = 2004-W52-1"+ , "2004-W52-0 = 2004-W52-1"+ , "2004-W52-1 = 2004-W52-1"+ , "2004-W52-4 = 2004-W52-4"+ , "2004-W52-6 = 2004-W52-6"+ , "2004-W52-7 = 2004-W52-7"+ , "2004-W52-8 = 2004-W52-7"+ , "2004-W52-9 = 2004-W52-7"+ , "2004-W53--2 = 2004-W53-1"+ , "2004-W53--1 = 2004-W53-1"+ , "2004-W53-0 = 2004-W53-1"+ , "2004-W53-1 = 2004-W53-1"+ , "2004-W53-4 = 2004-W53-4"+ , "2004-W53-6 = 2004-W53-6"+ , "2004-W53-7 = 2004-W53-7"+ , "2004-W53-8 = 2004-W53-7"+ , "2004-W53-9 = 2004-W53-7"+ , "2004-W54--2 = 2004-W53-1"+ , "2004-W54--1 = 2004-W53-1"+ , "2004-W54-0 = 2004-W53-1"+ , "2004-W54-1 = 2004-W53-1"+ , "2004-W54-4 = 2004-W53-4"+ , "2004-W54-6 = 2004-W53-6"+ , "2004-W54-7 = 2004-W53-7"+ , "2004-W54-8 = 2004-W53-7"+ , "2004-W54-9 = 2004-W53-7"+ ]
+ test/main/Test/Calendar/ConvertBack.hs view
@@ -0,0 +1,41 @@+module Test.Calendar.ConvertBack (+ convertBack,+) where++import Data.Time.Calendar+import Data.Time.Calendar.Julian+import Data.Time.Calendar.OrdinalDate+import Data.Time.Calendar.WeekDate+import Test.Tasty+import Test.Tasty.HUnit++checkDay :: Show t => (Day -> t) -> (t -> Day) -> (t -> Maybe Day) -> Day -> String+checkDay encodeDay decodeDay decodeDayValid day =+ let+ st = encodeDay day+ day' = decodeDay st+ mday' = decodeDayValid st+ a =+ if day /= day'+ then unwords [show day, "-> ", show st, "-> ", show day', "(diff", show (diffDays day' day) ++ ")"]+ else ""+ b =+ if Just day /= mday'+ then unwords [show day, "->", show st, "->", show mday']+ else ""+ in+ a ++ b++checkers :: [Day -> String]+checkers =+ [ checkDay toOrdinalDate (\(y, d) -> fromOrdinalDate y d) (\(y, d) -> fromOrdinalDateValid y d)+ , checkDay toWeekDate (\(y, w, d) -> fromWeekDate y w d) (\(y, w, d) -> fromWeekDateValid y w d)+ , checkDay toGregorian (\(y, m, d) -> fromGregorian y m d) (\(y, m, d) -> fromGregorianValid y m d)+ , checkDay toJulian (\(y, m, d) -> fromJulian y m d) (\(y, m, d) -> fromJulianValid y m d)+ ]++days :: [Day]+days = [ModifiedJulianDay 50000 .. ModifiedJulianDay 50200] ++ (fmap (\year -> (fromGregorian year 1 4)) [1980 .. 2000])++convertBack :: TestTree+convertBack = testCase "convertBack" $ assertEqual "" "" $ concatMap (\ch -> concatMap ch days) checkers
+ test/main/Test/Calendar/DayPeriod.hs view
@@ -0,0 +1,181 @@+module Test.Calendar.DayPeriod (+ testDayPeriod,+) where++import Data.Time.Calendar+import Data.Time.Calendar.Month+import Data.Time.Calendar.Quarter+import Test.Arbitrary ()+import Test.Tasty+import Test.Tasty.HUnit+import Test.Tasty.QuickCheck++newtype WDay = MkWDay Day+ deriving (Eq, Show)++instance Arbitrary WDay where+ arbitrary = do+ (MkWYear y) <- arbitrary+ (MkWMonthOfYear m) <- arbitrary+ (MkWDayOfMonth d) <- arbitrary+ pure $ MkWDay $ YearMonthDay y m d++newtype WYear = MkWYear Year+ deriving (Eq, Show)++instance Arbitrary WYear where+ arbitrary = fmap MkWYear $ choose (-1000, 3000)++newtype WMonthOfYear = MkWMonthOfYear MonthOfYear+ deriving (Eq, Show)++instance Arbitrary WMonthOfYear where+ arbitrary = fmap MkWMonthOfYear $ choose (-5, 17)++newtype WMonth = MkWMonth Month+ deriving (Eq, Show)++instance Arbitrary WMonth where+ arbitrary = do+ (MkWYear y) <- arbitrary+ (MkWMonthOfYear m) <- arbitrary+ pure $ MkWMonth $ YearMonth y m++newtype WDayOfMonth = MkWDayOfMonth DayOfMonth+ deriving (Eq, Show)++instance Arbitrary WDayOfMonth where+ arbitrary = fmap MkWDayOfMonth $ choose (-5, 35)++newtype WQuarterOfYear = MkWQuarterOfYear QuarterOfYear+ deriving (Eq, Show)++instance Arbitrary WQuarterOfYear where+ arbitrary = fmap MkWQuarterOfYear $ elements [Q1 .. Q4]++newtype WQuarter = MkWQuarter Quarter+ deriving (Eq, Show)++instance Arbitrary WQuarter where+ arbitrary = do+ (MkWYear y) <- arbitrary+ (MkWQuarterOfYear q) <- arbitrary+ pure $ MkWQuarter $ YearQuarter y q++testDayPeriod :: TestTree+testDayPeriod =+ testGroup+ "DayPeriod"+ [ testGroup "Day" testDay+ , testGroup "Month" testMonth+ , testGroup "Quarter" testQuarter+ , testGroup "Year" testYear+ , testGroup "Week" testWeek+ ]++testDay :: [TestTree]+testDay =+ [ testProperty "periodFirstDay" $ \(MkWDay d) ->+ periodFirstDay d == d+ , testProperty "periodLastDay" $ \(MkWDay d) ->+ periodLastDay d == d+ , testProperty "dayPeriod" $ \(MkWDay d) ->+ dayPeriod d == d+ , testProperty "periodAllDays" $ \(MkWDay d) ->+ periodAllDays d == [d]+ , testProperty "periodLength" $ \(MkWDay d) ->+ periodLength d == 1+ ]++testMonth :: [TestTree]+testMonth =+ [ testProperty "periodFirstDay" $ \(MkWMonth my@(YearMonth y m)) ->+ periodFirstDay my == YearMonthDay y m 1+ , testGroup+ "periodLastDay"+ [ testCase "leap year" $+ periodLastDay (YearMonth 2024 February) @?= YearMonthDay 2024 February 29+ , testCase "regular year" $+ periodLastDay (YearMonth 2023 February) @?= YearMonthDay 2023 February 28+ ]+ , testProperty "dayPeriod" $ \(MkWMonth my@(YearMonth y m), MkWDayOfMonth d) ->+ dayPeriod (YearMonthDay y m d) == my+ , testProperty "periodAllDays" $ \(MkWMonth my@(YearMonth y1 m1)) ->+ all (== (y1, m1)) $ map (\(YearMonthDay y2 m2 _) -> (y2, m2)) $ periodAllDays my+ , testGroup+ "periodLength"+ [ testProperty "property tests" $ \(MkWMonth my) ->+ periodLength my >= 28+ , testCase "leap year" $+ periodLength (YearMonth 2024 February) @?= 29+ , testCase "regular year" $+ periodLength (YearMonth 2023 February) @?= 28+ ]+ ]++testQuarter :: [TestTree]+testQuarter =+ [ testGroup+ "periodFirstDay"+ [ testProperty "Q1" $ \(MkWYear y) ->+ periodFirstDay (YearQuarter y Q1) == YearMonthDay y January 1+ , testProperty "Q2" $ \(MkWYear y) ->+ periodFirstDay (YearQuarter y Q2) == YearMonthDay y April 1+ , testProperty "Q3" $ \(MkWYear y) ->+ periodFirstDay (YearQuarter y Q3) == YearMonthDay y July 1+ , testProperty "Q4" $ \(MkWYear y) ->+ periodFirstDay (YearQuarter y Q4) == YearMonthDay y October 1+ ]+ , testGroup+ "periodLastDay"+ [ testProperty "Q1" $ \(MkWYear y) ->+ periodLastDay (YearQuarter y Q1) == YearMonthDay y March 31+ , testProperty "Q2" $ \(MkWYear y) ->+ periodLastDay (YearQuarter y Q2) == YearMonthDay y June 30+ , testProperty "Q3" $ \(MkWYear y) ->+ periodLastDay (YearQuarter y Q3) == YearMonthDay y September 30+ , testProperty "Q4" $ \(MkWYear y) ->+ periodLastDay (YearQuarter y Q4) == YearMonthDay y December 31+ ]+ , testProperty "dayPeriod" $ \(MkWMonth my@(YearMonth y m), MkWDayOfMonth d) ->+ dayPeriod (YearMonthDay y m d) == monthQuarter my+ , testProperty "periodAllDays" $ \(MkWQuarter q) ->+ all (== q) $ map dayQuarter $ periodAllDays q+ , testProperty "periodLength" $ \(MkWQuarter q) ->+ periodLength q >= 90+ ]++testYear :: [TestTree]+testYear =+ [ testProperty "periodFirstDay" $ \(MkWYear y) ->+ periodFirstDay y == YearMonthDay y January 1+ , testProperty "periodLastDay" $ \(MkWYear y) ->+ periodLastDay y == YearMonthDay y December 31+ , testProperty "dayPeriod" $ \(MkWYear y, MkWMonthOfYear m, MkWDayOfMonth d) ->+ dayPeriod (YearMonthDay y m d) == y+ , testProperty "periodAllDays" $ \(MkWYear y1) ->+ all (== y1) $ map (\(YearMonthDay y2 _ _) -> y2) $ periodAllDays y1+ , testProperty "periodLength" $ \(MkWYear y) ->+ periodLength y >= 365+ ]++testWeek :: [TestTree]+testWeek =+ [ testProperty "weekFirstDay/weekLastDay range" $ \dw (MkWDay d) ->+ let+ f = weekFirstDay dw d+ l = weekLastDay dw d+ in+ f <= d && d <= l+ , testProperty "weekFirstDay/weekLastDay range" $ \dw (MkWDay d) ->+ let+ f = weekFirstDay dw d+ l = weekLastDay dw d+ in+ addDays 6 f == l+ , testProperty "weekFirstDay dayOfWeek" $ \dw (MkWDay d) ->+ let+ f = weekFirstDay dw d+ in+ dayOfWeek f == dw+ ]
+ test/main/Test/Calendar/Duration.hs view
@@ -0,0 +1,106 @@+module Test.Calendar.Duration (+ testDuration,+) where++import Data.Time.Calendar+import Data.Time.Calendar.Julian+import Test.AddDiff+import Test.Arbitrary ()+import Test.Tasty+import Test.Tasty.HUnit+import Test.Tasty.QuickCheck hiding (reason)++type CalendarAddDiff = (AddDiff CalendarDiffDays Day, Integer -> Int -> Int -> Day)++gregorianClip :: CalendarAddDiff+gregorianClip = (MkAddDiff "gregorianClip" addGregorianDurationClip diffGregorianDurationClip, fromGregorian)++gregorianRollOver :: CalendarAddDiff+gregorianRollOver = (MkAddDiff "gregorianRollOver" addGregorianDurationRollOver diffGregorianDurationRollOver, fromGregorian)++julianClip :: CalendarAddDiff+julianClip = (MkAddDiff "julianClip" addJulianDurationClip diffJulianDurationClip, fromJulian)++julianRollOver :: CalendarAddDiff+julianRollOver = (MkAddDiff "julianRollOver" addJulianDurationRollOver diffJulianDurationRollOver, fromJulian)++addDiffs :: [CalendarAddDiff]+addDiffs =+ [ gregorianClip+ , gregorianRollOver+ , julianClip+ , julianRollOver+ ]++testAddDiffs :: TestTree+testAddDiffs =+ testGroup+ "add-diff"+ $ fmap (testAddDiff . fst) addDiffs++newtype Smallish = MkSmallish Integer deriving (Eq, Ord)++deriving newtype instance Show Smallish++instance Arbitrary Smallish where+ arbitrary = do+ b <- arbitrary+ n <- if b then choose (0, 60) else return 30+ return $ MkSmallish n++testPositiveDiff :: CalendarAddDiff -> TestTree+testPositiveDiff (MkAddDiff{..}, _) = testProperty adName $ \day1 (MkSmallish i) ->+ let+ day2 = addDays i day1+ r = adDifference day2 day1+ in+ property $ cdMonths r >= 0 && cdDays r >= 0++testPositiveDiffs :: TestTree+testPositiveDiffs =+ testGroup+ "positive-diff"+ $ fmap testPositiveDiff addDiffs++testSpecific :: CalendarAddDiff -> (Integer, Int, Int) -> (Integer, Int, Int) -> (Integer, Integer) -> TestTree+testSpecific (MkAddDiff{..}, fromYMD) (y2, m2, d2) (y1, m1, d1) (em, ed) =+ let+ day1 = fromYMD y1 m1 d1+ day2 = fromYMD y2 m2 d2+ expected = CalendarDiffDays em ed+ found = adDifference day2 day1+ in+ testCase (adName ++ ": " ++ show day2 ++ " - " ++ show day1) $ do+ assertEqual "add" day2 $ adAdd found day1+ assertEqual "diff" expected found++testSpecificPair :: (Integer, Int, Int) -> (Integer, Int, Int) -> (Integer, Integer) -> (Integer, Integer) -> TestTree+testSpecificPair day2 day1 clipD rollD =+ testGroup+ (show day2 ++ " - " ++ show day1)+ [ testSpecific gregorianClip day2 day1 clipD+ , testSpecific gregorianRollOver day2 day1 rollD+ , testSpecific julianClip day2 day1 clipD+ , testSpecific julianRollOver day2 day1 rollD+ ]++testSpecifics :: TestTree+testSpecifics =+ testGroup+ "specific"+ [ testSpecificPair (2017, 04, 07) (2017, 04, 07) (0, 0) (0, 0)+ , testSpecific gregorianClip (2017, 04, 07) (2017, 04, 01) (0, 6)+ , testSpecific gregorianClip (2017, 04, 01) (2017, 04, 07) (0, -6)+ , testSpecific gregorianClip (2017, 04, 07) (2017, 02, 01) (2, 6)+ , testSpecific gregorianClip (2017, 02, 01) (2017, 04, 07) (-2, -6)+ , testSpecificPair (2000, 03, 01) (2000, 01, 30) (1, 1) (1, 0)+ , testSpecificPair (2001, 03, 01) (2001, 01, 30) (1, 1) (0, 30)+ , testSpecificPair (2001, 03, 01) (2000, 01, 30) (13, 1) (12, 30)+ , testSpecificPair (2000, 03, 01) (2000, 01, 31) (1, 1) (0, 30)+ , testSpecificPair (2001, 03, 01) (2001, 01, 31) (1, 1) (0, 29)+ , testSpecificPair (2001, 03, 01) (2000, 01, 31) (13, 1) (12, 29)+ , testSpecificPair (2001, 10, 01) (2001, 08, 31) (1, 1) (1, 0)+ ]++testDuration :: TestTree+testDuration = testGroup "CalendarDiffDays" [testAddDiffs, testPositiveDiffs, testSpecifics]
+ test/main/Test/Calendar/Easter.hs view
@@ -0,0 +1,39 @@+module Test.Calendar.Easter (+ testEaster,+) where++import Data.Time.Calendar+import Data.Time.Calendar.Easter+import Data.Time.Format+import Test.Calendar.EasterRef+import Test.Tasty+import Test.Tasty.HUnit++--+days :: [Day]+days = [ModifiedJulianDay 53000 .. ModifiedJulianDay 53014]++showWithWDay :: Day -> String+showWithWDay = formatTime defaultTimeLocale "%F %A"++testEaster :: TestTree+testEaster =+ testCase "testEaster" $+ let+ ds = unlines $ map (\day -> unwords [showWithWDay day, "->", showWithWDay (sundayAfter day)]) days+ f y =+ unwords+ [ show y ++ ", Gregorian: moon,"+ , show (gregorianPaschalMoon y) ++ ": Easter,"+ , showWithWDay (gregorianEaster y)+ ]+ ++ "\n"+ g y =+ unwords+ [ show y ++ ", Orthodox : moon,"+ , show (orthodoxPaschalMoon y) ++ ": Easter,"+ , showWithWDay (orthodoxEaster y)+ ]+ ++ "\n"+ in+ assertEqual "" testEasterRef $ ds ++ concatMap (\y -> f y ++ g y) [2000 .. 2020]
+ test/main/Test/Calendar/EasterRef.hs view
@@ -0,0 +1,63 @@+module Test.Calendar.EasterRef where++testEasterRef :: String+testEasterRef =+ unlines+ [ "2003-12-27 Saturday -> 2003-12-28 Sunday"+ , "2003-12-28 Sunday -> 2004-01-04 Sunday"+ , "2003-12-29 Monday -> 2004-01-04 Sunday"+ , "2003-12-30 Tuesday -> 2004-01-04 Sunday"+ , "2003-12-31 Wednesday -> 2004-01-04 Sunday"+ , "2004-01-01 Thursday -> 2004-01-04 Sunday"+ , "2004-01-02 Friday -> 2004-01-04 Sunday"+ , "2004-01-03 Saturday -> 2004-01-04 Sunday"+ , "2004-01-04 Sunday -> 2004-01-11 Sunday"+ , "2004-01-05 Monday -> 2004-01-11 Sunday"+ , "2004-01-06 Tuesday -> 2004-01-11 Sunday"+ , "2004-01-07 Wednesday -> 2004-01-11 Sunday"+ , "2004-01-08 Thursday -> 2004-01-11 Sunday"+ , "2004-01-09 Friday -> 2004-01-11 Sunday"+ , "2004-01-10 Saturday -> 2004-01-11 Sunday"+ , "2000, Gregorian: moon, 2000-04-18: Easter, 2000-04-23 Sunday"+ , "2000, Orthodox : moon, 2000-04-23: Easter, 2000-04-30 Sunday"+ , "2001, Gregorian: moon, 2001-04-08: Easter, 2001-04-15 Sunday"+ , "2001, Orthodox : moon, 2001-04-12: Easter, 2001-04-15 Sunday"+ , "2002, Gregorian: moon, 2002-03-28: Easter, 2002-03-31 Sunday"+ , "2002, Orthodox : moon, 2002-05-01: Easter, 2002-05-05 Sunday"+ , "2003, Gregorian: moon, 2003-04-16: Easter, 2003-04-20 Sunday"+ , "2003, Orthodox : moon, 2003-04-20: Easter, 2003-04-27 Sunday"+ , "2004, Gregorian: moon, 2004-04-05: Easter, 2004-04-11 Sunday"+ , "2004, Orthodox : moon, 2004-04-09: Easter, 2004-04-11 Sunday"+ , "2005, Gregorian: moon, 2005-03-25: Easter, 2005-03-27 Sunday"+ , "2005, Orthodox : moon, 2005-04-28: Easter, 2005-05-01 Sunday"+ , "2006, Gregorian: moon, 2006-04-13: Easter, 2006-04-16 Sunday"+ , "2006, Orthodox : moon, 2006-04-17: Easter, 2006-04-23 Sunday"+ , "2007, Gregorian: moon, 2007-04-02: Easter, 2007-04-08 Sunday"+ , "2007, Orthodox : moon, 2007-04-06: Easter, 2007-04-08 Sunday"+ , "2008, Gregorian: moon, 2008-03-22: Easter, 2008-03-23 Sunday"+ , "2008, Orthodox : moon, 2008-04-25: Easter, 2008-04-27 Sunday"+ , "2009, Gregorian: moon, 2009-04-10: Easter, 2009-04-12 Sunday"+ , "2009, Orthodox : moon, 2009-04-14: Easter, 2009-04-19 Sunday"+ , "2010, Gregorian: moon, 2010-03-30: Easter, 2010-04-04 Sunday"+ , "2010, Orthodox : moon, 2010-04-03: Easter, 2010-04-04 Sunday"+ , "2011, Gregorian: moon, 2011-04-18: Easter, 2011-04-24 Sunday"+ , "2011, Orthodox : moon, 2011-04-22: Easter, 2011-04-24 Sunday"+ , "2012, Gregorian: moon, 2012-04-07: Easter, 2012-04-08 Sunday"+ , "2012, Orthodox : moon, 2012-04-11: Easter, 2012-04-15 Sunday"+ , "2013, Gregorian: moon, 2013-03-27: Easter, 2013-03-31 Sunday"+ , "2013, Orthodox : moon, 2013-04-30: Easter, 2013-05-05 Sunday"+ , "2014, Gregorian: moon, 2014-04-14: Easter, 2014-04-20 Sunday"+ , "2014, Orthodox : moon, 2014-04-18: Easter, 2014-04-20 Sunday"+ , "2015, Gregorian: moon, 2015-04-03: Easter, 2015-04-05 Sunday"+ , "2015, Orthodox : moon, 2015-04-07: Easter, 2015-04-12 Sunday"+ , "2016, Gregorian: moon, 2016-03-23: Easter, 2016-03-27 Sunday"+ , "2016, Orthodox : moon, 2016-04-26: Easter, 2016-05-01 Sunday"+ , "2017, Gregorian: moon, 2017-04-11: Easter, 2017-04-16 Sunday"+ , "2017, Orthodox : moon, 2017-04-15: Easter, 2017-04-16 Sunday"+ , "2018, Gregorian: moon, 2018-03-31: Easter, 2018-04-01 Sunday"+ , "2018, Orthodox : moon, 2018-04-04: Easter, 2018-04-08 Sunday"+ , "2019, Gregorian: moon, 2019-04-18: Easter, 2019-04-21 Sunday"+ , "2019, Orthodox : moon, 2019-04-23: Easter, 2019-04-28 Sunday"+ , "2020, Gregorian: moon, 2020-04-08: Easter, 2020-04-12 Sunday"+ , "2020, Orthodox : moon, 2020-04-12: Easter, 2020-04-19 Sunday"+ ]
+ test/main/Test/Calendar/LongWeekYears.hs view
@@ -0,0 +1,32 @@+module Test.Calendar.LongWeekYears (+ longWeekYears,+) where++import Data.Time.Calendar+import Data.Time.Calendar.WeekDate+import Test.Calendar.LongWeekYearsRef+import Test.Tasty+import Test.Tasty.HUnit++longYear :: Integer -> Bool+longYear year =+ case toWeekDate (fromGregorian year 12 31) of+ (_, 53, _) -> True+ _ -> False++showLongYear :: Integer -> String+showLongYear year =+ unwords+ [ show year ++ ":"+ , ( if isLeapYear year+ then "L"+ else " "+ )+ ++ ( if longYear year+ then "*"+ else " "+ )+ ]++longWeekYears :: TestTree+longWeekYears = testCase "longWeekYears" $ assertEqual "" longWeekYearsRef $ unlines $ map showLongYear [1901 .. 2050]
+ test/main/Test/Calendar/LongWeekYearsRef.hs view
@@ -0,0 +1,156 @@+module Test.Calendar.LongWeekYearsRef where++longWeekYearsRef :: String+longWeekYearsRef =+ unlines+ [ "1901: "+ , "1902: "+ , "1903: *"+ , "1904: L "+ , "1905: "+ , "1906: "+ , "1907: "+ , "1908: L*"+ , "1909: "+ , "1910: "+ , "1911: "+ , "1912: L "+ , "1913: "+ , "1914: *"+ , "1915: "+ , "1916: L "+ , "1917: "+ , "1918: "+ , "1919: "+ , "1920: L*"+ , "1921: "+ , "1922: "+ , "1923: "+ , "1924: L "+ , "1925: *"+ , "1926: "+ , "1927: "+ , "1928: L "+ , "1929: "+ , "1930: "+ , "1931: *"+ , "1932: L "+ , "1933: "+ , "1934: "+ , "1935: "+ , "1936: L*"+ , "1937: "+ , "1938: "+ , "1939: "+ , "1940: L "+ , "1941: "+ , "1942: *"+ , "1943: "+ , "1944: L "+ , "1945: "+ , "1946: "+ , "1947: "+ , "1948: L*"+ , "1949: "+ , "1950: "+ , "1951: "+ , "1952: L "+ , "1953: *"+ , "1954: "+ , "1955: "+ , "1956: L "+ , "1957: "+ , "1958: "+ , "1959: *"+ , "1960: L "+ , "1961: "+ , "1962: "+ , "1963: "+ , "1964: L*"+ , "1965: "+ , "1966: "+ , "1967: "+ , "1968: L "+ , "1969: "+ , "1970: *"+ , "1971: "+ , "1972: L "+ , "1973: "+ , "1974: "+ , "1975: "+ , "1976: L*"+ , "1977: "+ , "1978: "+ , "1979: "+ , "1980: L "+ , "1981: *"+ , "1982: "+ , "1983: "+ , "1984: L "+ , "1985: "+ , "1986: "+ , "1987: *"+ , "1988: L "+ , "1989: "+ , "1990: "+ , "1991: "+ , "1992: L*"+ , "1993: "+ , "1994: "+ , "1995: "+ , "1996: L "+ , "1997: "+ , "1998: *"+ , "1999: "+ , "2000: L "+ , "2001: "+ , "2002: "+ , "2003: "+ , "2004: L*"+ , "2005: "+ , "2006: "+ , "2007: "+ , "2008: L "+ , "2009: *"+ , "2010: "+ , "2011: "+ , "2012: L "+ , "2013: "+ , "2014: "+ , "2015: *"+ , "2016: L "+ , "2017: "+ , "2018: "+ , "2019: "+ , "2020: L*"+ , "2021: "+ , "2022: "+ , "2023: "+ , "2024: L "+ , "2025: "+ , "2026: *"+ , "2027: "+ , "2028: L "+ , "2029: "+ , "2030: "+ , "2031: "+ , "2032: L*"+ , "2033: "+ , "2034: "+ , "2035: "+ , "2036: L "+ , "2037: *"+ , "2038: "+ , "2039: "+ , "2040: L "+ , "2041: "+ , "2042: "+ , "2043: *"+ , "2044: L "+ , "2045: "+ , "2046: "+ , "2047: "+ , "2048: L*"+ , "2049: "+ , "2050: "+ ]
+ test/main/Test/Calendar/MonthDay.hs view
@@ -0,0 +1,51 @@+module Test.Calendar.MonthDay (+ testMonthDay,+) where++import Data.Time.Calendar+import Data.Time.Calendar.Month+import Data.Time.Calendar.MonthDay+import Test.Calendar.MonthDayRef+import Test.Tasty+import Test.Tasty.HUnit++showCompare :: (Eq a, Show a) => a -> String -> a -> String+showCompare a1 b a2+ | a1 == a2 = (show a1) ++ " == " ++ b+showCompare a1 b a2 = "DIFF: " ++ (show a1) ++ " -> " ++ b ++ " -> " ++ (show a2)++testMonthDay :: TestTree+testMonthDay =+ testGroup+ "MonthDay"+ [ testCase "good" $+ assertEqual "" testMonthDayRef $+ concat $+ map (\isL -> unlines (leap isL : yearDays isL)) [False, True]+ , testGroup+ "clip"+ [ testCase "12" $ assertEqual "" (YearMonthDay 2005 05 12) (MonthDay (MkMonth 24064) 12)+ , testCase "1" $ assertEqual "" (YearMonthDay 2005 05 1) (MonthDay (MkMonth 24064) 1)+ , testCase "0" $ assertEqual "" (YearMonthDay 2005 05 1) (MonthDay (MkMonth 24064) 0)+ , testCase "-1" $ assertEqual "" (YearMonthDay 2005 05 1) (MonthDay (MkMonth 24064) (-1))+ , testCase "31" $ assertEqual "" (YearMonthDay 2005 05 31) (MonthDay (MkMonth 24064) 31)+ , testCase "32" $ assertEqual "" (YearMonthDay 2005 05 31) (MonthDay (MkMonth 24064) 32)+ , testCase "33" $ assertEqual "" (YearMonthDay 2005 05 31) (MonthDay (MkMonth 24064) 33)+ ]+ ]+ where+ leap isLeap =+ if isLeap+ then "Leap:"+ else "Regular:"+ yearDays isLeap =+ map+ ( \yd ->+ let+ (m, d) = dayOfYearToMonthAndDay isLeap yd+ yd' = monthAndDayToDayOfYear isLeap m d+ mdtext = show m ++ "-" ++ show d+ in+ showCompare yd mdtext yd'+ )+ [-2 .. 369]
+ test/main/Test/Calendar/MonthDayRef.hs view
@@ -0,0 +1,752 @@+module Test.Calendar.MonthDayRef where++testMonthDayRef :: String+testMonthDayRef =+ unlines+ [ "Regular:"+ , "DIFF: -2 -> 1-1 -> 1"+ , "DIFF: -1 -> 1-1 -> 1"+ , "DIFF: 0 -> 1-1 -> 1"+ , "1 == 1-1"+ , "2 == 1-2"+ , "3 == 1-3"+ , "4 == 1-4"+ , "5 == 1-5"+ , "6 == 1-6"+ , "7 == 1-7"+ , "8 == 1-8"+ , "9 == 1-9"+ , "10 == 1-10"+ , "11 == 1-11"+ , "12 == 1-12"+ , "13 == 1-13"+ , "14 == 1-14"+ , "15 == 1-15"+ , "16 == 1-16"+ , "17 == 1-17"+ , "18 == 1-18"+ , "19 == 1-19"+ , "20 == 1-20"+ , "21 == 1-21"+ , "22 == 1-22"+ , "23 == 1-23"+ , "24 == 1-24"+ , "25 == 1-25"+ , "26 == 1-26"+ , "27 == 1-27"+ , "28 == 1-28"+ , "29 == 1-29"+ , "30 == 1-30"+ , "31 == 1-31"+ , "32 == 2-1"+ , "33 == 2-2"+ , "34 == 2-3"+ , "35 == 2-4"+ , "36 == 2-5"+ , "37 == 2-6"+ , "38 == 2-7"+ , "39 == 2-8"+ , "40 == 2-9"+ , "41 == 2-10"+ , "42 == 2-11"+ , "43 == 2-12"+ , "44 == 2-13"+ , "45 == 2-14"+ , "46 == 2-15"+ , "47 == 2-16"+ , "48 == 2-17"+ , "49 == 2-18"+ , "50 == 2-19"+ , "51 == 2-20"+ , "52 == 2-21"+ , "53 == 2-22"+ , "54 == 2-23"+ , "55 == 2-24"+ , "56 == 2-25"+ , "57 == 2-26"+ , "58 == 2-27"+ , "59 == 2-28"+ , "60 == 3-1"+ , "61 == 3-2"+ , "62 == 3-3"+ , "63 == 3-4"+ , "64 == 3-5"+ , "65 == 3-6"+ , "66 == 3-7"+ , "67 == 3-8"+ , "68 == 3-9"+ , "69 == 3-10"+ , "70 == 3-11"+ , "71 == 3-12"+ , "72 == 3-13"+ , "73 == 3-14"+ , "74 == 3-15"+ , "75 == 3-16"+ , "76 == 3-17"+ , "77 == 3-18"+ , "78 == 3-19"+ , "79 == 3-20"+ , "80 == 3-21"+ , "81 == 3-22"+ , "82 == 3-23"+ , "83 == 3-24"+ , "84 == 3-25"+ , "85 == 3-26"+ , "86 == 3-27"+ , "87 == 3-28"+ , "88 == 3-29"+ , "89 == 3-30"+ , "90 == 3-31"+ , "91 == 4-1"+ , "92 == 4-2"+ , "93 == 4-3"+ , "94 == 4-4"+ , "95 == 4-5"+ , "96 == 4-6"+ , "97 == 4-7"+ , "98 == 4-8"+ , "99 == 4-9"+ , "100 == 4-10"+ , "101 == 4-11"+ , "102 == 4-12"+ , "103 == 4-13"+ , "104 == 4-14"+ , "105 == 4-15"+ , "106 == 4-16"+ , "107 == 4-17"+ , "108 == 4-18"+ , "109 == 4-19"+ , "110 == 4-20"+ , "111 == 4-21"+ , "112 == 4-22"+ , "113 == 4-23"+ , "114 == 4-24"+ , "115 == 4-25"+ , "116 == 4-26"+ , "117 == 4-27"+ , "118 == 4-28"+ , "119 == 4-29"+ , "120 == 4-30"+ , "121 == 5-1"+ , "122 == 5-2"+ , "123 == 5-3"+ , "124 == 5-4"+ , "125 == 5-5"+ , "126 == 5-6"+ , "127 == 5-7"+ , "128 == 5-8"+ , "129 == 5-9"+ , "130 == 5-10"+ , "131 == 5-11"+ , "132 == 5-12"+ , "133 == 5-13"+ , "134 == 5-14"+ , "135 == 5-15"+ , "136 == 5-16"+ , "137 == 5-17"+ , "138 == 5-18"+ , "139 == 5-19"+ , "140 == 5-20"+ , "141 == 5-21"+ , "142 == 5-22"+ , "143 == 5-23"+ , "144 == 5-24"+ , "145 == 5-25"+ , "146 == 5-26"+ , "147 == 5-27"+ , "148 == 5-28"+ , "149 == 5-29"+ , "150 == 5-30"+ , "151 == 5-31"+ , "152 == 6-1"+ , "153 == 6-2"+ , "154 == 6-3"+ , "155 == 6-4"+ , "156 == 6-5"+ , "157 == 6-6"+ , "158 == 6-7"+ , "159 == 6-8"+ , "160 == 6-9"+ , "161 == 6-10"+ , "162 == 6-11"+ , "163 == 6-12"+ , "164 == 6-13"+ , "165 == 6-14"+ , "166 == 6-15"+ , "167 == 6-16"+ , "168 == 6-17"+ , "169 == 6-18"+ , "170 == 6-19"+ , "171 == 6-20"+ , "172 == 6-21"+ , "173 == 6-22"+ , "174 == 6-23"+ , "175 == 6-24"+ , "176 == 6-25"+ , "177 == 6-26"+ , "178 == 6-27"+ , "179 == 6-28"+ , "180 == 6-29"+ , "181 == 6-30"+ , "182 == 7-1"+ , "183 == 7-2"+ , "184 == 7-3"+ , "185 == 7-4"+ , "186 == 7-5"+ , "187 == 7-6"+ , "188 == 7-7"+ , "189 == 7-8"+ , "190 == 7-9"+ , "191 == 7-10"+ , "192 == 7-11"+ , "193 == 7-12"+ , "194 == 7-13"+ , "195 == 7-14"+ , "196 == 7-15"+ , "197 == 7-16"+ , "198 == 7-17"+ , "199 == 7-18"+ , "200 == 7-19"+ , "201 == 7-20"+ , "202 == 7-21"+ , "203 == 7-22"+ , "204 == 7-23"+ , "205 == 7-24"+ , "206 == 7-25"+ , "207 == 7-26"+ , "208 == 7-27"+ , "209 == 7-28"+ , "210 == 7-29"+ , "211 == 7-30"+ , "212 == 7-31"+ , "213 == 8-1"+ , "214 == 8-2"+ , "215 == 8-3"+ , "216 == 8-4"+ , "217 == 8-5"+ , "218 == 8-6"+ , "219 == 8-7"+ , "220 == 8-8"+ , "221 == 8-9"+ , "222 == 8-10"+ , "223 == 8-11"+ , "224 == 8-12"+ , "225 == 8-13"+ , "226 == 8-14"+ , "227 == 8-15"+ , "228 == 8-16"+ , "229 == 8-17"+ , "230 == 8-18"+ , "231 == 8-19"+ , "232 == 8-20"+ , "233 == 8-21"+ , "234 == 8-22"+ , "235 == 8-23"+ , "236 == 8-24"+ , "237 == 8-25"+ , "238 == 8-26"+ , "239 == 8-27"+ , "240 == 8-28"+ , "241 == 8-29"+ , "242 == 8-30"+ , "243 == 8-31"+ , "244 == 9-1"+ , "245 == 9-2"+ , "246 == 9-3"+ , "247 == 9-4"+ , "248 == 9-5"+ , "249 == 9-6"+ , "250 == 9-7"+ , "251 == 9-8"+ , "252 == 9-9"+ , "253 == 9-10"+ , "254 == 9-11"+ , "255 == 9-12"+ , "256 == 9-13"+ , "257 == 9-14"+ , "258 == 9-15"+ , "259 == 9-16"+ , "260 == 9-17"+ , "261 == 9-18"+ , "262 == 9-19"+ , "263 == 9-20"+ , "264 == 9-21"+ , "265 == 9-22"+ , "266 == 9-23"+ , "267 == 9-24"+ , "268 == 9-25"+ , "269 == 9-26"+ , "270 == 9-27"+ , "271 == 9-28"+ , "272 == 9-29"+ , "273 == 9-30"+ , "274 == 10-1"+ , "275 == 10-2"+ , "276 == 10-3"+ , "277 == 10-4"+ , "278 == 10-5"+ , "279 == 10-6"+ , "280 == 10-7"+ , "281 == 10-8"+ , "282 == 10-9"+ , "283 == 10-10"+ , "284 == 10-11"+ , "285 == 10-12"+ , "286 == 10-13"+ , "287 == 10-14"+ , "288 == 10-15"+ , "289 == 10-16"+ , "290 == 10-17"+ , "291 == 10-18"+ , "292 == 10-19"+ , "293 == 10-20"+ , "294 == 10-21"+ , "295 == 10-22"+ , "296 == 10-23"+ , "297 == 10-24"+ , "298 == 10-25"+ , "299 == 10-26"+ , "300 == 10-27"+ , "301 == 10-28"+ , "302 == 10-29"+ , "303 == 10-30"+ , "304 == 10-31"+ , "305 == 11-1"+ , "306 == 11-2"+ , "307 == 11-3"+ , "308 == 11-4"+ , "309 == 11-5"+ , "310 == 11-6"+ , "311 == 11-7"+ , "312 == 11-8"+ , "313 == 11-9"+ , "314 == 11-10"+ , "315 == 11-11"+ , "316 == 11-12"+ , "317 == 11-13"+ , "318 == 11-14"+ , "319 == 11-15"+ , "320 == 11-16"+ , "321 == 11-17"+ , "322 == 11-18"+ , "323 == 11-19"+ , "324 == 11-20"+ , "325 == 11-21"+ , "326 == 11-22"+ , "327 == 11-23"+ , "328 == 11-24"+ , "329 == 11-25"+ , "330 == 11-26"+ , "331 == 11-27"+ , "332 == 11-28"+ , "333 == 11-29"+ , "334 == 11-30"+ , "335 == 12-1"+ , "336 == 12-2"+ , "337 == 12-3"+ , "338 == 12-4"+ , "339 == 12-5"+ , "340 == 12-6"+ , "341 == 12-7"+ , "342 == 12-8"+ , "343 == 12-9"+ , "344 == 12-10"+ , "345 == 12-11"+ , "346 == 12-12"+ , "347 == 12-13"+ , "348 == 12-14"+ , "349 == 12-15"+ , "350 == 12-16"+ , "351 == 12-17"+ , "352 == 12-18"+ , "353 == 12-19"+ , "354 == 12-20"+ , "355 == 12-21"+ , "356 == 12-22"+ , "357 == 12-23"+ , "358 == 12-24"+ , "359 == 12-25"+ , "360 == 12-26"+ , "361 == 12-27"+ , "362 == 12-28"+ , "363 == 12-29"+ , "364 == 12-30"+ , "365 == 12-31"+ , "DIFF: 366 -> 12-31 -> 365"+ , "DIFF: 367 -> 12-31 -> 365"+ , "DIFF: 368 -> 12-31 -> 365"+ , "DIFF: 369 -> 12-31 -> 365"+ , "Leap:"+ , "DIFF: -2 -> 1-1 -> 1"+ , "DIFF: -1 -> 1-1 -> 1"+ , "DIFF: 0 -> 1-1 -> 1"+ , "1 == 1-1"+ , "2 == 1-2"+ , "3 == 1-3"+ , "4 == 1-4"+ , "5 == 1-5"+ , "6 == 1-6"+ , "7 == 1-7"+ , "8 == 1-8"+ , "9 == 1-9"+ , "10 == 1-10"+ , "11 == 1-11"+ , "12 == 1-12"+ , "13 == 1-13"+ , "14 == 1-14"+ , "15 == 1-15"+ , "16 == 1-16"+ , "17 == 1-17"+ , "18 == 1-18"+ , "19 == 1-19"+ , "20 == 1-20"+ , "21 == 1-21"+ , "22 == 1-22"+ , "23 == 1-23"+ , "24 == 1-24"+ , "25 == 1-25"+ , "26 == 1-26"+ , "27 == 1-27"+ , "28 == 1-28"+ , "29 == 1-29"+ , "30 == 1-30"+ , "31 == 1-31"+ , "32 == 2-1"+ , "33 == 2-2"+ , "34 == 2-3"+ , "35 == 2-4"+ , "36 == 2-5"+ , "37 == 2-6"+ , "38 == 2-7"+ , "39 == 2-8"+ , "40 == 2-9"+ , "41 == 2-10"+ , "42 == 2-11"+ , "43 == 2-12"+ , "44 == 2-13"+ , "45 == 2-14"+ , "46 == 2-15"+ , "47 == 2-16"+ , "48 == 2-17"+ , "49 == 2-18"+ , "50 == 2-19"+ , "51 == 2-20"+ , "52 == 2-21"+ , "53 == 2-22"+ , "54 == 2-23"+ , "55 == 2-24"+ , "56 == 2-25"+ , "57 == 2-26"+ , "58 == 2-27"+ , "59 == 2-28"+ , "60 == 2-29"+ , "61 == 3-1"+ , "62 == 3-2"+ , "63 == 3-3"+ , "64 == 3-4"+ , "65 == 3-5"+ , "66 == 3-6"+ , "67 == 3-7"+ , "68 == 3-8"+ , "69 == 3-9"+ , "70 == 3-10"+ , "71 == 3-11"+ , "72 == 3-12"+ , "73 == 3-13"+ , "74 == 3-14"+ , "75 == 3-15"+ , "76 == 3-16"+ , "77 == 3-17"+ , "78 == 3-18"+ , "79 == 3-19"+ , "80 == 3-20"+ , "81 == 3-21"+ , "82 == 3-22"+ , "83 == 3-23"+ , "84 == 3-24"+ , "85 == 3-25"+ , "86 == 3-26"+ , "87 == 3-27"+ , "88 == 3-28"+ , "89 == 3-29"+ , "90 == 3-30"+ , "91 == 3-31"+ , "92 == 4-1"+ , "93 == 4-2"+ , "94 == 4-3"+ , "95 == 4-4"+ , "96 == 4-5"+ , "97 == 4-6"+ , "98 == 4-7"+ , "99 == 4-8"+ , "100 == 4-9"+ , "101 == 4-10"+ , "102 == 4-11"+ , "103 == 4-12"+ , "104 == 4-13"+ , "105 == 4-14"+ , "106 == 4-15"+ , "107 == 4-16"+ , "108 == 4-17"+ , "109 == 4-18"+ , "110 == 4-19"+ , "111 == 4-20"+ , "112 == 4-21"+ , "113 == 4-22"+ , "114 == 4-23"+ , "115 == 4-24"+ , "116 == 4-25"+ , "117 == 4-26"+ , "118 == 4-27"+ , "119 == 4-28"+ , "120 == 4-29"+ , "121 == 4-30"+ , "122 == 5-1"+ , "123 == 5-2"+ , "124 == 5-3"+ , "125 == 5-4"+ , "126 == 5-5"+ , "127 == 5-6"+ , "128 == 5-7"+ , "129 == 5-8"+ , "130 == 5-9"+ , "131 == 5-10"+ , "132 == 5-11"+ , "133 == 5-12"+ , "134 == 5-13"+ , "135 == 5-14"+ , "136 == 5-15"+ , "137 == 5-16"+ , "138 == 5-17"+ , "139 == 5-18"+ , "140 == 5-19"+ , "141 == 5-20"+ , "142 == 5-21"+ , "143 == 5-22"+ , "144 == 5-23"+ , "145 == 5-24"+ , "146 == 5-25"+ , "147 == 5-26"+ , "148 == 5-27"+ , "149 == 5-28"+ , "150 == 5-29"+ , "151 == 5-30"+ , "152 == 5-31"+ , "153 == 6-1"+ , "154 == 6-2"+ , "155 == 6-3"+ , "156 == 6-4"+ , "157 == 6-5"+ , "158 == 6-6"+ , "159 == 6-7"+ , "160 == 6-8"+ , "161 == 6-9"+ , "162 == 6-10"+ , "163 == 6-11"+ , "164 == 6-12"+ , "165 == 6-13"+ , "166 == 6-14"+ , "167 == 6-15"+ , "168 == 6-16"+ , "169 == 6-17"+ , "170 == 6-18"+ , "171 == 6-19"+ , "172 == 6-20"+ , "173 == 6-21"+ , "174 == 6-22"+ , "175 == 6-23"+ , "176 == 6-24"+ , "177 == 6-25"+ , "178 == 6-26"+ , "179 == 6-27"+ , "180 == 6-28"+ , "181 == 6-29"+ , "182 == 6-30"+ , "183 == 7-1"+ , "184 == 7-2"+ , "185 == 7-3"+ , "186 == 7-4"+ , "187 == 7-5"+ , "188 == 7-6"+ , "189 == 7-7"+ , "190 == 7-8"+ , "191 == 7-9"+ , "192 == 7-10"+ , "193 == 7-11"+ , "194 == 7-12"+ , "195 == 7-13"+ , "196 == 7-14"+ , "197 == 7-15"+ , "198 == 7-16"+ , "199 == 7-17"+ , "200 == 7-18"+ , "201 == 7-19"+ , "202 == 7-20"+ , "203 == 7-21"+ , "204 == 7-22"+ , "205 == 7-23"+ , "206 == 7-24"+ , "207 == 7-25"+ , "208 == 7-26"+ , "209 == 7-27"+ , "210 == 7-28"+ , "211 == 7-29"+ , "212 == 7-30"+ , "213 == 7-31"+ , "214 == 8-1"+ , "215 == 8-2"+ , "216 == 8-3"+ , "217 == 8-4"+ , "218 == 8-5"+ , "219 == 8-6"+ , "220 == 8-7"+ , "221 == 8-8"+ , "222 == 8-9"+ , "223 == 8-10"+ , "224 == 8-11"+ , "225 == 8-12"+ , "226 == 8-13"+ , "227 == 8-14"+ , "228 == 8-15"+ , "229 == 8-16"+ , "230 == 8-17"+ , "231 == 8-18"+ , "232 == 8-19"+ , "233 == 8-20"+ , "234 == 8-21"+ , "235 == 8-22"+ , "236 == 8-23"+ , "237 == 8-24"+ , "238 == 8-25"+ , "239 == 8-26"+ , "240 == 8-27"+ , "241 == 8-28"+ , "242 == 8-29"+ , "243 == 8-30"+ , "244 == 8-31"+ , "245 == 9-1"+ , "246 == 9-2"+ , "247 == 9-3"+ , "248 == 9-4"+ , "249 == 9-5"+ , "250 == 9-6"+ , "251 == 9-7"+ , "252 == 9-8"+ , "253 == 9-9"+ , "254 == 9-10"+ , "255 == 9-11"+ , "256 == 9-12"+ , "257 == 9-13"+ , "258 == 9-14"+ , "259 == 9-15"+ , "260 == 9-16"+ , "261 == 9-17"+ , "262 == 9-18"+ , "263 == 9-19"+ , "264 == 9-20"+ , "265 == 9-21"+ , "266 == 9-22"+ , "267 == 9-23"+ , "268 == 9-24"+ , "269 == 9-25"+ , "270 == 9-26"+ , "271 == 9-27"+ , "272 == 9-28"+ , "273 == 9-29"+ , "274 == 9-30"+ , "275 == 10-1"+ , "276 == 10-2"+ , "277 == 10-3"+ , "278 == 10-4"+ , "279 == 10-5"+ , "280 == 10-6"+ , "281 == 10-7"+ , "282 == 10-8"+ , "283 == 10-9"+ , "284 == 10-10"+ , "285 == 10-11"+ , "286 == 10-12"+ , "287 == 10-13"+ , "288 == 10-14"+ , "289 == 10-15"+ , "290 == 10-16"+ , "291 == 10-17"+ , "292 == 10-18"+ , "293 == 10-19"+ , "294 == 10-20"+ , "295 == 10-21"+ , "296 == 10-22"+ , "297 == 10-23"+ , "298 == 10-24"+ , "299 == 10-25"+ , "300 == 10-26"+ , "301 == 10-27"+ , "302 == 10-28"+ , "303 == 10-29"+ , "304 == 10-30"+ , "305 == 10-31"+ , "306 == 11-1"+ , "307 == 11-2"+ , "308 == 11-3"+ , "309 == 11-4"+ , "310 == 11-5"+ , "311 == 11-6"+ , "312 == 11-7"+ , "313 == 11-8"+ , "314 == 11-9"+ , "315 == 11-10"+ , "316 == 11-11"+ , "317 == 11-12"+ , "318 == 11-13"+ , "319 == 11-14"+ , "320 == 11-15"+ , "321 == 11-16"+ , "322 == 11-17"+ , "323 == 11-18"+ , "324 == 11-19"+ , "325 == 11-20"+ , "326 == 11-21"+ , "327 == 11-22"+ , "328 == 11-23"+ , "329 == 11-24"+ , "330 == 11-25"+ , "331 == 11-26"+ , "332 == 11-27"+ , "333 == 11-28"+ , "334 == 11-29"+ , "335 == 11-30"+ , "336 == 12-1"+ , "337 == 12-2"+ , "338 == 12-3"+ , "339 == 12-4"+ , "340 == 12-5"+ , "341 == 12-6"+ , "342 == 12-7"+ , "343 == 12-8"+ , "344 == 12-9"+ , "345 == 12-10"+ , "346 == 12-11"+ , "347 == 12-12"+ , "348 == 12-13"+ , "349 == 12-14"+ , "350 == 12-15"+ , "351 == 12-16"+ , "352 == 12-17"+ , "353 == 12-18"+ , "354 == 12-19"+ , "355 == 12-20"+ , "356 == 12-21"+ , "357 == 12-22"+ , "358 == 12-23"+ , "359 == 12-24"+ , "360 == 12-25"+ , "361 == 12-26"+ , "362 == 12-27"+ , "363 == 12-28"+ , "364 == 12-29"+ , "365 == 12-30"+ , "366 == 12-31"+ , "DIFF: 367 -> 12-31 -> 366"+ , "DIFF: 368 -> 12-31 -> 366"+ , "DIFF: 369 -> 12-31 -> 366"+ ]
+ test/main/Test/Calendar/MonthOfYear.hs view
@@ -0,0 +1,26 @@+module Test.Calendar.MonthOfYear (+ testMonthOfYear,+) where++import Data.Foldable+import Data.Time.Calendar+import Test.Tasty+import Test.Tasty.HUnit++matchMonthOfYear :: MonthOfYear -> Int+matchMonthOfYear m = case m of+ January -> 1+ February -> 2+ March -> 3+ April -> 4+ May -> 5+ June -> 6+ July -> 7+ August -> 8+ September -> 9+ October -> 10+ November -> 11+ December -> 12++testMonthOfYear :: TestTree+testMonthOfYear = testCase "MonthOfYear" $ for_ [1 .. 12] $ \m -> assertEqual (show m) m $ matchMonthOfYear m
+ test/main/Test/Calendar/Valid.hs view
@@ -0,0 +1,164 @@+module Test.Calendar.Valid (+ testValid,+) where++import Data.Time+import Data.Time.Calendar.Julian+import Data.Time.Calendar.OrdinalDate+import Data.Time.Calendar.WeekDate+import Test.QuickCheck.Property+import Test.Tasty+import Test.Tasty.QuickCheck hiding (reason)++validResult :: (Eq c, Show c, Eq t, Show t) => (s -> c) -> Bool -> (t -> c) -> (c -> t) -> (c -> Maybe t) -> s -> Result+validResult sc valid toComponents fromComponents fromComponentsValid s =+ let+ c = sc s+ mt = fromComponentsValid c+ t' = fromComponents c+ c' = toComponents t'+ in+ if valid+ then case mt of+ Nothing -> rejected+ Just t ->+ if t' /= t+ then failed{reason = "'fromValid' gives " ++ show t ++ ", but 'from' gives " ++ show t'}+ else+ if c' /= c+ then+ failed+ { reason =+ "found valid, but converts "+ ++ show c+ ++ " -> "+ ++ show t'+ ++ " -> "+ ++ show c'+ }+ else succeeded+ else case mt of+ Nothing ->+ if c' /= c+ then succeeded+ else failed{reason = show c ++ " found invalid, but converts with " ++ show t'}+ Just _ -> rejected++validTest ::+ (Arbitrary s, Show s, Eq c, Show c, Eq t, Show t) =>+ String ->+ (s -> c) ->+ (t -> c) ->+ (c -> t) ->+ (c -> Maybe t) ->+ TestTree+validTest name sc toComponents fromComponents fromComponentsValid =+ testGroup+ name+ [ testProperty "valid" $ property $ validResult sc True toComponents fromComponents fromComponentsValid+ , testProperty "invalid" $ property $ validResult sc False toComponents fromComponents fromComponentsValid+ ]++toSundayStartWeek :: Day -> (Integer, Int, Int)+toSundayStartWeek day =+ let+ (y, _) = toOrdinalDate day+ (w, d) = sundayStartWeek day+ in+ (y, w, d)++toMondayStartWeek :: Day -> (Integer, Int, Int)+toMondayStartWeek day =+ let+ (y, _) = toOrdinalDate day+ (w, d) = mondayStartWeek day+ in+ (y, w, d)++newtype WYear+ = MkWYear Year+ deriving (Eq, Show)++instance Arbitrary WYear where+ arbitrary = fmap MkWYear $ choose (-1000, 3000)++newtype WMonthOfYear+ = MkWMonthOfYear MonthOfYear+ deriving (Eq, Show)++instance Arbitrary WMonthOfYear where+ arbitrary = fmap MkWMonthOfYear $ choose (-5, 17)++newtype WDayOfMonth+ = MkWDayOfMonth DayOfMonth+ deriving (Eq, Show)++instance Arbitrary WDayOfMonth where+ arbitrary = fmap MkWDayOfMonth $ choose (-5, 35)++newtype WDayOfYear+ = MkWDayOfYear DayOfYear+ deriving (Eq, Show)++instance Arbitrary WDayOfYear where+ arbitrary = fmap MkWDayOfYear $ choose (-20, 400)++newtype WWeekOfYear+ = MkWWeekOfYear WeekOfYear+ deriving (Eq, Show)++instance Arbitrary WWeekOfYear where+ arbitrary = fmap MkWWeekOfYear $ choose (-5, 60)++newtype WDayOfWeek+ = MkWDayOfWeek Int+ deriving (Eq, Show)++instance Arbitrary WDayOfWeek where+ arbitrary = fmap MkWDayOfWeek $ choose (-5, 15)++fromYMD :: (WYear, WMonthOfYear, WDayOfMonth) -> (Year, MonthOfYear, DayOfMonth)+fromYMD (MkWYear y, MkWMonthOfYear ym, MkWDayOfMonth md) = (y, ym, md)++fromYD :: (WYear, WDayOfYear) -> (Year, DayOfYear)+fromYD (MkWYear y, MkWDayOfYear yd) = (y, yd)++fromYWD :: (WYear, WWeekOfYear, WDayOfWeek) -> (Year, WeekOfYear, Int)+fromYWD (MkWYear y, MkWWeekOfYear yw, MkWDayOfWeek wd) = (y, yw, wd)++testValid :: TestTree+testValid =+ testGroup+ "testValid"+ [ validTest+ "Gregorian"+ fromYMD+ toGregorian+ (\(y, m, d) -> fromGregorian y m d)+ (\(y, m, d) -> fromGregorianValid y m d)+ , validTest+ "OrdinalDate"+ fromYD+ toOrdinalDate+ (\(y, d) -> fromOrdinalDate y d)+ (\(y, d) -> fromOrdinalDateValid y d)+ , validTest+ "WeekDate"+ fromYWD+ toWeekDate+ (\(y, w, d) -> fromWeekDate y w d)+ (\(y, w, d) -> fromWeekDateValid y w d)+ , validTest+ "SundayStartWeek"+ fromYWD+ toSundayStartWeek+ (\(y, w, d) -> fromSundayStartWeek y w d)+ (\(y, w, d) -> fromSundayStartWeekValid y w d)+ , validTest+ "MondayStartWeek"+ fromYWD+ toMondayStartWeek+ (\(y, w, d) -> fromMondayStartWeek y w d)+ (\(y, w, d) -> fromMondayStartWeekValid y w d)+ , validTest "Julian" fromYMD toJulian (\(y, m, d) -> fromJulian y m d) (\(y, m, d) -> fromJulianValid y m d)+ ]
+ test/main/Test/Calendar/Week.hs view
@@ -0,0 +1,248 @@+module Test.Calendar.Week (+ testWeek,+) where++import Data.Time.Calendar+import Data.Time.Calendar.OrdinalDate+import Data.Time.Calendar.WeekDate+import Test.Arbitrary ()+import Test.Tasty+import Test.Tasty.HUnit+import Test.TestUtil++testDay :: TestTree+testDay =+ nameTest "day" $ do+ let+ day = fromGregorian 2018 1 9+ assertEqual "" (ModifiedJulianDay 58127) day+ assertEqual "" (2018, 2, 2) $ toWeekDate day+ assertEqual "" Tuesday $ dayOfWeek day++allDaysOfWeek :: [DayOfWeek]+allDaysOfWeek = [Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday]++testAllDays :: String -> (DayOfWeek -> IO ()) -> TestTree+testAllDays name f = nameTest name $ fmap (\wd -> nameTest (show wd) $ f wd) allDaysOfWeek++testSucc :: TestTree+testSucc = testAllDays "succ" $ \wd -> assertEqual "" (toEnum $ succ $ fromEnum wd) $ succ wd++testPred :: TestTree+testPred = testAllDays "pred" $ \wd -> assertEqual "" (toEnum $ pred $ fromEnum wd) $ pred wd++testSequences :: TestTree+testSequences =+ nameTest+ "sequence"+ [ nameTest "[Monday .. Sunday]" $ assertEqual "" allDaysOfWeek [Monday .. Sunday]+ , nameTest "[Wednesday .. Wednesday]" $ assertEqual "" [Wednesday] [Wednesday .. Wednesday]+ , nameTest "[Sunday .. Saturday]" $+ assertEqual "" [Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday] [Sunday .. Saturday]+ , nameTest "[Thursday .. Wednesday]" $+ assertEqual "" [Thursday, Friday, Saturday, Sunday, Monday, Tuesday, Wednesday] [Thursday .. Wednesday]+ , nameTest "[Tuesday ..]"+ $ assertEqual+ ""+ [ Tuesday+ , Wednesday+ , Thursday+ , Friday+ , Saturday+ , Sunday+ , Monday+ , Tuesday+ , Wednesday+ , Thursday+ , Friday+ , Saturday+ , Sunday+ , Monday+ , Tuesday+ ]+ $ take 15 [Tuesday ..]+ , nameTest "[Wednesday, Tuesday ..]"+ $ assertEqual+ ""+ [ Wednesday+ , Tuesday+ , Monday+ , Sunday+ , Saturday+ , Friday+ , Thursday+ , Wednesday+ , Tuesday+ , Monday+ , Sunday+ , Saturday+ , Friday+ , Thursday+ , Wednesday+ ]+ $ take 15 [Wednesday, Tuesday ..]+ , nameTest "[Sunday, Friday ..]" $+ assertEqual "" [Sunday, Friday, Wednesday, Monday, Saturday, Thursday, Tuesday, Sunday] $+ take 8 [Sunday, Friday ..]+ , nameTest "[Monday,Sunday .. Tuesday]" $+ assertEqual "" [Monday, Sunday, Saturday, Friday, Thursday, Wednesday, Tuesday] [Monday, Sunday .. Tuesday]+ , nameTest "[Thursday, Saturday .. Tuesday]" $+ assertEqual "" [Thursday, Saturday, Monday, Wednesday, Friday, Sunday, Tuesday] [Thursday, Saturday .. Tuesday]+ ]++testReadShow :: TestTree+testReadShow = testAllDays "read show" $ \wd -> assertEqual "" wd $ read $ show wd++prop_firstDayOfWeekOnAfter_onAfter :: DayOfWeek -> Day -> Bool+prop_firstDayOfWeekOnAfter_onAfter dw d = firstDayOfWeekOnAfter dw d >= d++prop_firstDayOfWeekOnAfter_Day :: DayOfWeek -> Day -> Bool+prop_firstDayOfWeekOnAfter_Day dw d = dayOfWeek (firstDayOfWeekOnAfter dw d) == dw++prop_toFromWeekCalendar :: FirstWeekType -> DayOfWeek -> Day -> Bool+prop_toFromWeekCalendar wt ws d =+ let+ (y, wy, dw) = toWeekCalendar wt ws d+ in+ fromWeekCalendar wt ws y wy dw == d++prop_weekChanges :: FirstWeekType -> DayOfWeek -> Day -> Bool+prop_weekChanges wt ws d =+ let+ (_, wy0, _) = toWeekCalendar wt ws d+ (_, wy1, dw) = toWeekCalendar wt ws $ succ d+ in+ if dw == ws then wy0 /= wy1 else wy0 == wy1++prop_weekYearWholeStart :: DayOfWeek -> Year -> Bool+prop_weekYearWholeStart ws y =+ let+ d = fromWeekCalendar FirstWholeWeek ws y 1 ws+ (y', dy) = toOrdinalDate d+ in+ y == y' && dy >= 1 && dy <= 7++prop_weekYearMostStart :: DayOfWeek -> Year -> Bool+prop_weekYearMostStart ws y =+ let+ d = fromWeekCalendar FirstMostWeek ws y 2 ws+ (y', dy) = toOrdinalDate d+ in+ y == y' && dy >= 5 && dy <= 11++testDiff :: TestTree+testDiff =+ nameTest+ "diff"+ [ nameTest "Friday - Tuesday" $ assertEqual "" 3 $ dayOfWeekDiff Friday Tuesday+ , nameTest "Tuesday - Friday" $ assertEqual "" 4 $ dayOfWeekDiff Tuesday Friday+ , nameTest "firstDayOfWeekOnAfter_onAfter" prop_firstDayOfWeekOnAfter_onAfter+ , nameTest "firstDayOfWeekOnAfter_Day" prop_firstDayOfWeekOnAfter_Day+ , nameTest "toFromWeekCalendar" prop_toFromWeekCalendar+ , nameTest "weekChanges" prop_weekChanges+ , nameTest "weekYearWholeStart" prop_weekYearWholeStart+ , nameTest "weekYearMostStart" prop_weekYearMostStart+ ]++testWeekDays :: TestTree+testWeekDays =+ nameTest+ "Week Days"+ [ testGroup "weekAllDays" weekAllDaysTests+ , testGroup "weekFirstDay" weekFirstDayTests+ , testGroup "weekLastDay" weekLastDayTests+ ]++weekAllDaysTests :: [TestTree]+weekAllDaysTests =+ [ testGroup+ "Property Tests"+ [ nameTest "Week have 7 days" weekHaveSevenDays+ , nameTest "Day is part of the week" dayIsPartOfWeek+ ]+ , testGroup+ "Unit Tests"+ [ nameTest "FirstDay is less than Day-DayOfWeek" $+ assertEqual+ ""+ [YearMonthDay 2023 12 31 .. YearMonthDay 2024 1 6]+ (weekAllDays Sunday (YearMonthDay 2024 1 1))+ , nameTest "FirstDay is equal to Day-DayOfWeek" $+ assertEqual+ ""+ [YearMonthDay 2024 2 26 .. YearMonthDay 2024 3 3]+ (weekAllDays Monday (YearMonthDay 2024 2 26))+ , nameTest "FirstDay is greater than Day-DayOfWeek" $+ assertEqual+ ""+ [YearMonthDay 2022 2 15 .. YearMonthDay 2022 2 21]+ (weekAllDays Tuesday (YearMonthDay 2022 2 21))+ ]+ ]+ where+ weekHaveSevenDays :: DayOfWeek -> Day -> Bool+ weekHaveSevenDays fd d = length (weekAllDays fd d) == 7++ dayIsPartOfWeek :: DayOfWeek -> Day -> Bool+ dayIsPartOfWeek fd d = d `elem` weekAllDays fd d++weekFirstDayTests :: [TestTree]+weekFirstDayTests =+ [ testGroup+ "Property Tests"+ [ nameTest "FirsyDay matches the Day-DayOfWeek" firstDayMatchesDay+ ]+ , testGroup+ "Unit Tests"+ [ nameTest "FirstDay is less than Day-DayOfWeek" $+ assertEqual+ ""+ (YearMonthDay 2022 2 20)+ (weekFirstDay Sunday (YearMonthDay 2022 2 21))+ , nameTest "FirstDay is equal to Day-DayOfWeek" $+ assertEqual+ ""+ (YearMonthDay 2022 2 21)+ (weekFirstDay Monday (YearMonthDay 2022 2 21))+ , nameTest "FirstDay is greater than Day-DayOfWeek" $+ assertEqual+ ""+ (YearMonthDay 2022 2 15)+ (weekFirstDay Tuesday (YearMonthDay 2022 2 21))+ ]+ ]+ where+ firstDayMatchesDay :: DayOfWeek -> Day -> Bool+ firstDayMatchesDay fd d = dayOfWeek (weekFirstDay fd d) == fd++weekLastDayTests :: [TestTree]+weekLastDayTests =+ [ nameTest "FirstDay is less than Day-DayOfWeek" $+ assertEqual+ ""+ (YearMonthDay 2022 2 26)+ (weekLastDay Sunday (YearMonthDay 2022 2 21))+ , nameTest "FirstDay is equal to Day-DayOfWeek" $+ assertEqual+ ""+ (YearMonthDay 2022 2 27)+ (weekLastDay Monday (YearMonthDay 2022 2 21))+ , nameTest "FirstDay is greater than Day-DayOfWeek" $+ assertEqual+ ""+ (YearMonthDay 2022 2 21)+ (weekLastDay Tuesday (YearMonthDay 2022 2 21))+ ]++testWeek :: TestTree+testWeek =+ nameTest+ "Week"+ [ testDay+ , testSucc+ , testPred+ , testSequences+ , testReadShow+ , testDiff+ , testWeekDays+ ]
+ test/main/Test/Calendar/Year.hs view
@@ -0,0 +1,29 @@+module Test.Calendar.Year (+ testYear,+) where++import Data.Time.Calendar+import Data.Time.Calendar.OrdinalDate+import Test.Arbitrary ()+import Test.Tasty+import Test.Tasty.HUnit+import Test.TestUtil++cbRoundTrip :: TestTree+cbRoundTrip = nameTest "CE-BCE" $ \(YearDay y _) -> case y of+ CommonEra n -> case id y of+ BeforeCommonEra _ -> False+ _ -> n >= 1 && y == CommonEra n+ _ -> case id y of+ BeforeCommonEra n -> n >= 1 && y == BeforeCommonEra n+ _ -> False++testYear :: TestTree+testYear =+ nameTest+ "Year"+ [ cbRoundTrip+ , nameTest "succ 1" $ assertEqual "" (BeforeCommonEra 1) $ succ $ BeforeCommonEra 2+ , nameTest "succ 2" $ assertEqual "" (CommonEra 1) $ succ $ BeforeCommonEra 1+ , nameTest "succ 3" $ assertEqual "" (CommonEra 2) $ succ $ CommonEra 1+ ]
+ test/main/Test/Clock/Conversion.hs view
@@ -0,0 +1,27 @@+module Test.Clock.Conversion (+ testClockConversion,+) where++import Data.Time.Clock+import Data.Time.Clock.System+import Test.Tasty+import Test.Tasty.HUnit++testClockConversion :: TestTree+testClockConversion =+ testGroup "clock conversion" $+ let+ testPair :: (SystemTime, UTCTime) -> TestTree+ testPair (st, ut) =+ testGroup (show ut) $+ [ testCase "systemToUTCTime" $ assertEqual (show ut) ut $ systemToUTCTime st+ , testCase "utcToSystemTime" $ assertEqual (show ut) st $ utcToSystemTime ut+ ]+ in+ [ testPair (MkSystemTime 0 0, UTCTime systemEpochDay 0)+ , testPair (MkSystemTime 86399 0, UTCTime systemEpochDay 86399)+ , testPair (MkSystemTime 86399 999999999, UTCTime systemEpochDay 86399.999999999)+ , testPair (MkSystemTime 86399 1000000000, UTCTime systemEpochDay 86400)+ , testPair (MkSystemTime 86399 1999999999, UTCTime systemEpochDay 86400.999999999)+ , testPair (MkSystemTime 86400 0, UTCTime (succ systemEpochDay) 0)+ ]
+ test/main/Test/Clock/Pattern.hs view
@@ -0,0 +1,32 @@+module Test.Clock.Pattern (+ testClockPatterns,+) where++import Data.Time.Clock+import Test.Tasty+import Test.Tasty.HUnit++testClockPatterns :: TestTree+testClockPatterns =+ let+ testSame :: forall a. (Eq a, Show a) => TestName -> a -> a -> TestTree+ testSame name expected found = testCase name $ assertEqual "" expected found+ in+ testGroup "pattern" $+ [ testGroup+ "construct"+ [ testSame "Seconds" 52.4 (Seconds 52.4)+ , testSame "Seconds-Picoseconds" (Picoseconds 7_276_000_000_000) (Seconds 7.276)+ , testSame "Minutes-Seconds" (Seconds 210) (Minutes 3.5)+ , testSame "Hours-Minutes" (Minutes 120) (Hours 2)+ , testSame "Nominal" 37.4 (Nominal 37.4)+ ]+ , testGroup+ "deconstruct"+ [ testSame "Seconds" 52.4 ((\(Seconds x) -> x) 52.4)+ , testSame "Seconds-Picoseconds" 7.276 ((\(Seconds x) -> x) $ Picoseconds 7_276_000_000_000)+ , testSame "Minutes-Seconds" 3.5 ((\(Minutes x) -> x) $ Seconds 210)+ , testSame "Hours-Minutes" 2 ((\(Hours x) -> x) $ Minutes 120)+ , testSame "Nominal" 37.4 ((\(Nominal x) -> x) 37.4)+ ]+ ]
+ test/main/Test/Clock/Resolution.hs view
@@ -0,0 +1,65 @@+module Test.Clock.Resolution (+ testResolutions,+) where++import Control.Concurrent+import Data.Fixed+import Data.Time.Clock+import Data.Time.Clock.TAI+import Test.Tasty+import Test.Tasty.HUnit++repeatN :: Monad m => Int -> m a -> m [a]+repeatN 0 _ = return []+repeatN n ma = do+ a <- ma+ aa <- repeatN (n - 1) ma+ return $ a : aa++gcd' :: Real a => a -> a -> a+gcd' a 0 = a+gcd' a b = gcd' b (mod' a b)++gcdAll :: Real a => [a] -> a+gcdAll = foldr gcd' 0++testResolution :: (Show dt, Real dt) => String -> (at -> at -> dt) -> (dt, IO at) -> TestTree+testResolution name timeDiff (reportedRes, getTime) =+ testCase name $ do+ t0 <- getTime+ times0 <-+ repeatN 100 $ do+ threadDelay 0+ getTime+ times1 <-+ repeatN 100 $ -- 100us+ do+ threadDelay 1 -- 1us+ getTime+ times2 <-+ repeatN 100 $ -- 1ms+ do+ threadDelay 10 -- 10us+ getTime+ times3 <-+ repeatN 100 $ -- 10ms+ do+ threadDelay 100 -- 100us+ getTime+ times4 <-+ repeatN 100 $ -- 100ms+ do+ threadDelay 1000 -- 1ms+ getTime+ let+ times = fmap (\t -> timeDiff t t0) $ times0 ++ times1 ++ times2 ++ times3 ++ times4+ foundGrid = gcdAll times+ assertBool ("reported resolution: " <> show reportedRes <> ", found: " <> show foundGrid) $ foundGrid <= reportedRes++testResolutions :: TestTree+testResolutions =+ testGroup "resolution" $+ [testResolution "getCurrentTime" diffUTCTime (realToFrac getTime_resolution, getCurrentTime)]+ ++ case taiClock of+ Just clock -> [testResolution "taiClock" diffAbsoluteTime clock]+ Nothing -> []
+ test/main/Test/Clock/TAI.hs view
@@ -0,0 +1,60 @@+module Test.Clock.TAI (+ testTAI,+) where++import Data.Time+import Data.Time.Clock.TAI+import Test.Tasty+import Test.Tasty.HUnit+import Test.TestUtil++sampleLeapSecondMap :: LeapSecondMap+sampleLeapSecondMap d+ | d < fromGregorian 1972 1 1 = Nothing+sampleLeapSecondMap d+ | d < fromGregorian 1972 7 1 = Just 10+sampleLeapSecondMap d+ | d < fromGregorian 1975 1 1 = Just 11+sampleLeapSecondMap _ = Nothing++testTAI :: TestTree+testTAI =+ testGroup "leap second transition" $+ let+ dayA = fromGregorian 1972 6 30+ dayB = fromGregorian 1972 7 1+ utcTime1 = UTCTime dayA 86399+ utcTime2 = UTCTime dayA 86400+ utcTime3 = UTCTime dayB 0+ mAbsTime1 = utcToTAITime sampleLeapSecondMap utcTime1+ mAbsTime2 = utcToTAITime sampleLeapSecondMap utcTime2+ mAbsTime3 = utcToTAITime sampleLeapSecondMap utcTime3+ in+ [ testCase "mapping" $ do+ assertEqual "dayA" (Just 10) $ sampleLeapSecondMap dayA+ assertEqual "dayB" (Just 11) $ sampleLeapSecondMap dayB+ , testCase "day length" $ do+ assertEqual "dayA" (Just 86401) $ utcDayLength sampleLeapSecondMap dayA+ assertEqual "dayB" (Just 86400) $ utcDayLength sampleLeapSecondMap dayB+ , testCase "differences" $ do+ absTime1 <- assertJust mAbsTime1+ absTime2 <- assertJust mAbsTime2+ absTime3 <- assertJust mAbsTime3+ assertEqual "absTime2 - absTime1" 1 $ diffAbsoluteTime absTime2 absTime1+ assertEqual "absTime3 - absTime2" 1 $ diffAbsoluteTime absTime3 absTime2+ , testGroup+ "round-trip"+ [ testCase "1" $ do+ absTime <- assertJust mAbsTime1+ utcTime <- assertJust $ taiToUTCTime sampleLeapSecondMap absTime+ assertEqual "round-trip" utcTime1 utcTime+ , testCase "2" $ do+ absTime <- assertJust mAbsTime2+ utcTime <- assertJust $ taiToUTCTime sampleLeapSecondMap absTime+ assertEqual "round-trip" utcTime2 utcTime+ , testCase "3" $ do+ absTime <- assertJust mAbsTime3+ utcTime <- assertJust $ taiToUTCTime sampleLeapSecondMap absTime+ assertEqual "round-trip" utcTime3 utcTime+ ]+ ]
+ test/main/Test/Format/Compile.hs view
@@ -0,0 +1,14 @@+-- Tests succeed if module compiles+module Test.Format.Compile (++) where++import Data.Time++newtype WrappedUTCTime+ = MkWrappedUTCTime UTCTime+ deriving (FormatTime, ParseTime)++newtype Wrapped t+ = MkWrapped t+ deriving (FormatTime, ParseTime)
+ test/main/Test/Format/Format.hs view
@@ -0,0 +1,212 @@+module Test.Format.Format (+ testFormat,+) where++import Data.Proxy+import Data.Time+import Test.Tasty+import Test.Tasty.HUnit+import Test.TestUtil++-- as found in http://www.opengroup.org/onlinepubs/007908799/xsh/strftime.html+-- plus FgGklvz+-- f not supported+-- P not always supported+-- s time-zone dependent+chars :: [Char]+chars = "aAbBcCdDeFgGhHIjklmMnprRStTuUvVwWxXyYzZ%"++-- as found in "man strftime" on a glibc system. '#' is different, though+modifiers :: [Char]+modifiers = "_-0^"++widths :: [String]+widths = ["", "1", "2", "9", "12"]++formats :: [String]+formats =+ ["%G-W%V-%u", "%U-%w", "%W-%u"]+ ++ (fmap (\char -> '%' : [char]) chars)+ ++ ( concat $+ fmap+ (\char -> concat $ fmap (\width -> fmap (\modifier -> "%" ++ [modifier] ++ width ++ [char]) modifiers) widths)+ chars+ )++somestrings :: [String]+somestrings = ["", " ", "-", "\n"]++compareExpected :: (Eq t, Show t, ParseTime t) => String -> String -> String -> Proxy t -> TestTree+compareExpected testname fmt str proxy =+ testCase testname $ do+ let+ found :: ParseTime t => Proxy t -> Maybe t+ found _ = parseTimeM False defaultTimeLocale fmt str+ assertEqual "" Nothing $ found proxy++checkParse :: String -> String -> [TestTree]+checkParse fmt str =+ [ compareExpected "Day" fmt str (Proxy :: Proxy Day)+ , compareExpected "TimeOfDay" fmt str (Proxy :: Proxy TimeOfDay)+ , compareExpected "LocalTime" fmt str (Proxy :: Proxy LocalTime)+ , compareExpected "TimeZone" fmt str (Proxy :: Proxy TimeZone)+ , compareExpected "UTCTime" fmt str (Proxy :: Proxy UTCTime)+ ]++testCheckParse :: TestTree+testCheckParse = testGroup "checkParse" $ tgroup formats $ \fmt -> tgroup somestrings $ \str -> checkParse fmt str++days :: [Day]+days = [(fromGregorian 2018 1 5) .. (fromGregorian 2018 1 26)]++testDayOfWeek :: TestTree+testDayOfWeek =+ testGroup "DayOfWeek" $+ tgroup "uwaA" $ \fmt ->+ tgroup days $ \day ->+ let+ dayFormat = formatTime defaultTimeLocale ['%', fmt] day+ dowFormat = formatTime defaultTimeLocale ['%', fmt] $ dayOfWeek day+ in+ assertEqual "" dayFormat dowFormat++testZone :: String -> String -> Int -> TestTree+testZone fmt expected minutes =+ testCase (show fmt) $ assertEqual "" expected $ formatTime defaultTimeLocale fmt $ TimeZone minutes False ""++testZonePair :: String -> String -> Int -> TestTree+testZonePair mods expected minutes =+ testGroup+ (show mods ++ " " ++ show minutes)+ [testZone ("%" ++ mods ++ "z") expected minutes, testZone ("%" ++ mods ++ "Z") expected minutes]++testTimeZone :: TestTree+testTimeZone =+ testGroup+ "TimeZone"+ [ testZonePair "" "+0000" 0+ , testZonePair "E" "+00:00" 0+ , testZonePair "" "+0500" 300+ , testZonePair "E" "+05:00" 300+ , testZonePair "3" "+0500" 300+ , testZonePair "4E" "+05:00" 300+ , testZonePair "4" "+0500" 300+ , testZonePair "5E" "+05:00" 300+ , testZonePair "5" "+00500" 300+ , testZonePair "6E" "+005:00" 300+ , testZonePair "" "-0700" (-420)+ , testZonePair "E" "-07:00" (-420)+ , testZonePair "" "+1015" 615+ , testZonePair "E" "+10:15" 615+ , testZonePair "3" "+1015" 615+ , testZonePair "4E" "+10:15" 615+ , testZonePair "4" "+1015" 615+ , testZonePair "5E" "+10:15" 615+ , testZonePair "5" "+01015" 615+ , testZonePair "6E" "+010:15" 615+ , testZonePair "" "-1130" (-690)+ , testZonePair "E" "-11:30" (-690)+ ]++testAFormat :: FormatTime t => String -> String -> t -> TestTree+testAFormat fmt expected t = testCase fmt $ assertEqual "" expected $ formatTime defaultTimeLocale fmt t++testNominalDiffTime :: TestTree+testNominalDiffTime =+ testGroup+ "NominalDiffTime"+ [ testAFormat "%ww%Dd%Hh%Mm%ESs" "3w2d2h22m8.21s" $ (fromRational $ 23 * 86400 + 8528.21 :: NominalDiffTime)+ , testAFormat "%dd %hh %mm %ss %Ess" "0d 0h 0m 0s 0.74s" $ (fromRational $ 0.74 :: NominalDiffTime)+ , testAFormat "%dd %hh %mm %ss %Ess" "0d 0h 0m 0s -0.74s" $ (fromRational $ negate $ 0.74 :: NominalDiffTime)+ , testAFormat "%dd %hh %mm %ss %Ess %0Ess" "23d 554h 33262m 1995728s 1995728.21s 1995728.210000000000s" $+ (fromRational $ 23 * 86400 + 8528.21 :: NominalDiffTime)+ , testAFormat "%ww%Dd%Hh%Mm%Ss" "-3w-2d-2h-22m-8s" $+ (fromRational $ negate $ 23 * 86400 + 8528.21 :: NominalDiffTime)+ , testAFormat "%ww%Dd%Hh%Mm%ESs" "-3w-2d-2h-22m-8.21s" $+ (fromRational $ negate $ 23 * 86400 + 8528.21 :: NominalDiffTime)+ , testAFormat "%ww%Dd%Hh%Mm%Ss" "-3w-2d-2h-22m0s" $+ (fromRational $ negate $ 23 * 86400 + 8520.21 :: NominalDiffTime)+ , testAFormat "%ww%Dd%Hh%Mm%ESs" "-3w-2d-2h-22m-0.21s" $+ (fromRational $ negate $ 23 * 86400 + 8520.21 :: NominalDiffTime)+ , testAFormat "%dd %hh %mm %Ess" "-23d -554h -33262m -1995728.21s" $+ (fromRational $ negate $ 23 * 86400 + 8528.21 :: NominalDiffTime)+ , testAFormat "%3Es" "1.200" (1.2 :: NominalDiffTime)+ , testAFormat "%3ES" "01.200" (1.2 :: NominalDiffTime)+ , testAFormat "%3ES" "01.200" (61.2 :: NominalDiffTime)+ , testAFormat "%3Es" "1.245" (1.24582 :: NominalDiffTime)+ , testAFormat "%3ES" "01.245" (1.24582 :: NominalDiffTime)+ , testAFormat "%3ES" "01.245" (61.24582 :: NominalDiffTime)+ ]++testDiffTime :: TestTree+testDiffTime =+ testGroup+ "DiffTime"+ [ testAFormat "%ww%Dd%Hh%Mm%ESs" "3w2d2h22m8.21s" $ (fromRational $ 23 * 86400 + 8528.21 :: DiffTime)+ , testAFormat "%dd %hh %mm %ss %Ess" "0d 0h 0m 0s 0.74s" $ (fromRational $ 0.74 :: DiffTime)+ , testAFormat "%dd %hh %mm %ss %Ess" "0d 0h 0m 0s -0.74s" $ (fromRational $ negate $ 0.74 :: DiffTime)+ , testAFormat "%dd %hh %mm %ss %Ess %0Ess" "23d 554h 33262m 1995728s 1995728.21s 1995728.210000000000s" $+ (fromRational $ 23 * 86400 + 8528.21 :: DiffTime)+ , testAFormat "%ww%Dd%Hh%Mm%Ss" "-3w-2d-2h-22m-8s" $ (fromRational $ negate $ 23 * 86400 + 8528.21 :: DiffTime)+ , testAFormat "%ww%Dd%Hh%Mm%ESs" "-3w-2d-2h-22m-8.21s" $+ (fromRational $ negate $ 23 * 86400 + 8528.21 :: DiffTime)+ , testAFormat "%ww%Dd%Hh%Mm%Ss" "-3w-2d-2h-22m0s" $ (fromRational $ negate $ 23 * 86400 + 8520.21 :: DiffTime)+ , testAFormat "%ww%Dd%Hh%Mm%ESs" "-3w-2d-2h-22m-0.21s" $+ (fromRational $ negate $ 23 * 86400 + 8520.21 :: DiffTime)+ , testAFormat "%dd %hh %mm %Ess" "-23d -554h -33262m -1995728.21s" $+ (fromRational $ negate $ 23 * 86400 + 8528.21 :: DiffTime)+ , testAFormat "%3Es" "1.200" (1.2 :: DiffTime)+ , testAFormat "%3ES" "01.200" (1.2 :: DiffTime)+ , testAFormat "%3ES" "01.200" (61.2 :: DiffTime)+ , testAFormat "%3Es" "1.245" (1.24582 :: DiffTime)+ , testAFormat "%3ES" "01.245" (1.24582 :: DiffTime)+ , testAFormat "%3ES" "01.245" (61.24582 :: DiffTime)+ ]++testCalendarDiffDays :: TestTree+testCalendarDiffDays =+ testGroup+ "CalendarDiffDays"+ [ testAFormat "%yy%Bm%ww%Dd" "5y4m3w2d" $ CalendarDiffDays 64 23+ , testAFormat "%bm %dd" "64m 23d" $ CalendarDiffDays 64 23+ , testAFormat "%yy%Bm%ww%Dd" "-5y-4m-3w-2d" $ CalendarDiffDays (-64) (-23)+ , testAFormat "%bm %dd" "-64m -23d" $ CalendarDiffDays (-64) (-23)+ ]++testCalendarDiffTime :: TestTree+testCalendarDiffTime =+ testGroup+ "CalendarDiffTime"+ [ testAFormat "%yy%Bm%ww%Dd%Hh%Mm%Ss" "5y4m3w2d2h22m8s" $ CalendarDiffTime 64 $ 23 * 86400 + 8528.21+ , testAFormat "%yy%Bm%ww%Dd%Hh%Mm%ESs" "5y4m3w2d2h22m8.21s" $ CalendarDiffTime 64 $ 23 * 86400 + 8528.21+ , testAFormat "%yy%Bm%ww%Dd%Hh%Mm%0ESs" "5y4m3w2d2h22m08.210000000000s" $+ CalendarDiffTime 64 $+ 23 * 86400 + 8528.21+ , testAFormat "%bm %dd %hh %mm %Ess" "64m 23d 554h 33262m 1995728.21s" $+ CalendarDiffTime 64 $+ 23 * 86400 + 8528.21+ , testAFormat "%yy%Bm%ww%Dd%Hh%Mm%Ss" "-5y-4m-3w-2d-2h-22m-8s" $+ CalendarDiffTime (-64) $+ negate $+ 23 * 86400 + 8528.21+ , testAFormat "%yy%Bm%ww%Dd%Hh%Mm%ESs" "-5y-4m-3w-2d-2h-22m-8.21s" $+ CalendarDiffTime (-64) $+ negate $+ 23 * 86400 + 8528.21+ , testAFormat "%bm %dd %hh %mm %Ess" "-64m -23d -554h -33262m -1995728.21s" $+ CalendarDiffTime (-64) $+ negate $+ 23 * 86400 + 8528.21+ ]++testFormat :: TestTree+testFormat =+ testGroup "testFormat" $+ [ testCheckParse+ , testDayOfWeek+ , testTimeZone+ , testNominalDiffTime+ , testDiffTime+ , testCalendarDiffDays+ , testCalendarDiffTime+ ]
+ test/main/Test/Format/ISO8601.hs view
@@ -0,0 +1,355 @@+{-# OPTIONS -fno-warn-orphans #-}++module Test.Format.ISO8601 (+ testISO8601,+) where++import Data.Coerce+import Data.Ratio+import Data.Time+import Data.Time.Format.ISO8601+import Test.Arbitrary ()+import Test.QuickCheck.Property+import Test.Tasty+import Test.Tasty.HUnit+import Test.Tasty.QuickCheck hiding (reason)+import Test.TestUtil++deriving instance Eq ZonedTime++readShowProperty :: (Eq a, Show a) => (a -> Bool) -> Format a -> a -> Property+readShowProperty skip _ val | skip val = property Discard+readShowProperty _ fmt val =+ case formatShowM fmt val of+ Nothing -> property Discard+ Just str ->+ let+ found = formatParseM fmt str+ expected = Just val+ in+ property $+ if expected == found+ then succeeded+ else failed{reason = show str ++ ": expected " ++ (show expected) ++ ", found " ++ (show found)}++class SpecialTestValues a where+ testGen :: Gen a+ default testGen :: Arbitrary a => Gen a+ testGen = arbitrary++ -- | values that should always be tested+ specialTestValues :: [a]+ specialTestValues = []++instance {-# OVERLAPPABLE #-} Arbitrary a => SpecialTestValues a++instance SpecialTestValues TimeOfDay where+ specialTestValues = [TimeOfDay 0 0 0, TimeOfDay 0 0 60, TimeOfDay 1 0 60, TimeOfDay 24 0 0]++instance SpecialTestValues (Integer, Int) where+ testGen = do+ Small y <- arbitrary+ woy <- choose (-10, 120)+ pure (y, woy)++readShowTestCheck :: (Eq a, Show a, SpecialTestValues a) => (a -> Bool) -> Format a -> [TestTree]+readShowTestCheck skip fmt =+ [ nameTest "random" $ fmap (readShowProperty skip fmt) testGen+ , nameTest "special" $ fmap (\a -> nameTest (show a) $ readShowProperty skip fmt a) $ filter (not . skip) specialTestValues+ ]++readShowTest :: (Eq a, Show a, SpecialTestValues a) => Format a -> [TestTree]+readShowTest = readShowTestCheck $ \_ -> False++readBoth :: NameTest t => (FormatExtension -> t) -> [TestTree]+readBoth fmts = [nameTest "extended" $ fmts ExtendedFormat, nameTest "basic" $ fmts BasicFormat]++readShowTestsCheck :: (Eq a, Show a, SpecialTestValues a) => (a -> Bool) -> (FormatExtension -> Format a) -> [TestTree]+readShowTestsCheck skip fmts = readBoth $ \fe -> readShowTestCheck skip $ fmts fe++readShowTests :: (Eq a, Show a, SpecialTestValues a) => (FormatExtension -> Format a) -> [TestTree]+readShowTests = readShowTestsCheck $ \_ -> False++newtype Durational t = MkDurational t+ deriving Eq++instance Show t => Show (Durational t) where+ show (MkDurational t) = show t++instance Arbitrary (Durational CalendarDiffDays) where+ arbitrary = do+ mm <- choose (-10000, 10000)+ dd <- choose (-40, 40)+ return $ MkDurational $ CalendarDiffDays mm dd++instance Arbitrary (Durational CalendarDiffTime) where+ arbitrary =+ let+ limit = 40 * 86400+ picofactor = 10 ^ (12 :: Int)+ in+ do+ mm <- choose (-10000, 10000)+ ss <- choose (negate limit * picofactor, limit * picofactor)+ return $ MkDurational $ CalendarDiffTime mm $ fromRational $ ss % picofactor++durationalFormat :: Format a -> Format (Durational a)+durationalFormat = coerce++testReadShowFormat :: TestTree+testReadShowFormat =+ localOption (QuickCheckTests 1000) $+ nameTest+ "read-show format"+ [ nameTest "calendarFormat" $ readShowTests $ calendarFormat+ , nameTest "yearMonthFormat" $ readShowTest $ yearMonthFormat+ , nameTest "yearFormat" $ readShowTest $ yearFormat+ , nameTest "centuryFormat" $ readShowTest $ centuryFormat+ , nameTest "expandedCalendarFormat" $ readShowTests $ expandedCalendarFormat 6+ , nameTest "expandedYearMonthFormat" $ readShowTest $ expandedYearMonthFormat 6+ , nameTest "expandedYearFormat" $ readShowTest $ expandedYearFormat 6+ , nameTest "expandedCenturyFormat" $ readShowTest $ expandedCenturyFormat 4+ , nameTest "ordinalDateFormat" $ readShowTests $ ordinalDateFormat+ , nameTest "expandedOrdinalDateFormat" $ readShowTests $ expandedOrdinalDateFormat 6+ , nameTest "weekDateFormat" $ readShowTests $ weekDateFormat+ , nameTest "yearWeekFormat" $ readShowTests $ yearWeekFormat+ , nameTest "expandedWeekDateFormat" $ readShowTests $ expandedWeekDateFormat 6+ , nameTest "expandedYearWeekFormat" $ readShowTests $ expandedYearWeekFormat 6+ , nameTest "timeOfDayFormat" $ readShowTests $ timeOfDayFormat+ , nameTest "hourMinuteFormat" $ readShowTestsCheck (\(TimeOfDay _ _ s) -> s >= 60) $ hourMinuteFormat+ , nameTest "hourFormat" $ readShowTestCheck (\(TimeOfDay _ _ s) -> s >= 60) $ hourFormat+ , nameTest "withTimeDesignator" $ readShowTests $ \fe -> withTimeDesignator $ timeOfDayFormat fe+ , nameTest "withUTCDesignator" $ readShowTests $ \fe -> withUTCDesignator $ timeOfDayFormat fe+ , nameTest "timeOffsetFormat" $ readShowTests $ timeOffsetFormat+ , nameTest "timeOfDayAndOffsetFormat" $ readShowTests $ timeOfDayAndOffsetFormat+ , nameTest "localTimeFormat" $+ readShowTests $+ \fe -> localTimeFormat (calendarFormat fe) (timeOfDayFormat fe)+ , nameTest "zonedTimeFormat" $+ readShowTests $+ \fe -> zonedTimeFormat (calendarFormat fe) (timeOfDayFormat fe) fe+ , nameTest "utcTimeFormat" $ readShowTests $ \fe -> utcTimeFormat (calendarFormat fe) (timeOfDayFormat fe)+ , nameTest "dayAndTimeFormat" $+ readShowTests $+ \fe -> dayAndTimeFormat (calendarFormat fe) (timeOfDayFormat fe)+ , nameTest "timeAndOffsetFormat" $ readShowTests $ \fe -> timeAndOffsetFormat (timeOfDayFormat fe) fe+ , nameTest "durationDaysFormat" $ readShowTest $ durationDaysFormat+ , nameTest "durationTimeFormat" $ readShowTest $ durationTimeFormat+ , nameTest "alternativeDurationDaysFormat" $+ readBoth $+ \fe -> readShowTest (durationalFormat $ alternativeDurationDaysFormat fe)+ , nameTest "alternativeDurationTimeFormat" $+ readBoth $+ \fe -> readShowTest (durationalFormat $ alternativeDurationTimeFormat fe)+ , nameTest "intervalFormat" $+ readShowTests $ \fe ->+ intervalFormat (localTimeFormat (calendarFormat fe) (timeOfDayFormat fe)) durationTimeFormat+ , nameTest "recurringIntervalFormat" $+ readShowTests $ \fe ->+ recurringIntervalFormat (localTimeFormat (calendarFormat fe) (timeOfDayFormat fe)) durationTimeFormat+ ]++testShowReadFormat :: (Show t, Eq t) => String -> Format t -> String -> t -> TestTree+testShowReadFormat name fmt str val =+ nameTest+ (name ++ ": " ++ str)+ [ nameTest "show" $ assertEqual "" (Just str) $ formatShowM fmt val+ , nameTest "read" $ assertEqual "" (Just val) $ formatParseM fmt str+ ]++testReadFormat :: (Show t, Eq t) => String -> Format t -> String -> t -> TestTree+testReadFormat name fmt str val = nameTest (name ++ ": " ++ str) $ assertEqual "" (Just val) $ formatParseM fmt str++testShowFormats :: TestTree+testShowFormats =+ nameTest+ "show format"+ [ testShowReadFormat "durationDaysFormat" durationDaysFormat "P0D" $ CalendarDiffDays 0 0+ , testShowReadFormat "durationDaysFormat" durationDaysFormat "P4Y" $ CalendarDiffDays 48 0+ , testShowReadFormat "durationDaysFormat" durationDaysFormat "P7M" $ CalendarDiffDays 7 0+ , testShowReadFormat "durationDaysFormat" durationDaysFormat "P5D" $ CalendarDiffDays 0 5+ , testShowReadFormat "durationDaysFormat" durationDaysFormat "P2Y3M81D" $ CalendarDiffDays 27 81+ , testShowReadFormat "durationTimeFormat" durationTimeFormat "P0D" $ CalendarDiffTime 0 0+ , testShowReadFormat "durationTimeFormat" durationTimeFormat "P4Y" $ CalendarDiffTime 48 0+ , testShowReadFormat "durationTimeFormat" durationTimeFormat "P7M" $ CalendarDiffTime 7 0+ , testShowReadFormat "durationTimeFormat" durationTimeFormat "P5D" $ CalendarDiffTime 0 $ 5 * nominalDay+ , testShowReadFormat "durationTimeFormat" durationTimeFormat "P2Y3M81D" $ CalendarDiffTime 27 $ 81 * nominalDay+ , testShowReadFormat "durationTimeFormat" durationTimeFormat "PT2H" $ CalendarDiffTime 0 $ 7200+ , testShowReadFormat "durationTimeFormat" durationTimeFormat "PT3M" $ CalendarDiffTime 0 $ 180+ , testShowReadFormat "durationTimeFormat" durationTimeFormat "PT12S" $ CalendarDiffTime 0 $ 12+ , testShowReadFormat "durationTimeFormat" durationTimeFormat "PT1M18.77634S" $ CalendarDiffTime 0 $ 78.77634+ , testShowReadFormat "durationTimeFormat" durationTimeFormat "PT2H1M18.77634S" $ CalendarDiffTime 0 $ 7278.77634+ , testShowReadFormat "durationTimeFormat" durationTimeFormat "P5DT2H1M18.77634S" $+ CalendarDiffTime 0 $+ 5 * nominalDay + 7278.77634+ , testShowReadFormat "durationTimeFormat" durationTimeFormat "P7Y10M5DT2H1M18.77634S" $+ CalendarDiffTime 94 $+ 5 * nominalDay + 7278.77634+ , testShowReadFormat "durationTimeFormat" durationTimeFormat "P7Y10MT2H1M18.77634S" $+ CalendarDiffTime 94 $+ 7278.77634+ , testShowReadFormat "durationTimeFormat" durationTimeFormat "P8YT2H1M18.77634S" $ CalendarDiffTime 96 $ 7278.77634+ , testShowReadFormat "alternativeDurationDaysFormat" (alternativeDurationDaysFormat ExtendedFormat) "P0001-00-00" $+ CalendarDiffDays 12 0+ , testShowReadFormat "alternativeDurationDaysFormat" (alternativeDurationDaysFormat ExtendedFormat) "P0002-03-29" $+ CalendarDiffDays 27 29+ , testShowReadFormat "alternativeDurationDaysFormat" (alternativeDurationDaysFormat ExtendedFormat) "P0561-08-29" $+ CalendarDiffDays (561 * 12 + 8) 29+ , testShowReadFormat+ "alternativeDurationTimeFormat"+ (alternativeDurationTimeFormat ExtendedFormat)+ "P0000-00-01T00:00:00"+ $ CalendarDiffTime 0 86400+ , testShowReadFormat+ "alternativeDurationTimeFormat"+ (alternativeDurationTimeFormat ExtendedFormat)+ "P0007-10-05T02:01:18.77634"+ $ CalendarDiffTime 94+ $ 5 * nominalDay + 7278.77634+ , testShowReadFormat+ "alternativeDurationTimeFormat"+ (alternativeDurationTimeFormat ExtendedFormat)+ "P4271-10-05T02:01:18.77634"+ $ CalendarDiffTime (12 * 4271 + 10)+ $ 5 * nominalDay + 7278.77634+ , testShowReadFormat "centuryFormat" centuryFormat "02" 2+ , testShowReadFormat "centuryFormat" centuryFormat "21" 21+ , testShowReadFormat+ "intervalFormat etc."+ ( intervalFormat+ (localTimeFormat (calendarFormat ExtendedFormat) (timeOfDayFormat ExtendedFormat))+ durationTimeFormat+ )+ "2015-06-13T21:13:56/P1Y2M7DT5H33M2.34S"+ ( LocalTime (fromGregorian 2015 6 13) (TimeOfDay 21 13 56)+ , CalendarDiffTime 14 $ 7 * nominalDay + 5 * 3600 + 33 * 60 + 2.34+ )+ , testShowReadFormat+ "recurringIntervalFormat etc."+ ( recurringIntervalFormat+ (localTimeFormat (calendarFormat ExtendedFormat) (timeOfDayFormat ExtendedFormat))+ durationTimeFormat+ )+ "R74/2015-06-13T21:13:56/P1Y2M7DT5H33M2.34S"+ ( 74+ , LocalTime (fromGregorian 2015 6 13) (TimeOfDay 21 13 56)+ , CalendarDiffTime 14 $ 7 * nominalDay + 5 * 3600 + 33 * 60 + 2.34+ )+ , testShowReadFormat+ "recurringIntervalFormat etc."+ (recurringIntervalFormat (calendarFormat ExtendedFormat) durationDaysFormat)+ "R74/2015-06-13/P1Y2M7D"+ (74, fromGregorian 2015 6 13, CalendarDiffDays 14 7)+ , testShowReadFormat "timeOffsetFormat" iso8601Format "-06:30" (minutesToTimeZone (-390))+ , testShowReadFormat "timeOffsetFormat" iso8601Format "-06:00" (minutesToTimeZone (-360))+ , testReadFormat "timeOffsetFormat" iso8601Format "-06" (minutesToTimeZone (-360))+ , testShowReadFormat "timeOffsetFormat" iso8601Format "+11:00" (minutesToTimeZone 660)+ , testReadFormat "timeOffsetFormat" iso8601Format "+11" (minutesToTimeZone 660)+ , testShowReadFormat "timeOffsetFormat" iso8601Format "+00:00" (minutesToTimeZone 0)+ , testReadFormat "timeOffsetFormat" iso8601Format "+00" (minutesToTimeZone 0)+ , testReadFormat "timeOffsetFormat" iso8601Format "-00:00" (minutesToTimeZone 0)+ , testReadFormat "timeOffsetFormat" iso8601Format "-00" (minutesToTimeZone 0)+ , testShowReadFormat "timeOffsetFormat" (timeOffsetFormat BasicFormat) "+0000" (minutesToTimeZone 0)+ , testReadFormat "timeOffsetFormat" (timeOffsetFormat BasicFormat) "+00" (minutesToTimeZone 0)+ , testReadFormat "timeOffsetFormat" (timeOffsetFormat BasicFormat) "-0000" (minutesToTimeZone 0)+ , testReadFormat "timeOffsetFormat" (timeOffsetFormat BasicFormat) "-00" (minutesToTimeZone 0)+ , testShowReadFormat "timeOffsetFormat" iso8601Format "+00:10" (minutesToTimeZone 10)+ , testShowReadFormat "timeOffsetFormat" iso8601Format "-00:10" (minutesToTimeZone (-10))+ , testShowReadFormat "timeOffsetFormat" iso8601Format "+01:35" (minutesToTimeZone 95)+ , testShowReadFormat "timeOffsetFormat" iso8601Format "-01:35" (minutesToTimeZone (-95))+ , testShowReadFormat "timeOffsetFormat" (timeOffsetFormat BasicFormat) "+0135" (minutesToTimeZone 95)+ , testShowReadFormat "timeOffsetFormat" (timeOffsetFormat BasicFormat) "-0135" (minutesToTimeZone (-95))+ , testShowReadFormat+ "timeOffsetFormat"+ (timeOffsetFormat BasicFormat)+ "-1100"+ (minutesToTimeZone $ negate $ 11 * 60)+ , testShowReadFormat "timeOffsetFormat" (timeOffsetFormat BasicFormat) "+1015" (minutesToTimeZone $ 615)+ , testShowReadFormat+ "zonedTimeFormat"+ iso8601Format+ "2024-07-06T08:45:56.553-06:30"+ (ZonedTime (LocalTime (fromGregorian 2024 07 06) (TimeOfDay 8 45 56.553)) (minutesToTimeZone (-390)))+ , testShowReadFormat+ "zonedTimeFormat"+ iso8601Format+ "2024-07-06T08:45:56.553-06:00"+ (ZonedTime (LocalTime (fromGregorian 2024 07 06) (TimeOfDay 8 45 56.553)) (minutesToTimeZone (-360)))+ , testReadFormat+ "zonedTimeFormat"+ iso8601Format+ "2024-07-06T08:45:56.553-06"+ (ZonedTime (LocalTime (fromGregorian 2024 07 06) (TimeOfDay 8 45 56.553)) (minutesToTimeZone (-360)))+ , testShowReadFormat+ "zonedTimeFormat"+ iso8601Format+ "2024-07-06T08:45:56.553+06:30"+ (ZonedTime (LocalTime (fromGregorian 2024 07 06) (TimeOfDay 8 45 56.553)) (minutesToTimeZone 390))+ , testShowReadFormat+ "zonedTimeFormat"+ iso8601Format+ "2024-07-06T08:45:56.553+06:00"+ (ZonedTime (LocalTime (fromGregorian 2024 07 06) (TimeOfDay 8 45 56.553)) (minutesToTimeZone 360))+ , testReadFormat+ "zonedTimeFormat"+ iso8601Format+ "2024-07-06T08:45:56.553+06"+ (ZonedTime (LocalTime (fromGregorian 2024 07 06) (TimeOfDay 8 45 56.553)) (minutesToTimeZone 360))+ , testReadFormat+ "zonedTimeFormat"+ iso8601Format+ "2024-05-30T16:15:18Z"+ (ZonedTime (LocalTime (fromGregorian 2024 05 30) (TimeOfDay 16 15 18)) utc)+ , testReadFormat+ "zonedTimeFormat"+ iso8601Format+ "2024-05-30T16:15:18"+ (ZonedTime (LocalTime (fromGregorian 2024 05 30) (TimeOfDay 16 15 18)) utc)+ , testShowReadFormat+ "utcTimeFormat"+ iso8601Format+ "2024-07-06T08:45:56.553Z"+ (UTCTime (fromGregorian 2024 07 06) (timeOfDayToTime $ TimeOfDay 8 45 56.553))+ , testShowReadFormat+ "utcTimeFormat"+ iso8601Format+ "2028-12-31T23:59:60.9Z"+ (UTCTime (fromGregorian 2028 12 31) (timeOfDayToTime $ TimeOfDay 23 59 60.9))+ , testReadFormat+ "utcTimeFormat"+ iso8601Format+ "2028-12-31T23:59:60.9"+ (UTCTime (fromGregorian 2028 12 31) (timeOfDayToTime $ TimeOfDay 23 59 60.9))+ , testShowReadFormat "weekDateFormat" (weekDateFormat ExtendedFormat) "1994-W52-7" (fromGregorian 1995 1 1)+ , testShowReadFormat "weekDateFormat" (weekDateFormat ExtendedFormat) "1995-W01-1" (fromGregorian 1995 1 2)+ , testShowReadFormat "weekDateFormat" (weekDateFormat ExtendedFormat) "1996-W52-7" (fromGregorian 1996 12 29)+ , testShowReadFormat "weekDateFormat" (weekDateFormat ExtendedFormat) "1997-W01-2" (fromGregorian 1996 12 31)+ , testShowReadFormat "weekDateFormat" (weekDateFormat ExtendedFormat) "1997-W01-3" (fromGregorian 1997 1 1)+ , testShowReadFormat "weekDateFormat" (weekDateFormat ExtendedFormat) "1974-W32-6" (fromGregorian 1974 8 10)+ , testShowReadFormat "weekDateFormat" (weekDateFormat BasicFormat) "1974W326" (fromGregorian 1974 8 10)+ , testShowReadFormat "weekDateFormat" (weekDateFormat ExtendedFormat) "1995-W05-6" (fromGregorian 1995 2 4)+ , testShowReadFormat "weekDateFormat" (weekDateFormat BasicFormat) "1995W056" (fromGregorian 1995 2 4)+ , testShowReadFormat+ "weekDateFormat"+ (expandedWeekDateFormat 6 ExtendedFormat)+ "+001995-W05-6"+ (fromGregorian 1995 2 4)+ , testShowReadFormat "weekDateFormat" (expandedWeekDateFormat 6 BasicFormat) "+001995W056" (fromGregorian 1995 2 4)+ , testShowReadFormat "ordinalDateFormat" (ordinalDateFormat ExtendedFormat) "1846-235" (fromGregorian 1846 8 23)+ , testShowReadFormat "ordinalDateFormat" (ordinalDateFormat BasicFormat) "1844236" (fromGregorian 1844 8 23)+ , testShowReadFormat+ "ordinalDateFormat"+ (expandedOrdinalDateFormat 5 ExtendedFormat)+ "+01846-235"+ (fromGregorian 1846 8 23)+ , testShowReadFormat "hourMinuteFormat" (hourMinuteFormat ExtendedFormat) "13:17.25" (TimeOfDay 13 17 15)+ , testShowReadFormat "hourMinuteFormat" (hourMinuteFormat ExtendedFormat) "01:12.4" (TimeOfDay 1 12 24)+ , testShowReadFormat "hourMinuteFormat" (hourMinuteFormat BasicFormat) "1317.25" (TimeOfDay 13 17 15)+ , testShowReadFormat "hourMinuteFormat" (hourMinuteFormat BasicFormat) "0112.4" (TimeOfDay 1 12 24)+ , testShowReadFormat "hourFormat" hourFormat "22" (TimeOfDay 22 0 0)+ , testShowReadFormat "hourFormat" hourFormat "06" (TimeOfDay 6 0 0)+ , testShowReadFormat "hourFormat" hourFormat "18.9475" (TimeOfDay 18 56 51)+ ]++testISO8601 :: TestTree+testISO8601 = nameTest "ISO8601" [testShowFormats, testReadShowFormat]
+ test/main/Test/Format/ParseTime.hs view
@@ -0,0 +1,994 @@+{-# OPTIONS -fno-warn-orphans #-}++module Test.Format.ParseTime (+ testParseTime,+ test_parse_format,+) where++import Control.Monad+import Data.Char+import Data.Maybe+import Data.Proxy+import Data.Time+import Data.Time.Calendar.Month+import Data.Time.Calendar.OrdinalDate+import Data.Time.Calendar.Quarter+import Data.Time.Calendar.WeekDate+import Test.Arbitrary (supportedDayRange)+import Test.QuickCheck.Property+import Test.Tasty+import Test.Tasty.HUnit+import Test.Tasty.QuickCheck hiding (reason)+import Test.TestUtil++format :: FormatTime t => String -> t -> String+format f t = formatTime defaultTimeLocale f t++parse :: ParseTime t => Bool -> String -> String -> Maybe t+parse sp f t = parseTimeM sp defaultTimeLocale f t++data FormatOnly++data ParseAndFormat++data FormatCode pf t = MkFormatCode+ { fcModifier :: String+ , fcWidth :: Maybe Int+ , fcAlt :: Bool+ , fcSpecifier :: Char+ }++instance Show (FormatCode pf t) where+ show (MkFormatCode m w a s) =+ let+ ms = m+ ws = fromMaybe "" $ fmap show w+ as =+ if a+ then "E"+ else ""+ ss = [s]+ in+ '%' : (ms <> ws <> as <> ss)++formatCode :: FormatTime t => FormatCode pf t -> t -> String+formatCode fc = format $ show fc++parseCode :: ParseTime t => FormatCode ParseAndFormat t -> String -> Maybe t+parseCode fc = parse False $ show fc++class HasFormatCodes t where+ allFormatCodes :: Proxy t -> [(Bool, Char)]+ incompleteS :: Maybe t+ incompleteS = Nothing++minCodeWidth :: Char -> Int+minCodeWidth _ = 0++fcShrink :: FormatCode pf t -> [FormatCode pf t]+fcShrink fc =+ let+ fc1 = case fcWidth fc of+ Nothing -> []+ Just w+ | w > (minCodeWidth $ fcSpecifier fc) -> [fc{fcWidth = Nothing}, fc{fcWidth = Just $ w - 1}]+ Just _ -> [fc{fcWidth = Nothing}]+ fc2 = case fcAlt fc of+ False -> []+ True -> [fc{fcAlt = False}]+ fc3 = case fcModifier fc of+ "" -> []+ _ -> [fc{fcModifier = ""}]+ in+ fc1 ++ fc2 ++ fc3++instance HasFormatCodes t => Arbitrary (FormatCode FormatOnly t) where+ arbitrary = do+ m <- oneof [return "", oneof $ fmap return ["", "-", "_", "0", "^", "#"]]+ (a, s) <- oneof $ fmap return $ allFormatCodes (Proxy :: Proxy t)+ w <-+ case minCodeWidth s of+ 0 -> return Nothing+ mw -> oneof [return Nothing, fmap Just $ choose (mw, 15)]+ return $ MkFormatCode m w a s+ shrink = fcShrink++instance HasFormatCodes t => Arbitrary (FormatCode ParseAndFormat t) where+ arbitrary = do+ (a, s) <- oneof $ fmap return $ allFormatCodes (Proxy :: Proxy t)+ m <-+ case s of+ 'Z' -> return ""+ 'z' -> return ""+ _ -> oneof [return "", oneof $ fmap return ["", "-", "_", "0"]]+ return $ MkFormatCode m Nothing a s+ shrink = fcShrink++testParseTime :: TestTree+testParseTime =+ testGroup+ "testParseTime"+ [ readsTests+ , simpleFormatTests+ , extests+ , spacingTests+ , particularParseTests+ , badParseTests+ , defaultTimeZoneTests+ , militaryTimeZoneTests+ , propertyTests+ ]++yearDays :: Integer -> [Day]+yearDays y = [(fromGregorian y 1 1) .. (fromGregorian y 12 31)]++makeExhaustiveTest :: String -> [t] -> (t -> TestTree) -> TestTree+makeExhaustiveTest name cases f = testGroup name (fmap f cases)++extests :: TestTree+extests =+ testGroup+ "exhaustive"+ ( [ makeExhaustiveTest "parse %y" [0 .. 99] parseYY+ , makeExhaustiveTest "parse %-C %y 1900s" [0, 1, 50, 99] (parseCYY 19)+ , makeExhaustiveTest "parse %-C %y 2000s" [0, 1, 50, 99] (parseCYY 20)+ , makeExhaustiveTest "parse %-C %y 1400s" [0, 1, 50, 99] (parseCYY 14)+ , makeExhaustiveTest "parse %C %y 0700s" [0, 1, 50, 99] (parseCYY2 7)+ , makeExhaustiveTest "parse %-C %y 700s" [0, 1, 50, 99] (parseCYY 7)+ , makeExhaustiveTest "parse %-C %y -700s" [0, 1, 50, 99] (parseCYY (-7))+ , makeExhaustiveTest "parse %-C %y -70000s" [0, 1, 50, 99] (parseCYY (-70000))+ , makeExhaustiveTest "parse %-C %y 10000s" [0, 1, 50, 99] (parseCYY 100)+ , makeExhaustiveTest "parse %-C centuries" [20 .. 100] (parseCentury " ")+ , makeExhaustiveTest "parse %-C century X" [1, 10, 20, 100] (parseCentury "X")+ , makeExhaustiveTest "parse %-C century 2sp" [1, 10, 20, 100] (parseCentury " ")+ , makeExhaustiveTest "parse %-C century 5sp" [1, 10, 20, 100] (parseCentury " ")+ ]+ ++ ( concat $+ fmap+ ( \y ->+ [ {- (makeExhaustiveTest "parse %Y%m%d" (yearDays y) parseYMD)+ , -} (makeExhaustiveTest "parse %Y %m %d" (yearDays y) parseYearDayD)+ , (makeExhaustiveTest "parse %Y %-m %e" (yearDays y) parseYearDayE)+ ]+ )+ [1, 4, 20, 753, 2000, 2011, 10001, (-1166)]+ )+ )++testReads :: (Eq a, Show a, Read a) => [(a, String)] -> String -> TestTree+testReads expected target =+ let+ found = reads target+ result = assertEqual "" expected found+ name = show target+ in+ Test.Tasty.HUnit.testCase name result++readsTestsParensSpaces ::+ forall a.+ (Eq a, Show a, Read a) =>+ a ->+ String ->+ TestTree+readsTestsParensSpaces expected target =+ testGroup+ target+ [ testReads [(expected, "")] $ target+ , testReads [(expected, "")] $ "(" ++ target ++ ")"+ , testReads [(expected, "")] $ " (" ++ target ++ ")"+ , testReads [(expected, " ")] $ " ( " ++ target ++ " ) "+ , testReads [(expected, " ")] $ " (( " ++ target ++ " )) "+ , testReads ([] :: [(a, String)]) $ "(" ++ target+ , testReads [(expected, ")")] $ "" ++ target ++ ")"+ , testReads [(expected, "")] $ "((" ++ target ++ "))"+ , testReads [(expected, " ")] $ " ( ( " ++ target ++ " ) ) "+ ]++readsTests :: TestTree+readsTests =+ testGroup+ "reads"+ [ readsTestsParensSpaces (3 :: Integer) "3"+ , readsTestsParensSpaces "a" "\"a\""+ , readsTestsParensSpaces testDay "1912-07-08"+ , -- , readsTestsParensSpaces testDay "1912-7-8"+ readsTestsParensSpaces testTimeOfDay "08:04:02"+ -- , readsTestsParensSpaces testTimeOfDay "8:4:2"+ ]+ where+ testDay = fromGregorian 1912 7 8+ testTimeOfDay = TimeOfDay 8 4 2++epoch :: LocalTime+epoch = LocalTime (fromGregorian 1970 0 0) midnight++testReadSTime :: (Show a, Eq a, ParseTime a) => [(a, String)] -> String -> String -> TestTree+testReadSTime expected formatStr target =+ let+ found = readSTime False defaultTimeLocale formatStr target+ result = assertEqual "" expected found+ name = (show formatStr) ++ " of " ++ (show target)+ in+ Test.Tasty.HUnit.testCase name result++simpleFormatTests :: TestTree+simpleFormatTests =+ testGroup+ "simple"+ [ testReadSTime [(epoch, "")] "" ""+ , testReadSTime [(epoch, " ")] "" " "+ , testReadSTime [(epoch, "")] " " " "+ , testReadSTime [(epoch, "")] " " " "+ , testReadSTime [(epoch, "")] "%k" "0"+ , testReadSTime [(epoch, "")] "%k" " 0"+ , testReadSTime [(epoch, "")] "%m" "01"+ , testReadSTime [(epoch, " ")] "%m" "01 "+ , testReadSTime [(epoch, " ")] " %m" " 01 "+ , testReadSTime [(epoch, "")] " %m" " 01"+ , -- https://ghc.haskell.org/trac/ghc/ticket/9150+ testReadSTime [(epoch, "")] " %M" " 00"+ , testReadSTime [(epoch, "")] "%M " "00 "+ , testReadSTime [(epoch, "")] "%Q" ""+ , testReadSTime [(epoch, " ")] "%Q" " "+ , testReadSTime [(epoch, "X")] "%Q" "X"+ , testReadSTime [(epoch, " X")] "%Q" " X"+ , testReadSTime [(epoch, "")] "%Q " " "+ , testReadSTime [(epoch, "")] "%Q X" " X"+ , testReadSTime [(epoch, "")] "%QX" "X"+ ]++spacingForFormatTests :: (Show t, Eq t, ParseTime t) => t -> String -> String -> TestTree+spacingForFormatTests expected formatStr target =+ testGroup+ formatStr+ [ parseTest False (Just expected) formatStr target+ , parseTest True (Just expected) formatStr target+ , parseTest False (Just expected) (formatStr ++ " ") (target ++ " ")+ , parseTest True (Just expected) (formatStr ++ " ") (target ++ " ")+ , parseTest False (Just expected) (" " ++ formatStr) (" " ++ target)+ , parseTest True (Just expected) (" " ++ formatStr) (" " ++ target)+ , parseTest True (Just expected) ("" ++ formatStr) (" " ++ target)+ , parseTest True (Just expected) (" " ++ formatStr) (" " ++ target)+ ]++spacingTests :: TestTree+spacingTests =+ testGroup+ "spacing"+ [ spacingForFormatTests epoch "%Q" ""+ , spacingForFormatTests epoch "%Q" ".0"+ , spacingForFormatTests epoch "%k" " 0"+ , spacingForFormatTests epoch "%M" "00"+ , spacingForFormatTests epoch "%m" "01"+ , spacingForFormatTests (TimeZone 120 False "") "%z" "+0200"+ , spacingForFormatTests (TimeZone 120 False "") "%Z" "+0200"+ , spacingForFormatTests (TimeZone (-480) False "PST") "%Z" "PST"+ ]++particularParseTests :: TestTree+particularParseTests =+ testGroup+ "particular"+ [ parseTest @Day True Nothing "%-d%-m%0Y" "2122012" -- ISSUE #232+ , parseTest @Day True Nothing "%-d%-m%0Y" "2132012" -- ISSUE #232+ ]++badParseTests :: TestTree+badParseTests = testGroup "bad" [parseTest False (Nothing :: Maybe Day) "%Y" ""]++{-+parseYMD :: Day -> TestTree+parseYMD day = case toGregorian day of+ (y, m, d) -> parseTest False (Just day) "%Y%m%d" ((show y) ++ (show2 m) ++ (show2 d))+-}++parseYearDayD :: Day -> TestTree+parseYearDayD day = case toGregorian day of+ (y, m, d) -> parseTest False (Just day) "%Y %m %d" ((show y) ++ " " ++ (show2 m) ++ " " ++ (show2 d))++parseYearDayE :: Day -> TestTree+parseYearDayE day = case toGregorian day of+ (y, m, d) -> parseTest False (Just day) "%Y %-m %e" ((show y) ++ " " ++ (show m) ++ " " ++ (show d))++-- | 1969 - 2068+expectedYear :: Integer -> Integer+expectedYear i | i >= 69 = 1900 + i+expectedYear i = 2000 + i++show2 :: (Show n, Integral n) => n -> String+show2 i = (show (div i 10)) ++ (show (mod i 10))++parseYY :: Integer -> TestTree+parseYY i = parseTest False (Just (fromGregorian (expectedYear i) 1 1)) "%y" (show2 i)++parseCYY :: Integer -> Integer -> TestTree+parseCYY c i = parseTest False (Just (fromGregorian ((c * 100) + i) 1 1)) "%-C %y" ((show c) ++ " " ++ (show2 i))++parseCYY2 :: Integer -> Integer -> TestTree+parseCYY2 c i = parseTest False (Just (fromGregorian ((c * 100) + i) 1 1)) "%C %y" ((show2 c) ++ " " ++ (show2 i))++parseCentury :: String -> Integer -> TestTree+parseCentury int c =+ parseTest False (Just (fromGregorian (c * 100) 1 1)) ("%-C" ++ int ++ "%y") ((show c) ++ int ++ "00")++parseTest :: forall t. (Show t, Eq t, ParseTime t) => Bool -> Maybe t -> String -> String -> TestTree+parseTest sp expected formatStr target =+ let+ found = parse sp formatStr target+ result = assertEqual "" expected found+ name =+ (show formatStr)+ ++ " of "+ ++ (show target)+ ++ ( if sp+ then " allowing spaces"+ else ""+ )+ in+ Test.Tasty.HUnit.testCase name result++enumAdd :: Enum a => Int -> a -> a+enumAdd i a = toEnum (i + fromEnum a)++getMilZoneLetter :: Int -> Char+getMilZoneLetter 0 = 'Z'+getMilZoneLetter h | h < 0 = enumAdd (negate h) 'M'+getMilZoneLetter h | h < 10 = enumAdd (h - 1) 'A'+getMilZoneLetter h = enumAdd (h - 10) 'K'++getMilZone :: Int -> TimeZone+getMilZone hour = TimeZone (hour * 60) False [getMilZoneLetter hour]++testParseTimeZone :: TimeZone -> TestTree+testParseTimeZone tz = parseTest False (Just tz) "%Z" (timeZoneName tz)++defaultTimeZoneTests :: TestTree+defaultTimeZoneTests = testGroup "default time zones" (fmap testParseTimeZone (knownTimeZones defaultTimeLocale))++militaryTimeZoneTests :: TestTree+militaryTimeZoneTests = testGroup "military time zones" (fmap (testParseTimeZone . getMilZone) [-12 .. 12])++-- missing from the time package+instance Eq ZonedTime where+ ZonedTime t1 tz1 == ZonedTime t2 tz2 = t1 == t2 && tz1 == tz2++compareResult' :: (Eq a, Show a) => String -> a -> a -> Result+compareResult' extra expected found+ | expected == found = succeeded+ | otherwise = failed{reason = "expected " ++ (show expected) ++ ", found " ++ (show found) ++ extra}++compareResult :: (Eq a, Show a) => a -> a -> Result+compareResult = compareResult' ""++compareParse ::+ forall a.+ (Eq a, Show a, ParseTime a) =>+ a ->+ String ->+ String ->+ Result+compareParse expected fmt text = compareResult' (", parsing " ++ (show text)) (Just expected) (parse False fmt text)++--++-- * tests for debugging failing cases++--+test_parse_format :: (FormatTime t, ParseTime t, Show t) => String -> t -> (String, String, Maybe t)+test_parse_format f t =+ let+ s = format f t+ in+ (show t, s, parse False f s `asTypeOf` Just t)++--++-- * show and read++--+reads_expect :: a -> [(a, String)]+reads_expect t = [(t, "")]++prop_read_show :: (Read a, Show a, Eq a) => a -> Result+prop_read_show t = compareResult (reads_expect t) (reads (show t))++prop_read_show_ZonedUTC :: ZonedTime -> Result+prop_read_show_ZonedUTC t = compareResult (reads_expect $ zonedTimeToUTC t) (reads (show t))++prop_read_show_LocalUTC :: LocalTime -> Result+prop_read_show_LocalUTC t = compareResult (reads_expect $ localTimeToUTC utc t) (reads (show t))++prop_read_show_UTC_no_TZ :: UTCTime -> Result+prop_read_show_UTC_no_TZ t = compareResult (reads_expect t) $ reads $ show $ utcToLocalTime utc t++--++-- * special show functions++--+prop_parse_showWeekDate :: Day -> Result+prop_parse_showWeekDate d = compareParse d "%G-W%V-%u" (showWeekDate d)++prop_parse_showGregorian :: Day -> Result+prop_parse_showGregorian d = compareParse d "%Y-%m-%d" (showGregorian d)++prop_parse_showOrdinalDate :: Day -> Result+prop_parse_showOrdinalDate d = compareParse d "%Y-%j" (showOrdinalDate d)++--++-- * fromMondayStartWeek and fromSundayStartWeek++--+prop_fromMondayStartWeek :: Day -> Result+prop_fromMondayStartWeek d =+ let+ (w, wd) = mondayStartWeek d+ (y, _, _) = toGregorian d+ in+ compareResult d (fromMondayStartWeek y w wd)++prop_fromSundayStartWeek :: Day -> Result+prop_fromSundayStartWeek d =+ let+ (w, wd) = sundayStartWeek d+ (y, _, _) = toGregorian d+ in+ compareResult d (fromSundayStartWeek y w wd)++-- t == parse (format t)+prop_parse_format :: (Eq t, FormatTime t, ParseTime t, Show t) => FormatString t -> t -> Result+prop_parse_format (FormatString f) t = compareParse t f (format f t)++-- t == parse (upper (format t))+prop_parse_format_upper :: (Eq t, FormatTime t, ParseTime t, Show t) => FormatString t -> t -> Result+prop_parse_format_upper (FormatString f) t = compareParse t f (map toUpper $ format f t)++-- t == parse (lower (format t))+prop_parse_format_lower :: (Eq t, FormatTime t, ParseTime t, Show t) => FormatString t -> t -> Result+prop_parse_format_lower (FormatString f) t = compareParse t f (map toLower $ format f t)++-- Default time is 1970-01-01 00:00:00 +0000 (which was a Thursday)+in1970 :: Maybe String -> Char -> String -> Maybe String+in1970 _ 'j' "366" = Nothing -- 1970 was not a leap year+in1970 _ 'U' "53" = Nothing -- last day of 1970 was Sunday-start-week 52+in1970 _ 'W' "53" = Nothing -- last day of 1970 was Monday-start-week 52+in1970 (Just s) 'S' "60" = Just s -- no leap second without other data+in1970 _ _ s = Just s++-- format t == format (parse (format t))+prop_format_parse_format ::+ forall t.+ (HasFormatCodes t, FormatTime t, ParseTime t) =>+ Proxy t ->+ FormatCode ParseAndFormat t ->+ t ->+ Result+prop_format_parse_format _ fc v =+ let+ s1 = formatCode fc v+ ms1 = in1970 (fmap (formatCode fc) (incompleteS :: Maybe t)) (fcSpecifier fc) s1+ mv2 :: Maybe t+ mv2 = parseCode fc s1+ ms2 = fmap (formatCode fc) mv2+ in+ compareResult ms1 ms2++instance HasFormatCodes Day where+ allFormatCodes _ = [(False, s) | s <- "DFxYyCBbhmdejfVUW"]++instance HasFormatCodes TimeOfDay where+ allFormatCodes _ = [(False, s) | s <- "RTXrPpHkIlMSqQ"]++instance HasFormatCodes DayOfWeek where+ allFormatCodes _ = [(False, s) | s <- "uwaA"]++instance HasFormatCodes Month where+ allFormatCodes _ = [(False, s) | s <- "YyCBbhm"]++instance HasFormatCodes QuarterOfYear where+ allFormatCodes _ = [(False, s) | s <- "v"]++instance HasFormatCodes Quarter where+ allFormatCodes _ = allFormatCodes (Proxy :: Proxy QuarterOfYear) ++ [(False, s) | s <- "YyC"]++instance HasFormatCodes LocalTime where+ allFormatCodes _ = allFormatCodes (Proxy :: Proxy Day) ++ allFormatCodes (Proxy :: Proxy TimeOfDay)++instance HasFormatCodes TimeZone where+ allFormatCodes _ = [(a, s) | a <- [False, True], s <- "zZ"]++instance HasFormatCodes ZonedTime where+ allFormatCodes _ =+ [(False, s) | s <- "cs"]+ ++ allFormatCodes (Proxy :: Proxy LocalTime)+ ++ allFormatCodes (Proxy :: Proxy TimeZone)++instance HasFormatCodes UTCTime where+ allFormatCodes _ = [(False, s) | s <- "cs"] ++ allFormatCodes (Proxy :: Proxy LocalTime)+ incompleteS = Just $ UTCTime (fromGregorian 2000 1 1) 0++instance HasFormatCodes UniversalTime where+ allFormatCodes _ = allFormatCodes (Proxy :: Proxy LocalTime)++--++-- * crashes in parse++--+newtype Input+ = Input String++instance Show Input where+ show (Input s) = s++instance Arbitrary Input where+ arbitrary = liftM Input $ list cs+ where+ cs = elements (['0' .. '9'] ++ ['-', ' ', '/'] ++ ['a' .. 'z'] ++ ['A' .. 'Z'])+ list g = sized (\n -> choose (0, n) >>= \l -> replicateM l g)++instance CoArbitrary Input where+ coarbitrary (Input s) = coarbitrary (sum (map ord s))++prop_no_crash_bad_input :: (Eq t, ParseTime t) => FormatString t -> Input -> Property+prop_no_crash_bad_input fs@(FormatString f) (Input s) =+ property $+ case parse False f s of+ Nothing -> True+ Just t -> t == t `asTypeOf` formatType fs++--+--+--+newtype FormatString a+ = FormatString String++formatType :: FormatString t -> t+formatType _ = undefined++instance Show (FormatString a) where+ show (FormatString f) = show f++typedTests :: (forall t. (Eq t, FormatTime t, ParseTime t, Show t) => FormatString t -> t -> Result) -> [TestTree]+typedTests prop =+ [ nameTest "Day" $ tgroup dayFormats prop+ , nameTest "Month" $ tgroup monthFormats prop+ , nameTest "Quarter" $ tgroup quarterFormats prop+ , nameTest "TimeOfDay" $ tgroup timeOfDayFormats prop+ , nameTest "LocalTime" $ tgroup localTimeFormats prop+ , nameTest "TimeZone" $ tgroup timeZoneFormats prop+ , nameTest "ZonedTime" $ tgroup zonedTimeFormats prop+ , nameTest "ZonedTime" $+ tgroup zonedTimeAlmostFormats $+ \fmt t -> (todSec $ localTimeOfDay $ zonedTimeToLocalTime t) < 60 ==> prop fmt t+ , nameTest "UTCTime" $ tgroup utcTimeAlmostFormats $ \fmt t -> utctDayTime t < 86400 ==> prop fmt t+ , nameTest "UniversalTime" $ tgroup universalTimeFormats prop+ , nameTest "CalendarDiffDays" $ tgroup calendarDiffDaysFormats prop+ , nameTest "CalendarDiffTime" $ tgroup calendarDiffTimeFormats prop+ , nameTest "DiffTime" $ tgroup diffTimeFormats prop+ , nameTest "NominalDiffTime" $ tgroup nominalDiffTimeFormats prop+ ]++allTypes ::+ (forall t. (Eq t, Show t, Arbitrary t, FormatTime t, ParseTime t, HasFormatCodes t) => String -> Proxy t -> r) ->+ [r]+allTypes f =+ [ f "Day" (Proxy :: Proxy Day)+ , f "TimeOfDay" (Proxy :: Proxy TimeOfDay)+ , f "DayOfWeek" (Proxy :: Proxy DayOfWeek)+ , f "Month" (Proxy :: Proxy Month)+ , f "QuarterOfYear" (Proxy :: Proxy QuarterOfYear)+ , f "Quarter" (Proxy :: Proxy Quarter)+ , f "LocalTime" (Proxy :: Proxy LocalTime)+ , f "TimeZone" (Proxy :: Proxy TimeZone)+ , f "ZonedTime" (Proxy :: Proxy ZonedTime)+ , f "UTCTime" (Proxy :: Proxy UTCTime)+ , f "UniversalTime" (Proxy :: Proxy UniversalTime)+ ]++allLeapSecondTypes ::+ (forall t. (Eq t, Show t, Arbitrary t, FormatTime t, ParseTime t, HasFormatCodes t) => String -> t -> r) ->+ [r]+allLeapSecondTypes f =+ let+ day :: Day+ day = fromGregorian 2000 01 01+ lsTimeOfDay :: TimeOfDay+ lsTimeOfDay = TimeOfDay 23 59 60.5+ lsLocalTime :: LocalTime+ lsLocalTime = LocalTime day lsTimeOfDay+ lsZonedTime :: ZonedTime+ lsZonedTime = ZonedTime lsLocalTime utc+ lsUTCTime :: UTCTime+ lsUTCTime = UTCTime day 86400.5+ in+ [ f "TimeOfDay" lsTimeOfDay+ , f "LocalTime" lsLocalTime+ , f "ZonedTime" lsZonedTime+ , f "UTCTime" lsUTCTime+ ]++parseEmptyTest ::+ forall t.+ ParseTime t =>+ Proxy t ->+ Assertion+parseEmptyTest _ =+ case parse False "" "" :: Maybe t of+ Just _ -> return ()+ Nothing -> assertFailure "failed"++parseEmptyTests :: TestTree+parseEmptyTests = nameTest "parse empty" $ allTypes $ \name p -> nameTest name $ parseEmptyTest p++class (Eq a, Show a, ParseTime a) => TestParse a where+ nonPosixValue :: a -> Bool+ nonPosixValue _ = False++instance TestParse UTCTime where+ nonPosixValue (UTCTime _ dt) = dt >= 86400 || dt < 0++instance TestParse ZonedTime where+ nonPosixValue (ZonedTime t _) = nonPosixValue t++instance TestParse TimeZone++instance TestParse LocalTime where+ nonPosixValue (LocalTime _ t) = nonPosixValue t++instance TestParse Day++instance TestParse Month++instance TestParse DayOfWeek++instance TestParse TimeOfDay where+ nonPosixValue (TimeOfDay _ _ s) = s >= 60 || s < 0++prop_parse_s :: forall a. TestParse a => (UTCTime -> a) -> UTCTime -> Result+prop_parse_s f t =+ if nonPosixValue t+ then succeeded+ else+ let+ str = format "%s%Q" t+ found = parse False "%s%Q" str+ expected = f t+ in+ compareResult (Just expected) found++prop_parse_sz :: forall a. TestParse a => (ZonedTime -> a) -> ZonedTime -> Result+prop_parse_sz f t =+ if nonPosixValue t+ then succeeded+ else+ let+ str = format "%s%Q %z" t+ found = parse False "%s%Q %z" str+ expected = f t+ in+ compareResult (Just expected) found++zeroTimeZone :: TimeZone+zeroTimeZone = TimeZone 0 False ""++parse_s_tests :: TestTree+parse_s_tests =+ nameTest+ "parse_s"+ [ nameTest "UTCTime" $ prop_parse_s @UTCTime id+ , nameTest "ZonedTime" $ prop_parse_s @ZonedTime $ utcToZonedTime zeroTimeZone+ , nameTest "TimeZone" $ prop_parse_s @TimeZone $ \_ -> zeroTimeZone+ , nameTest "LocalTime" $ prop_parse_s @LocalTime $ utcToLocalTime zeroTimeZone+ , nameTest "Day" $ prop_parse_s @Day utctDay+ , nameTest "Month" $ prop_parse_s @Month $ (\(MonthDay m _) -> m) . utctDay+ , nameTest "DayOfWeek" $ prop_parse_s @DayOfWeek $ dayOfWeek . utctDay+ , nameTest "TimeOfDay" $ prop_parse_s @TimeOfDay $ localTimeOfDay . utcToLocalTime zeroTimeZone+ ]++parse_sz_tests :: TestTree+parse_sz_tests =+ nameTest+ "parse_sz"+ [ nameTest "UTCTime" $ prop_parse_sz @UTCTime zonedTimeToUTC+ , nameTest "ZonedTime" $ prop_parse_sz @ZonedTime id+ , nameTest "TimeZone" $ prop_parse_sz @TimeZone zonedTimeZone+ , nameTest "LocalTime" $ prop_parse_sz @LocalTime zonedTimeToLocalTime+ , nameTest "Day" $ prop_parse_sz @Day $ localDay . zonedTimeToLocalTime+ , nameTest "Month" $ prop_parse_sz @Month $ (\(MonthDay m _) -> m) . localDay . zonedTimeToLocalTime+ , nameTest "DayOfWeek" $ prop_parse_sz @DayOfWeek $ dayOfWeek . localDay . zonedTimeToLocalTime+ , nameTest "TimeOfDay" $ prop_parse_sz @TimeOfDay $ localTimeOfDay . zonedTimeToLocalTime+ ]++formatParseFormatTests :: TestTree+formatParseFormatTests =+ nameTest+ "format_parse_format"+ [ localOption (QuickCheckTests 50000) $+ nameTest "general" $+ allTypes $+ \name p -> nameTest name $ prop_format_parse_format p+ , nameTest "#177" $+ [ nameTest "start" $ \fc -> prop_format_parse_format Proxy fc (fst supportedDayRange)+ , nameTest "end" $ \fc -> prop_format_parse_format Proxy fc (snd supportedDayRange)+ ]+ , nameTest "leapsecond" $ allLeapSecondTypes $ \name t -> nameTest name $ \fc -> prop_format_parse_format Proxy fc t+ ]++badInputTests :: TestTree+badInputTests =+ nameTest+ "no_crash_bad_input"+ [ nameTest "Day" $ tgroup (dayFormats ++ partialDayFormats ++ failingPartialDayFormats) prop_no_crash_bad_input+ , nameTest "TimeOfDay" $ tgroup (timeOfDayFormats ++ partialTimeOfDayFormats) prop_no_crash_bad_input+ , nameTest "LocalTime" $ tgroup (localTimeFormats ++ partialLocalTimeFormats) prop_no_crash_bad_input+ , nameTest "TimeZone" $ tgroup (timeZoneFormats) prop_no_crash_bad_input+ , nameTest "ZonedTime" $+ tgroup (zonedTimeFormats ++ zonedTimeAlmostFormats ++ partialZonedTimeFormats) prop_no_crash_bad_input+ , nameTest "UTCTime" $ tgroup (utcTimeAlmostFormats ++ partialUTCTimeFormats) prop_no_crash_bad_input+ , nameTest "UniversalTime" $+ tgroup (universalTimeFormats ++ partialUniversalTimeFormats) prop_no_crash_bad_input+ ]++readShowTests :: TestTree+readShowTests =+ nameTest+ "read_show"+ [ nameTest "Day" (prop_read_show :: Day -> Result)+ , nameTest "Month" (prop_read_show :: Month -> Result)+ , nameTest "QuarterOfYear" (prop_read_show :: QuarterOfYear -> Result)+ , nameTest "Quarter" (prop_read_show :: Quarter -> Result)+ , nameTest "TimeOfDay" (prop_read_show :: TimeOfDay -> Result)+ , nameTest "LocalTime" (prop_read_show :: LocalTime -> Result)+ , nameTest "TimeZone" (prop_read_show :: TimeZone -> Result)+ , nameTest "ZonedTime" (prop_read_show :: ZonedTime -> Result)+ , nameTest "UTCTime" (prop_read_show :: UTCTime -> Result)+ , nameTest "UTCTime (zoned)" prop_read_show_ZonedUTC+ , nameTest "UTCTime (local)" prop_read_show_LocalUTC+ , nameTest "UTCTime (no TZ)" prop_read_show_UTC_no_TZ+ , nameTest "UniversalTime" (prop_read_show :: UniversalTime -> Result)+ , nameTest "NominalDiffTime" (prop_read_show :: NominalDiffTime -> Result)+ , nameTest "DiffTime" (prop_read_show :: DiffTime -> Result)+ , nameTest "CalendarDiffDays" (prop_read_show :: CalendarDiffDays -> Result)+ , nameTest "CalendarDiffTime" (prop_read_show :: CalendarDiffTime -> Result)+ ]++parseShowTests :: TestTree+parseShowTests =+ nameTest+ "parse_show"+ [ nameTest "showWeekDate" prop_parse_showWeekDate+ , nameTest "showGregorian" prop_parse_showGregorian+ , nameTest "showOrdinalDate" prop_parse_showOrdinalDate+ ]++propertyTests :: TestTree+propertyTests =+ localOption (QuickCheckTests 2000) $+ nameTest+ "properties"+ [ readShowTests+ , parseShowTests+ , nameTest "fromMondayStartWeek" prop_fromMondayStartWeek+ , nameTest "fromSundayStartWeek" prop_fromSundayStartWeek+ , nameTest "parse_format" $ typedTests prop_parse_format+ , nameTest "parse_format_lower" $ typedTests prop_parse_format_lower+ , nameTest "parse_format_upper" $ typedTests prop_parse_format_upper+ , parseEmptyTests+ , parse_s_tests+ , parse_sz_tests+ , formatParseFormatTests+ , badInputTests+ ]++dayFormats :: [FormatString Day]+dayFormats =+ map+ FormatString+ -- numeric year, month, day+ [ "%Y-%m-%d"+ , "%Y%m%d"+ , "%C%y%m%d"+ , "%Y %m %e"+ , "%m/%d/%Y"+ , "%d/%m/%Y"+ , "%Y/%d/%m"+ , "%D %C"+ , "%F"+ , -- month names+ "%Y-%B-%d"+ , "%Y-%b-%d"+ , "%Y-%h-%d"+ , "%C-%y-%B-%d"+ , "%C-%y-%b-%d"+ , "%C-%y-%h-%d"+ , -- ordinal dates+ "%Y-%j"+ , "%C-%y-%j"+ , -- ISO week dates+ "%G-%V-%u"+ , "%G-%V-%a"+ , "%G-%V-%A"+ , "%G-%V-%w"+ , "%A week %V, %G"+ , "day %V, week %A, %G"+ , "%G-W%V-%u"+ , "%f%g-%V-%u"+ , "%f%g-%V-%a"+ , "%f%g-%V-%A"+ , "%f%g-%V-%w"+ , "%A week %V, %f%g"+ , "day %V, week %A, %f%g"+ , "%f%g-W%V-%u"+ , -- monday and sunday week dates+ "%Y-w%U-%A"+ , "%Y-w%W-%A"+ , "%Y-%A-w%U"+ , "%Y-%A-w%W"+ , "%A week %U, %Y"+ , "%A week %W, %Y"+ ]++monthFormats :: [FormatString Month]+monthFormats =+ map+ FormatString+ -- numeric year, month+ [ "%Y-%m"+ , "%Y%m"+ , "%C%y%m"+ , "%Y %m"+ , "%m/%Y"+ , "%m/%Y"+ , "%Y/%m"+ , "%C %y %m"+ , -- month names+ "%Y-%B"+ , "%Y-%b"+ , "%Y-%h"+ , "%C-%y-%B"+ , "%C-%y-%b"+ , "%C-%y-%h"+ ]++quarterFormats :: [FormatString Quarter]+quarterFormats =+ map+ FormatString+ -- numeric year, quarter+ [ "%Y-%v"+ , "%Y-Q%v"+ , "%YQ%v"+ , "%C%y%v"+ , "%Y %v"+ , "%v/%Y"+ , "%v/%Y"+ , "%Y/%vm"+ , "%C %y %v"+ ]++timeOfDayFormats :: [FormatString TimeOfDay]+timeOfDayFormats =+ map+ FormatString+ -- 24 h formats+ [ "%H:%M:%S.%q"+ , "%k:%M:%S.%q"+ , "%H%M%S.%q"+ , "%T.%q"+ , "%X.%q"+ , "%R:%S.%q"+ , "%H:%M:%S%Q"+ , "%k:%M:%S%Q"+ , "%H%M%S%Q"+ , "%T%Q"+ , "%X%Q"+ , "%R:%S%Q"+ , -- 12 h formats+ "%I:%M:%S.%q %p"+ , "%I:%M:%S.%q %P"+ , "%l:%M:%S.%q %p"+ , "%r %q"+ , "%I:%M:%S%Q %p"+ , "%I:%M:%S%Q %P"+ , "%l:%M:%S%Q %p"+ , "%r %Q"+ ]++localTimeFormats :: [FormatString LocalTime]+localTimeFormats = map FormatString [] {-"%Q","%Q ","%QX"-}++timeZoneFormats :: [FormatString TimeZone]+timeZoneFormats = map FormatString ["%z", "%z%Z", "%Z%z", "%Z", "%Ez", "%EZ"]++zonedTimeFormats :: [FormatString ZonedTime]+zonedTimeFormats =+ map+ FormatString+ [ "%a, %d %b %Y %H:%M:%S.%q %z"+ , "%a, %d %b %Y %H:%M:%S%Q %z"+ , "%a, %d %b %Y %H:%M:%S.%q %Z"+ , "%a, %d %b %Y %H:%M:%S%Q %Z"+ ]++zonedTimeAlmostFormats :: [FormatString ZonedTime]+zonedTimeAlmostFormats = map FormatString ["%s.%q %z", "%s%Q %z", "%s.%q %Z", "%s%Q %Z"]++utcTimeAlmostFormats :: [FormatString UTCTime]+utcTimeAlmostFormats = map FormatString ["%s.%q", "%s%Q"]++universalTimeFormats :: [FormatString UniversalTime]+universalTimeFormats = map FormatString []++calendarDiffDaysFormats :: [FormatString CalendarDiffDays]+calendarDiffDaysFormats = map FormatString ["%yy%Bm%ww%Dd", "%yy%Bm%dd", "%bm%ww%Dd", "%bm%dd"]++calendarDiffTimeFormats :: [FormatString CalendarDiffTime]+calendarDiffTimeFormats =+ map+ FormatString+ [ "%yy%Bm%ww%Dd%Hh%Mm%ESs"+ , "%bm%ww%Dd%Hh%Mm%ESs"+ , "%bm%dd%Hh%Mm%ESs"+ , "%bm%hh%Mm%ESs"+ , "%bm%mm%ESs"+ , "%bm%mm%0ESs"+ , "%bm%Ess"+ , "%bm%0Ess"+ ]++diffTimeFormats :: [FormatString DiffTime]+diffTimeFormats =+ map FormatString ["%ww%Dd%Hh%Mm%ESs", "%dd%Hh%Mm%ESs", "%hh%Mm%ESs", "%mm%ESs", "%mm%0ESs", "%Ess", "%0Ess"]++nominalDiffTimeFormats :: [FormatString NominalDiffTime]+nominalDiffTimeFormats =+ map FormatString ["%ww%Dd%Hh%Mm%ESs", "%dd%Hh%Mm%ESs", "%hh%Mm%ESs", "%mm%ESs", "%mm%0ESs", "%Ess", "%0Ess"]++--++-- * Formats that do not include all the information++--+partialDayFormats :: [FormatString Day]+partialDayFormats = map FormatString []++partialTimeOfDayFormats :: [FormatString TimeOfDay]+partialTimeOfDayFormats = map FormatString ["%H", "%M", "%S", "%H:%M"]++partialLocalTimeFormats :: [FormatString LocalTime]+partialLocalTimeFormats = map FormatString []++partialZonedTimeFormats :: [FormatString ZonedTime]+partialZonedTimeFormats =+ map+ FormatString+ -- %s does not include second decimals+ [ "%s %z"+ , -- %S does not include second decimals+ "%c"+ , "%a, %d %b %Y %H:%M:%S %Z"+ ]++partialUTCTimeFormats :: [FormatString UTCTime]+partialUTCTimeFormats =+ map+ FormatString+ -- %s does not include second decimals+ [ "%s"+ , -- %c does not include second decimals+ "%c"+ ]++partialUniversalTimeFormats :: [FormatString UniversalTime]+partialUniversalTimeFormats = map FormatString []++failingPartialDayFormats :: [FormatString Day]+failingPartialDayFormats =+ map+ FormatString+ -- ISO week dates with two digit year.+ -- This can fail in the beginning or the end of a year where+ -- the ISO week date year does not match the gregorian year.+ ["%g-%V-%u", "%g-%V-%a", "%g-%V-%A", "%g-%V-%w", "%A week %V, %g", "day %V, week %A, %g", "%g-W%V-%u"]
+ test/main/Test/LocalTime/CalendarDiffTime.hs view
@@ -0,0 +1,121 @@+module Test.LocalTime.CalendarDiffTime (+ testCalendarDiffTime,+) where++import Data.Fixed+import Data.Time+import Test.AddDiff+import Test.Arbitrary ()+import Test.Tasty+import Test.Tasty.HUnit+import Test.TestUtil++utcClip :: AddDiff CalendarDiffTime UTCTime+utcClip = MkAddDiff "utcClip" addUTCDurationClip diffUTCDurationClip++utcRollOver :: AddDiff CalendarDiffTime UTCTime+utcRollOver = MkAddDiff "utcRollOver" addUTCDurationRollOver diffUTCDurationRollOver++localClip :: AddDiff CalendarDiffTime LocalTime+localClip = MkAddDiff "localClip" addLocalDurationClip diffLocalDurationClip++localRollOver :: AddDiff CalendarDiffTime LocalTime+localRollOver = MkAddDiff "localRollOver" addLocalDurationRollOver diffLocalDurationRollOver++testAddDiffs :: TestTree+testAddDiffs =+ testGroup+ "add-diff"+ [ testGroup "UTC" $ fmap testAddDiff [utcClip, utcRollOver]+ , testGroup "LocalTime" $ fmap testAddDiff [localClip, localRollOver]+ ]++utcTime :: Integer -> Int -> Int -> DiffTime -> UTCTime+utcTime y m d = UTCTime (YearMonthDay y m d)++localTime :: Integer -> Int -> Int -> Int -> Int -> Pico -> LocalTime+localTime y m d h minute s = LocalTime (YearMonthDay y m d) $ TimeOfDay h minute s++testSpecifics :: TestTree+testSpecifics =+ testGroup+ "specific"+ [ testGroup+ "add"+ [ testCase "UTC clip" $+ assertEqual+ "Jan 31 + 1 month clips to Feb 28"+ (utcTime 2001 2 28 0)+ (addUTCDurationClip (CalendarDiffTime 1 0) $ utcTime 2001 1 31 0)+ , testCase "UTC rollover" $+ assertEqual+ "Jan 31 + 1 month rolls over to Mar 3"+ (utcTime 2001 3 3 0)+ (addUTCDurationRollOver (CalendarDiffTime 1 0) $ utcTime 2001 1 31 0)+ , testCase "LocalTime clip" $+ assertEqual+ "Jan 31 + 1 month clips to Feb 28"+ (localTime 2001 2 28 0 0 0)+ (addLocalDurationClip (CalendarDiffTime 1 0) $ localTime 2001 1 31 0 0 0)+ , testCase "LocalTime rollover" $+ assertEqual+ "Jan 31 + 1 month rolls over to Mar 3"+ (localTime 2001 3 3 0 0 0)+ (addLocalDurationRollOver (CalendarDiffTime 1 0) $ localTime 2001 1 31 0 0 0)+ , testCase "time part" $+ assertEqual+ "the time part can carry into the next day"+ (localTime 2001 2 1 0 0 1)+ (addLocalDurationClip (CalendarDiffTime 0 2) $ localTime 2001 1 31 23 59 59)+ ]+ , testGroup+ "diff"+ [ testCase "UTC clip" $+ assertEqual+ "Mar 1 - Jan 30 clips as 1 month and 1 day"+ (CalendarDiffTime 1 nominalDay)+ (diffUTCDurationClip (utcTime 2001 3 1 0) $ utcTime 2001 1 30 0)+ , testCase "UTC rollover" $+ assertEqual+ "Mar 1 - Jan 30 rolls over as 30 days"+ (CalendarDiffTime 0 $ 30 * nominalDay)+ (diffUTCDurationRollOver (utcTime 2001 3 1 0) $ utcTime 2001 1 30 0)+ , testCase "LocalTime clip" $+ assertEqual+ "Mar 1 - Jan 30 clips as 1 month and 1 day"+ (CalendarDiffTime 1 nominalDay)+ (diffLocalDurationClip (localTime 2001 3 1 0 0 0) $ localTime 2001 1 30 0 0 0)+ , testCase "LocalTime rollover" $+ assertEqual+ "Mar 1 - Jan 30 rolls over as 30 days"+ (CalendarDiffTime 0 $ 30 * nominalDay)+ (diffLocalDurationRollOver (localTime 2001 3 1 0 0 0) $ localTime 2001 1 30 0 0 0)+ ]+ ]++testReadShowExact :: (Read a, Show a, Eq a) => String -> a -> TestTree+testReadShowExact t v =+ nameTest+ t+ [ nameTest "show" $ assertEqual "show" t $ show v+ , nameTest "read" $ assertEqual "read" v $ read t+ ]++testCalendarDiffTime :: TestTree+testCalendarDiffTime =+ nameTest+ "CalendarDiffTime"+ [ testReadShowExact "P0D" $ CalendarDiffTime 0 0+ , testReadShowExact "P1DT1S" $ CalendarDiffTime 0 $ secondsToNominalDiffTime 86401+ , testReadShowExact "P-1DT1S" $ CalendarDiffTime 0 $ secondsToNominalDiffTime $ negate 86399+ , testReadShowExact "P-1D" $ CalendarDiffTime 0 $ secondsToNominalDiffTime $ negate 86400+ , testReadShowExact "P-2DT23H59M59S" $ CalendarDiffTime 0 $ secondsToNominalDiffTime $ negate 86401+ , testReadShowExact "P1M-1DT1S" $ CalendarDiffTime 1 $ secondsToNominalDiffTime $ negate 86399+ , testReadShowExact "P1M-1D" $ CalendarDiffTime 1 $ secondsToNominalDiffTime $ negate 86400+ , testReadShowExact "P1M-2DT23H59M59S" $ CalendarDiffTime 1 $ secondsToNominalDiffTime $ negate 86401+ , testReadShowExact "P-1Y-1M-1DT1S" $ CalendarDiffTime (-13) $ secondsToNominalDiffTime $ negate 86399+ , testReadShowExact "P-1Y-1M-1D" $ CalendarDiffTime (-13) $ secondsToNominalDiffTime $ negate 86400+ , testReadShowExact "P-1Y-1M-2DT23H59M59S" $ CalendarDiffTime (-13) $ secondsToNominalDiffTime $ negate 86401+ , testAddDiffs+ , testSpecifics+ ]
+ test/main/Test/LocalTime/Time.hs view
@@ -0,0 +1,109 @@+module Test.LocalTime.Time (+ testTime,+) where++import Data.Time+import Data.Time.Calendar.OrdinalDate+import Data.Time.Calendar.WeekDate+import Test.LocalTime.TimeRef+import Test.Tasty+import Test.Tasty.HUnit++showCal :: Integer -> String+showCal mjd =+ let+ date = ModifiedJulianDay mjd+ (y, m, d) = toGregorian date+ date' = fromGregorian y m d+ in+ concat+ [ show mjd ++ "=" ++ showGregorian date ++ "=" ++ showOrdinalDate date ++ "=" ++ showWeekDate date ++ "\n"+ , if date == date'+ then ""+ else "=" ++ (show $ toModifiedJulianDay date') ++ "!"+ ]++testCal :: String+testCal =+ concat+ -- days around 1 BCE/1 CE+ [ concatMap showCal [-678950 .. -678930]+ , -- days around 1000 CE+ concatMap showCal [-313710 .. -313690]+ , -- days around MJD zero+ concatMap showCal [-30 .. 30]+ , showCal 40000+ , showCal 50000+ , -- 1900 not a leap year+ showCal 15078+ , showCal 15079+ , -- 1980 is a leap year+ showCal 44297+ , showCal 44298+ , showCal 44299+ , -- 1990 not a leap year+ showCal 47950+ , showCal 47951+ , -- 2000 is a leap year+ showCal 51602+ , showCal 51603+ , showCal 51604+ , -- years 2000 and 2001, plus some slop+ concatMap showCal [51540 .. 52280]+ ]++showUTCTime :: UTCTime -> String+showUTCTime (UTCTime d t) = show (toModifiedJulianDay d) ++ "," ++ show t++myzone :: TimeZone+myzone = hoursToTimeZone (-8)++leapSec1998Cal :: LocalTime+leapSec1998Cal = LocalTime (fromGregorian 1998 12 31) (TimeOfDay 23 59 60.5)++leapSec1998 :: UTCTime+leapSec1998 = localTimeToUTC utc leapSec1998Cal++testUTC :: String+testUTC =+ let+ lsMineCal = utcToLocalTime myzone leapSec1998+ lsMine = localTimeToUTC myzone lsMineCal+ in+ unlines [showCal 51178, show leapSec1998Cal, showUTCTime leapSec1998, show lsMineCal, showUTCTime lsMine]++neglong :: Rational+neglong = -120++poslong :: Rational+poslong = 120++testUT1 :: String+testUT1 =+ unlines+ [ show $ ut1ToLocalTime 0 $ ModJulianDate 51604.0+ , show $ ut1ToLocalTime 0 $ ModJulianDate 51604.5+ , show $ ut1ToLocalTime neglong $ ModJulianDate 51604.0+ , show $ ut1ToLocalTime neglong $ ModJulianDate 51604.5+ , show $ ut1ToLocalTime poslong $ ModJulianDate 51604.0+ , show $ ut1ToLocalTime poslong $ ModJulianDate 51604.5+ ]++testTimeOfDayToDayFraction :: String+testTimeOfDayToDayFraction =+ let+ f = dayFractionToTimeOfDay . timeOfDayToDayFraction+ in+ unlines+ [ show $ f $ TimeOfDay 12 34 56.789+ , show $ f $ TimeOfDay 12 34 56.789123+ , show $ f $ TimeOfDay 12 34 56.789123456+ , show $ f $ TimeOfDay 12 34 56.789123456789+ , show $ f $ TimeOfDay minBound 0 0+ ]++testTime :: TestTree+testTime =+ testCase "testTime" $+ assertEqual "times" testTimeRef $+ unlines [testCal, testUTC, testUT1, testTimeOfDayToDayFraction]
+ test/main/Test/LocalTime/TimeOfDay.hs view
@@ -0,0 +1,26 @@+module Test.LocalTime.TimeOfDay (+ testTimeOfDay,+) where++import Data.Time.LocalTime+import Test.Arbitrary ()+import Test.Tasty+import Test.Tasty.QuickCheck hiding (reason)++testTimeOfDay :: TestTree+testTimeOfDay =+ testGroup+ "TimeOfDay"+ [ testProperty "daysAndTimeOfDayToTime . timeToDaysAndTimeOfDay" $ \ndt ->+ let+ (d, tod) = timeToDaysAndTimeOfDay ndt+ ndt' = daysAndTimeOfDayToTime d tod+ in+ ndt' == ndt+ , testProperty "timeOfDayToTime . timeToTimeOfDay" $ \dt ->+ let+ tod = timeToTimeOfDay dt+ dt' = timeOfDayToTime tod+ in+ dt' == dt+ ]
+ test/main/Test/LocalTime/TimeRef.hs view
@@ -0,0 +1,896 @@+module Test.LocalTime.TimeRef where++import Data.Int++is64Bit :: Bool+is64Bit =+ if toInteger (maxBound :: Int) == toInteger (maxBound :: Int32)+ then False+ else+ if toInteger (maxBound :: Int) == toInteger (maxBound :: Int64)+ then True+ else error "unrecognised Int size"++testTimeRef :: String+testTimeRef =+ unlines+ [ "-678950=-0001-12-23=-0001-357=-0001-W51-4"+ , "-678949=-0001-12-24=-0001-358=-0001-W51-5"+ , "-678948=-0001-12-25=-0001-359=-0001-W51-6"+ , "-678947=-0001-12-26=-0001-360=-0001-W51-7"+ , "-678946=-0001-12-27=-0001-361=-0001-W52-1"+ , "-678945=-0001-12-28=-0001-362=-0001-W52-2"+ , "-678944=-0001-12-29=-0001-363=-0001-W52-3"+ , "-678943=-0001-12-30=-0001-364=-0001-W52-4"+ , "-678942=-0001-12-31=-0001-365=-0001-W52-5"+ , "-678941=0000-01-01=0000-001=-0001-W52-6"+ , "-678940=0000-01-02=0000-002=-0001-W52-7"+ , "-678939=0000-01-03=0000-003=0000-W01-1"+ , "-678938=0000-01-04=0000-004=0000-W01-2"+ , "-678937=0000-01-05=0000-005=0000-W01-3"+ , "-678936=0000-01-06=0000-006=0000-W01-4"+ , "-678935=0000-01-07=0000-007=0000-W01-5"+ , "-678934=0000-01-08=0000-008=0000-W01-6"+ , "-678933=0000-01-09=0000-009=0000-W01-7"+ , "-678932=0000-01-10=0000-010=0000-W02-1"+ , "-678931=0000-01-11=0000-011=0000-W02-2"+ , "-678930=0000-01-12=0000-012=0000-W02-3"+ , "-313710=0999-12-20=0999-354=0999-W51-5"+ , "-313709=0999-12-21=0999-355=0999-W51-6"+ , "-313708=0999-12-22=0999-356=0999-W51-7"+ , "-313707=0999-12-23=0999-357=0999-W52-1"+ , "-313706=0999-12-24=0999-358=0999-W52-2"+ , "-313705=0999-12-25=0999-359=0999-W52-3"+ , "-313704=0999-12-26=0999-360=0999-W52-4"+ , "-313703=0999-12-27=0999-361=0999-W52-5"+ , "-313702=0999-12-28=0999-362=0999-W52-6"+ , "-313701=0999-12-29=0999-363=0999-W52-7"+ , "-313700=0999-12-30=0999-364=1000-W01-1"+ , "-313699=0999-12-31=0999-365=1000-W01-2"+ , "-313698=1000-01-01=1000-001=1000-W01-3"+ , "-313697=1000-01-02=1000-002=1000-W01-4"+ , "-313696=1000-01-03=1000-003=1000-W01-5"+ , "-313695=1000-01-04=1000-004=1000-W01-6"+ , "-313694=1000-01-05=1000-005=1000-W01-7"+ , "-313693=1000-01-06=1000-006=1000-W02-1"+ , "-313692=1000-01-07=1000-007=1000-W02-2"+ , "-313691=1000-01-08=1000-008=1000-W02-3"+ , "-313690=1000-01-09=1000-009=1000-W02-4"+ , "-30=1858-10-18=1858-291=1858-W42-1"+ , "-29=1858-10-19=1858-292=1858-W42-2"+ , "-28=1858-10-20=1858-293=1858-W42-3"+ , "-27=1858-10-21=1858-294=1858-W42-4"+ , "-26=1858-10-22=1858-295=1858-W42-5"+ , "-25=1858-10-23=1858-296=1858-W42-6"+ , "-24=1858-10-24=1858-297=1858-W42-7"+ , "-23=1858-10-25=1858-298=1858-W43-1"+ , "-22=1858-10-26=1858-299=1858-W43-2"+ , "-21=1858-10-27=1858-300=1858-W43-3"+ , "-20=1858-10-28=1858-301=1858-W43-4"+ , "-19=1858-10-29=1858-302=1858-W43-5"+ , "-18=1858-10-30=1858-303=1858-W43-6"+ , "-17=1858-10-31=1858-304=1858-W43-7"+ , "-16=1858-11-01=1858-305=1858-W44-1"+ , "-15=1858-11-02=1858-306=1858-W44-2"+ , "-14=1858-11-03=1858-307=1858-W44-3"+ , "-13=1858-11-04=1858-308=1858-W44-4"+ , "-12=1858-11-05=1858-309=1858-W44-5"+ , "-11=1858-11-06=1858-310=1858-W44-6"+ , "-10=1858-11-07=1858-311=1858-W44-7"+ , "-9=1858-11-08=1858-312=1858-W45-1"+ , "-8=1858-11-09=1858-313=1858-W45-2"+ , "-7=1858-11-10=1858-314=1858-W45-3"+ , "-6=1858-11-11=1858-315=1858-W45-4"+ , "-5=1858-11-12=1858-316=1858-W45-5"+ , "-4=1858-11-13=1858-317=1858-W45-6"+ , "-3=1858-11-14=1858-318=1858-W45-7"+ , "-2=1858-11-15=1858-319=1858-W46-1"+ , "-1=1858-11-16=1858-320=1858-W46-2"+ , "0=1858-11-17=1858-321=1858-W46-3"+ , "1=1858-11-18=1858-322=1858-W46-4"+ , "2=1858-11-19=1858-323=1858-W46-5"+ , "3=1858-11-20=1858-324=1858-W46-6"+ , "4=1858-11-21=1858-325=1858-W46-7"+ , "5=1858-11-22=1858-326=1858-W47-1"+ , "6=1858-11-23=1858-327=1858-W47-2"+ , "7=1858-11-24=1858-328=1858-W47-3"+ , "8=1858-11-25=1858-329=1858-W47-4"+ , "9=1858-11-26=1858-330=1858-W47-5"+ , "10=1858-11-27=1858-331=1858-W47-6"+ , "11=1858-11-28=1858-332=1858-W47-7"+ , "12=1858-11-29=1858-333=1858-W48-1"+ , "13=1858-11-30=1858-334=1858-W48-2"+ , "14=1858-12-01=1858-335=1858-W48-3"+ , "15=1858-12-02=1858-336=1858-W48-4"+ , "16=1858-12-03=1858-337=1858-W48-5"+ , "17=1858-12-04=1858-338=1858-W48-6"+ , "18=1858-12-05=1858-339=1858-W48-7"+ , "19=1858-12-06=1858-340=1858-W49-1"+ , "20=1858-12-07=1858-341=1858-W49-2"+ , "21=1858-12-08=1858-342=1858-W49-3"+ , "22=1858-12-09=1858-343=1858-W49-4"+ , "23=1858-12-10=1858-344=1858-W49-5"+ , "24=1858-12-11=1858-345=1858-W49-6"+ , "25=1858-12-12=1858-346=1858-W49-7"+ , "26=1858-12-13=1858-347=1858-W50-1"+ , "27=1858-12-14=1858-348=1858-W50-2"+ , "28=1858-12-15=1858-349=1858-W50-3"+ , "29=1858-12-16=1858-350=1858-W50-4"+ , "30=1858-12-17=1858-351=1858-W50-5"+ , "40000=1968-05-24=1968-145=1968-W21-5"+ , "50000=1995-10-10=1995-283=1995-W41-2"+ , "15078=1900-02-28=1900-059=1900-W09-3"+ , "15079=1900-03-01=1900-060=1900-W09-4"+ , "44297=1980-02-28=1980-059=1980-W09-4"+ , "44298=1980-02-29=1980-060=1980-W09-5"+ , "44299=1980-03-01=1980-061=1980-W09-6"+ , "47950=1990-02-28=1990-059=1990-W09-3"+ , "47951=1990-03-01=1990-060=1990-W09-4"+ , "51602=2000-02-28=2000-059=2000-W09-1"+ , "51603=2000-02-29=2000-060=2000-W09-2"+ , "51604=2000-03-01=2000-061=2000-W09-3"+ , "51540=1999-12-28=1999-362=1999-W52-2"+ , "51541=1999-12-29=1999-363=1999-W52-3"+ , "51542=1999-12-30=1999-364=1999-W52-4"+ , "51543=1999-12-31=1999-365=1999-W52-5"+ , "51544=2000-01-01=2000-001=1999-W52-6"+ , "51545=2000-01-02=2000-002=1999-W52-7"+ , "51546=2000-01-03=2000-003=2000-W01-1"+ , "51547=2000-01-04=2000-004=2000-W01-2"+ , "51548=2000-01-05=2000-005=2000-W01-3"+ , "51549=2000-01-06=2000-006=2000-W01-4"+ , "51550=2000-01-07=2000-007=2000-W01-5"+ , "51551=2000-01-08=2000-008=2000-W01-6"+ , "51552=2000-01-09=2000-009=2000-W01-7"+ , "51553=2000-01-10=2000-010=2000-W02-1"+ , "51554=2000-01-11=2000-011=2000-W02-2"+ , "51555=2000-01-12=2000-012=2000-W02-3"+ , "51556=2000-01-13=2000-013=2000-W02-4"+ , "51557=2000-01-14=2000-014=2000-W02-5"+ , "51558=2000-01-15=2000-015=2000-W02-6"+ , "51559=2000-01-16=2000-016=2000-W02-7"+ , "51560=2000-01-17=2000-017=2000-W03-1"+ , "51561=2000-01-18=2000-018=2000-W03-2"+ , "51562=2000-01-19=2000-019=2000-W03-3"+ , "51563=2000-01-20=2000-020=2000-W03-4"+ , "51564=2000-01-21=2000-021=2000-W03-5"+ , "51565=2000-01-22=2000-022=2000-W03-6"+ , "51566=2000-01-23=2000-023=2000-W03-7"+ , "51567=2000-01-24=2000-024=2000-W04-1"+ , "51568=2000-01-25=2000-025=2000-W04-2"+ , "51569=2000-01-26=2000-026=2000-W04-3"+ , "51570=2000-01-27=2000-027=2000-W04-4"+ , "51571=2000-01-28=2000-028=2000-W04-5"+ , "51572=2000-01-29=2000-029=2000-W04-6"+ , "51573=2000-01-30=2000-030=2000-W04-7"+ , "51574=2000-01-31=2000-031=2000-W05-1"+ , "51575=2000-02-01=2000-032=2000-W05-2"+ , "51576=2000-02-02=2000-033=2000-W05-3"+ , "51577=2000-02-03=2000-034=2000-W05-4"+ , "51578=2000-02-04=2000-035=2000-W05-5"+ , "51579=2000-02-05=2000-036=2000-W05-6"+ , "51580=2000-02-06=2000-037=2000-W05-7"+ , "51581=2000-02-07=2000-038=2000-W06-1"+ , "51582=2000-02-08=2000-039=2000-W06-2"+ , "51583=2000-02-09=2000-040=2000-W06-3"+ , "51584=2000-02-10=2000-041=2000-W06-4"+ , "51585=2000-02-11=2000-042=2000-W06-5"+ , "51586=2000-02-12=2000-043=2000-W06-6"+ , "51587=2000-02-13=2000-044=2000-W06-7"+ , "51588=2000-02-14=2000-045=2000-W07-1"+ , "51589=2000-02-15=2000-046=2000-W07-2"+ , "51590=2000-02-16=2000-047=2000-W07-3"+ , "51591=2000-02-17=2000-048=2000-W07-4"+ , "51592=2000-02-18=2000-049=2000-W07-5"+ , "51593=2000-02-19=2000-050=2000-W07-6"+ , "51594=2000-02-20=2000-051=2000-W07-7"+ , "51595=2000-02-21=2000-052=2000-W08-1"+ , "51596=2000-02-22=2000-053=2000-W08-2"+ , "51597=2000-02-23=2000-054=2000-W08-3"+ , "51598=2000-02-24=2000-055=2000-W08-4"+ , "51599=2000-02-25=2000-056=2000-W08-5"+ , "51600=2000-02-26=2000-057=2000-W08-6"+ , "51601=2000-02-27=2000-058=2000-W08-7"+ , "51602=2000-02-28=2000-059=2000-W09-1"+ , "51603=2000-02-29=2000-060=2000-W09-2"+ , "51604=2000-03-01=2000-061=2000-W09-3"+ , "51605=2000-03-02=2000-062=2000-W09-4"+ , "51606=2000-03-03=2000-063=2000-W09-5"+ , "51607=2000-03-04=2000-064=2000-W09-6"+ , "51608=2000-03-05=2000-065=2000-W09-7"+ , "51609=2000-03-06=2000-066=2000-W10-1"+ , "51610=2000-03-07=2000-067=2000-W10-2"+ , "51611=2000-03-08=2000-068=2000-W10-3"+ , "51612=2000-03-09=2000-069=2000-W10-4"+ , "51613=2000-03-10=2000-070=2000-W10-5"+ , "51614=2000-03-11=2000-071=2000-W10-6"+ , "51615=2000-03-12=2000-072=2000-W10-7"+ , "51616=2000-03-13=2000-073=2000-W11-1"+ , "51617=2000-03-14=2000-074=2000-W11-2"+ , "51618=2000-03-15=2000-075=2000-W11-3"+ , "51619=2000-03-16=2000-076=2000-W11-4"+ , "51620=2000-03-17=2000-077=2000-W11-5"+ , "51621=2000-03-18=2000-078=2000-W11-6"+ , "51622=2000-03-19=2000-079=2000-W11-7"+ , "51623=2000-03-20=2000-080=2000-W12-1"+ , "51624=2000-03-21=2000-081=2000-W12-2"+ , "51625=2000-03-22=2000-082=2000-W12-3"+ , "51626=2000-03-23=2000-083=2000-W12-4"+ , "51627=2000-03-24=2000-084=2000-W12-5"+ , "51628=2000-03-25=2000-085=2000-W12-6"+ , "51629=2000-03-26=2000-086=2000-W12-7"+ , "51630=2000-03-27=2000-087=2000-W13-1"+ , "51631=2000-03-28=2000-088=2000-W13-2"+ , "51632=2000-03-29=2000-089=2000-W13-3"+ , "51633=2000-03-30=2000-090=2000-W13-4"+ , "51634=2000-03-31=2000-091=2000-W13-5"+ , "51635=2000-04-01=2000-092=2000-W13-6"+ , "51636=2000-04-02=2000-093=2000-W13-7"+ , "51637=2000-04-03=2000-094=2000-W14-1"+ , "51638=2000-04-04=2000-095=2000-W14-2"+ , "51639=2000-04-05=2000-096=2000-W14-3"+ , "51640=2000-04-06=2000-097=2000-W14-4"+ , "51641=2000-04-07=2000-098=2000-W14-5"+ , "51642=2000-04-08=2000-099=2000-W14-6"+ , "51643=2000-04-09=2000-100=2000-W14-7"+ , "51644=2000-04-10=2000-101=2000-W15-1"+ , "51645=2000-04-11=2000-102=2000-W15-2"+ , "51646=2000-04-12=2000-103=2000-W15-3"+ , "51647=2000-04-13=2000-104=2000-W15-4"+ , "51648=2000-04-14=2000-105=2000-W15-5"+ , "51649=2000-04-15=2000-106=2000-W15-6"+ , "51650=2000-04-16=2000-107=2000-W15-7"+ , "51651=2000-04-17=2000-108=2000-W16-1"+ , "51652=2000-04-18=2000-109=2000-W16-2"+ , "51653=2000-04-19=2000-110=2000-W16-3"+ , "51654=2000-04-20=2000-111=2000-W16-4"+ , "51655=2000-04-21=2000-112=2000-W16-5"+ , "51656=2000-04-22=2000-113=2000-W16-6"+ , "51657=2000-04-23=2000-114=2000-W16-7"+ , "51658=2000-04-24=2000-115=2000-W17-1"+ , "51659=2000-04-25=2000-116=2000-W17-2"+ , "51660=2000-04-26=2000-117=2000-W17-3"+ , "51661=2000-04-27=2000-118=2000-W17-4"+ , "51662=2000-04-28=2000-119=2000-W17-5"+ , "51663=2000-04-29=2000-120=2000-W17-6"+ , "51664=2000-04-30=2000-121=2000-W17-7"+ , "51665=2000-05-01=2000-122=2000-W18-1"+ , "51666=2000-05-02=2000-123=2000-W18-2"+ , "51667=2000-05-03=2000-124=2000-W18-3"+ , "51668=2000-05-04=2000-125=2000-W18-4"+ , "51669=2000-05-05=2000-126=2000-W18-5"+ , "51670=2000-05-06=2000-127=2000-W18-6"+ , "51671=2000-05-07=2000-128=2000-W18-7"+ , "51672=2000-05-08=2000-129=2000-W19-1"+ , "51673=2000-05-09=2000-130=2000-W19-2"+ , "51674=2000-05-10=2000-131=2000-W19-3"+ , "51675=2000-05-11=2000-132=2000-W19-4"+ , "51676=2000-05-12=2000-133=2000-W19-5"+ , "51677=2000-05-13=2000-134=2000-W19-6"+ , "51678=2000-05-14=2000-135=2000-W19-7"+ , "51679=2000-05-15=2000-136=2000-W20-1"+ , "51680=2000-05-16=2000-137=2000-W20-2"+ , "51681=2000-05-17=2000-138=2000-W20-3"+ , "51682=2000-05-18=2000-139=2000-W20-4"+ , "51683=2000-05-19=2000-140=2000-W20-5"+ , "51684=2000-05-20=2000-141=2000-W20-6"+ , "51685=2000-05-21=2000-142=2000-W20-7"+ , "51686=2000-05-22=2000-143=2000-W21-1"+ , "51687=2000-05-23=2000-144=2000-W21-2"+ , "51688=2000-05-24=2000-145=2000-W21-3"+ , "51689=2000-05-25=2000-146=2000-W21-4"+ , "51690=2000-05-26=2000-147=2000-W21-5"+ , "51691=2000-05-27=2000-148=2000-W21-6"+ , "51692=2000-05-28=2000-149=2000-W21-7"+ , "51693=2000-05-29=2000-150=2000-W22-1"+ , "51694=2000-05-30=2000-151=2000-W22-2"+ , "51695=2000-05-31=2000-152=2000-W22-3"+ , "51696=2000-06-01=2000-153=2000-W22-4"+ , "51697=2000-06-02=2000-154=2000-W22-5"+ , "51698=2000-06-03=2000-155=2000-W22-6"+ , "51699=2000-06-04=2000-156=2000-W22-7"+ , "51700=2000-06-05=2000-157=2000-W23-1"+ , "51701=2000-06-06=2000-158=2000-W23-2"+ , "51702=2000-06-07=2000-159=2000-W23-3"+ , "51703=2000-06-08=2000-160=2000-W23-4"+ , "51704=2000-06-09=2000-161=2000-W23-5"+ , "51705=2000-06-10=2000-162=2000-W23-6"+ , "51706=2000-06-11=2000-163=2000-W23-7"+ , "51707=2000-06-12=2000-164=2000-W24-1"+ , "51708=2000-06-13=2000-165=2000-W24-2"+ , "51709=2000-06-14=2000-166=2000-W24-3"+ , "51710=2000-06-15=2000-167=2000-W24-4"+ , "51711=2000-06-16=2000-168=2000-W24-5"+ , "51712=2000-06-17=2000-169=2000-W24-6"+ , "51713=2000-06-18=2000-170=2000-W24-7"+ , "51714=2000-06-19=2000-171=2000-W25-1"+ , "51715=2000-06-20=2000-172=2000-W25-2"+ , "51716=2000-06-21=2000-173=2000-W25-3"+ , "51717=2000-06-22=2000-174=2000-W25-4"+ , "51718=2000-06-23=2000-175=2000-W25-5"+ , "51719=2000-06-24=2000-176=2000-W25-6"+ , "51720=2000-06-25=2000-177=2000-W25-7"+ , "51721=2000-06-26=2000-178=2000-W26-1"+ , "51722=2000-06-27=2000-179=2000-W26-2"+ , "51723=2000-06-28=2000-180=2000-W26-3"+ , "51724=2000-06-29=2000-181=2000-W26-4"+ , "51725=2000-06-30=2000-182=2000-W26-5"+ , "51726=2000-07-01=2000-183=2000-W26-6"+ , "51727=2000-07-02=2000-184=2000-W26-7"+ , "51728=2000-07-03=2000-185=2000-W27-1"+ , "51729=2000-07-04=2000-186=2000-W27-2"+ , "51730=2000-07-05=2000-187=2000-W27-3"+ , "51731=2000-07-06=2000-188=2000-W27-4"+ , "51732=2000-07-07=2000-189=2000-W27-5"+ , "51733=2000-07-08=2000-190=2000-W27-6"+ , "51734=2000-07-09=2000-191=2000-W27-7"+ , "51735=2000-07-10=2000-192=2000-W28-1"+ , "51736=2000-07-11=2000-193=2000-W28-2"+ , "51737=2000-07-12=2000-194=2000-W28-3"+ , "51738=2000-07-13=2000-195=2000-W28-4"+ , "51739=2000-07-14=2000-196=2000-W28-5"+ , "51740=2000-07-15=2000-197=2000-W28-6"+ , "51741=2000-07-16=2000-198=2000-W28-7"+ , "51742=2000-07-17=2000-199=2000-W29-1"+ , "51743=2000-07-18=2000-200=2000-W29-2"+ , "51744=2000-07-19=2000-201=2000-W29-3"+ , "51745=2000-07-20=2000-202=2000-W29-4"+ , "51746=2000-07-21=2000-203=2000-W29-5"+ , "51747=2000-07-22=2000-204=2000-W29-6"+ , "51748=2000-07-23=2000-205=2000-W29-7"+ , "51749=2000-07-24=2000-206=2000-W30-1"+ , "51750=2000-07-25=2000-207=2000-W30-2"+ , "51751=2000-07-26=2000-208=2000-W30-3"+ , "51752=2000-07-27=2000-209=2000-W30-4"+ , "51753=2000-07-28=2000-210=2000-W30-5"+ , "51754=2000-07-29=2000-211=2000-W30-6"+ , "51755=2000-07-30=2000-212=2000-W30-7"+ , "51756=2000-07-31=2000-213=2000-W31-1"+ , "51757=2000-08-01=2000-214=2000-W31-2"+ , "51758=2000-08-02=2000-215=2000-W31-3"+ , "51759=2000-08-03=2000-216=2000-W31-4"+ , "51760=2000-08-04=2000-217=2000-W31-5"+ , "51761=2000-08-05=2000-218=2000-W31-6"+ , "51762=2000-08-06=2000-219=2000-W31-7"+ , "51763=2000-08-07=2000-220=2000-W32-1"+ , "51764=2000-08-08=2000-221=2000-W32-2"+ , "51765=2000-08-09=2000-222=2000-W32-3"+ , "51766=2000-08-10=2000-223=2000-W32-4"+ , "51767=2000-08-11=2000-224=2000-W32-5"+ , "51768=2000-08-12=2000-225=2000-W32-6"+ , "51769=2000-08-13=2000-226=2000-W32-7"+ , "51770=2000-08-14=2000-227=2000-W33-1"+ , "51771=2000-08-15=2000-228=2000-W33-2"+ , "51772=2000-08-16=2000-229=2000-W33-3"+ , "51773=2000-08-17=2000-230=2000-W33-4"+ , "51774=2000-08-18=2000-231=2000-W33-5"+ , "51775=2000-08-19=2000-232=2000-W33-6"+ , "51776=2000-08-20=2000-233=2000-W33-7"+ , "51777=2000-08-21=2000-234=2000-W34-1"+ , "51778=2000-08-22=2000-235=2000-W34-2"+ , "51779=2000-08-23=2000-236=2000-W34-3"+ , "51780=2000-08-24=2000-237=2000-W34-4"+ , "51781=2000-08-25=2000-238=2000-W34-5"+ , "51782=2000-08-26=2000-239=2000-W34-6"+ , "51783=2000-08-27=2000-240=2000-W34-7"+ , "51784=2000-08-28=2000-241=2000-W35-1"+ , "51785=2000-08-29=2000-242=2000-W35-2"+ , "51786=2000-08-30=2000-243=2000-W35-3"+ , "51787=2000-08-31=2000-244=2000-W35-4"+ , "51788=2000-09-01=2000-245=2000-W35-5"+ , "51789=2000-09-02=2000-246=2000-W35-6"+ , "51790=2000-09-03=2000-247=2000-W35-7"+ , "51791=2000-09-04=2000-248=2000-W36-1"+ , "51792=2000-09-05=2000-249=2000-W36-2"+ , "51793=2000-09-06=2000-250=2000-W36-3"+ , "51794=2000-09-07=2000-251=2000-W36-4"+ , "51795=2000-09-08=2000-252=2000-W36-5"+ , "51796=2000-09-09=2000-253=2000-W36-6"+ , "51797=2000-09-10=2000-254=2000-W36-7"+ , "51798=2000-09-11=2000-255=2000-W37-1"+ , "51799=2000-09-12=2000-256=2000-W37-2"+ , "51800=2000-09-13=2000-257=2000-W37-3"+ , "51801=2000-09-14=2000-258=2000-W37-4"+ , "51802=2000-09-15=2000-259=2000-W37-5"+ , "51803=2000-09-16=2000-260=2000-W37-6"+ , "51804=2000-09-17=2000-261=2000-W37-7"+ , "51805=2000-09-18=2000-262=2000-W38-1"+ , "51806=2000-09-19=2000-263=2000-W38-2"+ , "51807=2000-09-20=2000-264=2000-W38-3"+ , "51808=2000-09-21=2000-265=2000-W38-4"+ , "51809=2000-09-22=2000-266=2000-W38-5"+ , "51810=2000-09-23=2000-267=2000-W38-6"+ , "51811=2000-09-24=2000-268=2000-W38-7"+ , "51812=2000-09-25=2000-269=2000-W39-1"+ , "51813=2000-09-26=2000-270=2000-W39-2"+ , "51814=2000-09-27=2000-271=2000-W39-3"+ , "51815=2000-09-28=2000-272=2000-W39-4"+ , "51816=2000-09-29=2000-273=2000-W39-5"+ , "51817=2000-09-30=2000-274=2000-W39-6"+ , "51818=2000-10-01=2000-275=2000-W39-7"+ , "51819=2000-10-02=2000-276=2000-W40-1"+ , "51820=2000-10-03=2000-277=2000-W40-2"+ , "51821=2000-10-04=2000-278=2000-W40-3"+ , "51822=2000-10-05=2000-279=2000-W40-4"+ , "51823=2000-10-06=2000-280=2000-W40-5"+ , "51824=2000-10-07=2000-281=2000-W40-6"+ , "51825=2000-10-08=2000-282=2000-W40-7"+ , "51826=2000-10-09=2000-283=2000-W41-1"+ , "51827=2000-10-10=2000-284=2000-W41-2"+ , "51828=2000-10-11=2000-285=2000-W41-3"+ , "51829=2000-10-12=2000-286=2000-W41-4"+ , "51830=2000-10-13=2000-287=2000-W41-5"+ , "51831=2000-10-14=2000-288=2000-W41-6"+ , "51832=2000-10-15=2000-289=2000-W41-7"+ , "51833=2000-10-16=2000-290=2000-W42-1"+ , "51834=2000-10-17=2000-291=2000-W42-2"+ , "51835=2000-10-18=2000-292=2000-W42-3"+ , "51836=2000-10-19=2000-293=2000-W42-4"+ , "51837=2000-10-20=2000-294=2000-W42-5"+ , "51838=2000-10-21=2000-295=2000-W42-6"+ , "51839=2000-10-22=2000-296=2000-W42-7"+ , "51840=2000-10-23=2000-297=2000-W43-1"+ , "51841=2000-10-24=2000-298=2000-W43-2"+ , "51842=2000-10-25=2000-299=2000-W43-3"+ , "51843=2000-10-26=2000-300=2000-W43-4"+ , "51844=2000-10-27=2000-301=2000-W43-5"+ , "51845=2000-10-28=2000-302=2000-W43-6"+ , "51846=2000-10-29=2000-303=2000-W43-7"+ , "51847=2000-10-30=2000-304=2000-W44-1"+ , "51848=2000-10-31=2000-305=2000-W44-2"+ , "51849=2000-11-01=2000-306=2000-W44-3"+ , "51850=2000-11-02=2000-307=2000-W44-4"+ , "51851=2000-11-03=2000-308=2000-W44-5"+ , "51852=2000-11-04=2000-309=2000-W44-6"+ , "51853=2000-11-05=2000-310=2000-W44-7"+ , "51854=2000-11-06=2000-311=2000-W45-1"+ , "51855=2000-11-07=2000-312=2000-W45-2"+ , "51856=2000-11-08=2000-313=2000-W45-3"+ , "51857=2000-11-09=2000-314=2000-W45-4"+ , "51858=2000-11-10=2000-315=2000-W45-5"+ , "51859=2000-11-11=2000-316=2000-W45-6"+ , "51860=2000-11-12=2000-317=2000-W45-7"+ , "51861=2000-11-13=2000-318=2000-W46-1"+ , "51862=2000-11-14=2000-319=2000-W46-2"+ , "51863=2000-11-15=2000-320=2000-W46-3"+ , "51864=2000-11-16=2000-321=2000-W46-4"+ , "51865=2000-11-17=2000-322=2000-W46-5"+ , "51866=2000-11-18=2000-323=2000-W46-6"+ , "51867=2000-11-19=2000-324=2000-W46-7"+ , "51868=2000-11-20=2000-325=2000-W47-1"+ , "51869=2000-11-21=2000-326=2000-W47-2"+ , "51870=2000-11-22=2000-327=2000-W47-3"+ , "51871=2000-11-23=2000-328=2000-W47-4"+ , "51872=2000-11-24=2000-329=2000-W47-5"+ , "51873=2000-11-25=2000-330=2000-W47-6"+ , "51874=2000-11-26=2000-331=2000-W47-7"+ , "51875=2000-11-27=2000-332=2000-W48-1"+ , "51876=2000-11-28=2000-333=2000-W48-2"+ , "51877=2000-11-29=2000-334=2000-W48-3"+ , "51878=2000-11-30=2000-335=2000-W48-4"+ , "51879=2000-12-01=2000-336=2000-W48-5"+ , "51880=2000-12-02=2000-337=2000-W48-6"+ , "51881=2000-12-03=2000-338=2000-W48-7"+ , "51882=2000-12-04=2000-339=2000-W49-1"+ , "51883=2000-12-05=2000-340=2000-W49-2"+ , "51884=2000-12-06=2000-341=2000-W49-3"+ , "51885=2000-12-07=2000-342=2000-W49-4"+ , "51886=2000-12-08=2000-343=2000-W49-5"+ , "51887=2000-12-09=2000-344=2000-W49-6"+ , "51888=2000-12-10=2000-345=2000-W49-7"+ , "51889=2000-12-11=2000-346=2000-W50-1"+ , "51890=2000-12-12=2000-347=2000-W50-2"+ , "51891=2000-12-13=2000-348=2000-W50-3"+ , "51892=2000-12-14=2000-349=2000-W50-4"+ , "51893=2000-12-15=2000-350=2000-W50-5"+ , "51894=2000-12-16=2000-351=2000-W50-6"+ , "51895=2000-12-17=2000-352=2000-W50-7"+ , "51896=2000-12-18=2000-353=2000-W51-1"+ , "51897=2000-12-19=2000-354=2000-W51-2"+ , "51898=2000-12-20=2000-355=2000-W51-3"+ , "51899=2000-12-21=2000-356=2000-W51-4"+ , "51900=2000-12-22=2000-357=2000-W51-5"+ , "51901=2000-12-23=2000-358=2000-W51-6"+ , "51902=2000-12-24=2000-359=2000-W51-7"+ , "51903=2000-12-25=2000-360=2000-W52-1"+ , "51904=2000-12-26=2000-361=2000-W52-2"+ , "51905=2000-12-27=2000-362=2000-W52-3"+ , "51906=2000-12-28=2000-363=2000-W52-4"+ , "51907=2000-12-29=2000-364=2000-W52-5"+ , "51908=2000-12-30=2000-365=2000-W52-6"+ , "51909=2000-12-31=2000-366=2000-W52-7"+ , "51910=2001-01-01=2001-001=2001-W01-1"+ , "51911=2001-01-02=2001-002=2001-W01-2"+ , "51912=2001-01-03=2001-003=2001-W01-3"+ , "51913=2001-01-04=2001-004=2001-W01-4"+ , "51914=2001-01-05=2001-005=2001-W01-5"+ , "51915=2001-01-06=2001-006=2001-W01-6"+ , "51916=2001-01-07=2001-007=2001-W01-7"+ , "51917=2001-01-08=2001-008=2001-W02-1"+ , "51918=2001-01-09=2001-009=2001-W02-2"+ , "51919=2001-01-10=2001-010=2001-W02-3"+ , "51920=2001-01-11=2001-011=2001-W02-4"+ , "51921=2001-01-12=2001-012=2001-W02-5"+ , "51922=2001-01-13=2001-013=2001-W02-6"+ , "51923=2001-01-14=2001-014=2001-W02-7"+ , "51924=2001-01-15=2001-015=2001-W03-1"+ , "51925=2001-01-16=2001-016=2001-W03-2"+ , "51926=2001-01-17=2001-017=2001-W03-3"+ , "51927=2001-01-18=2001-018=2001-W03-4"+ , "51928=2001-01-19=2001-019=2001-W03-5"+ , "51929=2001-01-20=2001-020=2001-W03-6"+ , "51930=2001-01-21=2001-021=2001-W03-7"+ , "51931=2001-01-22=2001-022=2001-W04-1"+ , "51932=2001-01-23=2001-023=2001-W04-2"+ , "51933=2001-01-24=2001-024=2001-W04-3"+ , "51934=2001-01-25=2001-025=2001-W04-4"+ , "51935=2001-01-26=2001-026=2001-W04-5"+ , "51936=2001-01-27=2001-027=2001-W04-6"+ , "51937=2001-01-28=2001-028=2001-W04-7"+ , "51938=2001-01-29=2001-029=2001-W05-1"+ , "51939=2001-01-30=2001-030=2001-W05-2"+ , "51940=2001-01-31=2001-031=2001-W05-3"+ , "51941=2001-02-01=2001-032=2001-W05-4"+ , "51942=2001-02-02=2001-033=2001-W05-5"+ , "51943=2001-02-03=2001-034=2001-W05-6"+ , "51944=2001-02-04=2001-035=2001-W05-7"+ , "51945=2001-02-05=2001-036=2001-W06-1"+ , "51946=2001-02-06=2001-037=2001-W06-2"+ , "51947=2001-02-07=2001-038=2001-W06-3"+ , "51948=2001-02-08=2001-039=2001-W06-4"+ , "51949=2001-02-09=2001-040=2001-W06-5"+ , "51950=2001-02-10=2001-041=2001-W06-6"+ , "51951=2001-02-11=2001-042=2001-W06-7"+ , "51952=2001-02-12=2001-043=2001-W07-1"+ , "51953=2001-02-13=2001-044=2001-W07-2"+ , "51954=2001-02-14=2001-045=2001-W07-3"+ , "51955=2001-02-15=2001-046=2001-W07-4"+ , "51956=2001-02-16=2001-047=2001-W07-5"+ , "51957=2001-02-17=2001-048=2001-W07-6"+ , "51958=2001-02-18=2001-049=2001-W07-7"+ , "51959=2001-02-19=2001-050=2001-W08-1"+ , "51960=2001-02-20=2001-051=2001-W08-2"+ , "51961=2001-02-21=2001-052=2001-W08-3"+ , "51962=2001-02-22=2001-053=2001-W08-4"+ , "51963=2001-02-23=2001-054=2001-W08-5"+ , "51964=2001-02-24=2001-055=2001-W08-6"+ , "51965=2001-02-25=2001-056=2001-W08-7"+ , "51966=2001-02-26=2001-057=2001-W09-1"+ , "51967=2001-02-27=2001-058=2001-W09-2"+ , "51968=2001-02-28=2001-059=2001-W09-3"+ , "51969=2001-03-01=2001-060=2001-W09-4"+ , "51970=2001-03-02=2001-061=2001-W09-5"+ , "51971=2001-03-03=2001-062=2001-W09-6"+ , "51972=2001-03-04=2001-063=2001-W09-7"+ , "51973=2001-03-05=2001-064=2001-W10-1"+ , "51974=2001-03-06=2001-065=2001-W10-2"+ , "51975=2001-03-07=2001-066=2001-W10-3"+ , "51976=2001-03-08=2001-067=2001-W10-4"+ , "51977=2001-03-09=2001-068=2001-W10-5"+ , "51978=2001-03-10=2001-069=2001-W10-6"+ , "51979=2001-03-11=2001-070=2001-W10-7"+ , "51980=2001-03-12=2001-071=2001-W11-1"+ , "51981=2001-03-13=2001-072=2001-W11-2"+ , "51982=2001-03-14=2001-073=2001-W11-3"+ , "51983=2001-03-15=2001-074=2001-W11-4"+ , "51984=2001-03-16=2001-075=2001-W11-5"+ , "51985=2001-03-17=2001-076=2001-W11-6"+ , "51986=2001-03-18=2001-077=2001-W11-7"+ , "51987=2001-03-19=2001-078=2001-W12-1"+ , "51988=2001-03-20=2001-079=2001-W12-2"+ , "51989=2001-03-21=2001-080=2001-W12-3"+ , "51990=2001-03-22=2001-081=2001-W12-4"+ , "51991=2001-03-23=2001-082=2001-W12-5"+ , "51992=2001-03-24=2001-083=2001-W12-6"+ , "51993=2001-03-25=2001-084=2001-W12-7"+ , "51994=2001-03-26=2001-085=2001-W13-1"+ , "51995=2001-03-27=2001-086=2001-W13-2"+ , "51996=2001-03-28=2001-087=2001-W13-3"+ , "51997=2001-03-29=2001-088=2001-W13-4"+ , "51998=2001-03-30=2001-089=2001-W13-5"+ , "51999=2001-03-31=2001-090=2001-W13-6"+ , "52000=2001-04-01=2001-091=2001-W13-7"+ , "52001=2001-04-02=2001-092=2001-W14-1"+ , "52002=2001-04-03=2001-093=2001-W14-2"+ , "52003=2001-04-04=2001-094=2001-W14-3"+ , "52004=2001-04-05=2001-095=2001-W14-4"+ , "52005=2001-04-06=2001-096=2001-W14-5"+ , "52006=2001-04-07=2001-097=2001-W14-6"+ , "52007=2001-04-08=2001-098=2001-W14-7"+ , "52008=2001-04-09=2001-099=2001-W15-1"+ , "52009=2001-04-10=2001-100=2001-W15-2"+ , "52010=2001-04-11=2001-101=2001-W15-3"+ , "52011=2001-04-12=2001-102=2001-W15-4"+ , "52012=2001-04-13=2001-103=2001-W15-5"+ , "52013=2001-04-14=2001-104=2001-W15-6"+ , "52014=2001-04-15=2001-105=2001-W15-7"+ , "52015=2001-04-16=2001-106=2001-W16-1"+ , "52016=2001-04-17=2001-107=2001-W16-2"+ , "52017=2001-04-18=2001-108=2001-W16-3"+ , "52018=2001-04-19=2001-109=2001-W16-4"+ , "52019=2001-04-20=2001-110=2001-W16-5"+ , "52020=2001-04-21=2001-111=2001-W16-6"+ , "52021=2001-04-22=2001-112=2001-W16-7"+ , "52022=2001-04-23=2001-113=2001-W17-1"+ , "52023=2001-04-24=2001-114=2001-W17-2"+ , "52024=2001-04-25=2001-115=2001-W17-3"+ , "52025=2001-04-26=2001-116=2001-W17-4"+ , "52026=2001-04-27=2001-117=2001-W17-5"+ , "52027=2001-04-28=2001-118=2001-W17-6"+ , "52028=2001-04-29=2001-119=2001-W17-7"+ , "52029=2001-04-30=2001-120=2001-W18-1"+ , "52030=2001-05-01=2001-121=2001-W18-2"+ , "52031=2001-05-02=2001-122=2001-W18-3"+ , "52032=2001-05-03=2001-123=2001-W18-4"+ , "52033=2001-05-04=2001-124=2001-W18-5"+ , "52034=2001-05-05=2001-125=2001-W18-6"+ , "52035=2001-05-06=2001-126=2001-W18-7"+ , "52036=2001-05-07=2001-127=2001-W19-1"+ , "52037=2001-05-08=2001-128=2001-W19-2"+ , "52038=2001-05-09=2001-129=2001-W19-3"+ , "52039=2001-05-10=2001-130=2001-W19-4"+ , "52040=2001-05-11=2001-131=2001-W19-5"+ , "52041=2001-05-12=2001-132=2001-W19-6"+ , "52042=2001-05-13=2001-133=2001-W19-7"+ , "52043=2001-05-14=2001-134=2001-W20-1"+ , "52044=2001-05-15=2001-135=2001-W20-2"+ , "52045=2001-05-16=2001-136=2001-W20-3"+ , "52046=2001-05-17=2001-137=2001-W20-4"+ , "52047=2001-05-18=2001-138=2001-W20-5"+ , "52048=2001-05-19=2001-139=2001-W20-6"+ , "52049=2001-05-20=2001-140=2001-W20-7"+ , "52050=2001-05-21=2001-141=2001-W21-1"+ , "52051=2001-05-22=2001-142=2001-W21-2"+ , "52052=2001-05-23=2001-143=2001-W21-3"+ , "52053=2001-05-24=2001-144=2001-W21-4"+ , "52054=2001-05-25=2001-145=2001-W21-5"+ , "52055=2001-05-26=2001-146=2001-W21-6"+ , "52056=2001-05-27=2001-147=2001-W21-7"+ , "52057=2001-05-28=2001-148=2001-W22-1"+ , "52058=2001-05-29=2001-149=2001-W22-2"+ , "52059=2001-05-30=2001-150=2001-W22-3"+ , "52060=2001-05-31=2001-151=2001-W22-4"+ , "52061=2001-06-01=2001-152=2001-W22-5"+ , "52062=2001-06-02=2001-153=2001-W22-6"+ , "52063=2001-06-03=2001-154=2001-W22-7"+ , "52064=2001-06-04=2001-155=2001-W23-1"+ , "52065=2001-06-05=2001-156=2001-W23-2"+ , "52066=2001-06-06=2001-157=2001-W23-3"+ , "52067=2001-06-07=2001-158=2001-W23-4"+ , "52068=2001-06-08=2001-159=2001-W23-5"+ , "52069=2001-06-09=2001-160=2001-W23-6"+ , "52070=2001-06-10=2001-161=2001-W23-7"+ , "52071=2001-06-11=2001-162=2001-W24-1"+ , "52072=2001-06-12=2001-163=2001-W24-2"+ , "52073=2001-06-13=2001-164=2001-W24-3"+ , "52074=2001-06-14=2001-165=2001-W24-4"+ , "52075=2001-06-15=2001-166=2001-W24-5"+ , "52076=2001-06-16=2001-167=2001-W24-6"+ , "52077=2001-06-17=2001-168=2001-W24-7"+ , "52078=2001-06-18=2001-169=2001-W25-1"+ , "52079=2001-06-19=2001-170=2001-W25-2"+ , "52080=2001-06-20=2001-171=2001-W25-3"+ , "52081=2001-06-21=2001-172=2001-W25-4"+ , "52082=2001-06-22=2001-173=2001-W25-5"+ , "52083=2001-06-23=2001-174=2001-W25-6"+ , "52084=2001-06-24=2001-175=2001-W25-7"+ , "52085=2001-06-25=2001-176=2001-W26-1"+ , "52086=2001-06-26=2001-177=2001-W26-2"+ , "52087=2001-06-27=2001-178=2001-W26-3"+ , "52088=2001-06-28=2001-179=2001-W26-4"+ , "52089=2001-06-29=2001-180=2001-W26-5"+ , "52090=2001-06-30=2001-181=2001-W26-6"+ , "52091=2001-07-01=2001-182=2001-W26-7"+ , "52092=2001-07-02=2001-183=2001-W27-1"+ , "52093=2001-07-03=2001-184=2001-W27-2"+ , "52094=2001-07-04=2001-185=2001-W27-3"+ , "52095=2001-07-05=2001-186=2001-W27-4"+ , "52096=2001-07-06=2001-187=2001-W27-5"+ , "52097=2001-07-07=2001-188=2001-W27-6"+ , "52098=2001-07-08=2001-189=2001-W27-7"+ , "52099=2001-07-09=2001-190=2001-W28-1"+ , "52100=2001-07-10=2001-191=2001-W28-2"+ , "52101=2001-07-11=2001-192=2001-W28-3"+ , "52102=2001-07-12=2001-193=2001-W28-4"+ , "52103=2001-07-13=2001-194=2001-W28-5"+ , "52104=2001-07-14=2001-195=2001-W28-6"+ , "52105=2001-07-15=2001-196=2001-W28-7"+ , "52106=2001-07-16=2001-197=2001-W29-1"+ , "52107=2001-07-17=2001-198=2001-W29-2"+ , "52108=2001-07-18=2001-199=2001-W29-3"+ , "52109=2001-07-19=2001-200=2001-W29-4"+ , "52110=2001-07-20=2001-201=2001-W29-5"+ , "52111=2001-07-21=2001-202=2001-W29-6"+ , "52112=2001-07-22=2001-203=2001-W29-7"+ , "52113=2001-07-23=2001-204=2001-W30-1"+ , "52114=2001-07-24=2001-205=2001-W30-2"+ , "52115=2001-07-25=2001-206=2001-W30-3"+ , "52116=2001-07-26=2001-207=2001-W30-4"+ , "52117=2001-07-27=2001-208=2001-W30-5"+ , "52118=2001-07-28=2001-209=2001-W30-6"+ , "52119=2001-07-29=2001-210=2001-W30-7"+ , "52120=2001-07-30=2001-211=2001-W31-1"+ , "52121=2001-07-31=2001-212=2001-W31-2"+ , "52122=2001-08-01=2001-213=2001-W31-3"+ , "52123=2001-08-02=2001-214=2001-W31-4"+ , "52124=2001-08-03=2001-215=2001-W31-5"+ , "52125=2001-08-04=2001-216=2001-W31-6"+ , "52126=2001-08-05=2001-217=2001-W31-7"+ , "52127=2001-08-06=2001-218=2001-W32-1"+ , "52128=2001-08-07=2001-219=2001-W32-2"+ , "52129=2001-08-08=2001-220=2001-W32-3"+ , "52130=2001-08-09=2001-221=2001-W32-4"+ , "52131=2001-08-10=2001-222=2001-W32-5"+ , "52132=2001-08-11=2001-223=2001-W32-6"+ , "52133=2001-08-12=2001-224=2001-W32-7"+ , "52134=2001-08-13=2001-225=2001-W33-1"+ , "52135=2001-08-14=2001-226=2001-W33-2"+ , "52136=2001-08-15=2001-227=2001-W33-3"+ , "52137=2001-08-16=2001-228=2001-W33-4"+ , "52138=2001-08-17=2001-229=2001-W33-5"+ , "52139=2001-08-18=2001-230=2001-W33-6"+ , "52140=2001-08-19=2001-231=2001-W33-7"+ , "52141=2001-08-20=2001-232=2001-W34-1"+ , "52142=2001-08-21=2001-233=2001-W34-2"+ , "52143=2001-08-22=2001-234=2001-W34-3"+ , "52144=2001-08-23=2001-235=2001-W34-4"+ , "52145=2001-08-24=2001-236=2001-W34-5"+ , "52146=2001-08-25=2001-237=2001-W34-6"+ , "52147=2001-08-26=2001-238=2001-W34-7"+ , "52148=2001-08-27=2001-239=2001-W35-1"+ , "52149=2001-08-28=2001-240=2001-W35-2"+ , "52150=2001-08-29=2001-241=2001-W35-3"+ , "52151=2001-08-30=2001-242=2001-W35-4"+ , "52152=2001-08-31=2001-243=2001-W35-5"+ , "52153=2001-09-01=2001-244=2001-W35-6"+ , "52154=2001-09-02=2001-245=2001-W35-7"+ , "52155=2001-09-03=2001-246=2001-W36-1"+ , "52156=2001-09-04=2001-247=2001-W36-2"+ , "52157=2001-09-05=2001-248=2001-W36-3"+ , "52158=2001-09-06=2001-249=2001-W36-4"+ , "52159=2001-09-07=2001-250=2001-W36-5"+ , "52160=2001-09-08=2001-251=2001-W36-6"+ , "52161=2001-09-09=2001-252=2001-W36-7"+ , "52162=2001-09-10=2001-253=2001-W37-1"+ , "52163=2001-09-11=2001-254=2001-W37-2"+ , "52164=2001-09-12=2001-255=2001-W37-3"+ , "52165=2001-09-13=2001-256=2001-W37-4"+ , "52166=2001-09-14=2001-257=2001-W37-5"+ , "52167=2001-09-15=2001-258=2001-W37-6"+ , "52168=2001-09-16=2001-259=2001-W37-7"+ , "52169=2001-09-17=2001-260=2001-W38-1"+ , "52170=2001-09-18=2001-261=2001-W38-2"+ , "52171=2001-09-19=2001-262=2001-W38-3"+ , "52172=2001-09-20=2001-263=2001-W38-4"+ , "52173=2001-09-21=2001-264=2001-W38-5"+ , "52174=2001-09-22=2001-265=2001-W38-6"+ , "52175=2001-09-23=2001-266=2001-W38-7"+ , "52176=2001-09-24=2001-267=2001-W39-1"+ , "52177=2001-09-25=2001-268=2001-W39-2"+ , "52178=2001-09-26=2001-269=2001-W39-3"+ , "52179=2001-09-27=2001-270=2001-W39-4"+ , "52180=2001-09-28=2001-271=2001-W39-5"+ , "52181=2001-09-29=2001-272=2001-W39-6"+ , "52182=2001-09-30=2001-273=2001-W39-7"+ , "52183=2001-10-01=2001-274=2001-W40-1"+ , "52184=2001-10-02=2001-275=2001-W40-2"+ , "52185=2001-10-03=2001-276=2001-W40-3"+ , "52186=2001-10-04=2001-277=2001-W40-4"+ , "52187=2001-10-05=2001-278=2001-W40-5"+ , "52188=2001-10-06=2001-279=2001-W40-6"+ , "52189=2001-10-07=2001-280=2001-W40-7"+ , "52190=2001-10-08=2001-281=2001-W41-1"+ , "52191=2001-10-09=2001-282=2001-W41-2"+ , "52192=2001-10-10=2001-283=2001-W41-3"+ , "52193=2001-10-11=2001-284=2001-W41-4"+ , "52194=2001-10-12=2001-285=2001-W41-5"+ , "52195=2001-10-13=2001-286=2001-W41-6"+ , "52196=2001-10-14=2001-287=2001-W41-7"+ , "52197=2001-10-15=2001-288=2001-W42-1"+ , "52198=2001-10-16=2001-289=2001-W42-2"+ , "52199=2001-10-17=2001-290=2001-W42-3"+ , "52200=2001-10-18=2001-291=2001-W42-4"+ , "52201=2001-10-19=2001-292=2001-W42-5"+ , "52202=2001-10-20=2001-293=2001-W42-6"+ , "52203=2001-10-21=2001-294=2001-W42-7"+ , "52204=2001-10-22=2001-295=2001-W43-1"+ , "52205=2001-10-23=2001-296=2001-W43-2"+ , "52206=2001-10-24=2001-297=2001-W43-3"+ , "52207=2001-10-25=2001-298=2001-W43-4"+ , "52208=2001-10-26=2001-299=2001-W43-5"+ , "52209=2001-10-27=2001-300=2001-W43-6"+ , "52210=2001-10-28=2001-301=2001-W43-7"+ , "52211=2001-10-29=2001-302=2001-W44-1"+ , "52212=2001-10-30=2001-303=2001-W44-2"+ , "52213=2001-10-31=2001-304=2001-W44-3"+ , "52214=2001-11-01=2001-305=2001-W44-4"+ , "52215=2001-11-02=2001-306=2001-W44-5"+ , "52216=2001-11-03=2001-307=2001-W44-6"+ , "52217=2001-11-04=2001-308=2001-W44-7"+ , "52218=2001-11-05=2001-309=2001-W45-1"+ , "52219=2001-11-06=2001-310=2001-W45-2"+ , "52220=2001-11-07=2001-311=2001-W45-3"+ , "52221=2001-11-08=2001-312=2001-W45-4"+ , "52222=2001-11-09=2001-313=2001-W45-5"+ , "52223=2001-11-10=2001-314=2001-W45-6"+ , "52224=2001-11-11=2001-315=2001-W45-7"+ , "52225=2001-11-12=2001-316=2001-W46-1"+ , "52226=2001-11-13=2001-317=2001-W46-2"+ , "52227=2001-11-14=2001-318=2001-W46-3"+ , "52228=2001-11-15=2001-319=2001-W46-4"+ , "52229=2001-11-16=2001-320=2001-W46-5"+ , "52230=2001-11-17=2001-321=2001-W46-6"+ , "52231=2001-11-18=2001-322=2001-W46-7"+ , "52232=2001-11-19=2001-323=2001-W47-1"+ , "52233=2001-11-20=2001-324=2001-W47-2"+ , "52234=2001-11-21=2001-325=2001-W47-3"+ , "52235=2001-11-22=2001-326=2001-W47-4"+ , "52236=2001-11-23=2001-327=2001-W47-5"+ , "52237=2001-11-24=2001-328=2001-W47-6"+ , "52238=2001-11-25=2001-329=2001-W47-7"+ , "52239=2001-11-26=2001-330=2001-W48-1"+ , "52240=2001-11-27=2001-331=2001-W48-2"+ , "52241=2001-11-28=2001-332=2001-W48-3"+ , "52242=2001-11-29=2001-333=2001-W48-4"+ , "52243=2001-11-30=2001-334=2001-W48-5"+ , "52244=2001-12-01=2001-335=2001-W48-6"+ , "52245=2001-12-02=2001-336=2001-W48-7"+ , "52246=2001-12-03=2001-337=2001-W49-1"+ , "52247=2001-12-04=2001-338=2001-W49-2"+ , "52248=2001-12-05=2001-339=2001-W49-3"+ , "52249=2001-12-06=2001-340=2001-W49-4"+ , "52250=2001-12-07=2001-341=2001-W49-5"+ , "52251=2001-12-08=2001-342=2001-W49-6"+ , "52252=2001-12-09=2001-343=2001-W49-7"+ , "52253=2001-12-10=2001-344=2001-W50-1"+ , "52254=2001-12-11=2001-345=2001-W50-2"+ , "52255=2001-12-12=2001-346=2001-W50-3"+ , "52256=2001-12-13=2001-347=2001-W50-4"+ , "52257=2001-12-14=2001-348=2001-W50-5"+ , "52258=2001-12-15=2001-349=2001-W50-6"+ , "52259=2001-12-16=2001-350=2001-W50-7"+ , "52260=2001-12-17=2001-351=2001-W51-1"+ , "52261=2001-12-18=2001-352=2001-W51-2"+ , "52262=2001-12-19=2001-353=2001-W51-3"+ , "52263=2001-12-20=2001-354=2001-W51-4"+ , "52264=2001-12-21=2001-355=2001-W51-5"+ , "52265=2001-12-22=2001-356=2001-W51-6"+ , "52266=2001-12-23=2001-357=2001-W51-7"+ , "52267=2001-12-24=2001-358=2001-W52-1"+ , "52268=2001-12-25=2001-359=2001-W52-2"+ , "52269=2001-12-26=2001-360=2001-W52-3"+ , "52270=2001-12-27=2001-361=2001-W52-4"+ , "52271=2001-12-28=2001-362=2001-W52-5"+ , "52272=2001-12-29=2001-363=2001-W52-6"+ , "52273=2001-12-30=2001-364=2001-W52-7"+ , "52274=2001-12-31=2001-365=2002-W01-1"+ , "52275=2002-01-01=2002-001=2002-W01-2"+ , "52276=2002-01-02=2002-002=2002-W01-3"+ , "52277=2002-01-03=2002-003=2002-W01-4"+ , "52278=2002-01-04=2002-004=2002-W01-5"+ , "52279=2002-01-05=2002-005=2002-W01-6"+ , "52280=2002-01-06=2002-006=2002-W01-7"+ , ""+ , "51178=1998-12-31=1998-365=1998-W53-4"+ , ""+ , "1998-12-31 23:59:60.5"+ , "51178,86400.5s"+ , "1998-12-31 15:59:60.5"+ , "51178,86400.5s"+ , ""+ , "2000-03-01 00:00:00"+ , "2000-03-01 12:00:00"+ , "2000-02-29 16:00:00"+ , "2000-03-01 04:00:00"+ , "2000-03-01 08:00:00"+ , "2000-03-01 20:00:00"+ , ""+ , "12:34:56.789"+ , "12:34:56.789123"+ , "12:34:56.789123456"+ , "12:34:56.789123456789"+ , if is64Bit+ then "-9223372036854775808:00:00"+ else "-2147483648:00:00"+ , ""+ ]
+ test/main/Test/TestUtil.hs view
@@ -0,0 +1,39 @@+module Test.TestUtil where++import Test.QuickCheck.Property+import Test.Tasty+import Test.Tasty.HUnit+import Test.Tasty.QuickCheck++assertFailure' :: String -> IO a+assertFailure' s = do+ _ <- assertFailure s -- returns () in some versions+ return undefined++assertJust :: Maybe a -> IO a+assertJust (Just a) = return a+assertJust Nothing = assertFailure' "Nothing"++class NameTest a where+ nameTest :: String -> a -> TestTree++instance NameTest [TestTree] where+ nameTest = testGroup++instance NameTest Assertion where+ nameTest = Test.Tasty.HUnit.testCase++instance NameTest Property where+ nameTest = testProperty++instance NameTest Result where+ nameTest name = nameTest name . property++instance (Arbitrary a, Show a, Testable b) => NameTest (a -> b) where+ nameTest name = nameTest name . property++instance Testable a => NameTest (Gen a) where+ nameTest name = nameTest name . property++tgroup :: (Show a, NameTest t) => [a] -> (a -> t) -> [TestTree]+tgroup aa f = fmap (\a -> nameTest (show a) $ f a) aa
+ test/main/Test/Types.hs view
@@ -0,0 +1,52 @@+module Test.Types () where++import Control.DeepSeq+import Data.Data+import Data.Ix+import Data.Time+import Data.Time.Calendar.Month+import Data.Time.Calendar.Quarter+import Data.Time.Clock.System+import Data.Time.Clock.TAI++class (Typeable t, Data t, NFData t) => CheckDataInstances t++class (Typeable t, Data t, NFData t, Eq t) => CheckEqInstances t++class (Typeable t, Data t, NFData t, Eq t, Ord t) => CheckOrdInstances t++class (Typeable t, Data t, NFData t, Eq t, Ord t, Ix t, Enum t) => CheckEnumInstances t++class (Typeable t, Data t, NFData t, Eq t, Ord t, Ix t, Enum t, Bounded t) => CheckBoundedInstances t++instance CheckOrdInstances UTCTime++instance CheckOrdInstances NominalDiffTime++instance CheckEnumInstances Day++instance CheckEnumInstances DayOfWeek++instance CheckOrdInstances TimeOfDay++instance CheckOrdInstances LocalTime++instance CheckOrdInstances TimeZone++instance CheckDataInstances ZonedTime++instance CheckEqInstances CalendarDiffDays++instance CheckEqInstances CalendarDiffTime++instance CheckEnumInstances Month++instance CheckEnumInstances Quarter++instance CheckBoundedInstances QuarterOfYear++instance CheckOrdInstances SystemTime++instance CheckOrdInstances AbsoluteTime++instance CheckOrdInstances UniversalTime
+ test/template/Main.hs view
@@ -0,0 +1,31 @@+{-# LANGUAGE CPP #-}++module Main (main) where++import Data.Time.Clock+#if __GLASGOW_HASKELL__ >= 914+import qualified Language.Haskell.TH.Lift as TH+#else+import qualified Language.Haskell.TH.Syntax as TH+#endif+import Test.Tasty+import Test.Tasty.HUnit+import Test.TastyWrapper++testLift :: TestTree+testLift =+ testGroup+ "Lift instances"+ [ testCase "DiffTime" $ $$(TH.liftTyped (secondsToDiffTime 100)) @?= secondsToDiffTime 100+ , testCase "NominalDiffTime" $ $$(TH.liftTyped (secondsToNominalDiffTime 100)) @?= secondsToNominalDiffTime 100+ ]++tests :: TestTree+tests =+ testGroup+ "time-template"+ [ testLift+ ]++main :: IO ()+main = tastyWrapper $ defaultMain tests
+ test/template/Test/TastyWrapper.hs view
@@ -0,0 +1,20 @@+{-# LANGUAGE CPP #-}++module Test.TastyWrapper where++#if defined(javascript_HOST_ARCH)+import GHC.IO.Handle (hDuplicateTo)+import System.IO (IOMode (ReadMode), stdin, withFile)+#endif++tastyWrapper :: IO a -> IO a+#if defined(javascript_HOST_ARCH)+-- Tasty's console reporter queries terminal width through ansi-terminal, which+-- trips h$fdReady in the JS RTS when this test runs attached to a TTY.+tastyWrapper action =+ withFile "/dev/null" ReadMode $ \devNull -> do+ hDuplicateTo devNull stdin+ action+#else+tastyWrapper = id+#endif
+ test/unix/Main.hs view
@@ -0,0 +1,11 @@+module Main where++import Test.Format.Format+import Test.LocalTime.TimeZone+import Test.Tasty++tests :: TestTree+tests = testGroup "Time" [testGroup "Format" testFormat, testGroup "LocalTime" [testTimeZone]]++main :: IO ()+main = defaultMain tests
+ test/unix/Test/Format/Format.hs view
@@ -0,0 +1,282 @@+{-# OPTIONS -fno-warn-orphans #-}++module Test.Format.Format (+ testFormat,+) where++import Data.Char+import Data.Fixed as F+import Data.Time+import Data.Time.Clock.POSIX+import Foreign+import Foreign.C+import System.IO.Unsafe+import System.Random+import Test.QuickCheck hiding (Result)+import Test.QuickCheck.Property+import Test.Tasty+import Test.Tasty.HUnit+import Test.Tasty.QuickCheck+import Test.TestUtil++{-+ size_t format_time (+ char *s, size_t maxsize,+ const char *format,+ int isdst,int gmtoff,time_t t);+-}+foreign import ccall unsafe "FormatStuff.h format_time"+ format_time ::+ CString ->+ CSize ->+ CString ->+ CInt ->+ CInt ->+ CString ->+ CTime ->+ IO CSize++withBuffer :: Int -> (CString -> IO CSize) -> IO String+withBuffer n f =+ withArray+ (replicate n 0)+ ( \buffer -> do+ len <- f buffer+ peekCStringLen (buffer, fromIntegral len)+ )++unixFormatTime :: String -> TimeZone -> UTCTime -> String+unixFormatTime fmt zone time =+ unsafePerformIO $+ withCString+ fmt+ ( \pfmt ->+ withCString+ (timeZoneName zone)+ ( \pzonename ->+ withBuffer+ 100+ ( \buffer ->+ format_time+ buffer+ 100+ pfmt+ ( if timeZoneSummerOnly zone+ then 1+ else 0+ )+ (fromIntegral (timeZoneMinutes zone * 60))+ pzonename+ (fromInteger (floor (utcTimeToPOSIXSeconds time)))+ )+ )+ )++locale :: TimeLocale+locale = defaultTimeLocale{dateTimeFmt = "%a %b %e %H:%M:%S %Y"}++instance Random (F.Fixed res) where+ randomR (MkFixed lo, MkFixed hi) oldgen =+ let+ (v, newgen) = randomR (lo, hi) oldgen+ in+ (MkFixed v, newgen)+ random oldgen =+ let+ (v, newgen) = random oldgen+ in+ (MkFixed v, newgen)++instance Arbitrary TimeZone where+ arbitrary = do+ mins <- choose (-2000, 2000)+ dst <- arbitrary+ hasName <- arbitrary+ let+ name =+ if hasName+ then "ZONE"+ else ""+ return $ TimeZone mins dst name++instance Arbitrary TimeOfDay where+ arbitrary = do+ h <- choose (0, 23)+ m <- choose (0, 59)+ s <- choose (0, 59.999999999999) -- don't allow leap-seconds+ return $ TimeOfDay h m s++-- | The size of 'CTime' is platform-dependent.+secondsFitInCTime :: Integer -> Bool+secondsFitInCTime sec =+ let+ CTime ct = fromInteger sec+ sec' = toInteger ct+ in+ sec == sec'++instance Arbitrary UTCTime where+ arbitrary = do+ day <- choose (-25000, 75000)+ time <- arbitrary+ let+ -- verify that the created time can fit in the local CTime+ localT = LocalTime (ModifiedJulianDay day) time+ utcT = localTimeToUTC utc localT+ secondsInteger = floor (utcTimeToPOSIXSeconds utcT)+ if secondsFitInCTime (secondsInteger + 2 * 86400) && secondsFitInCTime (secondsInteger - 2 * 86400) -- two days slop each way+ then return utcT+ else arbitrary++padN :: Int -> Char -> String -> String+padN n _ s+ | n <= (length s) = s+padN n c s = (replicate (n - length s) c) ++ s++unixWorkarounds :: String -> String -> String+unixWorkarounds "%_Y" s = padN 4 ' ' s+unixWorkarounds "%0Y" s = padN 4 '0' s+unixWorkarounds "%_C" s = padN 2 ' ' s+unixWorkarounds "%0C" s = padN 2 '0' s+unixWorkarounds "%_G" s = padN 4 ' ' s+unixWorkarounds "%0G" s = padN 4 '0' s+unixWorkarounds "%_f" s = padN 2 ' ' s+unixWorkarounds "%0f" s = padN 2 '0' s+unixWorkarounds fmt s+ | elem 'z' fmt = dropWhile isPadChar s+ where+ isPadChar ' ' = True+ isPadChar '0' = True+ isPadChar _ = False+unixWorkarounds _ s = s++lastM :: [a] -> Maybe a+lastM [] = Nothing+lastM [a] = Just a+lastM (_ : aa) = lastM aa++compareFormat :: (String -> String) -> String -> TimeZone -> UTCTime -> Result+compareFormat _modUnix fmt zone _time+ | lastM fmt == Just 'Z' && timeZoneName zone == "" = rejected+compareFormat modUnix fmt zone time =+ let+ ctime = utcToZonedTime zone time+ haskellText = formatTime locale fmt ctime+ unixText = unixFormatTime fmt zone time+ expectedText = unixWorkarounds fmt (modUnix unixText)+ in+ assertEqualQC (show time ++ " with " ++ show zone) expectedText haskellText++-- as found in http://www.opengroup.org/onlinepubs/007908799/xsh/strftime.html+-- plus FgGklz+-- f not supported+-- P not always supported+-- s time-zone dependent+chars :: [Char]+chars = "aAbBcCdDeFgGhHIjklmMnprRStTuUVwWxXyYzZ%"++-- as found in "man strftime" on a glibc system. '#' is different, though+modifiers :: [String]+modifiers = ["", "_", "-", "0", "^"]++widths :: [String]+widths = ["", "1", "2", "9", "12"]++formats :: [String]+formats =+ ["%G-W%V-%u", "%U-%w", "%W-%u"]+ ++ ( do+ char <- chars+ width <- widths+ modifier <- modifiers+ return $ "%" ++ modifier ++ width ++ [char]+ )++hashformats :: [String]+hashformats = do+ char <- chars+ return $ "%#" ++ [char]++testCompareFormat :: [TestTree]+testCompareFormat =+ tgroup formats $ \fmt -> do+ time <- arbitrary+ zone <- arbitrary+ return $ compareFormat id fmt zone time++testCompareHashFormat :: [TestTree]+testCompareHashFormat =+ tgroup hashformats $ \fmt -> do+ time <- arbitrary+ zone <- arbitrary+ return $ compareFormat (fmap toLower) fmt zone time++formatUnitTest :: String -> Pico -> String -> TestTree+formatUnitTest fmt sec expected =+ nameTest (show fmt) $+ let+ tod = TimeOfDay 0 0 (1 + sec)+ found = formatTime locale fmt tod+ in+ assertEqual "" expected found++testQs :: [TestTree]+testQs =+ [ formatUnitTest "%q" 0 "000000000000"+ , formatUnitTest "%q" 0.37 "370000000000"+ , formatUnitTest "%0q" 0 "000000000000"+ , formatUnitTest "%0q" 0.37 "370000000000"+ , formatUnitTest "%_q" 0 " "+ , formatUnitTest "%_q" 0.37 "37 "+ , formatUnitTest "%-q" 0 ""+ , formatUnitTest "%-q" 0.37 "37"+ , formatUnitTest "%1q" 0 "0"+ , formatUnitTest "%1q" 0.37 "3"+ , formatUnitTest "%01q" 0 "0"+ , formatUnitTest "%01q" 0.37 "3"+ , formatUnitTest "%_1q" 0 " "+ , formatUnitTest "%_1q" 0.37 "3"+ , formatUnitTest "%-1q" 0 " "+ , formatUnitTest "%-1q" 0.37 "3"+ , formatUnitTest "%5q" 0 "00000"+ , formatUnitTest "%5q" 0.37 "37000"+ , formatUnitTest "%05q" 0 "00000"+ , formatUnitTest "%05q" 0.37 "37000"+ , formatUnitTest "%_5q" 0 " "+ , formatUnitTest "%_5q" 0.37 "37 "+ , formatUnitTest "%-5q" 0 " "+ , formatUnitTest "%-5q" 0.37 "37 "+ , formatUnitTest "%Q" 0 ""+ , formatUnitTest "%Q" 0.37 ".37"+ , formatUnitTest "%0Q" 0 ".000000000000"+ , formatUnitTest "%0Q" 0.37 ".370000000000"+ , formatUnitTest "%_Q" 0 ". "+ , formatUnitTest "%_Q" 0.37 ".37 "+ , formatUnitTest "%-Q" 0 ""+ , formatUnitTest "%-Q" 0.37 ".37"+ , formatUnitTest "%1Q" 0 ".0"+ , formatUnitTest "%1Q" 0.37 ".3"+ , formatUnitTest "%01Q" 0 ".0"+ , formatUnitTest "%01Q" 0.37 ".3"+ , formatUnitTest "%_1Q" 0 ". "+ , formatUnitTest "%_1Q" 0.37 ".3"+ , formatUnitTest "%-1Q" 0 ". "+ , formatUnitTest "%-1Q" 0.37 ".3"+ , formatUnitTest "%5Q" 0 ".00000"+ , formatUnitTest "%5Q" 0.37 ".37000"+ , formatUnitTest "%05Q" 0 ".00000"+ , formatUnitTest "%05Q" 0.37 ".37000"+ , formatUnitTest "%_5Q" 0 ". "+ , formatUnitTest "%_5Q" 0.37 ".37 "+ , formatUnitTest "%-5Q" 0 ". "+ , formatUnitTest "%-5Q" 0.37 ".37 "+ ]++strftimeHasGNUExts :: Bool+strftimeHasGNUExts = unixFormatTime "%_6Y" utc (UTCTime (fromGregorian 1980 1 1) 0) == " 1980"++testFormat :: [TestTree]+testFormat =+ if strftimeHasGNUExts+ then pure $ localOption (QuickCheckTests 10000) $ testGroup "testFormat" $ testCompareFormat ++ testCompareHashFormat ++ testQs+ else []
+ test/unix/Test/Format/FormatStuff.c view
@@ -0,0 +1,15 @@+#include "FormatStuff.h"++size_t format_time (+ char* buffer, size_t maxsize,+ const char* format,+ int isdst,int gmtoff,char* zonename,time_t t)+{+ t += gmtoff;+ struct tm tmd;+ gmtime_r(&t,&tmd);+ tmd.tm_isdst = isdst;+ tmd.tm_gmtoff = gmtoff;+ tmd.tm_zone = zonename;+ return strftime(buffer,maxsize,format,&tmd);+}
+ test/unix/Test/Format/FormatStuff.h view
@@ -0,0 +1,6 @@+#include <time.h>++size_t format_time (+ char *s, size_t maxsize,+ const char *format,+ int isdst,int gmtoff,char* zonename,time_t t);
+ test/unix/Test/LocalTime/TimeZone.hs view
@@ -0,0 +1,19 @@+module Test.LocalTime.TimeZone (+ testTimeZone,+) where++import Data.Time+import System.Environment (setEnv)+import Test.Tasty+import Test.Tasty.HUnit++testTimeZone :: TestTree+testTimeZone =+ testCase "getTimeZone respects TZ env var" $ do+ let+ epoch = UTCTime (ModifiedJulianDay 57000) 0+ setEnv "TZ" "UTC+0"+ zone1 <- getTimeZone epoch+ setEnv "TZ" "EST+5"+ zone2 <- getTimeZone epoch+ assertBool "zone not changed" $ zone1 /= zone2
+ test/unix/Test/TestUtil.hs view
@@ -0,0 +1,45 @@+module Test.TestUtil where++import Test.QuickCheck.Property+import Test.Tasty+import Test.Tasty.HUnit+import Test.Tasty.QuickCheck hiding (reason)++assertFailure' :: String -> IO a+assertFailure' s = do+ _ <- assertFailure s -- returns () in some versions+ return undefined++assertJust :: Maybe a -> IO a+assertJust (Just a) = return a+assertJust Nothing = assertFailure' "Nothing"++class NameTest a where+ nameTest :: String -> a -> TestTree++instance NameTest [TestTree] where+ nameTest = testGroup++instance NameTest Assertion where+ nameTest = Test.Tasty.HUnit.testCase++instance NameTest Property where+ nameTest = testProperty++instance NameTest Result where+ nameTest name = nameTest name . property++instance (Arbitrary a, Show a, Testable b) => NameTest (a -> b) where+ nameTest name = nameTest name . property++instance Testable a => NameTest (Gen a) where+ nameTest name = nameTest name . property++tgroup :: (Show a, NameTest t) => [a] -> (a -> t) -> [TestTree]+tgroup aa f = fmap (\a -> nameTest (show a) $ f a) aa++assertEqualQC :: (Show a, Eq a) => String -> a -> a -> Result+assertEqualQC _name expected found+ | expected == found = succeeded+assertEqualQC "" expected found = failed{reason = "expected " ++ show expected ++ ", found " ++ show found}+assertEqualQC name expected found = failed{reason = name ++ ": expected " ++ show expected ++ ", found " ++ show found}
time.cabal view
@@ -1,33 +1,67 @@+cabal-version: 3.0 name: time-version: 1.1.4+version: 1.16 stability: stable-license: BSD3+license: BSD-2-Clause license-file: LICENSE author: Ashley Yakeley maintainer: <ashley@semantic.org>-homepage: http://semantic.org/TimeLib/+homepage: https://github.com/haskell/time+bug-reports: https://github.com/haskell/time/issues synopsis: A time library-description: A time library-category: System-build-type: Custom-cabal-version: >=1.6+description: Time, clocks and calendars+category: Time+build-type: Configure+tested-with:+ GHC == 9.8.4,+ GHC == 9.10.3,+ GHC == 9.12.4,+ GHC == 9.14.1 x-follows-version-policy: extra-source-files: aclocal.m4 configure.ac configure- include/HsTime.h- include/HsTimeConfig.h.in+ lib/include/HsTime.h+ lib/include/HsTimeConfig.h.in+ test/unix/Test/Format/*.c+ test/unix/Test/Format/*.h extra-tmp-files: config.log config.status autom4te.cache- include/HsTimeConfig.h+ lib/include/HsTimeConfig.h+extra-doc-files:+ changelog.md +source-repository head+ type: git+ location: https://github.com/haskell/time+ library-{- build-depends: base == 4.*, old-locale+ hs-source-dirs: lib+ default-language: GHC2021+ default-extensions:+ NoGeneralizedNewtypeDeriving+ LambdaCase+ PatternSynonyms+ ViewPatterns+ ghc-options:+ -Wall+ -fwarn-tabs+ -Wno-deriving-typeable+ c-sources: lib/cbits/HsTime.c+ build-depends:+ base >= 4.19 && < 5,+ deepseq >= 1.1,+ -- template-haskell-lift was added as a boot library in GHC-9.14+ -- once we no longer wish to backport releases to older major releases,+ -- this conditional can be dropped+ if impl(ghc < 9.14)+ build-depends: template-haskell+ elif impl(ghc)+ build-depends: template-haskell-lift >= 0.1 && <0.2 if os(windows) build-depends: Win32 exposed-modules:@@ -37,34 +71,227 @@ Data.Time.Calendar.WeekDate, Data.Time.Calendar.Julian, Data.Time.Calendar.Easter,+ Data.Time.Calendar.Month,+ Data.Time.Calendar.Quarter, Data.Time.Clock,+ Data.Time.Clock.System, Data.Time.Clock.POSIX, Data.Time.Clock.TAI, Data.Time.LocalTime, Data.Time.Format,+ Data.Time.Format.ISO8601, Data.Time- extensions: ForeignFunctionInterface, CPP- c-sources: cbits/HsTime.c other-modules:- Data.Time.Calendar.Private,+ Data.Format,+ Data.Time.Calendar.CalendarDiffDays, Data.Time.Calendar.Days, Data.Time.Calendar.Gregorian, Data.Time.Calendar.JulianYearDay,- Data.Time.Clock.Scale,- Data.Time.Clock.UTC,- Data.Time.Clock.CTimeval,- Data.Time.Clock.UTCDiff,- Data.Time.LocalTime.TimeZone,- Data.Time.LocalTime.TimeOfDay,- Data.Time.LocalTime.LocalTime,- Data.Time.Format.Parse- include-dirs: include+ Data.Time.Calendar.Private,+ Data.Time.Calendar.Types,+ Data.Time.Calendar.Week,+ Data.Time.Format.Internal,+ Data.Time.Clock.Internal.DiffTime,+ Data.Time.Clock.Internal.AbsoluteTime,+ Data.Time.Clock.Internal.NominalDiffTime,+ Data.Time.Clock.Internal.POSIXTime,+ Data.Time.Clock.Internal.UniversalTime,+ Data.Time.Clock.Internal.SystemTime,+ Data.Time.Clock.Internal.UTCTime,+ Data.Time.Clock.Internal.CTimeval,+ Data.Time.Clock.Internal.UTCDiff,+ Data.Time.LocalTime.Internal.Foreign,+ Data.Time.LocalTime.Internal.TimeZone,+ Data.Time.LocalTime.Internal.TimeOfDay,+ Data.Time.LocalTime.Internal.CalendarDiffTime,+ Data.Time.LocalTime.Internal.LocalTime,+ Data.Time.LocalTime.Internal.ZonedTime,+ Data.Time.Format.Parse,+ Data.Time.Format.Locale,+ Data.Time.Format.Format.Class,+ Data.Time.Format.Format.Instances,+ Data.Time.Format.Parse.Class,+ Data.Time.Format.Parse.Instances+ if !impl(mhs)+ other-modules:+ Data.Time.Clock.Internal.CTimespec+ include-dirs: lib/include if os(windows) install-includes: HsTime.h else+ autogen-includes:+ HsTimeConfig.h install-includes: HsTime.h HsTimeConfig.h-} +test-suite ShowDefaultTZAbbreviations+ type: exitcode-stdio-1.0+ hs-source-dirs: test+ default-language: GHC2021+ ghc-options: -Wall -fwarn-tabs+ build-depends:+ base,+ time+ main-is: ShowDefaultTZAbbreviations.hs++test-suite ShowTime+ type: exitcode-stdio-1.0+ hs-source-dirs: test+ default-language: GHC2021+ ghc-options: -Wall -fwarn-tabs+ build-depends:+ base,+ time+ main-is: ShowTime.hs++test-suite ForeignCalls+ type: exitcode-stdio-1.0+ hs-source-dirs: test+ default-language: GHC2021+ ghc-options: -Wall -fwarn-tabs+ build-depends:+ base,+ time+ main-is: ForeignCalls.hs++test-suite test-main+ if arch (javascript)+ -- blocked by splitmix+ -- https://github.com/haskellari/splitmix/issues/93+ buildable: False+ type: exitcode-stdio-1.0+ hs-source-dirs: test/main+ default-language: GHC2021+ default-extensions:+ DefaultSignatures+ DerivingStrategies+ RecordWildCards+ UndecidableInstances+ ghc-options: -Wall -fwarn-tabs+ if !arch (wasm32)+ ghc-options: -threaded -rtsopts -with-rtsopts=-N+ build-depends:+ base,+ deepseq,+ time,+ random,+ QuickCheck,+ tasty,+ tasty-hunit,+ tasty-quickcheck,+ if impl(ghc < 9.14)+ build-depends: template-haskell+ elif impl(ghc)+ build-depends: template-haskell-lift >= 0.1 && <0.2+ main-is: Main.hs+ other-modules:+ Test.AddDiff+ Test.Types+ Test.TestUtil+ Test.Arbitrary+ Test.Calendar.AddDays+ Test.Calendar.AddDaysRef+ Test.Calendar.CalendarProps+ Test.Calendar.Calendars+ Test.Calendar.CalendarsRef+ Test.Calendar.ClipDates+ Test.Calendar.ClipDatesRef+ Test.Calendar.ConvertBack+ Test.Calendar.Duration+ Test.Calendar.Easter+ Test.Calendar.EasterRef+ Test.Calendar.DayPeriod+ Test.Calendar.LongWeekYears+ Test.Calendar.LongWeekYearsRef+ Test.Calendar.MonthDay+ Test.Calendar.MonthDayRef+ Test.Calendar.MonthOfYear+ Test.Calendar.Valid+ Test.Calendar.Week+ Test.Calendar.Year+ Test.Clock.Conversion+ Test.Clock.Pattern+ Test.Clock.Resolution+ Test.Clock.TAI+ Test.Format.Compile+ Test.Format.Format+ Test.Format.ParseTime+ Test.Format.ISO8601+ Test.LocalTime.CalendarDiffTime+ Test.LocalTime.Time+ Test.LocalTime.TimeOfDay+ Test.LocalTime.TimeRef++test-suite test-template+ if arch (wasm32)+ buildable: False+ type: exitcode-stdio-1.0+ hs-source-dirs: test/template+ default-language: GHC2021+ default-extensions:+ DerivingStrategies+ UndecidableInstances+ RecordWildCards+ TemplateHaskell+ ghc-options: -Wall -fwarn-tabs+ build-depends:+ base,+ deepseq,+ time,+ random,+ QuickCheck,+ tasty,+ tasty-hunit,+ tasty-quickcheck,+ if impl(ghc < 9.14)+ build-depends: template-haskell+ elif impl(ghc)+ build-depends: template-haskell-lift >= 0.1 && <0.2+ main-is: Main.hs+ other-modules:+ Test.TastyWrapper++test-suite test-unix+ if os(windows) || arch (javascript) || arch (wasm32)+ buildable: False+ type: exitcode-stdio-1.0+ hs-source-dirs: test/unix+ default-language: GHC2021+ default-extensions:+ UndecidableInstances+ ghc-options: -Wall -fwarn-tabs+ if !arch (wasm32)+ ghc-options: -threaded -rtsopts -with-rtsopts=-N+ c-sources: test/unix/Test/Format/FormatStuff.c+ build-depends:+ base,+ deepseq,+ time,+ random,+ QuickCheck,+ tasty,+ tasty-hunit,+ tasty-quickcheck+ main-is: Main.hs+ other-modules:+ Test.TestUtil+ Test.Format.Format+ Test.LocalTime.TimeZone++benchmark time-bench+ type: exitcode-stdio-1.0+ hs-source-dirs: benchmark+ default-language: GHC2021+ ghc-options: -Wall -fwarn-tabs+ build-depends:+ base,+ deepseq,+ time,+ criterion+ if impl(ghc < 9.14)+ build-depends: template-haskell+ elif impl(ghc)+ build-depends: template-haskell-lift >= 0.1 && <0.2+ main-is: Main.hs