time 1.4.2 → 1.5
raw patch · 120 files changed
+6713/−6826 lines, 120 filesdep +timedep −Cabaldep −old-localedep −processdep ~basedep ~test-frameworkdep ~test-framework-quickcheck2
Dependencies added: time
Dependencies removed: Cabal, old-locale, process
Dependency ranges changed: base, test-framework, test-framework-quickcheck2
Files
- Data/Time.hs +0/−12
- Data/Time/Calendar.hs +0/−8
- Data/Time/Calendar/Days.hs +0/−74
- 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/−50
- Data/Time/Calendar/WeekDate.hs +0/−53
- Data/Time/Clock.hs +0/−18
- Data/Time/Clock/CTimeval.hs +0/−32
- Data/Time/Clock/POSIX.hs +0/−66
- Data/Time/Clock/Scale.hs +0/−109
- Data/Time/Clock/TAI.hs +0/−143
- Data/Time/Clock/UTC.hs +0/−124
- Data/Time/Clock/UTCDiff.hs +0/−13
- Data/Time/Format.hs +0/−247
- Data/Time/Format/Parse.hs +0/−636
- Data/Time/LocalTime.hs +0/−10
- Data/Time/LocalTime/LocalTime.hs +0/−109
- Data/Time/LocalTime/TimeOfDay.hs +0/−97
- Data/Time/LocalTime/TimeZone.hs +0/−96
- LICENSE +2/−2
- Test.hs +0/−11
- Test/AddDays.hs +0/−41
- Test/AddDaysRef.hs +0/−250
- Test/ClipDates.hs +0/−46
- Test/ClipDatesRef.hs +0/−566
- Test/ConvertBack.hs +0/−40
- Test/CurrentTime.hs +0/−13
- Test/LongWeekYears.hs +0/−20
- Test/LongWeekYearsRef.hs +0/−155
- Test/RealToFracBenchmark.hs +0/−22
- Test/ShowDST.hs +0/−43
- Test/TAI_UTC_DAT.hs +0/−42
- Test/TestCalendars.hs +0/−30
- Test/TestCalendarsRef.hs +0/−9
- Test/TestEaster.hs +0/−38
- Test/TestEasterRef.hs +0/−62
- Test/TestFormat.hs +0/−186
- Test/TestFormatStuff.c +0/−15
- Test/TestFormatStuff.h +0/−6
- Test/TestMonthDay.hs +0/−22
- Test/TestMonthDayRef.hs +0/−751
- Test/TestParseDAT.hs +0/−53
- Test/TestParseDAT_Ref.hs +0/−95
- Test/TestParseTime.hs +0/−438
- Test/TestTime.hs +0/−106
- Test/TestTimeRef.hs +0/−881
- Test/TestTimeZone.hs +0/−17
- Test/TestUtil.hs +0/−38
- Test/Tests.hs +0/−30
- Test/TimeZone.hs +0/−10
- Test/UseCases.lhs +0/−83
- cbits/HsTime.c +0/−41
- configure +100/−95
- configure.ac +2/−2
- include/HsConfigure.h +0/−7
- include/HsTime.h +0/−23
- include/HsTimeConfig.h +0/−87
- include/HsTimeConfig.h.in +0/−86
- lib/Data/Time.hs +12/−0
- lib/Data/Time/Calendar.hs +8/−0
- lib/Data/Time/Calendar/Days.hs +74/−0
- lib/Data/Time/Calendar/Easter.hs +36/−0
- lib/Data/Time/Calendar/Gregorian.hs +82/−0
- lib/Data/Time/Calendar/Julian.hs +73/−0
- lib/Data/Time/Calendar/JulianYearDay.hs +46/−0
- lib/Data/Time/Calendar/MonthDay.hs +49/−0
- lib/Data/Time/Calendar/OrdinalDate.hs +127/−0
- lib/Data/Time/Calendar/Private.hs +50/−0
- lib/Data/Time/Calendar/WeekDate.hs +53/−0
- lib/Data/Time/Clock.hs +18/−0
- lib/Data/Time/Clock/CTimeval.hs +32/−0
- lib/Data/Time/Clock/POSIX.hs +66/−0
- lib/Data/Time/Clock/Scale.hs +109/−0
- lib/Data/Time/Clock/TAI.hs +143/−0
- lib/Data/Time/Clock/UTC.hs +124/−0
- lib/Data/Time/Clock/UTCDiff.hs +13/−0
- lib/Data/Time/Format.hs +246/−0
- lib/Data/Time/Format/Locale.hs +87/−0
- lib/Data/Time/Format/Parse.hs +489/−0
- lib/Data/Time/LocalTime.hs +10/−0
- lib/Data/Time/LocalTime/LocalTime.hs +109/−0
- lib/Data/Time/LocalTime/TimeOfDay.hs +97/−0
- lib/Data/Time/LocalTime/TimeZone.hs +96/−0
- lib/cbits/HsTime.c +41/−0
- lib/include/HsConfigure.h +7/−0
- lib/include/HsTime.h +23/−0
- lib/include/HsTimeConfig.h +87/−0
- lib/include/HsTimeConfig.h.in +86/−0
- test/ShowDefaultTZAbbreviations.hs +9/−0
- test/Test.hs +11/−0
- test/Test/AddDays.hs +41/−0
- test/Test/AddDaysRef.hs +250/−0
- test/Test/ClipDates.hs +46/−0
- test/Test/ClipDatesRef.hs +566/−0
- test/Test/ConvertBack.hs +40/−0
- test/Test/LongWeekYears.hs +20/−0
- test/Test/LongWeekYearsRef.hs +155/−0
- test/Test/TAI_UTC_DAT.hs +42/−0
- test/Test/TestCalendars.hs +30/−0
- test/Test/TestCalendarsRef.hs +9/−0
- test/Test/TestEaster.hs +36/−0
- test/Test/TestEasterRef.hs +62/−0
- test/Test/TestFormat.hs +185/−0
- test/Test/TestFormatStuff.c +15/−0
- test/Test/TestFormatStuff.h +6/−0
- test/Test/TestMonthDay.hs +22/−0
- test/Test/TestMonthDayRef.hs +751/−0
- test/Test/TestParseDAT.hs +53/−0
- test/Test/TestParseDAT_Ref.hs +95/−0
- test/Test/TestParseTime.hs +581/−0
- test/Test/TestTime.hs +106/−0
- test/Test/TestTimeRef.hs +881/−0
- test/Test/TestUtil.hs +39/−0
- test/Test/Tests.hs +30/−0
- time.cabal +35/−54
− 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,74 +0,0 @@-{-# OPTIONS -fno-warn-unused-imports #-}-#include "HsConfigure.h"--- #hide-module Data.Time.Calendar.Days-(- -- * Days- Day(..),addDays,diffDays-) where--import Control.DeepSeq-import Data.Ix-import Data.Typeable-#if LANGUAGE_Rank2Types-import Data.Data-#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-#if LANGUAGE_DeriveDataTypeable-#if LANGUAGE_Rank2Types- ,Data, Typeable-#endif-#endif- )--instance NFData Day where- rnf (ModifiedJulianDay a) = rnf a---- 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,50 +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--padN :: Int -> Char -> String -> String-padN i _ s | i <= 0 = s-padN i c s = (replicate i c) ++ s--show2Fixed :: NumericPadOption -> Pico -> String-show2Fixed opt x | x < 10 = pad1 opt (showFixed True x)-show2Fixed _ x = showFixed True x--showPaddedMin :: (Num t,Ord t,Show t) => Int -> NumericPadOption -> t -> String-showPaddedMin _ Nothing i = show i-showPaddedMin pl opt i | i < 0 = '-':(showPaddedMin pl opt (negate i))-showPaddedMin pl (Just c) i =- let s = show i in - padN (pl - (length s)) c s--show2 :: (Num t,Ord t,Show t) => NumericPadOption -> t -> String-show2 = showPaddedMin 2--show3 :: (Num t,Ord t,Show t) => NumericPadOption -> t -> String-show3 = showPaddedMin 3--show4 :: (Num t,Ord t,Show t) => NumericPadOption -> t -> String-show4 = showPaddedMin 4--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,32 +0,0 @@--- #hide-module Data.Time.Clock.CTimeval where--#ifndef mingw32_HOST_OS--- All Unix-specific, this--import Foreign.Safe-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- throwErrnoIfMinus1_ "gettimeofday" $ gettimeofday ptval nullPtr- peek ptval- )--#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,109 +0,0 @@-{-# LANGUAGE Trustworthy #-}-{-# OPTIONS -fno-warn-unused-imports #-}-#include "HsConfigure.h"--- #hide-module Data.Time.Clock.Scale-(- -- * Universal Time- -- | Time as measured by the earth.- UniversalTime(..),-- -- * Absolute intervals- DiffTime,- secondsToDiffTime, picosecondsToDiffTime-) where--import Control.DeepSeq-import Data.Ratio ((%))-import Data.Fixed-import Data.Typeable-#if LANGUAGE_Rank2Types-import Data.Data-#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-#if LANGUAGE_DeriveDataTypeable-#if LANGUAGE_Rank2Types- ,Data, Typeable-#endif-#endif- )---- necessary because H98 doesn't have "cunning newtype" derivation-instance NFData UniversalTime where- rnf (ModJulianDate a) = rnf a---- | 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-#if LANGUAGE_DeriveDataTypeable-#if LANGUAGE_Rank2Types-#if HAS_DataPico- ,Data, Typeable-#else-#endif-#endif-#endif- )---- necessary because H98 doesn't have "cunning newtype" derivation-instance NFData DiffTime -- FIXME: Data.Fixed had no NFData instances yet at time of writing---- 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)---- necessary because H98 doesn't have "cunning newtype" derivation-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---- | 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)--{-# RULES-"realToFrac/DiffTime->Pico" realToFrac = \ (MkDiffTime ps) -> ps-"realToFrac/Pico->DiffTime" realToFrac = MkDiffTime- #-}-
− Data/Time/Clock/TAI.hs
@@ -1,143 +0,0 @@-{-# OPTIONS -fno-warn-unused-imports #-}-#include "HsConfigure.h"--- | 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 Control.DeepSeq-import Data.Typeable-import Data.Fixed-#if LANGUAGE_Rank2Types-import Data.Data-#endif---- | AbsoluteTime is TAI, time as measured by a clock.-newtype AbsoluteTime = MkAbsoluteTime {unAbsoluteTime :: DiffTime} deriving (Eq,Ord-#if LANGUAGE_DeriveDataTypeable-#if LANGUAGE_Rank2Types-#if HAS_DataPico- ,Data, Typeable-#endif-#endif-#endif- )--instance NFData AbsoluteTime where- rnf (MkAbsoluteTime a) = rnf a--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,124 +0,0 @@-{-# OPTIONS -fno-warn-unused-imports #-}-{-# LANGUAGE Trustworthy #-}-#include "HsConfigure.h"--- #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 Control.DeepSeq-import Data.Time.Calendar.Days-import Data.Time.Clock.Scale-import Data.Fixed-import Data.Typeable-#if LANGUAGE_Rank2Types-import Data.Data-#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 {- -- | the day- utctDay :: Day,- -- | the time from midnight, 0 <= t < 86401s (because of leap-seconds)- utctDayTime :: DiffTime-}-#if LANGUAGE_DeriveDataTypeable-#if LANGUAGE_Rank2Types-#if HAS_DataPico- deriving (Data, Typeable)-#endif-#endif-#endif--instance NFData UTCTime where- rnf (UTCTime d t) = d `deepseq` t `deepseq` ()--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-#if LANGUAGE_DeriveDataTypeable-#if LANGUAGE_Rank2Types-#if HAS_DataPico- ,Data, Typeable-#endif-#endif-#endif- )---- necessary because H98 doesn't have "cunning newtype" derivation-instance NFData NominalDiffTime -- FIXME: Data.Fixed had no NFData instances yet at time of writing--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--{-# 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- #-}-
− 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 in 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 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@ 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, 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------ [@%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@------ [@%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 Week Date format, no padding. Note @%0G@ and @%_G@ pad to four chars------ [@%g@] year of century for Week Date format, 0-padded to two chars, @00@ - @99@------ [@%f@] century for Week Date format, no padding. Note @%0f@ and @%_f@ pad to two chars------ [@%V@] week of year for Week Date format, 0-padded to two chars, @01@ - @53@------ [@%u@] day of week 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 of year where weeks start on Sunday (as 'sundayStartWeek'), 0-padded to two chars, @00@ - @53@------ [@%w@] day of week number, @0@ (= Sunday) - @6@ (= Saturday)------ [@%W@] week of year where weeks start on Monday (as 'mondayStartWeek'), 0-padded to two chars, @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 (\_ opt -> (show4 (fromMaybe Nothing opt)) . fst . toOrdinalDate)- formatCharacter 'y' = Just (\_ opt -> (show2 (fromMaybe (Just '0') opt)) . mod100 . fst . toOrdinalDate)- formatCharacter 'C' = Just (\_ opt -> (show2 (fromMaybe Nothing 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 (\_ opt -> (show4 (fromMaybe Nothing opt)) . (\(y,_,_) -> y) . toWeekDate)- formatCharacter 'g' = Just (\_ opt -> (show2 (fromMaybe (Just '0') opt)) . mod100 . (\(y,_,_) -> y) . toWeekDate)- formatCharacter 'f' = Just (\_ opt -> (show2 (fromMaybe Nothing 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,636 +0,0 @@-{-# OPTIONS -fno-warn-orphans #-}-#include "HsConfigure.h"---- #hide-module Data.Time.Format.Parse - (- -- * UNIX-style parsing-#if LANGUAGE_Rank2Types- parseTime, readTime, readsTime,-#endif- 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--#if LANGUAGE_Rank2Types-import Control.Monad-#endif-import Data.Char-import Data.Fixed-import Data.List-import Data.Maybe-import Data.Ratio-import System.Locale-#if LANGUAGE_Rank2Types-import Text.ParserCombinators.ReadP hiding (char, string)-#endif--#if LANGUAGE_Rank2Types--- | 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-#endif--- | 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).- -- In the absence of @%C@ or @%Y@, century is 1969 - 2068.- buildTime :: TimeLocale -- ^ The time locale.- -> [(Char,String)] -- ^ Pairs of format characters and the - -- corresponding part of the input.- -> t--#if LANGUAGE_Rank2Types--- | Parses a time value given a format string.--- Supports the same %-codes as 'formatTime', including @%-@, @%_@ and @%0@ modifiers.--- 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@.------ [@%0Y@] accepts exactly four digits.------ [@%0G@] accepts exactly four digits.------ [@%0C@] accepts exactly two digits.------ [@%0f@] accepts exactly two digits.----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 goodReadsTime l fmt s of- [t] -> 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 goodReadsTime l fmt s of- [t] -> t- [] -> error $ "readTime: no parse of " ++ show s- _ -> error $ "readTime: multiple parses of " ++ show s--goodReadsTime :: ParseTime t =>- TimeLocale -- ^ Time locale.- -> String -- ^ Format string- -> String -- ^ Input string.- -> [t]-goodReadsTime l fmt s = [t | (t,r) <- readsTime l fmt s, all isSpace r]---- | 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-----data Padding = NoPadding | SpacePadding | ZeroPadding- deriving Show--type DateFormat = [DateFormatSpec]--data DateFormatSpec = Value (Maybe Padding) Char- | WhiteSpace- | Literal Char- deriving Show--parseFormat :: TimeLocale -> String -> DateFormat-parseFormat l = p- where p "" = []- p ('%': '-' : c :cs) = (pc (Just NoPadding) c) ++ p cs- p ('%': '_' : c :cs) = (pc (Just SpacePadding) c) ++ p cs- p ('%': '0' : c :cs) = (pc (Just ZeroPadding) c) ++ p cs- p ('%': c :cs) = (pc Nothing c) ++ p cs- p (c:cs) | isSpace c = WhiteSpace : p cs- p (c:cs) = Literal c : p cs- pc _ 'c' = p (dateTimeFmt l)- pc _ 'R' = p "%H:%M"- pc _ 'T' = p "%H:%M:%S"- pc _ 'X' = p (timeFmt l)- pc _ 'r' = p (time12Fmt l)- pc _ 'D' = p "%m/%d/%y"- pc _ 'F' = p "%Y-%m-%d"- pc _ 'x' = p (dateFmt l)- pc _ 'h' = p "%b"- pc _ '%' = [Literal '%']- pc mpad c = [Value mpad c]--parseInput :: TimeLocale -> DateFormat -> ReadP [(Char,String)]-parseInput _ [] = return []-parseInput l (Value mpad c:ff) = do- s <- parseValue l mpad c- r <- parseInput l ff- return ((c,s):r)-parseInput l (Literal c:ff) = do- _ <- char c- parseInput l ff-parseInput l (WhiteSpace:ff) = do- _ <- satisfy isSpace- case ff of- (WhiteSpace:_) -> return ()- _ -> skipSpaces- parseInput l ff---- | Get the string corresponding to the given format specifier.-parseValue :: TimeLocale -> Maybe Padding -> Char -> ReadP String-parseValue l mpad c = - case c of- -- century- 'C' -> digits SpacePadding 2- 'f' -> digits SpacePadding 2-- -- year- 'Y' -> digits SpacePadding 4- 'G' -> digits SpacePadding 4- - -- year of century- 'y' -> digits ZeroPadding 2- 'g' -> digits ZeroPadding 2-- -- month of year- 'B' -> oneOf (map fst (months l))- 'b' -> oneOf (map snd (months l))- 'm' -> digits ZeroPadding 2- - -- day of month- 'd' -> digits ZeroPadding 2- 'e' -> digits SpacePadding 2- - -- week of year- 'V' -> digits ZeroPadding 2- 'U' -> digits ZeroPadding 2- 'W' -> digits 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' -> digits 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' -> digits ZeroPadding 2- 'k' -> digits SpacePadding 2- - -- hour of dayhalf (i.e. 12h)- 'I' -> digits ZeroPadding 2- 'l' -> digits SpacePadding 2- - -- minute of hour- 'M' -> digits ZeroPadding 2- - -- second of minute- 'S' -> digits ZeroPadding 2- - -- picosecond of second- 'q' -> digits ZeroPadding 12- 'Q' -> liftM2 (:) (char '.') (munch isDigit) <++ return ""-- -- time zone- 'z' -> numericTZ- 'Z' -> munch1 isAlpha <++- numericTZ <++- return "" -- produced by %Z for LocalTime-- -- seconds since epoch- 's' -> (char '-' >> liftM ('-':) (munch1 isDigit)) - <++ munch1 isDigit-- _ -> fail $ "Unknown format character: " ++ show c- where- oneOf = choice . map string- digitsforce ZeroPadding n = count n (satisfy isDigit)- digitsforce SpacePadding _n = skipSpaces >> many1 (satisfy isDigit)- digitsforce NoPadding _n = many1 (satisfy isDigit)- digits pad = digitsforce (fromMaybe pad mpad)- numericTZ = do s <- choice [char '+', char '-']- h <- digitsforce ZeroPadding 2- optional (char ':')- m <- digitsforce ZeroPadding 2- return (s:h++m)-#endif------- * Instances for the time package types-----data DayComponent = Century Integer -- century of all years- | CenturyYear Integer -- 0-99, last two digits of both real years and week years- | YearMonth Int -- 1-12- | MonthDay Int -- 1-31- | YearDay Int -- 1-366- | WeekDay Int -- 1-7 (mon-sun)- | YearWeek 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- -- %C: century (all but the last two digits of the year), 00 - 99- 'C' -> [Century (read x)]- -- %f century (all but the last two digits of the year), 00 - 99- 'f' -> [Century (read x)]- -- %Y: year- 'Y' -> let y = read x in [Century (y `div` 100), CenturyYear (y `mod` 100)]- -- %G: year for Week Date format- 'G' -> let y = read x in [Century (y `div` 100), CenturyYear (y `mod` 100)]- -- %y: last two digits of year, 00 - 99- 'y' -> [CenturyYear (read x)]- -- %g: last two digits of year for Week Date format, 00 - 99- 'g' -> [CenturyYear (read x)]- -- %B: month name, long form (fst from months locale), January - December- 'B' -> [YearMonth (1 + fromJust (elemIndex (up x) (map (up . fst) (months l))))]- -- %b: month name, short form (snd from months locale), Jan - Dec- 'b' -> [YearMonth (1 + fromJust (elemIndex (up x) (map (up . snd) (months l))))]- -- %m: month of year, leading 0 as needed, 01 - 12- 'm' -> [YearMonth (read x)]- -- %d: day of month, leading 0 as needed, 01 - 31- 'd' -> [MonthDay (read x)]- -- %e: day of month, leading space as needed, 1 - 31- 'e' -> [MonthDay (read x)]- -- %V: week for Week Date format, 01 - 53- 'V' -> [YearWeek ISOWeek (read x)]- -- %U: week number of year, where weeks start on Sunday (as sundayStartWeek), 01 - 53- 'U' -> [YearWeek SundayWeek (read x)]- -- %W: week number of year, where weeks start on Monday (as mondayStartWeek), 01 - 53- 'W' -> [YearWeek MondayWeek (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)]- -- %w: day of week number, 0 (= Sunday) - 6 (= Saturday)- 'w' -> [WeekDay (((read x + 6) `mod` 7) + 1)]- -- %j: day of year for Ordinal Date format, 001 - 366- 'j' -> [YearDay (read x)]- _ -> []-- buildDay cs = rest cs- where- y = let - d = safeLast 70 [x | CenturyYear x <- cs]- c = safeLast (if d >= 69 then 19 else 20) [x | Century x <- cs]- in 100 * c + d-- rest (YearMonth m:_) = let d = safeLast 1 [x | MonthDay x <- cs]- in fromGregorian y m d- rest (YearDay d:_) = fromOrdinalDate y d- rest (YearWeek 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 [YearMonth 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--#if LANGUAGE_Rank2Types-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 ]-#endif--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]---- Dubious-_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,109 +0,0 @@-{-# OPTIONS -fno-warn-orphans -fno-warn-unused-imports #-}-#include "HsConfigure.h"---- #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 Control.DeepSeq-import Data.Typeable-#if LANGUAGE_Rank2Types-import Data.Data-#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-#if LANGUAGE_DeriveDataTypeable-#if LANGUAGE_Rank2Types-#if HAS_DataPico- ,Data, Typeable-#endif-#endif-#endif- )--instance NFData LocalTime where- rnf (LocalTime d t) = d `deepseq` t `deepseq` ()--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-}-#if LANGUAGE_DeriveDataTypeable-#if LANGUAGE_Rank2Types-#if HAS_DataPico- deriving (Data, Typeable)-#endif-#endif-#endif--instance NFData ZonedTime where- rnf (ZonedTime lt z) = lt `deepseq` z `deepseq` ()--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,97 +0,0 @@-{-# OPTIONS -fno-warn-unused-imports #-}-#include "HsConfigure.h"--- #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 Control.DeepSeq-import Data.Typeable-import Data.Fixed-#if LANGUAGE_Rank2Types-import Data.Data-#endif---- | 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-#if LANGUAGE_DeriveDataTypeable-#if LANGUAGE_Rank2Types-#if HAS_DataPico- ,Data, Typeable-#endif-#endif-#endif- )--instance NFData TimeOfDay where- rnf (TimeOfDay h m s) = h `deepseq` m `deepseq` s `seq` () -- FIXME: Data.Fixed had no NFData instances yet at time of writing---- | 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) / realToFrac posixDayLength
− Data/Time/LocalTime/TimeZone.hs
@@ -1,96 +0,0 @@-{-# OPTIONS -fno-warn-unused-imports #-}-{-# LANGUAGE ForeignFunctionInterface #-}-#include "HsConfigure.h"---- #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.Safe-import Foreign.C-import Control.DeepSeq-import Data.Typeable-#if LANGUAGE_Rank2Types-import Data.Data-#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 {- -- | 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-#if LANGUAGE_DeriveDataTypeable-#if LANGUAGE_Rank2Types- ,Data, Typeable-#endif-#endif- )--instance NFData TimeZone where- rnf (TimeZone m so n) = m `deepseq` so `deepseq` n `deepseq` ()---- | 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-2010.-All rights reserved.+TimeLib is Copyright (c) Ashley Yakeley, 2004-2014. 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:
− Test.hs
@@ -1,11 +0,0 @@-module Main where-import Test.Framework-import Test.Tests-import Foreign.C.Types--main :: IO ()-main = do- if (toRational (1000000000000 :: CTime)) /= (1000000000000 :: Rational)- then putStrLn "WARNING: Some tests will incorrectly fail due to a 32-bit time_t C type."- else return ()- defaultMain tests
− Test/AddDays.hs
@@ -1,41 +0,0 @@-module Test.AddDays where--import Data.Time.Calendar-import Test.TestUtil-import Test.AddDaysRef--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 :: Test-addDaysTest = pureTest "addDays" $- diff addDaysRef $ unlines resultDays
− Test/AddDaysRef.hs
@@ -1,250 +0,0 @@-module Test.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/ClipDates.hs
@@ -1,46 +0,0 @@-{-# Language TupleSections #-}--module Test.ClipDates where--import Data.Time.Calendar.OrdinalDate-import Data.Time.Calendar.WeekDate-import Data.Time.Calendar-import Test.TestUtil-import Test.ClipDatesRef--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------clipDates :: Test-clipDates = pureTest "clipDates" $- let - yad = unlines $ map yearAndDay $ - tupleUp2 [1968,1969,1971] [-4,0,1,200,364,365,366,367,700]- -- greg = unlines $ 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]-- iso = unlines $ map iSOWeekDay $ - tupleUp3 [1968,1969,2004] [-20,-1,0,1,20,51,52,53,54] [-2,-1,0,1,4,6,7,8,9]-- in diff clipDatesRef $ - concat [ "YearAndDay\n", yad, "Gregorian\n", greg, "ISOWeekDay\n", iso ]
− Test/ClipDatesRef.hs
@@ -1,566 +0,0 @@-module Test.ClipDatesRef where--clipDatesRef :: String-clipDatesRef =- unlines - [ "YearAndDay"- , "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"- , "Gregorian"- , "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"- , "ISOWeekDay"- , "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/ConvertBack.hs
@@ -1,40 +0,0 @@-module Test.ConvertBack where--import Data.Time.Calendar.OrdinalDate-import Data.Time.Calendar.Julian-import Data.Time.Calendar.WeekDate-import Data.Time.Calendar-import Test.TestUtil--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 :: Test-convertBack = pureTest "convertBack" $- diff "" $ concatMap (\ch -> concatMap ch days) checkers
− Test/CurrentTime.hs
@@ -1,13 +0,0 @@-{-# OPTIONS -Wall -Werror #-}--module Main where--import Data.Time--main :: IO ()-main = do- now <- getCurrentTime- putStrLn (show (utctDay now) ++ "," ++ show (utctDayTime now))- putStrLn (show (utcToZonedTime utc now :: ZonedTime))- myzone <- getCurrentTimeZone- putStrLn (show (utcToZonedTime myzone now :: ZonedTime))
− Test/LongWeekYears.hs
@@ -1,20 +0,0 @@-module Test.LongWeekYears where--import Data.Time.Calendar.WeekDate-import Data.Time.Calendar-import Test.TestUtil-import Test.LongWeekYearsRef--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 :: Test-longWeekYears = pureTest "longWeekYears" $- diff longWeekYearsRef $ unlines $ map showLongYear [1901 .. 2050]
− Test/LongWeekYearsRef.hs
@@ -1,155 +0,0 @@-module Test.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/RealToFracBenchmark.hs
@@ -1,22 +0,0 @@-{- Contributed by Liyang HU <haskell.org@liyang.hu> -}-module Main where--import Prelude-import Control.Applicative-import Control.Monad-import Control.DeepSeq-import Data.Time-import Data.Time.Clock.POSIX-import System.Random--main :: IO ()-main = do- ts <- replicateM 100000 $ do- t <- posixSecondsToUTCTime . realToFrac <$>- ( (*) . fromInteger <$> randomRIO (-15*10^21, 15*10^21) <*>- randomIO :: IO Double ) :: IO UTCTime- rnf t `seq` return t- now <- getCurrentTime- print . sum $ map (diffUTCTime now) ts- print =<< flip diffUTCTime now <$> getCurrentTime-
− Test/ShowDST.hs
@@ -1,43 +0,0 @@-{-# OPTIONS -Wall -Werror #-}--module Main where--import Data.Time--monthBeginning :: TimeZone -> Integer -> Int -> UTCTime-monthBeginning zone year month = localTimeToUTC zone- (LocalTime (fromGregorian year month 1) midnight)--findTransition :: UTCTime -> UTCTime -> IO [(UTCTime,TimeZone,TimeZone)]-findTransition a b = do- za <- getTimeZone a- zb <- getTimeZone b- if za == zb then return [] else do- let c = addUTCTime ((diffUTCTime b a) / 2) a- if a == c then return [(b,za,zb)] else do- tp <- findTransition a c- tq <- findTransition c b- return (tp ++ tq)--showZoneTime :: TimeZone -> UTCTime -> String-showZoneTime zone time = show (utcToZonedTime zone time)--showTransition :: (UTCTime,TimeZone,TimeZone) -> String-showTransition (time,zone1,zone2) = (showZoneTime zone1 time) ++ " => " ++ (showZoneTime zone2 time)--main :: IO ()-main = do- now <- getCurrentTime- zone <- getTimeZone now- let (year,_,_) = toGregorian (localDay (utcToLocalTime zone now))- putStrLn ("DST adjustments for " ++ show year ++ ":")- let t0 = monthBeginning zone year 1- let t1 = monthBeginning zone year 4- let t2 = monthBeginning zone year 7- let t3 = monthBeginning zone year 10- let t4 = monthBeginning zone (year + 1) 1- tr1 <- findTransition t0 t1- tr2 <- findTransition t1 t2- tr3 <- findTransition t2 t3- tr4 <- findTransition t3 t4- mapM_ (putStrLn . showTransition) (tr1 ++ tr2 ++ tr3 ++ tr4)
− Test/TAI_UTC_DAT.hs
@@ -1,42 +0,0 @@-module Test.TAI_UTC_DAT where--taiUTC_DAT :: String-taiUTC_DAT =- unlines - [ "1961 JAN 1 =JD 2437300.5 TAI-UTC= 1.4228180 S + (MJD - 37300.) X 0.001296 S"- , "1961 AUG 1 =JD 2437512.5 TAI-UTC= 1.3728180 S + (MJD - 37300.) X 0.001296 S"- , "1962 JAN 1 =JD 2437665.5 TAI-UTC= 1.8458580 S + (MJD - 37665.) X 0.0011232S"- , "1963 NOV 1 =JD 2438334.5 TAI-UTC= 1.9458580 S + (MJD - 37665.) X 0.0011232S"- , "1964 JAN 1 =JD 2438395.5 TAI-UTC= 3.2401300 S + (MJD - 38761.) X 0.001296 S"- , "1964 APR 1 =JD 2438486.5 TAI-UTC= 3.3401300 S + (MJD - 38761.) X 0.001296 S"- , "1964 SEP 1 =JD 2438639.5 TAI-UTC= 3.4401300 S + (MJD - 38761.) X 0.001296 S"- , "1965 JAN 1 =JD 2438761.5 TAI-UTC= 3.5401300 S + (MJD - 38761.) X 0.001296 S"- , "1965 MAR 1 =JD 2438820.5 TAI-UTC= 3.6401300 S + (MJD - 38761.) X 0.001296 S"- , "1965 JUL 1 =JD 2438942.5 TAI-UTC= 3.7401300 S + (MJD - 38761.) X 0.001296 S"- , "1965 SEP 1 =JD 2439004.5 TAI-UTC= 3.8401300 S + (MJD - 38761.) X 0.001296 S"- , "1966 JAN 1 =JD 2439126.5 TAI-UTC= 4.3131700 S + (MJD - 39126.) X 0.002592 S"- , "1968 FEB 1 =JD 2439887.5 TAI-UTC= 4.2131700 S + (MJD - 39126.) X 0.002592 S"- , "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"- , "1973 JAN 1 =JD 2441683.5 TAI-UTC= 12.0 S + (MJD - 41317.) X 0.0 S"- , "1974 JAN 1 =JD 2442048.5 TAI-UTC= 13.0 S + (MJD - 41317.) X 0.0 S"- , "1975 JAN 1 =JD 2442413.5 TAI-UTC= 14.0 S + (MJD - 41317.) X 0.0 S"- , "1976 JAN 1 =JD 2442778.5 TAI-UTC= 15.0 S + (MJD - 41317.) X 0.0 S"- , "1977 JAN 1 =JD 2443144.5 TAI-UTC= 16.0 S + (MJD - 41317.) X 0.0 S"- , "1978 JAN 1 =JD 2443509.5 TAI-UTC= 17.0 S + (MJD - 41317.) X 0.0 S"- , "1979 JAN 1 =JD 2443874.5 TAI-UTC= 18.0 S + (MJD - 41317.) X 0.0 S"- , "1980 JAN 1 =JD 2444239.5 TAI-UTC= 19.0 S + (MJD - 41317.) X 0.0 S"- , "1981 JUL 1 =JD 2444786.5 TAI-UTC= 20.0 S + (MJD - 41317.) X 0.0 S"- , "1982 JUL 1 =JD 2445151.5 TAI-UTC= 21.0 S + (MJD - 41317.) X 0.0 S"- , "1983 JUL 1 =JD 2445516.5 TAI-UTC= 22.0 S + (MJD - 41317.) X 0.0 S"- , "1985 JUL 1 =JD 2446247.5 TAI-UTC= 23.0 S + (MJD - 41317.) X 0.0 S"- , "1988 JAN 1 =JD 2447161.5 TAI-UTC= 24.0 S + (MJD - 41317.) X 0.0 S"- , "1990 JAN 1 =JD 2447892.5 TAI-UTC= 25.0 S + (MJD - 41317.) X 0.0 S"- , "1991 JAN 1 =JD 2448257.5 TAI-UTC= 26.0 S + (MJD - 41317.) X 0.0 S"- , "1992 JUL 1 =JD 2448804.5 TAI-UTC= 27.0 S + (MJD - 41317.) X 0.0 S"- , "1993 JUL 1 =JD 2449169.5 TAI-UTC= 28.0 S + (MJD - 41317.) X 0.0 S"- , "1994 JUL 1 =JD 2449534.5 TAI-UTC= 29.0 S + (MJD - 41317.) X 0.0 S"- , "1996 JAN 1 =JD 2450083.5 TAI-UTC= 30.0 S + (MJD - 41317.) X 0.0 S"- , "1997 JUL 1 =JD 2450630.5 TAI-UTC= 31.0 S + (MJD - 41317.) X 0.0 S"- , "1999 JAN 1 =JD 2451179.5 TAI-UTC= 32.0 S + (MJD - 41317.) X 0.0 S"- , "2006 JAN 1 =JD 2453736.5 TAI-UTC= 33.0 S + (MJD - 41317.) X 0.0 S" ]
− Test/TestCalendars.hs
@@ -1,30 +0,0 @@-module Test.TestCalendars where--import Data.Time.Calendar.Julian-import Data.Time.Calendar.WeekDate-import Data.Time.Calendar-import Test.TestUtil-import Test.TestCalendarsRef--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 :: Test-testCalendars = pureTest "testCalendars" $- diff testCalendarsRef $ unlines $ map (\d -> showShowers d) days- where- showShowers day = - concatMap (\(nm,shower) -> unwords [" ==", nm, shower day]) showers
− Test/TestCalendarsRef.hs
@@ -1,9 +0,0 @@-module Test.TestCalendarsRef 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/TestEaster.hs
@@ -1,38 +0,0 @@-{-# OPTIONS -Wall -Werror #-}--module Test.TestEaster where--import Data.Time.Calendar.Easter-import Data.Time.Calendar-import Data.Time.Format--import System.Locale--import Test.TestUtil-import Test.TestEasterRef------days :: [Day]-days = [ModifiedJulianDay 53000 .. ModifiedJulianDay 53014]--showWithWDay :: Day -> String-showWithWDay = formatTime defaultTimeLocale "%F %A"--testEaster :: Test-testEaster = pureTest "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 diff testEasterRef $ ds ++ concatMap (\y -> f y ++ g y) [2000..2020]
− Test/TestEasterRef.hs
@@ -1,62 +0,0 @@-module Test.TestEasterRef 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/TestFormat.hs
@@ -1,186 +0,0 @@-{-# LANGUAGE ForeignFunctionInterface #-}--module Test.TestFormat where--import Data.Time-import Data.Time.Clock.POSIX-import Data.Char-import System.Locale-import Foreign-import Foreign.C-import Control.Exception;-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 "TestFormatStuff.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 -> IO String-unixFormatTime fmt zone time = 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 (truncate (utcTimeToPOSIXSeconds time)))- )- ))--locale :: TimeLocale-locale = defaultTimeLocale {dateTimeFmt = "%a %b %e %H:%M:%S %Y"}--zones :: [TimeZone]-zones = [utc,TimeZone 87 True "Fenwickian Daylight Time"]--baseTime0 :: UTCTime-baseTime0 = localTimeToUTC utc (LocalTime (fromGregorian 1970 01 01) midnight)--baseTime1 :: UTCTime-baseTime1 = localTimeToUTC utc (LocalTime (fromGregorian 2000 01 01) midnight)--getDay :: Integer -> UTCTime-getDay day = addUTCTime ((fromInteger day) * posixDayLength) baseTime1--getYearP1 :: Integer -> UTCTime-getYearP1 year = localTimeToUTC utc (LocalTime (fromGregorian year 01 01) midnight)--getYearP2 :: Integer -> UTCTime-getYearP2 year = localTimeToUTC utc (LocalTime (fromGregorian year 02 04) midnight)--getYearP3 :: Integer -> UTCTime-getYearP3 year = localTimeToUTC utc (LocalTime (fromGregorian year 03 04) midnight)--getYearP4 :: Integer -> UTCTime-getYearP4 year = localTimeToUTC utc (LocalTime (fromGregorian year 12 31) midnight)--years :: [Integer]-years = [999,1000,1899,1900,1901] ++ [1980..2000] ++ [9999,10000]--times :: [UTCTime]-times = [baseTime0] ++ (fmap getDay [0..23]) ++ (fmap getDay [0..100]) ++- (fmap getYearP1 years) ++ (fmap getYearP2 years) ++ (fmap getYearP3 years) ++ (fmap getYearP4 years)--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 _ s = s--compareFormat :: String -> (String -> String) -> String -> TimeZone -> UTCTime -> Test-compareFormat testname modUnix fmt zone time = let- ctime = utcToZonedTime zone time - haskellText = formatTime locale fmt ctime- in ioTest (testname ++ ": " ++ (show fmt) ++ " of " ++ (show ctime)) $- do- unixText <- unixFormatTime fmt zone time- let expectedText = unixWorkarounds fmt (modUnix unixText)- return $ diff 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 :: [Char]-modifiers = "_-0^"--formats :: [String]-formats = ["%G-W%V-%u","%U-%w","%W-%u"] ++ (fmap (\char -> '%':char:[]) chars)- ++ (concat (fmap (\char -> fmap (\modifier -> '%':modifier:char:[]) modifiers) chars))--hashformats :: [String]-hashformats = (fmap (\char -> '%':'#':char:[]) chars)--somestrings :: [String]-somestrings = ["", " ", "-", "\n"]--getBottom :: a -> IO (Maybe Control.Exception.SomeException);-getBottom a = Control.Exception.catch (seq a (return Nothing)) (return . Just); --safeString :: String -> IO String-safeString s = do- msx <- getBottom s- case msx of- Just sx -> return (show sx)- Nothing -> case s of- (c:cc) -> do- mcx <- getBottom c- case mcx of- Just cx -> return (show cx)- Nothing -> do- ss <- safeString cc- return (c:ss)- [] -> return ""--compareExpected :: (Eq t,Show t,ParseTime t) => String -> String -> String -> Maybe t -> Test-compareExpected testname fmt str expected = ioTest (testname ++ ": " ++ (show fmt) ++ " on " ++ (show str)) $ do- let found = parseTime defaultTimeLocale fmt str- mex <- getBottom found- case mex of- Just ex -> return $ Fail $ unwords [ "Exception: expected" , show expected ++ ", caught", show ex]- Nothing -> return $ diff expected found--class (ParseTime t) => TestParse t where- expectedParse :: String -> String -> Maybe t- expectedParse "%Z" str | all isSpace str = Just (buildTime defaultTimeLocale [])- expectedParse "%_Z" str | all isSpace str = Just (buildTime defaultTimeLocale [])- expectedParse "%-Z" str | all isSpace str = Just (buildTime defaultTimeLocale [])- expectedParse "%0Z" str | all isSpace str = Just (buildTime defaultTimeLocale [])- expectedParse _ _ = Nothing--instance TestParse Day-instance TestParse TimeOfDay-instance TestParse LocalTime-instance TestParse TimeZone-instance TestParse ZonedTime-instance TestParse UTCTime--checkParse :: String -> String -> [Test]-checkParse fmt str- = [ compareExpected "Day" fmt str (expectedParse fmt str :: Maybe Day)- , compareExpected "TimeOfDay" fmt str (expectedParse fmt str :: Maybe TimeOfDay)- , compareExpected "LocalTime" fmt str (expectedParse fmt str :: Maybe LocalTime)- , compareExpected "TimeZone" fmt str (expectedParse fmt str :: Maybe TimeZone)- , compareExpected "UTCTime" fmt str (expectedParse fmt str :: Maybe UTCTime) ]--testCheckParse :: [Test]-testCheckParse = concatMap (\fmt -> concatMap (\str -> checkParse fmt str) somestrings) formats--testCompareFormat :: [Test]-testCompareFormat = concatMap (\fmt -> concatMap (\time -> fmap (\zone -> compareFormat "compare format" id fmt zone time) zones) times) formats--testCompareHashFormat :: [Test]-testCompareHashFormat = concatMap (\fmt -> concatMap (\time -> fmap (\zone -> compareFormat "compare hashformat" (fmap toLower) fmt zone time) zones) times) hashformats--testFormats :: [Test]-testFormats = [- testGroup "checkParse" testCheckParse,- testGroup "compare format" testCompareFormat,- testGroup "compare hashformat" testCompareHashFormat- ]--testFormat :: Test-testFormat = testGroup "testFormat" testFormats
− Test/TestFormatStuff.c
@@ -1,15 +0,0 @@-#include "TestFormatStuff.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/TestFormatStuff.h
@@ -1,6 +0,0 @@-#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/TestMonthDay.hs
@@ -1,22 +0,0 @@-module Test.TestMonthDay where--import Data.Time.Calendar.MonthDay-import Test.TestUtil-import Test.TestMonthDayRef--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 :: Test-testMonthDay = pureTest "testMonthDay" $- diff testMonthDayRef $ concat $ map (\isL -> unlines (leap isL : yearDays isL)) [False,True]- 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/TestMonthDayRef.hs
@@ -1,751 +0,0 @@-module Test.TestMonthDayRef 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/TestParseDAT.hs
@@ -1,53 +0,0 @@-module Test.TestParseDAT where--import Data.Time-import Data.Time.Clock.TAI-import Test.TestUtil-import Test.TestParseDAT_Ref-import Test.TAI_UTC_DAT--tods :: [TimeOfDay]-tods = [- TimeOfDay 0 0 0,- TimeOfDay 0 0 0.5,- TimeOfDay 0 0 1,- TimeOfDay 0 0 1.5,- TimeOfDay 0 0 2,- TimeOfDay 23 59 28,- TimeOfDay 23 59 28.5,- TimeOfDay 23 59 29,- TimeOfDay 23 59 29.5,- TimeOfDay 23 59 30,- TimeOfDay 23 59 30.5,- TimeOfDay 23 59 31,- TimeOfDay 23 59 31.5,- TimeOfDay 23 59 32,- TimeOfDay 23 59 59,- TimeOfDay 23 59 59.5,- TimeOfDay 23 59 60,- TimeOfDay 23 59 60.5- ]--times :: [LocalTime]-times =- fmap (LocalTime (fromGregorian 1998 04 02)) tods ++- fmap (LocalTime (fromGregorian 1998 12 30)) tods ++- fmap (LocalTime (fromGregorian 1998 12 31)) tods ++- fmap (LocalTime (fromGregorian 1999 01 01)) tods ++- fmap (LocalTime (fromGregorian 1999 01 02)) tods--testParseDAT :: Test-testParseDAT = pureTest "testParseDAT" $ diff testParseDAT_Ref parseDAT where- parseDAT = - let lst = parseTAIUTCDATFile taiUTC_DAT in - unlines $ map- (\lt ->- let- utcTime = localTimeToUTC utc lt- taiTime = utcToTAITime lst utcTime- utcTime' = taiToUTCTime lst taiTime- in if utcTime == utcTime'- then unwords [show utcTime, "==", show taiTime]- else unwords [ "correction:", show utcTime, "->", show taiTime, "->", show utcTime']- )- times
− Test/TestParseDAT_Ref.hs
@@ -1,95 +0,0 @@-module Test.TestParseDAT_Ref where--testParseDAT_Ref :: String-testParseDAT_Ref =- unlines- [ "1998-04-02 00:00:00 UTC == 1998-04-02 00:00:31 TAI"- , "1998-04-02 00:00:00.5 UTC == 1998-04-02 00:00:31.5 TAI"- , "1998-04-02 00:00:01 UTC == 1998-04-02 00:00:32 TAI"- , "1998-04-02 00:00:01.5 UTC == 1998-04-02 00:00:32.5 TAI"- , "1998-04-02 00:00:02 UTC == 1998-04-02 00:00:33 TAI"- , "1998-04-02 23:59:28 UTC == 1998-04-02 23:59:59 TAI"- , "1998-04-02 23:59:28.5 UTC == 1998-04-02 23:59:59.5 TAI"- , "1998-04-02 23:59:29 UTC == 1998-04-03 00:00:00 TAI"- , "1998-04-02 23:59:29.5 UTC == 1998-04-03 00:00:00.5 TAI"- , "1998-04-02 23:59:30 UTC == 1998-04-03 00:00:01 TAI"- , "1998-04-02 23:59:30.5 UTC == 1998-04-03 00:00:01.5 TAI"- , "1998-04-02 23:59:31 UTC == 1998-04-03 00:00:02 TAI"- , "1998-04-02 23:59:31.5 UTC == 1998-04-03 00:00:02.5 TAI"- , "1998-04-02 23:59:32 UTC == 1998-04-03 00:00:03 TAI"- , "1998-04-02 23:59:59 UTC == 1998-04-03 00:00:30 TAI"- , "1998-04-02 23:59:59.5 UTC == 1998-04-03 00:00:30.5 TAI"- , "correction: 1998-04-02 23:59:60 UTC -> 1998-04-03 00:00:31 TAI -> 1998-04-03 00:00:00 UTC"- , "correction: 1998-04-02 23:59:60.5 UTC -> 1998-04-03 00:00:31.5 TAI -> 1998-04-03 00:00:00.5 UTC"- , "1998-12-30 00:00:00 UTC == 1998-12-30 00:00:31 TAI"- , "1998-12-30 00:00:00.5 UTC == 1998-12-30 00:00:31.5 TAI"- , "1998-12-30 00:00:01 UTC == 1998-12-30 00:00:32 TAI"- , "1998-12-30 00:00:01.5 UTC == 1998-12-30 00:00:32.5 TAI"- , "1998-12-30 00:00:02 UTC == 1998-12-30 00:00:33 TAI"- , "1998-12-30 23:59:28 UTC == 1998-12-30 23:59:59 TAI"- , "1998-12-30 23:59:28.5 UTC == 1998-12-30 23:59:59.5 TAI"- , "1998-12-30 23:59:29 UTC == 1998-12-31 00:00:00 TAI"- , "1998-12-30 23:59:29.5 UTC == 1998-12-31 00:00:00.5 TAI"- , "1998-12-30 23:59:30 UTC == 1998-12-31 00:00:01 TAI"- , "1998-12-30 23:59:30.5 UTC == 1998-12-31 00:00:01.5 TAI"- , "1998-12-30 23:59:31 UTC == 1998-12-31 00:00:02 TAI"- , "1998-12-30 23:59:31.5 UTC == 1998-12-31 00:00:02.5 TAI"- , "1998-12-30 23:59:32 UTC == 1998-12-31 00:00:03 TAI"- , "1998-12-30 23:59:59 UTC == 1998-12-31 00:00:30 TAI"- , "1998-12-30 23:59:59.5 UTC == 1998-12-31 00:00:30.5 TAI"- , "correction: 1998-12-30 23:59:60 UTC -> 1998-12-31 00:00:31 TAI -> 1998-12-31 00:00:00 UTC"- , "correction: 1998-12-30 23:59:60.5 UTC -> 1998-12-31 00:00:31.5 TAI -> 1998-12-31 00:00:00.5 UTC"- , "1998-12-31 00:00:00 UTC == 1998-12-31 00:00:31 TAI"- , "1998-12-31 00:00:00.5 UTC == 1998-12-31 00:00:31.5 TAI"- , "1998-12-31 00:00:01 UTC == 1998-12-31 00:00:32 TAI"- , "1998-12-31 00:00:01.5 UTC == 1998-12-31 00:00:32.5 TAI"- , "1998-12-31 00:00:02 UTC == 1998-12-31 00:00:33 TAI"- , "1998-12-31 23:59:28 UTC == 1998-12-31 23:59:59 TAI"- , "1998-12-31 23:59:28.5 UTC == 1998-12-31 23:59:59.5 TAI"- , "1998-12-31 23:59:29 UTC == 1999-01-01 00:00:00 TAI"- , "1998-12-31 23:59:29.5 UTC == 1999-01-01 00:00:00.5 TAI"- , "1998-12-31 23:59:30 UTC == 1999-01-01 00:00:01 TAI"- , "1998-12-31 23:59:30.5 UTC == 1999-01-01 00:00:01.5 TAI"- , "1998-12-31 23:59:31 UTC == 1999-01-01 00:00:02 TAI"- , "1998-12-31 23:59:31.5 UTC == 1999-01-01 00:00:02.5 TAI"- , "1998-12-31 23:59:32 UTC == 1999-01-01 00:00:03 TAI"- , "1998-12-31 23:59:59 UTC == 1999-01-01 00:00:30 TAI"- , "1998-12-31 23:59:59.5 UTC == 1999-01-01 00:00:30.5 TAI"- , "1998-12-31 23:59:60 UTC == 1999-01-01 00:00:31 TAI"- , "1998-12-31 23:59:60.5 UTC == 1999-01-01 00:00:31.5 TAI"- , "1999-01-01 00:00:00 UTC == 1999-01-01 00:00:32 TAI"- , "1999-01-01 00:00:00.5 UTC == 1999-01-01 00:00:32.5 TAI"- , "1999-01-01 00:00:01 UTC == 1999-01-01 00:00:33 TAI"- , "1999-01-01 00:00:01.5 UTC == 1999-01-01 00:00:33.5 TAI"- , "1999-01-01 00:00:02 UTC == 1999-01-01 00:00:34 TAI"- , "1999-01-01 23:59:28 UTC == 1999-01-02 00:00:00 TAI"- , "1999-01-01 23:59:28.5 UTC == 1999-01-02 00:00:00.5 TAI"- , "1999-01-01 23:59:29 UTC == 1999-01-02 00:00:01 TAI"- , "1999-01-01 23:59:29.5 UTC == 1999-01-02 00:00:01.5 TAI"- , "1999-01-01 23:59:30 UTC == 1999-01-02 00:00:02 TAI"- , "1999-01-01 23:59:30.5 UTC == 1999-01-02 00:00:02.5 TAI"- , "1999-01-01 23:59:31 UTC == 1999-01-02 00:00:03 TAI"- , "1999-01-01 23:59:31.5 UTC == 1999-01-02 00:00:03.5 TAI"- , "1999-01-01 23:59:32 UTC == 1999-01-02 00:00:04 TAI"- , "1999-01-01 23:59:59 UTC == 1999-01-02 00:00:31 TAI"- , "1999-01-01 23:59:59.5 UTC == 1999-01-02 00:00:31.5 TAI"- , "correction: 1999-01-01 23:59:60 UTC -> 1999-01-02 00:00:32 TAI -> 1999-01-02 00:00:00 UTC"- , "correction: 1999-01-01 23:59:60.5 UTC -> 1999-01-02 00:00:32.5 TAI -> 1999-01-02 00:00:00.5 UTC"- , "1999-01-02 00:00:00 UTC == 1999-01-02 00:00:32 TAI"- , "1999-01-02 00:00:00.5 UTC == 1999-01-02 00:00:32.5 TAI"- , "1999-01-02 00:00:01 UTC == 1999-01-02 00:00:33 TAI"- , "1999-01-02 00:00:01.5 UTC == 1999-01-02 00:00:33.5 TAI"- , "1999-01-02 00:00:02 UTC == 1999-01-02 00:00:34 TAI"- , "1999-01-02 23:59:28 UTC == 1999-01-03 00:00:00 TAI"- , "1999-01-02 23:59:28.5 UTC == 1999-01-03 00:00:00.5 TAI"- , "1999-01-02 23:59:29 UTC == 1999-01-03 00:00:01 TAI"- , "1999-01-02 23:59:29.5 UTC == 1999-01-03 00:00:01.5 TAI"- , "1999-01-02 23:59:30 UTC == 1999-01-03 00:00:02 TAI"- , "1999-01-02 23:59:30.5 UTC == 1999-01-03 00:00:02.5 TAI"- , "1999-01-02 23:59:31 UTC == 1999-01-03 00:00:03 TAI"- , "1999-01-02 23:59:31.5 UTC == 1999-01-03 00:00:03.5 TAI"- , "1999-01-02 23:59:32 UTC == 1999-01-03 00:00:04 TAI"- , "1999-01-02 23:59:59 UTC == 1999-01-03 00:00:31 TAI"- , "1999-01-02 23:59:59.5 UTC == 1999-01-03 00:00:31.5 TAI"- , "correction: 1999-01-02 23:59:60 UTC -> 1999-01-03 00:00:32 TAI -> 1999-01-03 00:00:00 UTC"- , "correction: 1999-01-02 23:59:60.5 UTC -> 1999-01-03 00:00:32.5 TAI -> 1999-01-03 00:00:00.5 UTC" ]
− Test/TestParseTime.hs
@@ -1,438 +0,0 @@-{-# OPTIONS -fno-warn-type-defaults -fno-warn-unused-binds -fno-warn-orphans #-}-{-# LANGUAGE FlexibleInstances, ExistentialQuantification #-}--module Test.TestParseTime where--import Control.Monad-import Data.Char-import Data.Ratio-import Data.Time-import Data.Time.Calendar.OrdinalDate-import Data.Time.Calendar.WeekDate-import Data.Time.Clock.POSIX-import System.Locale-import Test.QuickCheck hiding (Result)-import Test.TestUtil--ntest :: Int-ntest = 1000--type NamedProperty = (String, Property)--testParseTime :: Test-testParseTime = testGroup "testParseTime"- [- testGroup "extests" extests,- testGroup "properties" (fmap (\(n,prop) -> testProperty n prop) properties)- ]--yearDays :: Integer -> [Day]-yearDays y = [(fromGregorian y 1 1) .. (fromGregorian y 12 31)]--makeExhaustiveTest :: String -> [t] -> (t -> Test) -> Test-makeExhaustiveTest name cases f = testGroup name (fmap f cases)--extests :: [Test]-extests = [- 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 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])--parseYMD :: Day -> Test-parseYMD day = case toGregorian day of- (y,m,d) -> parseTest (Just day) "%Y%m%d" ((show y) ++ (show2 m) ++ (show2 d))--parseYearDayD :: Day -> Test-parseYearDayD day = case toGregorian day of- (y,m,d) -> parseTest (Just day) "%Y %m %d" ((show y) ++ " " ++ (show2 m) ++ " " ++ (show2 d))--parseYearDayE :: Day -> Test-parseYearDayE day = case toGregorian day of- (y,m,d) -> parseTest (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 -> Test-parseYY i = parseTest (Just (fromGregorian (expectedYear i) 1 1)) "%y" (show2 i)--parseCYY :: Integer -> Integer -> Test-parseCYY c i = parseTest (Just (fromGregorian ((c * 100) + i) 1 1)) "%-C %y" ((show c) ++ " " ++ (show2 i))--parseCYY2 :: Integer -> Integer -> Test-parseCYY2 c i = parseTest (Just (fromGregorian ((c * 100) + i) 1 1)) "%C %y" ((show2 c) ++ " " ++ (show2 i))--parseCentury :: String -> Integer -> Test-parseCentury int c = parseTest (Just (fromGregorian (c * 100) 1 1)) ("%-C" ++ int ++ "%y") ((show c) ++ int ++ "00")--parseTest :: (Show t, Eq t, ParseTime t) => Maybe t -> String -> String -> Test-parseTest expected formatStr target = - let- found = parse formatStr target- result = diff expected found- name = (show formatStr) ++ " of " ++ (show target)- in pureTest name result--readsTest :: (Show t, Eq t, ParseTime t) => Maybe t -> String -> String -> Test-readsTest expected formatStr target = - let- ff (Just e) = [(e,"")]- ff Nothing = []- found = readsTime defaultTimeLocale formatStr target- result = diff (ff expected) found- name = (show formatStr) ++ " of " ++ (show target)- in pureTest name result--parse :: ParseTime t => String -> String -> Maybe t-parse f t = parseTime defaultTimeLocale f t--format :: (FormatTime t) => String -> t -> String-format f t = formatTime defaultTimeLocale f t--instance Arbitrary Day where- arbitrary = liftM ModifiedJulianDay $ choose (-313698, 2973483) -- 1000-01-1 to 9999-12-31--instance CoArbitrary Day where- coarbitrary (ModifiedJulianDay d) = coarbitrary d--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)- secondsToDiffTime' :: Integer -> DiffTime- secondsToDiffTime' = fromInteger- picosecondsToDiffTime' :: Integer -> DiffTime- picosecondsToDiffTime' x = fromRational (x % 10^12)--instance CoArbitrary DiffTime where- coarbitrary t = coarbitrary (fromEnum t)--instance Arbitrary TimeOfDay where- arbitrary = liftM timeToTimeOfDay arbitrary--instance CoArbitrary TimeOfDay where- coarbitrary t = coarbitrary (timeOfDayToTime t)--instance Arbitrary LocalTime where- arbitrary = liftM2 LocalTime arbitrary arbitrary--instance CoArbitrary LocalTime where- coarbitrary t = coarbitrary (truncate (utcTimeToPOSIXSeconds (localTimeToUTC utc t)) :: Integer)--instance Arbitrary TimeZone where- arbitrary = liftM minutesToTimeZone $ choose (-720,720)--instance CoArbitrary TimeZone where- coarbitrary tz = coarbitrary (timeZoneMinutes tz)--instance Arbitrary ZonedTime where- arbitrary = liftM2 ZonedTime arbitrary arbitrary--instance CoArbitrary ZonedTime where- coarbitrary t = coarbitrary (truncate (utcTimeToPOSIXSeconds (zonedTimeToUTC t)) :: Integer)--instance Arbitrary UTCTime where- arbitrary = liftM2 UTCTime arbitrary arbitrary--instance CoArbitrary UTCTime where- coarbitrary t = coarbitrary (truncate (utcTimeToPOSIXSeconds t) :: Integer)---- missing from the time package-instance Eq ZonedTime where- ZonedTime t1 tz1 == ZonedTime t2 tz2 = t1 == t2 && tz1 == tz2---- --- * tests for dbugging 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 f s `asTypeOf` Just t)------- * show and read -----prop_read_show :: (Read a, Show a, Eq a) => a -> Bool-prop_read_show t = read (show t) == t------- * special show functions-----prop_parse_showWeekDate :: Day -> Bool-prop_parse_showWeekDate d = parse "%G-W%V-%u" (showWeekDate d) == Just d--prop_parse_showGregorian :: Day -> Bool-prop_parse_showGregorian d = parse "%Y-%m-%d" (showGregorian d) == Just d--prop_parse_showOrdinalDate :: Day -> Bool-prop_parse_showOrdinalDate d = parse "%Y-%j" (showOrdinalDate d) == Just d------- * fromMondayStartWeek and fromSundayStartWeek-----prop_fromMondayStartWeek :: Day -> Bool-prop_fromMondayStartWeek d = - let (w,wd) = mondayStartWeek d- (y,_,_) = toGregorian d- in fromMondayStartWeek y w wd == d--prop_fromSundayStartWeek :: Day -> Bool-prop_fromSundayStartWeek d = - let (w,wd) = sundayStartWeek d- (y,_,_) = toGregorian d- in fromSundayStartWeek y w wd == d------- * format and parse ------- | Helper for defining named properties.-prop_named :: (Arbitrary t, Show t, Testable a)- => String -> (FormatString s -> t -> a) -> String -> FormatString s -> NamedProperty-prop_named n prop typeName f = (n ++ " " ++ typeName ++ " " ++ show f, property (prop f))--prop_parse_format :: (Eq t, FormatTime t, ParseTime t) => FormatString t -> t -> Bool-prop_parse_format (FormatString f) t = parse f (format f t) == Just t--prop_parse_format_named :: (Arbitrary t, Eq t, Show t, FormatTime t, ParseTime t) - => String -> FormatString t -> NamedProperty-prop_parse_format_named = prop_named "prop_parse_format" prop_parse_format---- Verify case-insensitivity with upper case.-prop_parse_format_upper :: (Eq t, FormatTime t, ParseTime t) => FormatString t -> t -> Bool-prop_parse_format_upper (FormatString f) t = parse f (map toUpper $ format f t) == Just t--prop_parse_format_upper_named :: (Arbitrary t, Eq t, Show t, FormatTime t, ParseTime t) - => String -> FormatString t -> NamedProperty-prop_parse_format_upper_named = prop_named "prop_parse_format_upper" prop_parse_format_upper---- Verify case-insensitivity with lower case.-prop_parse_format_lower :: (Eq t, FormatTime t, ParseTime t) => FormatString t -> t -> Bool-prop_parse_format_lower (FormatString f) t = parse f (map toLower $ format f t) == Just t--prop_parse_format_lower_named :: (Arbitrary t, Eq t, Show t, FormatTime t, ParseTime t) - => String -> FormatString t -> NamedProperty-prop_parse_format_lower_named = prop_named "prop_parse_format_lower" prop_parse_format_lower--prop_format_parse_format :: (FormatTime t, ParseTime t) => FormatString t -> t -> Bool-prop_format_parse_format (FormatString f) t = - fmap (format f) (parse f (format f t) `asTypeOf` Just t) == Just (format f t)--prop_format_parse_format_named :: (Arbitrary t, Show t, FormatTime t, ParseTime t) - => String -> FormatString t -> NamedProperty-prop_format_parse_format_named = prop_named "prop_format_parse_format" prop_format_parse_format------- * 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 f s of- Nothing -> True- Just t -> t == t `asTypeOf` formatType fs- where -prop_no_crash_bad_input_named :: (Eq t, ParseTime t)- => String -> FormatString t -> NamedProperty-prop_no_crash_bad_input_named = prop_named "prop_no_crash_bad_input" prop_no_crash_bad_input------------newtype FormatString a = FormatString String--formatType :: FormatString t -> t-formatType _ = undefined--castFormatString :: FormatString a -> FormatString b-castFormatString (FormatString f) = FormatString f--instance Show (FormatString a) where- show (FormatString f) = show f--properties :: [NamedProperty]-properties = - [("prop_fromMondayStartWeek", property prop_fromMondayStartWeek),- ("prop_fromSundayStartWeek", property prop_fromSundayStartWeek)]- ++ [("prop_read_show Day", property (prop_read_show :: Day -> Bool)),- ("prop_read_show TimeOfDay", property (prop_read_show :: TimeOfDay -> Bool)),- ("prop_read_show LocalTime", property (prop_read_show :: LocalTime -> Bool)),- ("prop_read_show TimeZone", property (prop_read_show :: TimeZone -> Bool)),- ("prop_read_show ZonedTime", property (prop_read_show :: ZonedTime -> Bool)),- ("prop_read_show UTCTime", property (prop_read_show :: UTCTime -> Bool))]- ++ [("prop_parse_showWeekDate", property prop_parse_showWeekDate),- ("prop_parse_showGregorian", property prop_parse_showGregorian),- ("prop_parse_showOrdinalDate", property prop_parse_showOrdinalDate)]-- ++ map (prop_parse_format_named "Day") dayFormats- ++ map (prop_parse_format_named "TimeOfDay") timeOfDayFormats- ++ map (prop_parse_format_named "LocalTime") localTimeFormats- ++ map (prop_parse_format_named "TimeZone") timeZoneFormats- ++ map (prop_parse_format_named "ZonedTime") zonedTimeFormats- ++ map (prop_parse_format_named "UTCTime") utcTimeFormats-- ++ map (prop_parse_format_upper_named "Day") dayFormats- ++ map (prop_parse_format_upper_named "TimeOfDay") timeOfDayFormats- ++ map (prop_parse_format_upper_named "LocalTime") localTimeFormats- ++ map (prop_parse_format_upper_named "TimeZone") timeZoneFormats- ++ map (prop_parse_format_upper_named "ZonedTime") zonedTimeFormats- ++ map (prop_parse_format_upper_named "UTCTime") utcTimeFormats-- ++ map (prop_parse_format_lower_named "Day") dayFormats- ++ map (prop_parse_format_lower_named "TimeOfDay") timeOfDayFormats- ++ map (prop_parse_format_lower_named "LocalTime") localTimeFormats- ++ map (prop_parse_format_lower_named "TimeZone") timeZoneFormats- ++ map (prop_parse_format_lower_named "ZonedTime") zonedTimeFormats- ++ map (prop_parse_format_lower_named "UTCTime") utcTimeFormats-- ++ map (prop_format_parse_format_named "Day") partialDayFormats- ++ map (prop_format_parse_format_named "TimeOfDay") partialTimeOfDayFormats- ++ map (prop_format_parse_format_named "LocalTime") partialLocalTimeFormats- ++ map (prop_format_parse_format_named "ZonedTime") partialZonedTimeFormats- ++ map (prop_format_parse_format_named "UTCTime") partialUTCTimeFormats-- ++ map (prop_no_crash_bad_input_named "Day") (dayFormats ++ partialDayFormats ++ failingPartialDayFormats)- ++ map (prop_no_crash_bad_input_named "TimeOfDay") (timeOfDayFormats ++ partialTimeOfDayFormats)- ++ map (prop_no_crash_bad_input_named "LocalTime") (localTimeFormats ++ partialLocalTimeFormats)- ++ map (prop_no_crash_bad_input_named "TimeZone") (timeZoneFormats)- ++ map (prop_no_crash_bad_input_named "ZonedTime") (zonedTimeFormats ++ partialZonedTimeFormats)- ++ map (prop_no_crash_bad_input_named "UTCTime") (utcTimeFormats ++ partialUTCTimeFormats)----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",- -- ordinal dates- "%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"- ]--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 $ - []-{-- -- there's soo many of them...- concat [ [df ++ " " ++ tf, tf ++ " " ++ df] | FormatString df <- dayFormats, - FormatString tf <- timeOfDayFormats]--}--timeZoneFormats :: [FormatString TimeZone]-timeZoneFormats = map FormatString ["%z","%z%Z","%Z%z","%Z"]--zonedTimeFormats :: [FormatString ZonedTime]-zonedTimeFormats = map FormatString- ["%a, %d %b %Y %H:%M:%S.%q %z", "%a, %d %b %Y %H:%M:%S%Q %z", "%s.%q %z", "%s%Q %z",- "%a, %d %b %Y %H:%M:%S.%q %Z", "%a, %d %b %Y %H:%M:%S%Q %Z", "%s.%q %Z", "%s%Q %Z"]--utcTimeFormats :: [FormatString UTCTime]-utcTimeFormats = map FormatString - ["%s.%q","%s%Q"]------- * Formats that do not include all the information-----partialDayFormats :: [FormatString Day]-partialDayFormats = map FormatString- [ ]--partialTimeOfDayFormats :: [FormatString TimeOfDay]-partialTimeOfDayFormats = map FormatString- [ ]--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"- ]-------- * Known failures-----knownFailures :: [NamedProperty]-knownFailures =- map (prop_format_parse_format_named "Day") failingPartialDayFormats--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/TestTime.hs
@@ -1,106 +0,0 @@-module Test.TestTime where--import Data.Time.Calendar.OrdinalDate-import Data.Time.Calendar.WeekDate-import Data.Time-import Test.TestUtil-import Test.TestTimeRef--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 ]--testTime :: Test-testTime = pureTest "testTime" $- diff testTimeRef $ unlines [testCal, testUTC, testUT1, testTimeOfDayToDayFraction]
− Test/TestTimeRef.hs
@@ -1,881 +0,0 @@-module Test.TestTimeRef where--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"- ,"" ]
− Test/TestTimeZone.hs
@@ -1,17 +0,0 @@-{-# OPTIONS -Wall -Werror #-}--module Test.TestTimeZone where--import Data.Time-import System.Posix.Env (putEnv)-import Test.TestUtil--testTimeZone :: Test-testTimeZone = ioTest "getTimeZone respects TZ env var" $ do- putEnv "TZ=UTC+0"- zone1 <- getTimeZone epoch- putEnv "TZ=EST+5"- zone2 <- getTimeZone epoch- return $ diff False (zone1 == zone2)- where- epoch = UTCTime (ModifiedJulianDay 0) 0
− Test/TestUtil.hs
@@ -1,38 +0,0 @@-{-# OPTIONS -fno-warn-overlapping-patterns #-}-module Test.TestUtil- (- module Test.TestUtil,- module Test.Framework,- module Test.Framework.Providers.QuickCheck2- ) where--import Test.Framework-import Test.Framework.Providers.API-import Test.Framework.Providers.QuickCheck2--data Result = Pass | Fail String--instance Show Result where- show Pass = "passed"- show (Fail s) = "failed: " ++ s--instance TestResultlike () Result where- testSucceeded Pass = True- testSucceeded (Fail _) = False--instance Testlike () Result (IO Result) where- testTypeName _ = "Cases"- runTest _ ior = do- r <- ior- return (Finished r,return ())--ioTest :: String -> IO Result -> Test-ioTest = Test--pureTest :: String -> Result -> Test-pureTest name result = ioTest name (return result)--diff :: (Show a,Eq a) => a -> a -> Result-diff expected found | expected == found = Pass-diff expected found = Fail ("expected " ++ (show expected) ++ " but found " ++ (show found))-
− Test/Tests.hs
@@ -1,30 +0,0 @@-module Test.Tests where--import Test.Framework--import Test.AddDays-import Test.ClipDates-import Test.ConvertBack-import Test.LongWeekYears-import Test.TestCalendars-import Test.TestEaster-import Test.TestFormat-import Test.TestMonthDay-import Test.TestParseDAT-import Test.TestParseTime-import Test.TestTime-import Test.TestTimeZone--tests :: [Test]-tests = [ addDaysTest- , clipDates- , convertBack- , longWeekYears- , testCalendars- , testEaster- , testFormat- , testMonthDay- , testParseDAT- , testParseTime- , testTime- , testTimeZone ]
− Test/TimeZone.hs
@@ -1,10 +0,0 @@-{-# OPTIONS -Wall -Werror #-}--module Main where--import Data.Time--main :: IO ()-main = do- zone <- getCurrentTimeZone- putStrLn (timeZoneOffsetString zone)
− Test/UseCases.lhs
@@ -1,83 +0,0 @@-> module UseCases where-> import Data.Time.Calendar.OrdinalDate-> import Data.Time-> import System.Locale---From Brian Smith:-<http://www.haskell.org/pipermail/libraries/2005-July/004060.html>--Use cases (primarily taken from real-world corporate IT applications I have -developed) :--* What is the equivalent (or closest aproximation) of the SQL DateTime type -(date and time without any timezone information)? What is the equivalent of -the SQL Date type (date without any timezone information)?--> type SQLDateTime = LocalTime-> type SQLDate = Day--* The user enters a date as "7/4/2005." How do I determine if this date is -before or after July 1st of this year?--TODO: Parsing--* How do I present the date "July 1st of this year" to the user in M/D/YYYY -format?--> july1st = do-> now <- getZonedTime-> let (thisYear,_,_) = toGregorian (localDay (zonedTimeToLocalTime now))-> let day = fromGregorian thisYear 7 1-> return (formatTime defaultTimeLocale "%m/%d/%Y" day)--This actually gives "07/01/2005" rather than "7/1/2005".-ISSUE: Should I make additional %-codes for this?---* How do I truncate a datetime to midnight of the same day? How do I -truncate a date to the first of the month? How do I truncate a date to the -first day of the year it occurred in?--> truncateToMidnight (LocalTime day _) = (LocalTime day midnight)--> truncateToFirstOfMonth day = fromGregorian y m 1 where-> (y,m,_) = toGregorian day--> truncateToJan1st day = fromOrdinalDate y 1 where-> (y,_) = toOrdinalDate day--* Given a date X, how do I find the last day of the month that X occurs in. -For example, If X is July 4th, 2005, then I want the result to be July 31st, -2005. If X is Februrary 5, then I want the result to be Februrary 28 for -non-leap-years and February 29 for leap years.--> lastDayOfMonth day = fromGregorian y m (gregorianMonthLength y m) where-> (y,m,_) = toGregorian day--* The user enters a time T with no date, e.g. "17:30". How do I merge this -time onto a date D (e.g. July 4, 2005), so that the result has is a datetime -with date D and the time T (July 4, 2005 at 17:30).--> mergeDateAndTime = LocalTime--* Given two datetimes T1, T2, how do I determine if they are on the same -date?--> sameDay (LocalTime d1 _) (LocalTime d2 _) = d1 == d2---From Simon Marlow:-<http://www.haskell.org/pipermail/libraries/2005-July/004066.html>--I just had a little look around, mainly at System.Time.Calendar. I-think the structure is rather complicated - I wanted to find out how to-get a CalendarTime for "this time tomorrow", and ended up with this:--*System.Time.Calendar> let c' =-c{ztTime=zttime{dtDay=dtday{gregDay=day+1}}} where { zttime = ztTime c;-dtday = dtDay zttime; day = gregDay dtday }--> thisTimeTomorrow (ZonedTime (LocalTime day tod) zone) = (ZonedTime (LocalTime (addDays 1 day) tod) zone)--
− cbits/HsTime.c
@@ -1,41 +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;- tzset();- 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;-}
configure view
@@ -1,13 +1,11 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles.-# Generated by GNU Autoconf 2.68 for Haskell time package 1.4.0.2.+# Generated by GNU Autoconf 2.69 for Haskell time package 1.4.0.2. # # Report bugs to <ashley@semantic.org>. # #-# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,-# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software-# Foundation, Inc.+# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. # # # This configure script is free software; the Free Software Foundation@@ -136,6 +134,31 @@ # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH +# 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'.+$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2+as_fn_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="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh@@ -169,7 +192,8 @@ else exitcode=1; echo positional parameters were not saved. fi-test x\$exitcode = x0 || exit 1"+test x\$exitcode = x0 || 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'\" &&@@ -214,21 +238,25 @@ if test "x$CONFIG_SHELL" != x; then :- # 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- export CONFIG_SHELL- 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+"$@"}+ 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'.+$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2+exit 255 fi if test x$as_have_required = xno; then :@@ -331,6 +359,14 @@ } # 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@@ -452,6 +488,10 @@ chmod +x "$as_me.lineno" || { $as_echo "$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).@@ -486,16 +526,16 @@ # ... 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'.+ # 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 -p'+ as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else- as_ln_s='cp -p'+ as_ln_s='cp -pR' fi else- as_ln_s='cp -p'+ as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null@@ -507,28 +547,8 @@ 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+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'"@@ -565,7 +585,7 @@ PACKAGE_BUGREPORT='ashley@semantic.org' PACKAGE_URL='' -ac_unique_file="include/HsTime.h"+ac_unique_file="lib/include/HsTime.h" # Factoring default headers for most tests. ac_includes_default="\ #include <stdio.h>@@ -1123,8 +1143,6 @@ if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe- $as_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@@ -1359,9 +1377,9 @@ if $ac_init_version; then cat <<\_ACEOF Haskell time package configure 1.4.0.2-generated by GNU Autoconf 2.68+generated by GNU Autoconf 2.69 -Copyright (C) 2010 Free Software Foundation, Inc.+Copyright (C) 2012 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF@@ -1638,7 +1656,7 @@ test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes ||- $as_test_x conftest$ac_exeext+ test -x conftest$ac_exeext }; then : ac_retval=0 else@@ -1831,7 +1849,7 @@ running configure, to aid debugging if configure makes a mistake. It was created by Haskell time package $as_me 1.4.0.2, which was-generated by GNU Autoconf 2.68. Invocation command line was+generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2222,7 +2240,7 @@ 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 as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2@@ -2262,7 +2280,7 @@ 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 as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2@@ -2315,7 +2333,7 @@ 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 as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2@@ -2356,7 +2374,7 @@ 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 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@@ -2414,7 +2432,7 @@ 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 as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2@@ -2458,7 +2476,7 @@ 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 as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2@@ -2904,8 +2922,7 @@ /* end confdefs.h. */ #include <stdarg.h> #include <stdio.h>-#include <sys/types.h>-#include <sys/stat.h>+struct stat; /* 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);@@ -2991,7 +3008,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu -ac_config_headers="$ac_config_headers include/HsTimeConfig.h"+ac_config_headers="$ac_config_headers lib/include/HsTimeConfig.h" @@ -3149,7 +3166,7 @@ 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+ as_fn_executable_p "$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@@ -3215,7 +3232,7 @@ 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+ as_fn_executable_p "$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@@ -3997,16 +4014,16 @@ # ... 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'.+ # 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 -p'+ as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else- as_ln_s='cp -p'+ as_ln_s='cp -pR' fi else- as_ln_s='cp -p'+ as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null@@ -4066,29 +4083,17 @@ 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 +# 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'" @@ -4109,7 +4114,7 @@ # values after options handling. ac_log=" This file was extended by Haskell time package $as_me 1.4.0.2, which was-generated by GNU Autoconf 2.68. Invocation command line was+generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS@@ -4162,10 +4167,10 @@ ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ Haskell time package config.status 1.4.0.2-configured by $0, generated by GNU Autoconf 2.68,+configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" -Copyright (C) 2010 Free Software Foundation, Inc.+Copyright (C) 2012 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." @@ -4245,7 +4250,7 @@ _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+ set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL'@@ -4274,7 +4279,7 @@ for ac_config_target in $ac_config_targets do case $ac_config_target in- "include/HsTimeConfig.h") CONFIG_HEADERS="$CONFIG_HEADERS include/HsTimeConfig.h" ;;+ "lib/include/HsTimeConfig.h") CONFIG_HEADERS="$CONFIG_HEADERS lib/include/HsTimeConfig.h" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac
configure.ac view
@@ -1,7 +1,7 @@ AC_INIT([Haskell time package], [1.4.0.2], [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],@@ -10,7 +10,7 @@ AC_ARG_WITH([compiler],[Haskell compiler]) AC_PROG_CC() -AC_CONFIG_HEADERS([include/HsTimeConfig.h])+AC_CONFIG_HEADERS([lib/include/HsTimeConfig.h]) AC_CHECK_HEADERS([time.h]) AC_CHECK_FUNCS([gmtime_r localtime_r])
− include/HsConfigure.h
@@ -1,7 +0,0 @@-#define HAS_DataPico 0-#if LANGUAGE_Rank2Types-#if MIN_VERSION_base(4,2,0)-#undef HAS_DataPico-#define HAS_DataPico 1-#endif-#endif
− 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,87 +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 a 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.4.0.2"--/* Define to the one symbol short name of this package. */-#define PACKAGE_TARNAME "time"--/* Define to the home page for this package. */-#define PACKAGE_URL ""--/* Define to the version of this package. */-#define PACKAGE_VERSION "1.4.0.2"--/* 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,86 +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 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 <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 home page for this package. */-#undef PACKAGE_URL--/* 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/Time.hs view
@@ -0,0 +1,12 @@+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
+ lib/Data/Time/Calendar.hs view
@@ -0,0 +1,8 @@+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
+ lib/Data/Time/Calendar/Days.hs view
@@ -0,0 +1,74 @@+{-# OPTIONS -fno-warn-unused-imports #-}+#include "HsConfigure.h"+-- #hide+module Data.Time.Calendar.Days+(+ -- * Days+ Day(..),addDays,diffDays+) where++import Control.DeepSeq+import Data.Ix+import Data.Typeable+#if LANGUAGE_Rank2Types+import Data.Data+#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+#if LANGUAGE_DeriveDataTypeable+#if LANGUAGE_Rank2Types+ ,Data, Typeable+#endif+#endif+ )++instance NFData Day where+ rnf (ModifiedJulianDay a) = rnf a++-- 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+-}
+ lib/Data/Time/Calendar/Easter.hs view
@@ -0,0 +1,36 @@+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
+ lib/Data/Time/Calendar/Gregorian.hs view
@@ -0,0 +1,82 @@+{-# 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
+ lib/Data/Time/Calendar/Julian.hs view
@@ -0,0 +1,73 @@+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)
+ lib/Data/Time/Calendar/JulianYearDay.hs view
@@ -0,0 +1,46 @@+-- #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)
+ lib/Data/Time/Calendar/MonthDay.hs view
@@ -0,0 +1,49 @@+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
+ lib/Data/Time/Calendar/OrdinalDate.hs view
@@ -0,0 +1,127 @@+-- | 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'))+
+ lib/Data/Time/Calendar/Private.hs view
@@ -0,0 +1,50 @@+-- #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++padN :: Int -> Char -> String -> String+padN i _ s | i <= 0 = s+padN i c s = (replicate i c) ++ s++show2Fixed :: NumericPadOption -> Pico -> String+show2Fixed opt x | x < 10 = pad1 opt (showFixed True x)+show2Fixed _ x = showFixed True x++showPaddedMin :: (Num t,Ord t,Show t) => Int -> NumericPadOption -> t -> String+showPaddedMin _ Nothing i = show i+showPaddedMin pl opt i | i < 0 = '-':(showPaddedMin pl opt (negate i))+showPaddedMin pl (Just c) i =+ let s = show i in + padN (pl - (length s)) c s++show2 :: (Num t,Ord t,Show t) => NumericPadOption -> t -> String+show2 = showPaddedMin 2++show3 :: (Num t,Ord t,Show t) => NumericPadOption -> t -> String+show3 = showPaddedMin 3++show4 :: (Num t,Ord t,Show t) => NumericPadOption -> t -> String+show4 = showPaddedMin 4++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
+ lib/Data/Time/Calendar/WeekDate.hs view
@@ -0,0 +1,53 @@+-- | 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
+ lib/Data/Time/Clock.hs view
@@ -0,0 +1,18 @@+-- | 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
+ lib/Data/Time/Clock/CTimeval.hs view
@@ -0,0 +1,32 @@+-- #hide+module Data.Time.Clock.CTimeval where++#ifndef mingw32_HOST_OS+-- All Unix-specific, this++import Foreign.Safe+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+ throwErrnoIfMinus1_ "gettimeofday" $ gettimeofday ptval nullPtr+ peek ptval+ )++#endif
+ lib/Data/Time/Clock/POSIX.hs view
@@ -0,0 +1,66 @@+-- | 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
+ lib/Data/Time/Clock/Scale.hs view
@@ -0,0 +1,109 @@+{-# LANGUAGE Trustworthy #-}+{-# OPTIONS -fno-warn-unused-imports #-}+#include "HsConfigure.h"+-- #hide+module Data.Time.Clock.Scale+(+ -- * Universal Time+ -- | Time as measured by the earth.+ UniversalTime(..),++ -- * Absolute intervals+ DiffTime,+ secondsToDiffTime, picosecondsToDiffTime+) where++import Control.DeepSeq+import Data.Ratio ((%))+import Data.Fixed+import Data.Typeable+#if LANGUAGE_Rank2Types+import Data.Data+#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+#if LANGUAGE_DeriveDataTypeable+#if LANGUAGE_Rank2Types+ ,Data, Typeable+#endif+#endif+ )++-- necessary because H98 doesn't have "cunning newtype" derivation+instance NFData UniversalTime where+ rnf (ModJulianDate a) = rnf a++-- | 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+#if LANGUAGE_DeriveDataTypeable+#if LANGUAGE_Rank2Types+#if HAS_DataPico+ ,Data, Typeable+#else+#endif+#endif+#endif+ )++-- necessary because H98 doesn't have "cunning newtype" derivation+instance NFData DiffTime -- FIXME: Data.Fixed had no NFData instances yet at time of writing++-- 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)++-- necessary because H98 doesn't have "cunning newtype" derivation+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++-- | 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)++{-# RULES+"realToFrac/DiffTime->Pico" realToFrac = \ (MkDiffTime ps) -> ps+"realToFrac/Pico->DiffTime" realToFrac = MkDiffTime+ #-}+
+ lib/Data/Time/Clock/TAI.hs view
@@ -0,0 +1,143 @@+{-# OPTIONS -fno-warn-unused-imports #-}+#include "HsConfigure.h"+-- | 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 Control.DeepSeq+import Data.Typeable+import Data.Fixed+#if LANGUAGE_Rank2Types+import Data.Data+#endif++-- | AbsoluteTime is TAI, time as measured by a clock.+newtype AbsoluteTime = MkAbsoluteTime {unAbsoluteTime :: DiffTime} deriving (Eq,Ord+#if LANGUAGE_DeriveDataTypeable+#if LANGUAGE_Rank2Types+#if HAS_DataPico+ ,Data, Typeable+#endif+#endif+#endif+ )++instance NFData AbsoluteTime where+ rnf (MkAbsoluteTime a) = rnf a++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
+ lib/Data/Time/Clock/UTC.hs view
@@ -0,0 +1,124 @@+{-# OPTIONS -fno-warn-unused-imports #-}+{-# LANGUAGE Trustworthy #-}+#include "HsConfigure.h"+-- #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 Control.DeepSeq+import Data.Time.Calendar.Days+import Data.Time.Clock.Scale+import Data.Fixed+import Data.Typeable+#if LANGUAGE_Rank2Types+import Data.Data+#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 {+ -- | the day+ utctDay :: Day,+ -- | the time from midnight, 0 <= t < 86401s (because of leap-seconds)+ utctDayTime :: DiffTime+}+#if LANGUAGE_DeriveDataTypeable+#if LANGUAGE_Rank2Types+#if HAS_DataPico+ deriving (Data, Typeable)+#endif+#endif+#endif++instance NFData UTCTime where+ rnf (UTCTime d t) = d `deepseq` t `deepseq` ()++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+#if LANGUAGE_DeriveDataTypeable+#if LANGUAGE_Rank2Types+#if HAS_DataPico+ ,Data, Typeable+#endif+#endif+#endif+ )++-- necessary because H98 doesn't have "cunning newtype" derivation+instance NFData NominalDiffTime -- FIXME: Data.Fixed had no NFData instances yet at time of writing++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++{-# 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+ #-}+
+ lib/Data/Time/Clock/UTCDiff.hs view
@@ -0,0 +1,13 @@+-- #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)
+ lib/Data/Time/Format.hs view
@@ -0,0 +1,246 @@+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 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 in 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 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@ 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, 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+--+-- [@%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@+--+-- [@%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 Week Date format, no padding. Note @%0G@ and @%_G@ pad to four chars+--+-- [@%g@] year of century for Week Date format, 0-padded to two chars, @00@ - @99@+--+-- [@%f@] century for Week Date format, no padding. Note @%0f@ and @%_f@ pad to two chars+--+-- [@%V@] week of year for Week Date format, 0-padded to two chars, @01@ - @53@+--+-- [@%u@] day of week 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 of year where weeks start on Sunday (as 'sundayStartWeek'), 0-padded to two chars, @00@ - @53@+--+-- [@%w@] day of week number, @0@ (= Sunday) - @6@ (= Saturday)+--+-- [@%W@] week of year where weeks start on Monday (as 'mondayStartWeek'), 0-padded to two chars, @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 (\_ opt -> (show4 (fromMaybe Nothing opt)) . fst . toOrdinalDate)+ formatCharacter 'y' = Just (\_ opt -> (show2 (fromMaybe (Just '0') opt)) . mod100 . fst . toOrdinalDate)+ formatCharacter 'C' = Just (\_ opt -> (show2 (fromMaybe Nothing 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 (\_ opt -> (show4 (fromMaybe Nothing opt)) . (\(y,_,_) -> y) . toWeekDate)+ formatCharacter 'g' = Just (\_ opt -> (show2 (fromMaybe (Just '0') opt)) . mod100 . (\(y,_,_) -> y) . toWeekDate)+ formatCharacter 'f' = Just (\_ opt -> (show2 (fromMaybe Nothing 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)
+ lib/Data/Time/Format/Locale.hs view
@@ -0,0 +1,87 @@+-- Note: this file derives from old-locale:System.Locale.hs, which is copyright (c) The University of Glasgow 2001++module Data.Time.Format.Locale (++ TimeLocale(..)++ , defaultTimeLocale++ , iso8601DateFormat+ , rfc822DateFormat+ )+where++import Data.Time.LocalTime++data TimeLocale = TimeLocale {+ -- |full and abbreviated week days+ 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 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"+ ]+ }++{- | 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,489 @@+{-# OPTIONS -fno-warn-orphans #-}+#include "HsConfigure.h"++-- #hide+module Data.Time.Format.Parse+ (+ -- * UNIX-style parsing+#if LANGUAGE_Rank2Types+ parseTimeM, parseTimeOrError, readSTime, readPTime,+ parseTime, readTime, readsTime,+#endif+ ParseTime(..),+ -- * Locale+ module Data.Time.Format.Locale+ ) 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++#if LANGUAGE_Rank2Types+import Control.Monad+#endif+import Data.Char+import Data.Fixed+import Data.List+import Data.Maybe+import Data.Ratio+import Data.Time.Format.Locale+#if LANGUAGE_Rank2Types+import Text.ParserCombinators.ReadP hiding (char, string)+#endif++#if LANGUAGE_Rank2Types+-- | 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+#endif+-- | 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).+ -- In the absence of @%C@ or @%Y@, century is 1969 - 2068.+ buildTime :: TimeLocale -- ^ The time locale.+ -> [(Char,String)] -- ^ Pairs of format characters and the+ -- corresponding part of the input.+ -> t++#if LANGUAGE_Rank2Types+-- | Parses a time value given a format string.+-- Supports the same %-codes as 'formatTime', including @%-@, @%_@ and @%0@ modifiers.+-- 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@.+--+-- [@%0Y@] accepts exactly four digits.+--+-- [@%0G@] accepts exactly four digits.+--+-- [@%0C@] accepts exactly two digits.+--+-- [@%0f@] accepts exactly two digits.+--+parseTimeM :: (Monad m,ParseTime t) =>+ Bool -- ^ Accept leading and trailing whitespace?+ -> TimeLocale -- ^ Time locale.+ -> String -- ^ Format string.+ -> String -- ^ Input string.+ -> m t -- ^ Return the time value, or fail if the input could+ -- not be parsed using the given format.+parseTimeM acceptWS l fmt s = case parseTimeList acceptWS l fmt s of+ [t] -> return t+ [] -> fail $ "parseTimeM: no parse of " ++ show s+ _ -> fail $ "parseTimeM: multiple parses of " ++ show s++-- | 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 =>+ Bool -- ^ Accept leading and trailing whitespace?+ -> TimeLocale -- ^ Time locale.+ -> String -- ^ Format string.+ -> String -- ^ Input string.+ -> t -- ^ The time value.+parseTimeOrError acceptWS l fmt s = case parseTimeList acceptWS l fmt s of+ [t] -> t+ [] -> error $ "parseTimeOrError: no parse of " ++ show s+ _ -> error $ "parseTimeOrError: multiple parses of " ++ show s++parseTimeList :: ParseTime t =>+ Bool -- ^ Accept leading and trailing whitespace?+ -> TimeLocale -- ^ Time locale.+ -> String -- ^ Format string+ -> String -- ^ Input string.+ -> [t]+parseTimeList False l fmt s = [t | (t,"") <- readSTime False l fmt s]+parseTimeList True l fmt s = [t | (t,r) <- readSTime True l fmt s, all isSpace r]++-- | Parse a time value given a format string. See 'parseTimeM' for details.+readSTime :: ParseTime t =>+ Bool -- ^ Accept leading whitespace?+ -> TimeLocale -- ^ Time locale.+ -> String -- ^ Format string+ -> ReadS t+readSTime acceptWS l f = readP_to_S (readPTime acceptWS l f)++-- | Parse a time value given a format string. See 'parseTimeM' for details.+readPTime :: ParseTime t =>+ Bool -- ^ Accept leading whitespace?+ -> TimeLocale -- ^ Time locale.+ -> String -- ^ Format string+ -> ReadP t+readPTime False l f = readPOnlyTime l f+readPTime True l f = (skipSpaces >> readPOnlyTime l f) <++ readPOnlyTime l f++-- | Parse a time value given a format string (without allowing leading whitespace). See 'parseTimeM' for details.+readPOnlyTime :: ParseTime t =>+ TimeLocale -- ^ Time locale.+ -> String -- ^ Format string+ -> ReadP t+readPOnlyTime l f = liftM (buildTime l) (parseInput l (parseFormat l f))++{-# DEPRECATED parseTime "use \"parseTimeM True\" instead" #-}+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 = parseTimeM True++{-# DEPRECATED readTime "use \"parseTimeOrError True\" instead" #-}+readTime :: ParseTime t =>+ TimeLocale -- ^ Time locale.+ -> String -- ^ Format string.+ -> String -- ^ Input string.+ -> t -- ^ The time value.+readTime = parseTimeOrError True++{-# DEPRECATED readsTime "use \"readSTime True\" instead" #-}+readsTime :: ParseTime t =>+ TimeLocale -- ^ Time locale.+ -> String -- ^ Format string+ -> ReadS t+readsTime = readSTime True+++--+-- * Internals+--++data Padding = NoPadding | SpacePadding | ZeroPadding+ deriving Show++type DateFormat = [DateFormatSpec]++data DateFormatSpec = Value (Maybe Padding) Char+ | WhiteSpace+ | Literal Char+ deriving Show++parseFormat :: TimeLocale -> String -> DateFormat+parseFormat l = p+ where p "" = []+ p ('%': '-' : c :cs) = (pc (Just NoPadding) c) ++ p cs+ p ('%': '_' : c :cs) = (pc (Just SpacePadding) c) ++ p cs+ p ('%': '0' : c :cs) = (pc (Just ZeroPadding) c) ++ p cs+ p ('%': c :cs) = (pc Nothing c) ++ p cs+ p (c:cs) | isSpace c = WhiteSpace : p cs+ p (c:cs) = Literal c : p cs+ pc _ 'c' = p (dateTimeFmt l)+ pc _ 'R' = p "%H:%M"+ pc _ 'T' = p "%H:%M:%S"+ pc _ 'X' = p (timeFmt l)+ pc _ 'r' = p (time12Fmt l)+ pc _ 'D' = p "%m/%d/%y"+ pc _ 'F' = p "%Y-%m-%d"+ pc _ 'x' = p (dateFmt l)+ pc _ 'h' = p "%b"+ pc _ '%' = [Literal '%']+ pc mpad c = [Value mpad c]++parseInput :: TimeLocale -> DateFormat -> ReadP [(Char,String)]+parseInput _ [] = return []+parseInput l (Value mpad c:ff) = do+ s <- parseValue l mpad c+ r <- parseInput l ff+ return ((c,s):r)+parseInput l (Literal c:ff) = do+ _ <- char c+ parseInput l ff+parseInput l (WhiteSpace:ff) = do+ _ <- satisfy isSpace+ case ff of+ (WhiteSpace:_) -> return ()+ _ -> skipSpaces+ parseInput l ff++-- | Get the string corresponding to the given format specifier.+parseValue :: TimeLocale -> Maybe Padding -> Char -> ReadP String+parseValue l mpad c =+ case c of+ -- century+ 'C' -> digits SpacePadding 2+ 'f' -> digits SpacePadding 2++ -- year+ 'Y' -> digits SpacePadding 4+ 'G' -> digits SpacePadding 4++ -- year of century+ 'y' -> digits ZeroPadding 2+ 'g' -> digits ZeroPadding 2++ -- month of year+ 'B' -> oneOf (map fst (months l))+ 'b' -> oneOf (map snd (months l))+ 'm' -> digits ZeroPadding 2++ -- day of month+ 'd' -> digits ZeroPadding 2+ 'e' -> digits SpacePadding 2++ -- week of year+ 'V' -> digits ZeroPadding 2+ 'U' -> digits ZeroPadding 2+ 'W' -> digits 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' -> digits 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' -> digits ZeroPadding 2+ 'k' -> digits SpacePadding 2++ -- hour of dayhalf (i.e. 12h)+ 'I' -> digits ZeroPadding 2+ 'l' -> digits SpacePadding 2++ -- minute of hour+ 'M' -> digits ZeroPadding 2++ -- second of minute+ 'S' -> digits ZeroPadding 2++ -- picosecond of second+ 'q' -> digits ZeroPadding 12+ 'Q' -> liftM2 (:) (char '.') (munch isDigit) <++ return ""++ -- time zone+ 'z' -> numericTZ+ 'Z' -> munch1 isAlpha <+++ numericTZ <+++ return "" -- produced by %Z for LocalTime++ -- seconds since epoch+ 's' -> (char '-' >> liftM ('-':) (munch1 isDigit))+ <++ munch1 isDigit++ _ -> fail $ "Unknown format character: " ++ show c+ where+ oneOf = choice . map string+ digitsforce ZeroPadding n = count n (satisfy isDigit)+ digitsforce SpacePadding _n = skipSpaces >> many1 (satisfy isDigit)+ digitsforce NoPadding _n = many1 (satisfy isDigit)+ digits pad = digitsforce (fromMaybe pad mpad)+ numericTZ = do s <- choice [char '+', char '-']+ h <- digitsforce ZeroPadding 2+ optional (char ':')+ m <- digitsforce ZeroPadding 2+ return (s:h++m)+#endif++--+-- * Instances for the time package types+--++data DayComponent = Century Integer -- century of all years+ | CenturyYear Integer -- 0-99, last two digits of both real years and week years+ | YearMonth Int -- 1-12+ | MonthDay Int -- 1-31+ | YearDay Int -- 1-366+ | WeekDay Int -- 1-7 (mon-sun)+ | YearWeek 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+ -- %C: century (all but the last two digits of the year), 00 - 99+ 'C' -> [Century (read x)]+ -- %f century (all but the last two digits of the year), 00 - 99+ 'f' -> [Century (read x)]+ -- %Y: year+ 'Y' -> let y = read x in [Century (y `div` 100), CenturyYear (y `mod` 100)]+ -- %G: year for Week Date format+ 'G' -> let y = read x in [Century (y `div` 100), CenturyYear (y `mod` 100)]+ -- %y: last two digits of year, 00 - 99+ 'y' -> [CenturyYear (read x)]+ -- %g: last two digits of year for Week Date format, 00 - 99+ 'g' -> [CenturyYear (read x)]+ -- %B: month name, long form (fst from months locale), January - December+ 'B' -> [YearMonth (1 + fromJust (elemIndex (up x) (map (up . fst) (months l))))]+ -- %b: month name, short form (snd from months locale), Jan - Dec+ 'b' -> [YearMonth (1 + fromJust (elemIndex (up x) (map (up . snd) (months l))))]+ -- %m: month of year, leading 0 as needed, 01 - 12+ 'm' -> [YearMonth (read x)]+ -- %d: day of month, leading 0 as needed, 01 - 31+ 'd' -> [MonthDay (read x)]+ -- %e: day of month, leading space as needed, 1 - 31+ 'e' -> [MonthDay (read x)]+ -- %V: week for Week Date format, 01 - 53+ 'V' -> [YearWeek ISOWeek (read x)]+ -- %U: week number of year, where weeks start on Sunday (as sundayStartWeek), 01 - 53+ 'U' -> [YearWeek SundayWeek (read x)]+ -- %W: week number of year, where weeks start on Monday (as mondayStartWeek), 01 - 53+ 'W' -> [YearWeek MondayWeek (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)]+ -- %w: day of week number, 0 (= Sunday) - 6 (= Saturday)+ 'w' -> [WeekDay (((read x + 6) `mod` 7) + 1)]+ -- %j: day of year for Ordinal Date format, 001 - 366+ 'j' -> [YearDay (read x)]+ _ -> []++ buildDay cs = rest cs+ where+ y = let+ d = safeLast 70 [x | CenturyYear x <- cs]+ c = safeLast (if d >= 69 then 19 else 20) [x | Century x <- cs]+ in 100 * c + d++ rest (YearMonth m:_) = let d = safeLast 1 [x | MonthDay x <- cs]+ in fromGregorian y m d+ rest (YearDay d:_) = fromOrdinalDate y d+ rest (YearWeek 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 [YearMonth 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)++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++instance ParseTime TimeZone where+ buildTime l = 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 find (\tz -> y == timeZoneName tz) (knownTimeZones l) of+ Just tz -> tz+ Nothing -> case y of+ [yc] | Just hours <- getMilZoneHours yc -> TimeZone (hours * 60) False y+ _ -> TimeZone offset dst y+ | otherwise -> zone+ _ -> t+ where zone = TimeZone (readTzOffset x) dst name++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]++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++#if LANGUAGE_Rank2Types+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"++instance Read TimeZone where+ readsPrec _ = readParen False $ readSTime True 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 ]+#endif+
+ lib/Data/Time/LocalTime.hs view
@@ -0,0 +1,10 @@+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
+ lib/Data/Time/LocalTime/LocalTime.hs view
@@ -0,0 +1,109 @@+{-# OPTIONS -fno-warn-orphans -fno-warn-unused-imports #-}+#include "HsConfigure.h"++-- #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 Control.DeepSeq+import Data.Typeable+#if LANGUAGE_Rank2Types+import Data.Data+#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+#if LANGUAGE_DeriveDataTypeable+#if LANGUAGE_Rank2Types+#if HAS_DataPico+ ,Data, Typeable+#endif+#endif+#endif+ )++instance NFData LocalTime where+ rnf (LocalTime d t) = d `deepseq` t `deepseq` ()++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+}+#if LANGUAGE_DeriveDataTypeable+#if LANGUAGE_Rank2Types+#if HAS_DataPico+ deriving (Data, Typeable)+#endif+#endif+#endif++instance NFData ZonedTime where+ rnf (ZonedTime lt z) = lt `deepseq` z `deepseq` ()++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)
+ lib/Data/Time/LocalTime/TimeOfDay.hs view
@@ -0,0 +1,97 @@+{-# OPTIONS -fno-warn-unused-imports #-}+#include "HsConfigure.h"+-- #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 Control.DeepSeq+import Data.Typeable+import Data.Fixed+#if LANGUAGE_Rank2Types+import Data.Data+#endif++-- | 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+#if LANGUAGE_DeriveDataTypeable+#if LANGUAGE_Rank2Types+#if HAS_DataPico+ ,Data, Typeable+#endif+#endif+#endif+ )++instance NFData TimeOfDay where+ rnf (TimeOfDay h m s) = h `deepseq` m `deepseq` s `seq` () -- FIXME: Data.Fixed had no NFData instances yet at time of writing++-- | 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) / realToFrac posixDayLength
+ lib/Data/Time/LocalTime/TimeZone.hs view
@@ -0,0 +1,96 @@+{-# OPTIONS -fno-warn-unused-imports #-}+{-# LANGUAGE ForeignFunctionInterface #-}+#include "HsConfigure.h"++-- #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.Safe+import Foreign.C+import Control.DeepSeq+import Data.Typeable+#if LANGUAGE_Rank2Types+import Data.Data+#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 {+ -- | 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+#if LANGUAGE_DeriveDataTypeable+#if LANGUAGE_Rank2Types+ ,Data, Typeable+#endif+#endif+ )++instance NFData TimeZone where+ rnf (TimeZone m so n) = m `deepseq` so `deepseq` n `deepseq` ()++-- | 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
+ lib/cbits/HsTime.c view
@@ -0,0 +1,41 @@+#include "HsTime.h"+#include <stdio.h>++long int get_current_timezone_seconds (time_t t,int* pdst,char const* * pname)+{+ tzset();+#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;+}
+ lib/include/HsConfigure.h view
@@ -0,0 +1,7 @@+#define HAS_DataPico 0+#if LANGUAGE_Rank2Types+#if MIN_VERSION_base(4,2,0)+#undef HAS_DataPico+#define HAS_DataPico 1+#endif+#endif
+ lib/include/HsTime.h view
@@ -0,0 +1,23 @@+#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
+ lib/include/HsTimeConfig.h view
@@ -0,0 +1,87 @@+/* lib/include/HsTimeConfig.h. Generated from HsTimeConfig.h.in by configure. */+/* lib/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 a 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.4.0.2"++/* Define to the one symbol short name of this package. */+#define PACKAGE_TARNAME "time"++/* Define to the home page for this package. */+#define PACKAGE_URL ""++/* Define to the version of this package. */+#define PACKAGE_VERSION "1.4.0.2"++/* 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 */
+ lib/include/HsTimeConfig.h.in view
@@ -0,0 +1,86 @@+/* lib/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 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 <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 home page for this package. */+#undef PACKAGE_URL++/* 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
+ test/ShowDefaultTZAbbreviations.hs view
@@ -0,0 +1,9 @@+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/Test.hs view
@@ -0,0 +1,11 @@+module Main where+import Test.Framework+import Test.Tests+import Foreign.C.Types++main :: IO ()+main = do+ if (toRational (1000000000000 :: CTime)) /= (1000000000000 :: Rational)+ then putStrLn "WARNING: Some tests will incorrectly fail due to a 32-bit time_t C type."+ else return ()+ defaultMain tests
+ test/Test/AddDays.hs view
@@ -0,0 +1,41 @@+module Test.AddDays where++import Data.Time.Calendar+import Test.TestUtil+import Test.AddDaysRef++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 :: Test+addDaysTest = pureTest "addDays" $+ diff addDaysRef $ unlines resultDays
+ test/Test/AddDaysRef.hs view
@@ -0,0 +1,250 @@+module Test.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/Test/ClipDates.hs view
@@ -0,0 +1,46 @@+{-# Language TupleSections #-}++module Test.ClipDates where++import Data.Time.Calendar.OrdinalDate+import Data.Time.Calendar.WeekDate+import Data.Time.Calendar+import Test.TestUtil+import Test.ClipDatesRef++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++--++clipDates :: Test+clipDates = pureTest "clipDates" $+ let + yad = unlines $ map yearAndDay $ + tupleUp2 [1968,1969,1971] [-4,0,1,200,364,365,366,367,700]+ ++ greg = unlines $ 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]++ iso = unlines $ map iSOWeekDay $ + tupleUp3 [1968,1969,2004] [-20,-1,0,1,20,51,52,53,54] [-2,-1,0,1,4,6,7,8,9]++ in diff clipDatesRef $ + concat [ "YearAndDay\n", yad, "Gregorian\n", greg, "ISOWeekDay\n", iso ]
+ test/Test/ClipDatesRef.hs view
@@ -0,0 +1,566 @@+module Test.ClipDatesRef where++clipDatesRef :: String+clipDatesRef =+ unlines + [ "YearAndDay"+ , "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"+ , "Gregorian"+ , "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"+ , "ISOWeekDay"+ , "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/Test/ConvertBack.hs view
@@ -0,0 +1,40 @@+module Test.ConvertBack where++import Data.Time.Calendar.OrdinalDate+import Data.Time.Calendar.Julian+import Data.Time.Calendar.WeekDate+import Data.Time.Calendar+import Test.TestUtil++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 :: Test+convertBack = pureTest "convertBack" $+ diff "" $ concatMap (\ch -> concatMap ch days) checkers
+ test/Test/LongWeekYears.hs view
@@ -0,0 +1,20 @@+module Test.LongWeekYears where++import Data.Time.Calendar.WeekDate+import Data.Time.Calendar+import Test.TestUtil+import Test.LongWeekYearsRef++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 :: Test+longWeekYears = pureTest "longWeekYears" $+ diff longWeekYearsRef $ unlines $ map showLongYear [1901 .. 2050]
+ test/Test/LongWeekYearsRef.hs view
@@ -0,0 +1,155 @@+module Test.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/Test/TAI_UTC_DAT.hs view
@@ -0,0 +1,42 @@+module Test.TAI_UTC_DAT where++taiUTC_DAT :: String+taiUTC_DAT =+ unlines + [ "1961 JAN 1 =JD 2437300.5 TAI-UTC= 1.4228180 S + (MJD - 37300.) X 0.001296 S"+ , "1961 AUG 1 =JD 2437512.5 TAI-UTC= 1.3728180 S + (MJD - 37300.) X 0.001296 S"+ , "1962 JAN 1 =JD 2437665.5 TAI-UTC= 1.8458580 S + (MJD - 37665.) X 0.0011232S"+ , "1963 NOV 1 =JD 2438334.5 TAI-UTC= 1.9458580 S + (MJD - 37665.) X 0.0011232S"+ , "1964 JAN 1 =JD 2438395.5 TAI-UTC= 3.2401300 S + (MJD - 38761.) X 0.001296 S"+ , "1964 APR 1 =JD 2438486.5 TAI-UTC= 3.3401300 S + (MJD - 38761.) X 0.001296 S"+ , "1964 SEP 1 =JD 2438639.5 TAI-UTC= 3.4401300 S + (MJD - 38761.) X 0.001296 S"+ , "1965 JAN 1 =JD 2438761.5 TAI-UTC= 3.5401300 S + (MJD - 38761.) X 0.001296 S"+ , "1965 MAR 1 =JD 2438820.5 TAI-UTC= 3.6401300 S + (MJD - 38761.) X 0.001296 S"+ , "1965 JUL 1 =JD 2438942.5 TAI-UTC= 3.7401300 S + (MJD - 38761.) X 0.001296 S"+ , "1965 SEP 1 =JD 2439004.5 TAI-UTC= 3.8401300 S + (MJD - 38761.) X 0.001296 S"+ , "1966 JAN 1 =JD 2439126.5 TAI-UTC= 4.3131700 S + (MJD - 39126.) X 0.002592 S"+ , "1968 FEB 1 =JD 2439887.5 TAI-UTC= 4.2131700 S + (MJD - 39126.) X 0.002592 S"+ , "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"+ , "1973 JAN 1 =JD 2441683.5 TAI-UTC= 12.0 S + (MJD - 41317.) X 0.0 S"+ , "1974 JAN 1 =JD 2442048.5 TAI-UTC= 13.0 S + (MJD - 41317.) X 0.0 S"+ , "1975 JAN 1 =JD 2442413.5 TAI-UTC= 14.0 S + (MJD - 41317.) X 0.0 S"+ , "1976 JAN 1 =JD 2442778.5 TAI-UTC= 15.0 S + (MJD - 41317.) X 0.0 S"+ , "1977 JAN 1 =JD 2443144.5 TAI-UTC= 16.0 S + (MJD - 41317.) X 0.0 S"+ , "1978 JAN 1 =JD 2443509.5 TAI-UTC= 17.0 S + (MJD - 41317.) X 0.0 S"+ , "1979 JAN 1 =JD 2443874.5 TAI-UTC= 18.0 S + (MJD - 41317.) X 0.0 S"+ , "1980 JAN 1 =JD 2444239.5 TAI-UTC= 19.0 S + (MJD - 41317.) X 0.0 S"+ , "1981 JUL 1 =JD 2444786.5 TAI-UTC= 20.0 S + (MJD - 41317.) X 0.0 S"+ , "1982 JUL 1 =JD 2445151.5 TAI-UTC= 21.0 S + (MJD - 41317.) X 0.0 S"+ , "1983 JUL 1 =JD 2445516.5 TAI-UTC= 22.0 S + (MJD - 41317.) X 0.0 S"+ , "1985 JUL 1 =JD 2446247.5 TAI-UTC= 23.0 S + (MJD - 41317.) X 0.0 S"+ , "1988 JAN 1 =JD 2447161.5 TAI-UTC= 24.0 S + (MJD - 41317.) X 0.0 S"+ , "1990 JAN 1 =JD 2447892.5 TAI-UTC= 25.0 S + (MJD - 41317.) X 0.0 S"+ , "1991 JAN 1 =JD 2448257.5 TAI-UTC= 26.0 S + (MJD - 41317.) X 0.0 S"+ , "1992 JUL 1 =JD 2448804.5 TAI-UTC= 27.0 S + (MJD - 41317.) X 0.0 S"+ , "1993 JUL 1 =JD 2449169.5 TAI-UTC= 28.0 S + (MJD - 41317.) X 0.0 S"+ , "1994 JUL 1 =JD 2449534.5 TAI-UTC= 29.0 S + (MJD - 41317.) X 0.0 S"+ , "1996 JAN 1 =JD 2450083.5 TAI-UTC= 30.0 S + (MJD - 41317.) X 0.0 S"+ , "1997 JUL 1 =JD 2450630.5 TAI-UTC= 31.0 S + (MJD - 41317.) X 0.0 S"+ , "1999 JAN 1 =JD 2451179.5 TAI-UTC= 32.0 S + (MJD - 41317.) X 0.0 S"+ , "2006 JAN 1 =JD 2453736.5 TAI-UTC= 33.0 S + (MJD - 41317.) X 0.0 S" ]
+ test/Test/TestCalendars.hs view
@@ -0,0 +1,30 @@+module Test.TestCalendars where++import Data.Time.Calendar.Julian+import Data.Time.Calendar.WeekDate+import Data.Time.Calendar+import Test.TestUtil+import Test.TestCalendarsRef++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 :: Test+testCalendars = pureTest "testCalendars" $+ diff testCalendarsRef $ unlines $ map (\d -> showShowers d) days+ where+ showShowers day = + concatMap (\(nm,shower) -> unwords [" ==", nm, shower day]) showers
+ test/Test/TestCalendarsRef.hs view
@@ -0,0 +1,9 @@+module Test.TestCalendarsRef 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/Test/TestEaster.hs view
@@ -0,0 +1,36 @@+{-# OPTIONS -Wall -Werror #-}++module Test.TestEaster where++import Data.Time.Calendar.Easter+import Data.Time.Calendar+import Data.Time.Format++import Test.TestUtil+import Test.TestEasterRef++--++days :: [Day]+days = [ModifiedJulianDay 53000 .. ModifiedJulianDay 53014]++showWithWDay :: Day -> String+showWithWDay = formatTime defaultTimeLocale "%F %A"++testEaster :: Test+testEaster = pureTest "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 diff testEasterRef $ ds ++ concatMap (\y -> f y ++ g y) [2000..2020]
+ test/Test/TestEasterRef.hs view
@@ -0,0 +1,62 @@+module Test.TestEasterRef 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/Test/TestFormat.hs view
@@ -0,0 +1,185 @@+{-# LANGUAGE ForeignFunctionInterface #-}++module Test.TestFormat where++import Data.Time+import Data.Time.Clock.POSIX+import Data.Char+import Foreign+import Foreign.C+import Control.Exception;+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 "TestFormatStuff.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 -> IO String+unixFormatTime fmt zone time = 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 (truncate (utcTimeToPOSIXSeconds time)))+ )+ ))++locale :: TimeLocale+locale = defaultTimeLocale {dateTimeFmt = "%a %b %e %H:%M:%S %Y"}++zones :: [TimeZone]+zones = [utc,TimeZone 87 True "Fenwickian Daylight Time"]++baseTime0 :: UTCTime+baseTime0 = localTimeToUTC utc (LocalTime (fromGregorian 1970 01 01) midnight)++baseTime1 :: UTCTime+baseTime1 = localTimeToUTC utc (LocalTime (fromGregorian 2000 01 01) midnight)++getDay :: Integer -> UTCTime+getDay day = addUTCTime ((fromInteger day) * posixDayLength) baseTime1++getYearP1 :: Integer -> UTCTime+getYearP1 year = localTimeToUTC utc (LocalTime (fromGregorian year 01 01) midnight)++getYearP2 :: Integer -> UTCTime+getYearP2 year = localTimeToUTC utc (LocalTime (fromGregorian year 02 04) midnight)++getYearP3 :: Integer -> UTCTime+getYearP3 year = localTimeToUTC utc (LocalTime (fromGregorian year 03 04) midnight)++getYearP4 :: Integer -> UTCTime+getYearP4 year = localTimeToUTC utc (LocalTime (fromGregorian year 12 31) midnight)++years :: [Integer]+years = [999,1000,1899,1900,1901] ++ [1980..2000] ++ [9999,10000]++times :: [UTCTime]+times = [baseTime0] ++ (fmap getDay [0..23]) ++ (fmap getDay [0..100]) +++ (fmap getYearP1 years) ++ (fmap getYearP2 years) ++ (fmap getYearP3 years) ++ (fmap getYearP4 years)++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 _ s = s++compareFormat :: String -> (String -> String) -> String -> TimeZone -> UTCTime -> Test+compareFormat testname modUnix fmt zone time = let+ ctime = utcToZonedTime zone time+ haskellText = formatTime locale fmt ctime+ in ioTest (testname ++ ": " ++ (show fmt) ++ " of " ++ (show ctime)) $+ do+ unixText <- unixFormatTime fmt zone time+ let expectedText = unixWorkarounds fmt (modUnix unixText)+ return $ diff 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 :: [Char]+modifiers = "_-0^"++formats :: [String]+formats = ["%G-W%V-%u","%U-%w","%W-%u"] ++ (fmap (\char -> '%':char:[]) chars)+ ++ (concat (fmap (\char -> fmap (\modifier -> '%':modifier:char:[]) modifiers) chars))++hashformats :: [String]+hashformats = (fmap (\char -> '%':'#':char:[]) chars)++somestrings :: [String]+somestrings = ["", " ", "-", "\n"]++getBottom :: a -> IO (Maybe Control.Exception.SomeException);+getBottom a = Control.Exception.catch (seq a (return Nothing)) (return . Just);++safeString :: String -> IO String+safeString s = do+ msx <- getBottom s+ case msx of+ Just sx -> return (show sx)+ Nothing -> case s of+ (c:cc) -> do+ mcx <- getBottom c+ case mcx of+ Just cx -> return (show cx)+ Nothing -> do+ ss <- safeString cc+ return (c:ss)+ [] -> return ""++compareExpected :: (Eq t,Show t,ParseTime t) => String -> String -> String -> Maybe t -> Test+compareExpected testname fmt str expected = ioTest (testname ++ ": " ++ (show fmt) ++ " on " ++ (show str)) $ do+ let found = parseTimeM False defaultTimeLocale fmt str+ mex <- getBottom found+ case mex of+ Just ex -> return $ Fail $ unwords [ "Exception: expected" , show expected ++ ", caught", show ex]+ Nothing -> return $ diff expected found++class (ParseTime t) => TestParse t where+ expectedParse :: String -> String -> Maybe t+ expectedParse "%Z" "" = Just (buildTime defaultTimeLocale [])+ expectedParse "%_Z" "" = Just (buildTime defaultTimeLocale [])+ expectedParse "%-Z" "" = Just (buildTime defaultTimeLocale [])+ expectedParse "%0Z" "" = Just (buildTime defaultTimeLocale [])+ expectedParse _ _ = Nothing++instance TestParse Day+instance TestParse TimeOfDay+instance TestParse LocalTime+instance TestParse TimeZone+instance TestParse ZonedTime+instance TestParse UTCTime++checkParse :: String -> String -> [Test]+checkParse fmt str+ = [ compareExpected "Day" fmt str (expectedParse fmt str :: Maybe Day)+ , compareExpected "TimeOfDay" fmt str (expectedParse fmt str :: Maybe TimeOfDay)+ , compareExpected "LocalTime" fmt str (expectedParse fmt str :: Maybe LocalTime)+ , compareExpected "TimeZone" fmt str (expectedParse fmt str :: Maybe TimeZone)+ , compareExpected "UTCTime" fmt str (expectedParse fmt str :: Maybe UTCTime) ]++testCheckParse :: [Test]+testCheckParse = concatMap (\fmt -> concatMap (\str -> checkParse fmt str) somestrings) formats++testCompareFormat :: [Test]+testCompareFormat = concatMap (\fmt -> concatMap (\time -> fmap (\zone -> compareFormat "compare format" id fmt zone time) zones) times) formats++testCompareHashFormat :: [Test]+testCompareHashFormat = concatMap (\fmt -> concatMap (\time -> fmap (\zone -> compareFormat "compare hashformat" (fmap toLower) fmt zone time) zones) times) hashformats++testFormats :: [Test]+testFormats = [+ testGroup "checkParse" testCheckParse,+ testGroup "compare format" testCompareFormat,+ testGroup "compare hashformat" testCompareHashFormat+ ]++testFormat :: Test+testFormat = testGroup "testFormat" testFormats
+ test/Test/TestFormatStuff.c view
@@ -0,0 +1,15 @@+#include "TestFormatStuff.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/Test/TestFormatStuff.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/Test/TestMonthDay.hs view
@@ -0,0 +1,22 @@+module Test.TestMonthDay where++import Data.Time.Calendar.MonthDay+import Test.TestUtil+import Test.TestMonthDayRef++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 :: Test+testMonthDay = pureTest "testMonthDay" $+ diff testMonthDayRef $ concat $ map (\isL -> unlines (leap isL : yearDays isL)) [False,True]+ 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/Test/TestMonthDayRef.hs view
@@ -0,0 +1,751 @@+module Test.TestMonthDayRef 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/Test/TestParseDAT.hs view
@@ -0,0 +1,53 @@+module Test.TestParseDAT where++import Data.Time+import Data.Time.Clock.TAI+import Test.TestUtil+import Test.TestParseDAT_Ref+import Test.TAI_UTC_DAT++tods :: [TimeOfDay]+tods = [+ TimeOfDay 0 0 0,+ TimeOfDay 0 0 0.5,+ TimeOfDay 0 0 1,+ TimeOfDay 0 0 1.5,+ TimeOfDay 0 0 2,+ TimeOfDay 23 59 28,+ TimeOfDay 23 59 28.5,+ TimeOfDay 23 59 29,+ TimeOfDay 23 59 29.5,+ TimeOfDay 23 59 30,+ TimeOfDay 23 59 30.5,+ TimeOfDay 23 59 31,+ TimeOfDay 23 59 31.5,+ TimeOfDay 23 59 32,+ TimeOfDay 23 59 59,+ TimeOfDay 23 59 59.5,+ TimeOfDay 23 59 60,+ TimeOfDay 23 59 60.5+ ]++times :: [LocalTime]+times =+ fmap (LocalTime (fromGregorian 1998 04 02)) tods +++ fmap (LocalTime (fromGregorian 1998 12 30)) tods +++ fmap (LocalTime (fromGregorian 1998 12 31)) tods +++ fmap (LocalTime (fromGregorian 1999 01 01)) tods +++ fmap (LocalTime (fromGregorian 1999 01 02)) tods++testParseDAT :: Test+testParseDAT = pureTest "testParseDAT" $ diff testParseDAT_Ref parseDAT where+ parseDAT = + let lst = parseTAIUTCDATFile taiUTC_DAT in + unlines $ map+ (\lt ->+ let+ utcTime = localTimeToUTC utc lt+ taiTime = utcToTAITime lst utcTime+ utcTime' = taiToUTCTime lst taiTime+ in if utcTime == utcTime'+ then unwords [show utcTime, "==", show taiTime]+ else unwords [ "correction:", show utcTime, "->", show taiTime, "->", show utcTime']+ )+ times
+ test/Test/TestParseDAT_Ref.hs view
@@ -0,0 +1,95 @@+module Test.TestParseDAT_Ref where++testParseDAT_Ref :: String+testParseDAT_Ref =+ unlines+ [ "1998-04-02 00:00:00 UTC == 1998-04-02 00:00:31 TAI"+ , "1998-04-02 00:00:00.5 UTC == 1998-04-02 00:00:31.5 TAI"+ , "1998-04-02 00:00:01 UTC == 1998-04-02 00:00:32 TAI"+ , "1998-04-02 00:00:01.5 UTC == 1998-04-02 00:00:32.5 TAI"+ , "1998-04-02 00:00:02 UTC == 1998-04-02 00:00:33 TAI"+ , "1998-04-02 23:59:28 UTC == 1998-04-02 23:59:59 TAI"+ , "1998-04-02 23:59:28.5 UTC == 1998-04-02 23:59:59.5 TAI"+ , "1998-04-02 23:59:29 UTC == 1998-04-03 00:00:00 TAI"+ , "1998-04-02 23:59:29.5 UTC == 1998-04-03 00:00:00.5 TAI"+ , "1998-04-02 23:59:30 UTC == 1998-04-03 00:00:01 TAI"+ , "1998-04-02 23:59:30.5 UTC == 1998-04-03 00:00:01.5 TAI"+ , "1998-04-02 23:59:31 UTC == 1998-04-03 00:00:02 TAI"+ , "1998-04-02 23:59:31.5 UTC == 1998-04-03 00:00:02.5 TAI"+ , "1998-04-02 23:59:32 UTC == 1998-04-03 00:00:03 TAI"+ , "1998-04-02 23:59:59 UTC == 1998-04-03 00:00:30 TAI"+ , "1998-04-02 23:59:59.5 UTC == 1998-04-03 00:00:30.5 TAI"+ , "correction: 1998-04-02 23:59:60 UTC -> 1998-04-03 00:00:31 TAI -> 1998-04-03 00:00:00 UTC"+ , "correction: 1998-04-02 23:59:60.5 UTC -> 1998-04-03 00:00:31.5 TAI -> 1998-04-03 00:00:00.5 UTC"+ , "1998-12-30 00:00:00 UTC == 1998-12-30 00:00:31 TAI"+ , "1998-12-30 00:00:00.5 UTC == 1998-12-30 00:00:31.5 TAI"+ , "1998-12-30 00:00:01 UTC == 1998-12-30 00:00:32 TAI"+ , "1998-12-30 00:00:01.5 UTC == 1998-12-30 00:00:32.5 TAI"+ , "1998-12-30 00:00:02 UTC == 1998-12-30 00:00:33 TAI"+ , "1998-12-30 23:59:28 UTC == 1998-12-30 23:59:59 TAI"+ , "1998-12-30 23:59:28.5 UTC == 1998-12-30 23:59:59.5 TAI"+ , "1998-12-30 23:59:29 UTC == 1998-12-31 00:00:00 TAI"+ , "1998-12-30 23:59:29.5 UTC == 1998-12-31 00:00:00.5 TAI"+ , "1998-12-30 23:59:30 UTC == 1998-12-31 00:00:01 TAI"+ , "1998-12-30 23:59:30.5 UTC == 1998-12-31 00:00:01.5 TAI"+ , "1998-12-30 23:59:31 UTC == 1998-12-31 00:00:02 TAI"+ , "1998-12-30 23:59:31.5 UTC == 1998-12-31 00:00:02.5 TAI"+ , "1998-12-30 23:59:32 UTC == 1998-12-31 00:00:03 TAI"+ , "1998-12-30 23:59:59 UTC == 1998-12-31 00:00:30 TAI"+ , "1998-12-30 23:59:59.5 UTC == 1998-12-31 00:00:30.5 TAI"+ , "correction: 1998-12-30 23:59:60 UTC -> 1998-12-31 00:00:31 TAI -> 1998-12-31 00:00:00 UTC"+ , "correction: 1998-12-30 23:59:60.5 UTC -> 1998-12-31 00:00:31.5 TAI -> 1998-12-31 00:00:00.5 UTC"+ , "1998-12-31 00:00:00 UTC == 1998-12-31 00:00:31 TAI"+ , "1998-12-31 00:00:00.5 UTC == 1998-12-31 00:00:31.5 TAI"+ , "1998-12-31 00:00:01 UTC == 1998-12-31 00:00:32 TAI"+ , "1998-12-31 00:00:01.5 UTC == 1998-12-31 00:00:32.5 TAI"+ , "1998-12-31 00:00:02 UTC == 1998-12-31 00:00:33 TAI"+ , "1998-12-31 23:59:28 UTC == 1998-12-31 23:59:59 TAI"+ , "1998-12-31 23:59:28.5 UTC == 1998-12-31 23:59:59.5 TAI"+ , "1998-12-31 23:59:29 UTC == 1999-01-01 00:00:00 TAI"+ , "1998-12-31 23:59:29.5 UTC == 1999-01-01 00:00:00.5 TAI"+ , "1998-12-31 23:59:30 UTC == 1999-01-01 00:00:01 TAI"+ , "1998-12-31 23:59:30.5 UTC == 1999-01-01 00:00:01.5 TAI"+ , "1998-12-31 23:59:31 UTC == 1999-01-01 00:00:02 TAI"+ , "1998-12-31 23:59:31.5 UTC == 1999-01-01 00:00:02.5 TAI"+ , "1998-12-31 23:59:32 UTC == 1999-01-01 00:00:03 TAI"+ , "1998-12-31 23:59:59 UTC == 1999-01-01 00:00:30 TAI"+ , "1998-12-31 23:59:59.5 UTC == 1999-01-01 00:00:30.5 TAI"+ , "1998-12-31 23:59:60 UTC == 1999-01-01 00:00:31 TAI"+ , "1998-12-31 23:59:60.5 UTC == 1999-01-01 00:00:31.5 TAI"+ , "1999-01-01 00:00:00 UTC == 1999-01-01 00:00:32 TAI"+ , "1999-01-01 00:00:00.5 UTC == 1999-01-01 00:00:32.5 TAI"+ , "1999-01-01 00:00:01 UTC == 1999-01-01 00:00:33 TAI"+ , "1999-01-01 00:00:01.5 UTC == 1999-01-01 00:00:33.5 TAI"+ , "1999-01-01 00:00:02 UTC == 1999-01-01 00:00:34 TAI"+ , "1999-01-01 23:59:28 UTC == 1999-01-02 00:00:00 TAI"+ , "1999-01-01 23:59:28.5 UTC == 1999-01-02 00:00:00.5 TAI"+ , "1999-01-01 23:59:29 UTC == 1999-01-02 00:00:01 TAI"+ , "1999-01-01 23:59:29.5 UTC == 1999-01-02 00:00:01.5 TAI"+ , "1999-01-01 23:59:30 UTC == 1999-01-02 00:00:02 TAI"+ , "1999-01-01 23:59:30.5 UTC == 1999-01-02 00:00:02.5 TAI"+ , "1999-01-01 23:59:31 UTC == 1999-01-02 00:00:03 TAI"+ , "1999-01-01 23:59:31.5 UTC == 1999-01-02 00:00:03.5 TAI"+ , "1999-01-01 23:59:32 UTC == 1999-01-02 00:00:04 TAI"+ , "1999-01-01 23:59:59 UTC == 1999-01-02 00:00:31 TAI"+ , "1999-01-01 23:59:59.5 UTC == 1999-01-02 00:00:31.5 TAI"+ , "correction: 1999-01-01 23:59:60 UTC -> 1999-01-02 00:00:32 TAI -> 1999-01-02 00:00:00 UTC"+ , "correction: 1999-01-01 23:59:60.5 UTC -> 1999-01-02 00:00:32.5 TAI -> 1999-01-02 00:00:00.5 UTC"+ , "1999-01-02 00:00:00 UTC == 1999-01-02 00:00:32 TAI"+ , "1999-01-02 00:00:00.5 UTC == 1999-01-02 00:00:32.5 TAI"+ , "1999-01-02 00:00:01 UTC == 1999-01-02 00:00:33 TAI"+ , "1999-01-02 00:00:01.5 UTC == 1999-01-02 00:00:33.5 TAI"+ , "1999-01-02 00:00:02 UTC == 1999-01-02 00:00:34 TAI"+ , "1999-01-02 23:59:28 UTC == 1999-01-03 00:00:00 TAI"+ , "1999-01-02 23:59:28.5 UTC == 1999-01-03 00:00:00.5 TAI"+ , "1999-01-02 23:59:29 UTC == 1999-01-03 00:00:01 TAI"+ , "1999-01-02 23:59:29.5 UTC == 1999-01-03 00:00:01.5 TAI"+ , "1999-01-02 23:59:30 UTC == 1999-01-03 00:00:02 TAI"+ , "1999-01-02 23:59:30.5 UTC == 1999-01-03 00:00:02.5 TAI"+ , "1999-01-02 23:59:31 UTC == 1999-01-03 00:00:03 TAI"+ , "1999-01-02 23:59:31.5 UTC == 1999-01-03 00:00:03.5 TAI"+ , "1999-01-02 23:59:32 UTC == 1999-01-03 00:00:04 TAI"+ , "1999-01-02 23:59:59 UTC == 1999-01-03 00:00:31 TAI"+ , "1999-01-02 23:59:59.5 UTC == 1999-01-03 00:00:31.5 TAI"+ , "correction: 1999-01-02 23:59:60 UTC -> 1999-01-03 00:00:32 TAI -> 1999-01-03 00:00:00 UTC"+ , "correction: 1999-01-02 23:59:60.5 UTC -> 1999-01-03 00:00:32.5 TAI -> 1999-01-03 00:00:00.5 UTC" ]
+ test/Test/TestParseTime.hs view
@@ -0,0 +1,581 @@+{-# OPTIONS -fno-warn-type-defaults -fno-warn-unused-binds -fno-warn-orphans #-}+{-# LANGUAGE FlexibleInstances, ExistentialQuantification #-}++module Test.TestParseTime where++import Control.Monad+import Data.Char+import Data.Ratio+import Data.Time+import Data.Time.Calendar.OrdinalDate+import Data.Time.Calendar.WeekDate+import Data.Time.Clock.POSIX+import Test.QuickCheck hiding (Result,reason)+import Test.QuickCheck.Property hiding (result)+import Test.TestUtil hiding (Result)++ntest :: Int+ntest = 1000++type NamedProperty = (String, Property)++testParseTime :: Test+testParseTime = testGroup "testParseTime"+ [+ readOtherTypesTest,+ readTests,+ simpleFormatTests,+ extests,+ particularParseTests,+ badParseTests,+ defaultTimeZoneTests,+ militaryTimeZoneTests,+ testGroup "properties" (fmap (\(n,prop) -> testProperty n prop) properties)+ ]++yearDays :: Integer -> [Day]+yearDays y = [(fromGregorian y 1 1) .. (fromGregorian y 12 31)]++makeExhaustiveTest :: String -> [t] -> (t -> Test) -> Test+makeExhaustiveTest name cases f = testGroup name (fmap f cases)++extests :: Test+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 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]))++readTest :: (Eq a,Show a,Read a) => [(a,String)] -> String -> Test+readTest expected target = let+ found = reads target+ result = diff expected found+ name = show target+ in pureTest name result++readTestsParensSpaces :: forall a. (Eq a,Show a,Read a) => a -> String -> Test+readTestsParensSpaces expected target = testGroup target+ [+ readTest [(expected,"")] $ target,+ readTest [(expected,"")] $ "("++target++")",+ readTest [(expected,"")] $ " ("++target++")",+ readTest [(expected," ")] $ " ( "++target++" ) ",+ readTest [(expected," ")] $ " (( "++target++" )) ",+ readTest ([] :: [(a,String)]) $ "("++target,+ readTest [(expected,")")] $ ""++target++")",+ readTest [(expected,"")] $ "(("++target++"))",+ readTest [(expected," ")] $ " ( ( "++target++" ) ) "+ ] where++readOtherTypesTest :: Test+readOtherTypesTest = testGroup "read other types"+ [+ readTestsParensSpaces 3 "3",+ readTestsParensSpaces "a" "\"a\""+ ]++readTests :: Test+readTests = testGroup "read times"+ [+ readTestsParensSpaces testDay "1912-07-08",+ --readTestsParensSpaces testDay "1912-7-8",+ readTestsParensSpaces testTimeOfDay "08:04:02"+ --,readTestsParensSpaces testTimeOfDay "8:4:2"+ ] where+ testDay = fromGregorian 1912 7 8+ testTimeOfDay = TimeOfDay 8 4 2++epoch :: LocalTime+epoch = LocalTime (fromGregorian 1970 0 0) midnight++simpleFormatTests :: Test+simpleFormatTests = testGroup "simple"+ [+ readsTest [(epoch,"")] "" "",+ readsTest [(epoch," ")] "" " ",+ readsTest [(epoch,"")] " " " ",+ readsTest [(epoch,"")] " " " ",+ readsTest [(epoch,"")] "%k" "0",+ readsTest [(epoch,"")] "%k" " 0",+ readsTest [(epoch,"")] "%m" "01",+ readsTest [(epoch," ")] "%m" "01 ",+ readsTest [(epoch," ")] " %m" " 01 ",+ readsTest [(epoch,"")] " %m" " 01",+ -- https://ghc.haskell.org/trac/ghc/ticket/9150+ readsTest [(epoch,"")] " %M" " 00",+ readsTest [(epoch,"")] "%M " "00 ",+ readsTest [(epoch,"")] "%Q" "",+ readsTest [(epoch," ")] "%Q" " ",+ readsTest [(epoch,"X")] "%Q" "X",+ readsTest [(epoch," X")] "%Q" " X",+ readsTest [(epoch,"")] "%Q " " ",+ readsTest [(epoch,"")] "%Q X" " X",+ readsTest [(epoch,"")] "%QX" "X"+ ] where+ readsTest :: (Show a, Eq a, ParseTime a) => [(a,String)] -> String -> String -> Test+ readsTest expected formatStr target = let+ found = readSTime False defaultTimeLocale formatStr target+ result = diff expected found+ name = (show formatStr) ++ " of " ++ (show target)+ in pureTest name result++spacingTests :: (Show t, Eq t, ParseTime t) => t -> String -> String -> Test+spacingTests expected formatStr target = testGroup "particular"+ [+ 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)+ ]++particularParseTests :: Test+particularParseTests = testGroup "particular"+ [+ spacingTests epoch "%Q" "",+ spacingTests epoch "%Q" ".0",+ spacingTests epoch "%k" " 0",+ spacingTests epoch "%M" "00",+ spacingTests epoch "%m" "01",+ spacingTests (TimeZone 120 False "") "%z" "+0200",+ spacingTests (TimeZone 120 False "") "%Z" "+0200",+ spacingTests (TimeZone (-480) False "PST") "%Z" "PST"+ ]++badParseTests :: Test+badParseTests = testGroup "bad"+ [+ parseTest False (Nothing :: Maybe Day) "%Y" ""+ ]++parseYMD :: Day -> Test+parseYMD day = case toGregorian day of+ (y,m,d) -> parseTest False (Just day) "%Y%m%d" ((show y) ++ (show2 m) ++ (show2 d))++parseYearDayD :: Day -> Test+parseYearDayD day = case toGregorian day of+ (y,m,d) -> parseTest False (Just day) "%Y %m %d" ((show y) ++ " " ++ (show2 m) ++ " " ++ (show2 d))++parseYearDayE :: Day -> Test+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 -> Test+parseYY i = parseTest False (Just (fromGregorian (expectedYear i) 1 1)) "%y" (show2 i)++parseCYY :: Integer -> Integer -> Test+parseCYY c i = parseTest False (Just (fromGregorian ((c * 100) + i) 1 1)) "%-C %y" ((show c) ++ " " ++ (show2 i))++parseCYY2 :: Integer -> Integer -> Test+parseCYY2 c i = parseTest False (Just (fromGregorian ((c * 100) + i) 1 1)) "%C %y" ((show2 c) ++ " " ++ (show2 i))++parseCentury :: String -> Integer -> Test+parseCentury int c = parseTest False (Just (fromGregorian (c * 100) 1 1)) ("%-C" ++ int ++ "%y") ((show c) ++ int ++ "00")++parseTest :: (Show t, Eq t, ParseTime t) => Bool -> Maybe t -> String -> String -> Test+parseTest sp expected formatStr target =+ let+ found = parse sp formatStr target+ result = diff expected found+ name = (show formatStr) ++ " of " ++ (show target) ++ (if sp then " allowing spaces" else "")+ in pureTest name result+{-+readsTest :: forall t. (Show t, Eq t, ParseTime t) => Maybe t -> String -> String -> Test+readsTest (Just e) = readsTest' [(e,"")]+readsTest Nothing = readsTest' ([] :: [(t,String)])+-}++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 -> Test+testParseTimeZone tz = parseTest False (Just tz) "%Z" (timeZoneName tz)++defaultTimeZoneTests :: Test+defaultTimeZoneTests = testGroup "default time zones" (fmap testParseTimeZone (knownTimeZones defaultTimeLocale))++militaryTimeZoneTests :: Test+militaryTimeZoneTests = testGroup "military time zones" (fmap (testParseTimeZone . getMilZone) [-12 .. 12])+++parse :: ParseTime t => Bool -> String -> String -> Maybe t+parse sp f t = parseTimeM sp defaultTimeLocale f t++format :: (FormatTime t) => String -> t -> String+format f t = formatTime defaultTimeLocale f t++instance Arbitrary Day where+ arbitrary = liftM ModifiedJulianDay $ choose (-313698, 2973483) -- 1000-01-1 to 9999-12-31++instance CoArbitrary Day where+ coarbitrary (ModifiedJulianDay d) = coarbitrary d++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)+ secondsToDiffTime' :: Integer -> DiffTime+ secondsToDiffTime' = fromInteger+ picosecondsToDiffTime' :: Integer -> DiffTime+ picosecondsToDiffTime' x = fromRational (x % 10^12)++instance CoArbitrary DiffTime where+ coarbitrary t = coarbitrary (fromEnum t)++instance Arbitrary TimeOfDay where+ arbitrary = liftM timeToTimeOfDay arbitrary++instance CoArbitrary TimeOfDay where+ coarbitrary t = coarbitrary (timeOfDayToTime t)++instance Arbitrary LocalTime where+ arbitrary = liftM2 LocalTime arbitrary arbitrary++instance CoArbitrary LocalTime where+ coarbitrary t = coarbitrary (truncate (utcTimeToPOSIXSeconds (localTimeToUTC utc t)) :: Integer)++instance Arbitrary TimeZone where+ arbitrary = liftM minutesToTimeZone $ choose (-720,720)++instance CoArbitrary TimeZone where+ coarbitrary tz = coarbitrary (timeZoneMinutes tz)++instance Arbitrary ZonedTime where+ arbitrary = liftM2 ZonedTime arbitrary arbitrary++instance CoArbitrary ZonedTime where+ coarbitrary t = coarbitrary (truncate (utcTimeToPOSIXSeconds (zonedTimeToUTC t)) :: Integer)++instance Arbitrary UTCTime where+ arbitrary = liftM2 UTCTime arbitrary arbitrary++instance CoArbitrary UTCTime where+ coarbitrary t = coarbitrary (truncate (utcTimeToPOSIXSeconds t) :: Integer)++-- 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 dbugging 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+--++prop_read_show :: (Read a, Show a, Eq a) => a -> Result+prop_read_show t = compareResult [(t,"")] (reads (show t))++prop_read_show' :: (Read a, Show a, Eq a) => a -> Result+prop_read_show' t = compareResult t (read (show 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)++--+-- * format and parse+--++-- | Helper for defining named properties.+prop_named :: (Arbitrary t, Show t, Testable a)+ => String -> (FormatString s -> t -> a) -> String -> FormatString s -> NamedProperty+prop_named n prop typeName f = (n ++ " " ++ typeName ++ " " ++ show f, property (prop f))++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)++prop_parse_format_named :: (Arbitrary t, Eq t, Show t, FormatTime t, ParseTime t)+ => String -> FormatString t -> NamedProperty+prop_parse_format_named = prop_named "prop_parse_format" prop_parse_format++-- Verify case-insensitivity with upper case.+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)++prop_parse_format_upper_named :: (Arbitrary t, Eq t, Show t, FormatTime t, ParseTime t)+ => String -> FormatString t -> NamedProperty+prop_parse_format_upper_named = prop_named "prop_parse_format_upper" prop_parse_format_upper++-- Verify case-insensitivity with lower case.+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)++prop_parse_format_lower_named :: (Arbitrary t, Eq t, Show t, FormatTime t, ParseTime t)+ => String -> FormatString t -> NamedProperty+prop_parse_format_lower_named = prop_named "prop_parse_format_lower" prop_parse_format_lower++prop_format_parse_format :: (FormatTime t, ParseTime t, Show t) => FormatString t -> t -> Result+prop_format_parse_format (FormatString f) t = compareResult+ (Just (format f t))+ (fmap (format f) (parse False f (format f t) `asTypeOf` Just t))++prop_format_parse_format_named :: (Arbitrary t, Show t, FormatTime t, ParseTime t)+ => String -> FormatString t -> NamedProperty+prop_format_parse_format_named = prop_named "prop_format_parse_format" prop_format_parse_format++--+-- * 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+ where+prop_no_crash_bad_input_named :: (Eq t, ParseTime t)+ => String -> FormatString t -> NamedProperty+prop_no_crash_bad_input_named = prop_named "prop_no_crash_bad_input" prop_no_crash_bad_input++--+--+--++newtype FormatString a = FormatString String++formatType :: FormatString t -> t+formatType _ = undefined++castFormatString :: FormatString a -> FormatString b+castFormatString (FormatString f) = FormatString f++instance Show (FormatString a) where+ show (FormatString f) = show f++properties :: [NamedProperty]+properties =+ [("prop_fromMondayStartWeek", property prop_fromMondayStartWeek),+ ("prop_fromSundayStartWeek", property prop_fromSundayStartWeek)]+ ++ [("prop_read_show Day", property (prop_read_show :: Day -> Result)),+ ("prop_read_show TimeOfDay", property (prop_read_show :: TimeOfDay -> Result)),+ ("prop_read_show LocalTime", property (prop_read_show :: LocalTime -> Result)),+ ("prop_read_show TimeZone", property (prop_read_show :: TimeZone -> Result)),+ ("prop_read_show ZonedTime", property (prop_read_show :: ZonedTime -> Result)),+ ("prop_read_show UTCTime", property (prop_read_show :: UTCTime -> Result))]+ ++ [("prop_parse_showWeekDate", property prop_parse_showWeekDate),+ ("prop_parse_showGregorian", property prop_parse_showGregorian),+ ("prop_parse_showOrdinalDate", property prop_parse_showOrdinalDate)]++ ++ map (prop_parse_format_named "Day") dayFormats+ ++ map (prop_parse_format_named "TimeOfDay") timeOfDayFormats+ ++ map (prop_parse_format_named "LocalTime") localTimeFormats+ ++ map (prop_parse_format_named "TimeZone") timeZoneFormats+ ++ map (prop_parse_format_named "ZonedTime") zonedTimeFormats+ ++ map (prop_parse_format_named "UTCTime") utcTimeFormats++ ++ map (prop_parse_format_upper_named "Day") dayFormats+ ++ map (prop_parse_format_upper_named "TimeOfDay") timeOfDayFormats+ ++ map (prop_parse_format_upper_named "LocalTime") localTimeFormats+ ++ map (prop_parse_format_upper_named "TimeZone") timeZoneFormats+ ++ map (prop_parse_format_upper_named "ZonedTime") zonedTimeFormats+ ++ map (prop_parse_format_upper_named "UTCTime") utcTimeFormats++ ++ map (prop_parse_format_lower_named "Day") dayFormats+ ++ map (prop_parse_format_lower_named "TimeOfDay") timeOfDayFormats+ ++ map (prop_parse_format_lower_named "LocalTime") localTimeFormats+ ++ map (prop_parse_format_lower_named "TimeZone") timeZoneFormats+ ++ map (prop_parse_format_lower_named "ZonedTime") zonedTimeFormats+ ++ map (prop_parse_format_lower_named "UTCTime") utcTimeFormats++ ++ map (prop_format_parse_format_named "Day") partialDayFormats+ ++ map (prop_format_parse_format_named "TimeOfDay") partialTimeOfDayFormats+ ++ map (prop_format_parse_format_named "LocalTime") partialLocalTimeFormats+ ++ map (prop_format_parse_format_named "ZonedTime") partialZonedTimeFormats+ ++ map (prop_format_parse_format_named "UTCTime") partialUTCTimeFormats++ ++ map (prop_no_crash_bad_input_named "Day") (dayFormats ++ partialDayFormats ++ failingPartialDayFormats)+ ++ map (prop_no_crash_bad_input_named "TimeOfDay") (timeOfDayFormats ++ partialTimeOfDayFormats)+ ++ map (prop_no_crash_bad_input_named "LocalTime") (localTimeFormats ++ partialLocalTimeFormats)+ ++ map (prop_no_crash_bad_input_named "TimeZone") (timeZoneFormats)+ ++ map (prop_no_crash_bad_input_named "ZonedTime") (zonedTimeFormats ++ partialZonedTimeFormats)+ ++ map (prop_no_crash_bad_input_named "UTCTime") (utcTimeFormats ++ partialUTCTimeFormats)++++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",+ -- ordinal dates+ "%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"+ ]++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 $+ concat [ [df ++ " " ++ tf, tf ++ " " ++ df] | FormatString df <- dayFormats,+ FormatString tf <- timeOfDayFormats]++localTimeFormats :: [FormatString LocalTime]+localTimeFormats = map FormatString [{-"%Q","%Q ","%QX"-}]++timeZoneFormats :: [FormatString TimeZone]+timeZoneFormats = map FormatString ["%z","%z%Z","%Z%z","%Z"]++zonedTimeFormats :: [FormatString ZonedTime]+zonedTimeFormats = map FormatString+ ["%a, %d %b %Y %H:%M:%S.%q %z", "%a, %d %b %Y %H:%M:%S%Q %z", "%s.%q %z", "%s%Q %z",+ "%a, %d %b %Y %H:%M:%S.%q %Z", "%a, %d %b %Y %H:%M:%S%Q %Z", "%s.%q %Z", "%s%Q %Z"]++utcTimeFormats :: [FormatString UTCTime]+utcTimeFormats = map FormatString+ ["%s.%q","%s%Q"]++--+-- * Formats that do not include all the information+--++partialDayFormats :: [FormatString Day]+partialDayFormats = map FormatString+ [ ]++partialTimeOfDayFormats :: [FormatString TimeOfDay]+partialTimeOfDayFormats = map FormatString+ [ ]++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"+ ]+++--+-- * Known failures+--++knownFailures :: [NamedProperty]+knownFailures =+ map (prop_format_parse_format_named "Day") failingPartialDayFormats++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/Test/TestTime.hs view
@@ -0,0 +1,106 @@+module Test.TestTime where++import Data.Time.Calendar.OrdinalDate+import Data.Time.Calendar.WeekDate+import Data.Time+import Test.TestUtil+import Test.TestTimeRef++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 ]++testTime :: Test+testTime = pureTest "testTime" $+ diff testTimeRef $ unlines [testCal, testUTC, testUT1, testTimeOfDayToDayFraction]
+ test/Test/TestTimeRef.hs view
@@ -0,0 +1,881 @@+module Test.TestTimeRef where++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"+ ,"" ]
+ test/Test/TestUtil.hs view
@@ -0,0 +1,39 @@+{-# OPTIONS -fno-warn-overlapping-patterns #-}+module Test.TestUtil+ (+ module Test.TestUtil,+ module Test.Framework,+ module Test.Framework.Providers.QuickCheck2+ ) where++import Test.Framework+import Test.Framework.Providers.API+import Test.Framework.Providers.QuickCheck2+import Data.Typeable++data Result = Pass | Fail String deriving Typeable++instance Show Result where+ show Pass = "passed"+ show (Fail s) = "failed: " ++ s++instance TestResultlike () Result where+ testSucceeded Pass = True+ testSucceeded (Fail _) = False++instance Testlike () Result (IO Result) where+ testTypeName _ = "Cases"+ runTest _ ior = do+ r <- ior+ return (Finished r,return ())++ioTest :: String -> IO Result -> Test+ioTest = Test++pureTest :: String -> Result -> Test+pureTest name result = ioTest name (return result)++diff :: (Show a,Eq a) => a -> a -> Result+diff expected found | expected == found = Pass+diff expected found = Fail ("expected " ++ (show expected) ++ " but found " ++ (show found))+
+ test/Test/Tests.hs view
@@ -0,0 +1,30 @@+module Test.Tests where++import Test.Framework++import Test.AddDays+import Test.ClipDates+import Test.ConvertBack+import Test.LongWeekYears+import Test.TestCalendars+import Test.TestEaster+import Test.TestFormat+import Test.TestMonthDay+import Test.TestParseDAT+import Test.TestParseTime+import Test.TestTime+import Test.TestTimeZone++tests :: [Test]+tests = [ addDaysTest+ , clipDates+ , convertBack+ , longWeekYears+ , testCalendars+ , testEaster+ , testFormat+ , testMonthDay+ , testParseDAT+ , testParseTime+ , testTime+ , testTimeZone ]
time.cabal view
@@ -1,11 +1,12 @@ name: time-version: 1.4.2+version: 1.5 stability: stable license: BSD3 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@@ -17,34 +18,32 @@ aclocal.m4 configure.ac configure- include/HsConfigure.h- include/HsTime.h- include/HsTimeConfig.h.in- Test/*.hs- Test/*.lhs- Test/*.c- Test/*.h+ lib/include/HsConfigure.h+ lib/include/HsTime.h+ lib/include/HsTimeConfig.h.in+ test/Test/*.c+ test/Test/*.h extra-tmp-files: config.log config.status autom4te.cache- include/HsTimeConfig.h+ lib/include/HsTimeConfig.h source-repository head- type: darcs- location: http://code.haskell.org/time/+ type: git+ location: https://github.com/haskell/time library- build-depends: + hs-source-dirs: lib+ build-depends: base >= 4.4 && < 5,- deepseq >= 1.1,- old-locale+ deepseq >= 1.1 ghc-options: -Wall default-language: Haskell2010 if impl(ghc)- default-extensions: - Rank2Types - DeriveDataTypeable + default-extensions:+ Rank2Types+ DeriveDataTypeable StandaloneDeriving cpp-options: -DLANGUAGE_Rank2Types -DLANGUAGE_DeriveDataTypeable -DLANGUAGE_StandaloneDeriving else@@ -67,7 +66,7 @@ Data.Time.Format, Data.Time default-extensions: CPP- c-sources: cbits/HsTime.c+ c-sources: lib/cbits/HsTime.c other-modules: Data.Time.Calendar.Private, Data.Time.Calendar.Days,@@ -81,7 +80,8 @@ Data.Time.LocalTime.TimeOfDay, Data.Time.LocalTime.LocalTime, Data.Time.Format.Parse- include-dirs: include+ Data.Time.Format.Locale+ include-dirs: lib/include if os(windows) install-includes: HsTime.h@@ -90,10 +90,19 @@ HsTime.h HsTimeConfig.h +test-suite ShowDefaultTZAbbreviations+ hs-source-dirs: test+ type: exitcode-stdio-1.0+ build-depends:+ base,+ time == 1.5+ main-is: ShowDefaultTZAbbreviations.hs+ test-suite tests+ hs-source-dirs: test type: exitcode-stdio-1.0 default-language: Haskell2010- default-extensions: + default-extensions: Rank2Types CPP DeriveDataTypeable@@ -103,19 +112,15 @@ FlexibleInstances UndecidableInstances ScopedTypeVariables- cpp-options: -DLANGUAGE_Rank2Types -DLANGUAGE_DeriveDataTypeable -DLANGUAGE_StandaloneDeriving ghc-options: -Wall- c-sources: cbits/HsTime.c Test/TestFormatStuff.c- include-dirs: include- build-depends: + c-sources: test/Test/TestFormatStuff.c+ build-depends: base, deepseq,- Cabal >= 1.16,- old-locale,- process,+ time == 1.5, QuickCheck >= 2.5.1,- test-framework >= 0.6.1 && < 0.7,- test-framework-quickcheck2 >= 0.2.12,+ test-framework >= 0.8,+ test-framework-quickcheck2 >= 0.3, unix main-is: Test.hs other-modules:@@ -142,27 +147,3 @@ Test.AddDaysRef Test.TestUtil - Data.Time.Calendar.Private,- 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- Data.Time.Calendar,- Data.Time.Calendar.MonthDay,- Data.Time.Calendar.OrdinalDate,- Data.Time.Calendar.WeekDate,- Data.Time.Calendar.Julian,- Data.Time.Calendar.Easter,- Data.Time.Clock,- Data.Time.Clock.POSIX,- Data.Time.Clock.TAI,- Data.Time.LocalTime,- Data.Time.Format,- Data.Time