time-compat 1.9.6.1 → 1.9.7
raw patch · 20 files changed
+35/−467 lines, 20 filesdep −base-compatdep −old-localedep ~QuickCheckdep ~basedep ~base-orphans
Dependencies removed: base-compat, old-locale
Dependency ranges changed: QuickCheck, base, base-orphans, deepseq, hashable, tasty, tasty-quickcheck, time
Files
- CHANGELOG.md +4/−0
- src/Data/Format.hs +0/−21
- src/Data/Time/Calendar/Compat.hs +1/−20
- src/Data/Time/Calendar/Julian/Compat.hs +0/−8
- src/Data/Time/Calendar/Month/Compat.hs +1/−18
- src/Data/Time/Calendar/MonthDay/Compat.hs +0/−8
- src/Data/Time/Calendar/OrdinalDate/Compat.hs +0/−42
- src/Data/Time/Calendar/Quarter/Compat.hs +0/−8
- src/Data/Time/Calendar/WeekDate/Compat.hs +0/−12
- src/Data/Time/Clock/Compat.hs +0/−18
- src/Data/Time/Clock/POSIX/Compat.hs +0/−6
- src/Data/Time/Clock/System/Compat.hs +0/−100
- src/Data/Time/Clock/TAI/Compat.hs +0/−50
- src/Data/Time/Format/Compat.hs +2/−50
- src/Data/Time/Format/ISO8601/Compat.hs +0/−8
- src/Data/Time/Orphans.hs +0/−31
- test/main/Test/Calendar/CalendarProps.hs +0/−9
- test/main/Test/Clock/Resolution.hs +3/−6
- test/main/Test/Format/ParseTime.hs +1/−5
- time-compat.cabal +23/−47
CHANGELOG.md view
@@ -1,3 +1,7 @@+# 1.9.7++- Drop support for GHCs prior 8.6.5+ # 1.9.6.1 - Support `time-1.12`.
src/Data/Format.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE CPP #-} module Data.Format ( Productish(..) , Summish(..)@@ -23,24 +22,12 @@ , decimalFormat ) where -#if MIN_VERSION_base(4,9,0) import Control.Monad.Fail import Prelude hiding (fail)-#endif-#if MIN_VERSION_base(4,8,0) import Data.Void-#endif import Data.Char import Text.ParserCombinators.ReadP --#if MIN_VERSION_base(4,8,0)-#else-data Void-absurd :: Void -> a-absurd v = seq v $ error "absurd"-#endif- class IsoVariant f where isoMap :: (a -> b) -> (b -> a) -> f a -> f b @@ -63,11 +50,7 @@ parseReader :: (-#if MIN_VERSION_base(4,9,0) MonadFail m-#else- Monad m-#endif ) => ReadP t -> String -> m t parseReader readp s = case [ t | (t,"") <- readP_to_S readp s] of [t] -> return t@@ -90,11 +73,7 @@ -- | Parse a value in the format formatParseM :: (-#if MIN_VERSION_base(4,9,0) MonadFail m-#else- Monad m-#endif ) => Format t -> String -> m t formatParseM format = parseReader $ formatReadP format
src/Data/Time/Calendar/Compat.hs view
@@ -1,9 +1,7 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE DeriveDataTypeable #-}-#if __GLASGOW_HASKELL__ >= 710 {-# LANGUAGE PatternSynonyms #-} {-# LANGUAGE ViewPatterns #-}-#endif module Data.Time.Calendar.Compat ( -- * Days Day(..),addDays,diffDays,@@ -31,9 +29,7 @@ -- * Type aliases DayOfMonth, MonthOfYear, Year,-#if __GLASGOW_HASKELL__ >= 710 pattern YearMonthDay,-#endif ) where import Data.Time.Calendar@@ -48,10 +44,6 @@ import Data.Time.Calendar.WeekDate.Compat #endif -#if !MIN_VERSION_time(1,5,0)-import System.Locale (TimeLocale (..))-#endif- import Control.DeepSeq (NFData (..)) import Data.Data (Data, Typeable) import Data.Monoid (Monoid (..))@@ -71,14 +63,7 @@ data CalendarDiffDays = CalendarDiffDays { cdMonths :: Integer , cdDays :: Integer- } deriving (Eq,- Data-#if __GLASGOW_HASKELL__ >= 802-#endif- ,Typeable-#if __GLASGOW_HASKELL__ >= 802-#endif- )+ } deriving (Eq, Data, Typeable) -- | Additive instance Semigroup CalendarDiffDays where@@ -161,17 +146,13 @@ #endif #if !MIN_VERSION_time(1,11,0)-#if __GLASGOW_HASKELL__ >= 710 -- | Bidirectional abstract constructor for the proleptic Gregorian calendar. -- Invalid values will be clipped to the correct range, month first, then day. pattern YearMonthDay :: Year -> MonthOfYear -> DayOfMonth -> Day pattern YearMonthDay y m d <- (toGregorian -> (y,m,d)) where YearMonthDay y m d = fromGregorian y m d -#if __GLASGOW_HASKELL__ >= 802 {-# COMPLETE YearMonthDay #-}-#endif-#endif #endif -------------------------------------------------------------------------------
src/Data/Time/Calendar/Julian/Compat.hs view
@@ -1,8 +1,6 @@ {-# LANGUAGE CPP #-}-#if __GLASGOW_HASKELL__ >= 710 {-# LANGUAGE PatternSynonyms #-} {-# LANGUAGE ViewPatterns #-}-#endif module Data.Time.Calendar.Julian.Compat ( Year, MonthOfYear, DayOfMonth, DayOfYear, @@ -14,9 +12,7 @@ isJulianLeapYear, toJulian,fromJulian,-#if __GLASGOW_HASKELL__ >= 710 pattern JulianYearMonthDay,-#endif fromJulianValid,showJulian,julianMonthLength, -- calendrical arithmetic@@ -80,15 +76,11 @@ #endif #if !MIN_VERSION_time(1,11,0)-#if __GLASGOW_HASKELL__ >= 710 -- | Bidirectional abstract constructor for the proleptic Julian calendar. -- Invalid values will be clipped to the correct range, month first, then day. pattern JulianYearMonthDay :: Year -> MonthOfYear -> DayOfMonth -> Day pattern JulianYearMonthDay y m d <- (toJulian -> (y,m,d)) where JulianYearMonthDay y m d = fromJulian y m d -#if __GLASGOW_HASKELL__ >= 802 {-# COMPLETE JulianYearMonthDay #-}-#endif-#endif #endif
src/Data/Time/Calendar/Month/Compat.hs view
@@ -1,18 +1,12 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE DeriveDataTypeable #-}-#if __GLASGOW_HASKELL__ >= 710 {-# LANGUAGE PatternSynonyms #-} {-# LANGUAGE ViewPatterns #-}-#endif module Data.Time.Calendar.Month.Compat ( Month(..), addMonths, diffMonths,-#if __GLASGOW_HASKELL__ >= 710 pattern YearMonth,-#endif fromYearMonthValid,-#if __GLASGOW_HASKELL__ >= 710 pattern MonthDay,-#endif fromMonthDayValid, -- * time-compat extras fromYearMonth,@@ -113,10 +107,8 @@ #if MIN_VERSION_time(1,9,0) #define FORMAT_OPTS fo-#elif MIN_VERSION_time(1,8,0)-#define FORMAT_OPTS tl mpo i #else-#define FORMAT_OPTS tl mpo+#define FORMAT_OPTS tl mpo i #endif #if MIN_VERSION_time(1,9,0)@@ -158,17 +150,13 @@ toYearMonth (MkMonth m) = case divMod' m 12 of (y, my) -> (y, succ (fromInteger my)) -#if __GLASGOW_HASKELL__ >= 710 -- | Bidirectional abstract constructor. -- Invalid months of year will be clipped to the correct range. pattern YearMonth :: Year -> MonthOfYear -> Month pattern YearMonth y my <- (toYearMonth -> (y, my)) where YearMonth y my = fromYearMonth y my -#if __GLASGOW_HASKELL__ >= 802 {-# COMPLETE YearMonth #-}-#endif-#endif -- | Part of 'MonthDay' pattern toMonthDay :: Day -> (Month,DayOfMonth)@@ -184,17 +172,12 @@ fromMonthDayValid m dm = case toYearMonth m of (y, my) -> fromGregorianValid y my dm -#if __GLASGOW_HASKELL__ >= 710 -- | Bidirectional abstract constructor. -- Invalid days of month will be clipped to the correct range. pattern MonthDay :: Month -> DayOfMonth -> Day pattern MonthDay m dm <- (toMonthDay -> (m,dm)) where MonthDay (YearMonth y my) dm = fromGregorian y my dm --#if __GLASGOW_HASKELL__ >= 802 {-# COMPLETE MonthDay #-}-#endif-#endif #endif
src/Data/Time/Calendar/MonthDay/Compat.hs view
@@ -1,12 +1,8 @@ {-# LANGUAGE CPP #-}-#if __GLASGOW_HASKELL__ >= 710 {-# LANGUAGE PatternSynonyms #-}-#endif module Data.Time.Calendar.MonthDay.Compat ( MonthOfYear, DayOfMonth, DayOfYear,-#if __GLASGOW_HASKELL__ >= 710 -- patterns-#endif monthAndDayToDayOfYear, monthAndDayToDayOfYearValid, dayOfYearToMonthAndDay,@@ -23,7 +19,6 @@ {- #if !MIN_VERSION_time(1,12,0)-#if __GLASGOW_HASKELL__ >= 710 pattern January :: MonthOfYear pattern January = 1 @@ -61,9 +56,6 @@ pattern December :: MonthOfYear pattern December = 12 -#if __GLASGOW_HASKELL__ >= 802 {-# COMPLETE January, February, March, April, May, June, July, August, September, October, November, December #-}-#endif-#endif #endif -}
src/Data/Time/Calendar/OrdinalDate/Compat.hs view
@@ -1,15 +1,11 @@ {-# LANGUAGE CPP #-}-#if __GLASGOW_HASKELL__ >= 710 {-# LANGUAGE PatternSynonyms #-} {-# LANGUAGE ViewPatterns #-}-#endif module Data.Time.Calendar.OrdinalDate.Compat ( Day, Year, DayOfYear, WeekOfYear, toOrdinalDate, fromOrdinalDate,-#if __GLASGOW_HASKELL__ >= 710 pattern YearDay,-#endif fromOrdinalDateValid, showOrdinalDate, isLeapYear,@@ -24,11 +20,7 @@ import Data.Time.Orphans () import Data.Time.Calendar.OrdinalDate hiding (fromSundayStartWeekValid)-#if MIN_VERSION_time(1,6,0) import Data.Time.Calendar.OrdinalDate (fromSundayStartWeekValid)-#else-import Data.Time.Calendar.Private-#endif #if !MIN_VERSION_time(1,11,0) import Data.Time.Calendar@@ -37,46 +29,12 @@ #if !MIN_VERSION_time(1,11,0) -#if __GLASGOW_HASKELL__ >= 710 -- | Bidirectional abstract constructor for ISO 8601 Ordinal Date format. -- Invalid day numbers will be clipped to the correct range (1 to 365 or 366). pattern YearDay :: Year -> DayOfYear -> Day pattern YearDay y d <- (toOrdinalDate -> (y,d)) where YearDay y d = fromOrdinalDate y d -#if __GLASGOW_HASKELL__ >= 802 {-# COMPLETE YearDay #-}-#endif-#endif -#endif--#if !MIN_VERSION_time(1,6,0)-fromSundayStartWeekValid ::- Year -- ^ Year.- -> WeekOfYear -- ^ Sunday-starting week number (as @%U@ in 'Data.Time.Format.formatTime').- -> Int -- ^ Day of week.- -- Sunday is 0, Saturday is 6 (as @%w@ in 'Data.Time.Format.formatTime').- -> Maybe Day-fromSundayStartWeekValid year w d = do- d' <- clipValid 0 6 d- let- -- first day of the year- firstDay = fromOrdinalDate year 1- -- 0-based week of year- zbFirstSunday = (4 - toModifiedJulianDay firstDay) `mod` 7- -- 0-based week number- zbWeek = w - 1- -- 0-based day of week- zbDay = d'- -- 0-based day in year- zbYearDay = zbFirstSunday + 7 * toInteger zbWeek + toInteger zbDay- zbYearDay' <-- clipValid- 0- (if isLeapYear year- then 365- else 364)- zbYearDay- return $ addDays zbYearDay' firstDay #endif
src/Data/Time/Calendar/Quarter/Compat.hs view
@@ -1,15 +1,11 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE DeriveDataTypeable #-}-#if __GLASGOW_HASKELL__ >= 710 {-# LANGUAGE PatternSynonyms #-} {-# LANGUAGE ViewPatterns #-}-#endif module Data.Time.Calendar.Quarter.Compat ( QuarterOfYear(..), addQuarters, diffQuarters, Quarter(..),-#if __GLASGOW_HASKELL__ >= 710 pattern YearQuarter,-#endif monthOfYearQuarter, monthQuarter, dayQuarter,@@ -122,16 +118,12 @@ diffQuarters :: Quarter -> Quarter -> Integer diffQuarters (MkQuarter a) (MkQuarter b) = a - b -#if __GLASGOW_HASKELL__ >= 710 -- | Bidirectional abstract constructor. pattern YearQuarter :: Year -> QuarterOfYear -> Quarter pattern YearQuarter y qy <- (toYearQuarter -> (y, qy)) where YearQuarter y qy = fromYearQuarter y qy -#if __GLASGOW_HASKELL__ >= 802 {-# COMPLETE YearQuarter #-}-#endif-#endif monthOfYearQuarter :: MonthOfYear -> QuarterOfYear monthOfYearQuarter my | my <= 3 = Q1
src/Data/Time/Calendar/WeekDate/Compat.hs view
@@ -1,10 +1,8 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE BangPatterns #-} {-# LANGUAGE DeriveDataTypeable #-}-#if __GLASGOW_HASKELL__ >= 710 {-# LANGUAGE PatternSynonyms #-} {-# LANGUAGE ViewPatterns #-}-#endif module Data.Time.Calendar.WeekDate.Compat ( Year, WeekOfYear, DayOfWeek(..), dayOfWeek, FirstWeekType (..),@@ -16,9 +14,7 @@ -- * ISO 8601 Week Date format toWeekDate, fromWeekDate,-#if __GLASGOW_HASKELL__ >= 710 pattern YearWeekDay,-#endif fromWeekDateValid, showWeekDate, ) where@@ -108,17 +104,13 @@ d = fromWeekCalendar wt ws y wy dw in if toWeekCalendar wt ws d == (y,wy,dw) then Just d else Nothing -#if __GLASGOW_HASKELL__ >= 710 -- | Bidirectional abstract constructor for ISO 8601 Week Date format. -- Invalid week values will be clipped to the correct range. pattern YearWeekDay :: Year -> WeekOfYear -> DayOfWeek -> Day pattern YearWeekDay y wy dw <- (toWeekDate -> (y,wy,toEnum -> dw)) where YearWeekDay y wy dw = fromWeekDate y wy (fromEnum dw) -#if __GLASGOW_HASKELL__ >= 802 {-# COMPLETE YearWeekDay #-}-#endif-#endif #endif @@ -178,11 +170,7 @@ toSomeDay :: DayOfWeek -> Day toSomeDay d = ModifiedJulianDay (fromIntegral $ fromEnum d + 4) -#if MIN_VERSION_time(1,8,0) #define FORMAT_OPTS tl mpo i-#else-#define FORMAT_OPTS tl mpo-#endif instance FormatTime DayOfWeek where formatCharacter 'u' = fmap (\f FORMAT_OPTS d -> f FORMAT_OPTS (toSomeDay d)) (formatCharacter 'u')
src/Data/Time/Clock/Compat.hs view
@@ -50,21 +50,3 @@ nominalDiffTimeToSeconds = realToFrac #endif--#if !MIN_VERSION_time(1,8,0)--- | One day in 'NominalDiffTime'.-nominalDay :: NominalDiffTime-nominalDay = 86400-#endif--#if !MIN_VERSION_time(1,8,0)--- | The resolution of 'getSystemTime', 'getCurrentTime', 'getPOSIXTime'-getTime_resolution :: DiffTime-getTime_resolution = 1E-6 -- microsecond-#endif--#if !MIN_VERSION_time(1,6,0)--- | Get the number of picoseconds in a 'DiffTime'.-diffTimeToPicoseconds :: DiffTime -> Integer-diffTimeToPicoseconds = truncate . (1000000000000 *)-#endif
src/Data/Time/Clock/POSIX/Compat.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE CPP #-} module Data.Time.Clock.POSIX.Compat ( posixDayLength,POSIXTime,posixSecondsToUTCTime,utcTimeToPOSIXSeconds,getPOSIXTime,getCurrentTime, systemToPOSIXTime,@@ -9,8 +8,3 @@ import Data.Time import Data.Time.Clock.POSIX import Data.Time.Clock.System.Compat--#if !MIN_VERSION_time(1,8,0)-systemToPOSIXTime :: SystemTime -> POSIXTime-systemToPOSIXTime (MkSystemTime s ns) = (fromIntegral s) + (fromIntegral ns) * 1E-9-#endif
src/Data/Time/Clock/System/Compat.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE CPP #-} {-# LANGUAGE DeriveDataTypeable #-} module Data.Time.Clock.System.Compat ( systemEpochDay,@@ -11,103 +10,4 @@ ) where import Data.Time.Orphans ()--#if MIN_VERSION_time(1,8,0) import Data.Time.Clock.System-#else--import Control.DeepSeq (NFData (..))-import Data.Int (Int64)-import Data.Word (Word32)-import Data.Typeable (Typeable)-import Data.Data (Data)--import Data.Time.Clock.TAI.Compat-import Data.Time.Clock.POSIX-import Data.Time.Compat---- | 'SystemTime' is time returned by system clock functions.--- Its semantics depends on the clock function, but the epoch is typically the beginning of 1970.--- Note that 'systemNanoseconds' of 1E9 to 2E9-1 can be used to represent leap seconds.-data SystemTime = MkSystemTime- { systemSeconds :: {-# UNPACK #-} !Int64- , systemNanoseconds :: {-# UNPACK #-} !Word32- } deriving (Eq,Ord,Show,Typeable,Data)--instance NFData SystemTime where- rnf a = a `seq` ()---- | Get the system time, epoch start of 1970 UTC, leap-seconds ignored.--- 'getSystemTime' is typically much faster than 'getCurrentTime'.-getSystemTime :: IO SystemTime----- Use gettimeofday-getSystemTime = do- t <- getPOSIXTime- let secs = truncate t- let nsecs = truncate $ 1000000000 * (t - fromIntegral secs)- return (MkSystemTime secs nsecs)---- | Map leap-second values to the start of the following second.--- The resulting 'systemNanoseconds' will always be in the range 0 to 1E9-1.-truncateSystemTimeLeapSecond :: SystemTime -> SystemTime-truncateSystemTimeLeapSecond (MkSystemTime seconds nanoseconds) | nanoseconds >= 1000000000 = MkSystemTime (succ seconds) 0-truncateSystemTimeLeapSecond t = t---- | Convert 'SystemTime' to 'UTCTime', matching zero 'SystemTime' to midnight of 'systemEpochDay' UTC.-systemToUTCTime :: SystemTime -> UTCTime-systemToUTCTime (MkSystemTime seconds nanoseconds) = let- days :: Int64- timeSeconds :: Int64- (days, timeSeconds) = seconds `divMod` 86400-- day :: Day- day = addDays (fromIntegral days) systemEpochDay-- timeNanoseconds :: Int64- timeNanoseconds = timeSeconds * 1000000000 + (fromIntegral nanoseconds)-- timePicoseconds :: Int64- timePicoseconds = timeNanoseconds * 1000-- time :: DiffTime- time = picosecondsToDiffTime $ fromIntegral timePicoseconds- in UTCTime day time---- | Convert 'UTCTime' to 'SystemTime', matching zero 'SystemTime' to midnight of 'systemEpochDay' UTC.-utcToSystemTime :: UTCTime -> SystemTime-utcToSystemTime (UTCTime day time) = let- days :: Int64- days = fromIntegral $ diffDays day systemEpochDay-- timePicoseconds :: Int64- timePicoseconds = fromIntegral $ diffTimeToPicoseconds time-- timeNanoseconds :: Int64- timeNanoseconds = timePicoseconds `div` 1000-- timeSeconds :: Int64- nanoseconds :: Int64- (timeSeconds,nanoseconds) = if timeNanoseconds >= 86400000000000 then (86399,timeNanoseconds - 86399000000000) else timeNanoseconds `divMod` 1000000000-- seconds :: Int64- seconds = days * 86400 + timeSeconds-- in MkSystemTime seconds $ fromIntegral nanoseconds--systemEpochAbsolute :: AbsoluteTime-systemEpochAbsolute = taiNominalDayStart systemEpochDay---- | Convert 'SystemTime' to 'AbsoluteTime', matching zero 'SystemTime' to midnight of 'systemEpochDay' TAI.-systemToTAITime :: SystemTime -> AbsoluteTime-systemToTAITime (MkSystemTime s ns) = let- diff :: DiffTime- diff = (fromIntegral s) + (fromIntegral ns) * 1E-9- in addAbsoluteTime diff systemEpochAbsolute---- | The day of the epoch of 'SystemTime', 1970-01-01-systemEpochDay :: Day-systemEpochDay = ModifiedJulianDay 40587--#endif
src/Data/Time/Clock/TAI/Compat.hs view
@@ -8,12 +8,7 @@ LeapSecondMap, -- * conversion between UTC and TAI with map-#if MIN_VERSION_time(1,7,0) T.utcDayLength,T.utcToTAITime,T.taiToUTCTime,-#else- utcDayLength,utcToTAITime,taiToUTCTime,-#endif- taiClock, ) where @@ -22,48 +17,3 @@ import Data.Time.Compat import Data.Time.Clock.TAI hiding (utcDayLength,utcToTAITime,taiToUTCTime) import qualified Data.Time.Clock.TAI as T--import Data.Fixed (div')---- | This type is either 'LeapSecondMap' or 'LeapSecondTable', depending--- on the version of @time@ (changed in @time-1.7.0@).-#if !(MIN_VERSION_time(1,7,0))-type LeapSecondMap = Day -> Maybe Int--utcDayLength :: LeapSecondMap -> Day -> Maybe DiffTime-utcDayLength lsmap day = do- i0 <- lsmap day- i1 <- lsmap $ addDays 1 day- return $ realToFrac (86400 + i1 - i0)--dayStart :: LeapSecondMap -> Day -> Maybe AbsoluteTime-dayStart lsmap day = do- i <- lsmap day- return $ addAbsoluteTime (realToFrac $ (toModifiedJulianDay day) * 86400 + toInteger i) taiEpoch--utcToTAITime :: LeapSecondMap -> UTCTime -> Maybe AbsoluteTime-utcToTAITime lsmap (UTCTime day dtime) = do- t <- dayStart lsmap day- return $ addAbsoluteTime dtime t--taiToUTCTime :: LeapSecondMap -> AbsoluteTime -> Maybe UTCTime-taiToUTCTime lsmap abstime = let- stable day = do- dayt <- dayStart lsmap day- len <- utcDayLength lsmap day- let- dtime = diffAbsoluteTime abstime dayt- day' = addDays (div' dtime len) day- if day == day' then return (UTCTime day dtime) else stable day'- in stable $ ModifiedJulianDay $ div' (diffAbsoluteTime abstime taiEpoch) 86400-#endif--#if !(MIN_VERSION_time(1,8,0))-taiNominalDayStart :: Day -> AbsoluteTime-taiNominalDayStart (ModifiedJulianDay ds) =- addAbsoluteTime (secondsToDiffTime (ds * 86400)) taiEpoch---- | TAI clock, if it exists. Note that it is unlikely to be set correctly, without due care and attention.-taiClock :: Maybe (DiffTime,IO AbsoluteTime)-taiClock = Nothing-#endif
src/Data/Time/Format/Compat.hs view
@@ -23,64 +23,17 @@ import Data.Time.Orphans () -#if !MIN_VERSION_time(1,5,0)-import Data.Time.Format-import System.Locale (TimeLocale, defaultTimeLocale, iso8601DateFormat, rfc822DateFormat)-import Text.ParserCombinators.ReadP (readP_to_S, readS_to_P, ReadP)-#else-#if !(MIN_VERSION_time(1,9,0)) || !(MIN_VERSION_base(4,9,0))+#if !(MIN_VERSION_time(1,9,0)) import Data.Time.Format hiding (parseTimeM) #else import Data.Time.Format #endif-#endif import qualified Control.Monad.Fail as Fail import qualified Data.Time.Format -#if !MIN_VERSION_time(1,5,0)-parseTimeM- :: (Fail.MonadFail 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 in-parseTimeM _acceptWS l fmt s = case parseTime l fmt s of- Just x -> return x- Nothing -> Fail.fail "parseTimeM: no parse"--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 parseTime l fmt s of- Just x -> x- Nothing -> error "parseTimeOrError: no parse"---- | 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 = readsTime 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 acceptWS l f = readS_to_P (readSTime acceptWS l f)--#else- -- parseTimeM has always Fail.MonadFail constraint-#if !MIN_VERSION_time(1,9,0) || !MIN_VERSION_base(4,9,0)+#if !MIN_VERSION_time(1,9,0) -- | Parses a time value given a format string. -- -- This variant from @time-compat@ has always 'Fail.MonadFail' constraint.@@ -94,7 +47,6 @@ -> String -- ^ Input string. -> m t -- ^ Return the time value, or fail if the in parseTimeM = Data.Time.Format.parseTimeM-#endif #endif #if MIN_VERSION_time(1,10,0)
src/Data/Time/Format/ISO8601/Compat.hs view
@@ -80,11 +80,7 @@ -- | Parse a value in either extended or basic format parseFormatExtension :: (-#if MIN_VERSION_base(4,9,0) MonadFail m-#else- Monad m-#endif ) => (FormatExtension -> Format t) -> String -> m t parseFormatExtension ff = parseReader $ formatReadPExtension ff @@ -357,11 +353,7 @@ -- | Parse the most commonly used ISO 8601 format. iso8601ParseM :: (-#if MIN_VERSION_base(4,9,0) MonadFail m-#else- Monad m-#endif ,ISO8601 t) => String -> m t iso8601ParseM = formatParseM iso8601Format
src/Data/Time/Orphans.hs view
@@ -15,15 +15,8 @@ import Data.Time.Format import Data.Hashable (Hashable (..)) -#if MIN_VERSION_time(1,5,0) import Data.Time.Format (TimeLocale (..))-#else-import System.Locale (TimeLocale (..))-#endif--#if MIN_VERSION_time(1,8,0) import Data.Time.Clock.System-#endif #if !MIN_VERSION_time(1,11,0) import Data.Fixed (Pico)@@ -38,39 +31,15 @@ import Data.Time.Calendar.Quarter #endif -#if !MIN_VERSION_time(1,6,0)-instance ParseTime UniversalTime where- -- substituteTimeSpecifier _ = timeSubstituteTimeSpecifier- -- parseTimeSpecifier _ = timeParseTimeSpecifier- buildTime l xs = localTimeToUT1 0 (buildTime l xs)--instance FormatTime UniversalTime where- formatCharacter c = fmap (\f tl fo t -> f tl fo (ut1ToLocalTime 0 t)) (formatCharacter c)--instance Show UniversalTime where- show t = show (ut1ToLocalTime 0 t)--instance Read UniversalTime where- readsPrec n s = [ (localTimeToUT1 0 t, r) | (t,r) <- readsPrec n s ]-#endif-- #if MIN_VERSION_time(1,9,0) && !MIN_VERSION_time(1,11,0) deriving instance Ord DayOfWeek #endif #if MIN_VERSION_time(1,9,0) && !MIN_VERSION_time(1,10,0)-#if __GLASGOW_HASKELL__ <710-deriving instance Typeable DayOfWeek-#endif deriving instance Data DayOfWeek #endif #if MIN_VERSION_time(1,8,0) && !MIN_VERSION_time(1,10,0)-#if __GLASGOW_HASKELL__ <710-deriving instance Typeable SystemTime-#endif- deriving instance Data SystemTime #endif
test/main/Test/Calendar/CalendarProps.hs view
@@ -3,7 +3,6 @@ ( testCalendarProps ) where -#if __GLASGOW_HASKELL__ >= 710 import Data.Time.Calendar.Month.Compat import Data.Time.Calendar.Quarter.Compat import Test.TestUtil@@ -24,11 +23,3 @@ testCalendarProps :: TestTree testCalendarProps = nameTest "calender-props" [testYearMonth,testMonthDay,testYearQuarter]-#else--import Test.Tasty--testCalendarProps :: TestTree-testCalendarProps = testGroup "calendar-props" []--#endif
test/main/Test/Clock/Resolution.hs view
@@ -25,7 +25,7 @@ gcdAll = foldr gcd' 0 testResolution :: (Show dt, Real dt) => String -> (at -> at -> dt) -> (dt, IO at) -> TestTree-testResolution name timeDiff (res, getTime) =+testResolution name timeDiff (reportedRes, getTime) = testCase name $ do t0 <- getTime times0 <-@@ -53,11 +53,8 @@ threadDelay 1000 -- 1ms getTime let times = fmap (\t -> timeDiff t t0) $ times0 ++ times1 ++ times2 ++ times3 ++ times4-#if MIN_VERSION_time(1,8,0)- assertEqual "resolution" res $ gcdAll times-#else- assertBool ("resolution " ++ show (res, gcdAll times)) (res >= gcdAll times)-#endif+ foundGrid = gcdAll times+ assertBool ("resolution " ++ show (reportedRes, foundGrid)) (foundGrid <= reportedRes) testResolutions :: TestTree testResolutions =
test/main/Test/Format/ParseTime.hs view
@@ -5,10 +5,6 @@ , test_parse_format ) where -#if MIN_VERSION_base(4,11,0)-#else-import Data.Semigroup hiding (option)-#endif import Control.Monad import Data.Char import Data.Maybe@@ -24,7 +20,7 @@ import Test.Tasty.HUnit import Test.Tasty.QuickCheck hiding (reason) import Test.TestUtil-import Text.Read.Compat+import Text.Read format :: FormatTime t => String -> t -> String format f t = formatTime defaultTimeLocale f t
time-compat.cabal view
@@ -1,6 +1,6 @@ cabal-version: 1.12 name: time-compat-version: 1.9.6.1+version: 1.9.7 synopsis: Compatibility package for time description: This packages tries to compat as much of @time@ features as possible.@@ -23,54 +23,31 @@ build-type: Simple extra-source-files: CHANGELOG.md tested-with:- GHC ==7.4.2- || ==7.6.3- || ==7.8.4- || ==7.10.3- || ==8.0.2- || ==8.2.2- || ==8.4.4- || ==8.6.5+ GHC ==8.6.5 || ==8.8.4- || ==8.10.4- || ==9.0.1+ || ==8.10.7+ || ==9.0.2+ || ==9.2.8+ || ==9.4.8+ || ==9.6.5+ || ==9.8.2+ || ==9.10.1 source-repository head type: git location: https://github.com/haskellari/time-compat.git -flag old-locale- description: If true, use old-locale, otherwise use time 1.5 or newer.- manual: False- default: False- library- default-language: Haskell2010- hs-source-dirs: src- other-extensions: CPP-- if impl(ghc >=7.2)- default-extensions: Trustworthy-+ default-language: Haskell2010+ hs-source-dirs: src+ other-extensions: CPP+ default-extensions: Trustworthy build-depends:- base >=4.5 && <4.16- , base-orphans >=0.8.4 && <0.9- , deepseq >=1.3.0.0 && <1.4 || >=1.4.1.1 && <1.5- , time >=1.4 && <1.7 || >=1.8 && <1.9 || >=1.9.2 && <1.9.4 || >=1.10 && <1.10.1 || >=1.11 && <1.11.2 || >=1.12 && <1.13- , hashable >=1.3.2.0 && <1.4-- if flag(old-locale)- build-depends:- old-locale >=1.0.0.2 && <1.1- , time >=1.4 && <1.5-- else- build-depends: time >=1.5-- if !impl(ghc >=8.0)- build-depends:- fail >=4.9.0.0 && <4.10- , semigroups >=0.18.5 && <0.20+ base >=4.12 && <4.21+ , base-orphans >=0.9.2 && <0.10+ , deepseq >=1.4.4.0 && <1.6+ , hashable >=1.4.4.0 && <1.5+ , time >=1.8.0.2 && <1.9 || >=1.9.2 && <1.9.4 || >=1.10 && <1.10.1 || >=1.11 && <1.11.2 || >=1.12 && <1.13 exposed-modules: Data.Time.Calendar.Compat@@ -104,8 +81,8 @@ build-depends: base , deepseq- , HUnit >=1.3.1 && <1.3.2 || >=1.6.0.0 && <1.7- , hashable >=1.3.1.0 && <1.4+ , hashable >=1.4.0.0 && <1.5+ , HUnit >=1.3.1 && <1.3.2 || >=1.6.0.0 && <1.7 , time-compat -- This test-suite is from time library@@ -138,11 +115,10 @@ ghc-options: -Wall -fwarn-tabs build-depends: base- , base-compat >=0.10.5 && <0.12 , deepseq- , QuickCheck >=2.13 && <2.15+ , QuickCheck >=2.13 && <2.16 , tagged >=0.8.6 && <0.9- , tasty >=1.2.1 && <1.5+ , tasty >=1.5 && <1.6 , tasty-hunit >=0.10 && <0.11 , tasty-quickcheck >=0.10 && <0.11 , time-compat@@ -150,7 +126,7 @@ if !impl(ghc >=8.0) build-depends: fail >=4.9.0.0 && <4.10- , semigroups >=0.18.5 && <0.20+ , semigroups >=0.18.5 && <0.21 build-depends: time main-is: Main.hs