packages feed

time-recurrence 0.9.1 → 0.9.2

raw patch · 3 files changed

+27/−28 lines, 3 filesdep ~data-ordlistdep ~mtldep ~test-framework

Dependency ranges changed: data-ordlist, mtl, test-framework, test-framework-hunit, time

Files

src/Data/Time/CalendarTime/CalendarTime.hs view
@@ -23,14 +23,14 @@ -- | A representation of calendar time separated into year, month, day, and so on. data CalendarTime = CalendarTime      {-      calendarSecond   :: Int-    , calendarMinute   :: Int-    , calendarHour     :: Int-    , calendarDay      :: Int-    , calendarMonth    :: Month-    , calendarYear     :: Integer-    , calendarWeekDay  :: WeekDay-    , calendarYearDay  :: Int+      calendarSecond   :: Int           -- 0 .. 61+    , calendarMinute   :: Int           -- 0 .. 59+    , calendarHour     :: Int           -- 0 .. 23+    , calendarDay      :: Int           -- 1 .. 31+    , calendarMonth    :: Month         -- January .. December+    , calendarYear     :: Integer       -- 0 ..+    , calendarWeekDay  :: WeekDay       -- Sunday .. Saturday+    , calendarYearDay  :: Int           -- 1 .. 366     , calendarTimeZone :: TimeZone } deriving (Eq,Ord,Show) @@ -78,7 +78,7 @@     instance CalendarTimeConvertible UTCTime where-  toCalendarTime (UTCTime utcDay utcTime) = CalendarTime (fromEnum ss) mm hh d (toEnum m) y weekDay yearDay utc+  toCalendarTime (UTCTime utcDay utcTime) = CalendarTime (truncate ss) mm hh d (toEnum m) y weekDay yearDay utc     where       (TimeOfDay hh mm ss) = timeToTimeOfDay utcTime       (y, m, d, weekDay, yearDay) = dayInfo utcDay
src/Data/Time/Moment/FutureMoments.hs view
@@ -61,17 +61,16 @@       im <- ask       return $ iterate (next (interval im) (period im)) (moment im) --- | Normalize an bounded ordinal index---   Pass an upper-bound 'ub' and an index 'idx'---   Converts 'idx' < 0 into valid 'idx' > 0 or---   Nothing-normalizeOrdinalIndex :: Int -> Int -> Maybe Int-normalizeOrdinalIndex _ 0 = Nothing-normalizeOrdinalIndex ub idx =-  if abs idx > ub+-- | Normalize an bounded ordinal index between a lower and upper bound+--   Negative indexes are allowed and index from the upper bound to the lower+--   Any other value returns Nothing+normalizeOrdinalIndex :: Int -> Int -> Int -> Maybe Int+normalizeOrdinalIndex lb ub idx =+  if abx < lb || abx > ub     then Nothing     else Just $ (idx + ub') `mod` ub'   where+    abx = abs idx     ub' = ub + 1  enumYearDays ::@@ -82,7 +81,7 @@ enumYearDays days as = return $ concatMap (enumYearDays' days) as   where     enumYearDays' days a = mapMaybe (withYearDay a) (days' a days)-    days' a = mapMaybe $ normalizeOrdinalIndex (daysInYear a)+    days' a = mapMaybe $ normalizeOrdinalIndex 1 (daysInYear a)  enumMonths ::    (CalendarTimeConvertible a, Moment a) => @@ -112,7 +111,7 @@ enumDays days as = return $ concatMap (enumDays' days) as   where     enumDays' days a = mapMaybe (withDay a) (days' a days)-    days' a = mapMaybe $ normalizeOrdinalIndex (lastDayOfMonth a)+    days' a = mapMaybe $ normalizeOrdinalIndex 1 (lastDayOfMonth a)  enumWeekDaysInWeek ::   (CalendarTimeConvertible a, Moment a) =>@@ -146,7 +145,7 @@ enumHours hours as = return $ concatMap (enumHours' hours) as   where     enumHours' hours a = mapMaybe (withHour a) (hours' a hours)-    hours' _ = mapMaybe $ normalizeOrdinalIndex 23+    hours' _ = mapMaybe $ normalizeOrdinalIndex 0 23  enumMinutes ::   (CalendarTimeConvertible a, Moment a) =>@@ -156,7 +155,7 @@ enumMinutes ms as = return $ concatMap (enumMinutes' ms) as   where     enumMinutes' ms a = mapMaybe (withMinute a) (ms' a ms)-    ms' _ = mapMaybe $ normalizeOrdinalIndex 59+    ms' _ = mapMaybe $ normalizeOrdinalIndex 0 59  enumSeconds ::   (CalendarTimeConvertible a, Moment a) =>@@ -166,13 +165,13 @@ enumSeconds secs as = return $ concatMap (enumSeconds' secs) as   where     enumSeconds' secs a = mapMaybe (withSecond a) (secs' a secs)-    secs' _ = mapMaybe $ normalizeOrdinalIndex 60+    secs' _ = mapMaybe $ normalizeOrdinalIndex 0 61  groupWith :: (Ord b) => (a -> b) -> [a] -> [[a]] groupWith f = groupBy (\a b -> f a == f b)  nth :: [Int] -> [a] -> [a]-nth ns as = map ((as !!) . pred) $ mapMaybe (normalizeOrdinalIndex (length as)) ns+nth ns as = map ((as !!) . pred) $ mapMaybe (normalizeOrdinalIndex 0 (length as)) ns  nth' ::   (Ord b) =>
time-recurrence.cabal view
@@ -7,7 +7,7 @@ -- The package version. See the Haskell package versioning policy -- (http://www.haskell.org/haskellwiki/Package_versioning_policy) for -- standards guiding when and how versions should be incremented.-Version:             0.9.1+Version:             0.9.2  -- A short (one-line) description of the package. Synopsis:            Generate recurring dates.@@ -85,7 +85,7 @@   -- Packages needed in order to build this package.   Build-depends:       base >= 4 && < 5,                        time >= 1.4 && < 1.5,-                       data-ordlist >= 0.4 && < 0.4.5,+                       data-ordlist >= 0.4.5,                        mtl >= 2.0 && < 2.2      Default-Language:    Haskell98@@ -102,10 +102,10 @@   ghc-options:          -Wall -fno-warn-name-shadowing -fno-warn-orphans   build-depends:        base >= 4 && < 5,                         time >= 1.4 && < 1.5,-                        data-ordlist >= 0.4 && < 0.5,+                        data-ordlist >= 0.4.5,                         mtl >= 2.0 && < 2.2,-                        test-framework >= 0.4 && < 0.7,-                        test-framework-hunit >= 0.2 && < 0.3,+                        test-framework >= 0.8,+                        test-framework-hunit >= 0.3.0,                         HUnit >= 1.2 && < 1.3,                         old-locale >= 1.0 && < 1.1   other-modules: