time-recurrence 0.5.2 → 0.6
raw patch · 3 files changed
+18/−10 lines, 3 filesdep ~time
Dependency ranges changed: time
Files
- README +5/−5
- src/Data/Time/CalendarTime/CalendarTime.hs +10/−2
- time-recurrence.cabal +3/−3
README view
@@ -79,25 +79,25 @@ > take 10 $ recur monthly `starting` sep1997 $ > enumWeekDaysInMonth [Friday] >=>-> nthWeekDayInMonth [1]+> nthWeekDayOfMonth [1] Monthly on the first Friday until Dec. 24, 1997 > takeWhile (<= dec1997) $ recur monthly `starting` sep1997 $ > enumWeekDaysInMonth [Friday] >=>-> nthWeekDayInMonth [1]+> nthWeekDayOfMonth [1] Every other month on the first and last Sunday of the month for 10 occurrences: > take 10 $ recur monthly `by` 2 `starting` sep1997 $ > enumWeekDaysInMonth [Sunday] >=>-> nthWeekDayInMonth [1,-1]+> nthWeekDayOfMonth [1,-1] Monthly on the second-to-last Monday of the month for 6 months: > take 6 $ recur monthly `starting` sep1997 $ > enumWeekDaysInMonth [Monday] >=>-> nthWeekDayInMonth [-2]+> nthWeekDayOfMonth [-2] Monthly on the third-to-last day of the month, forever: @@ -186,7 +186,7 @@ > take 3 $ recur monthly `starting` sep1997 $ > enumWeekDaysInMonth [Tuesday .. Thursday] >=>-> nthWeekDayInMonth [3]+> nthWeekDayOfMonth [3] The second-to-last weekday of the month:
src/Data/Time/CalendarTime/CalendarTime.hs view
@@ -39,11 +39,13 @@ class CalendarTimeConvertible t where -- | Convert to a 'CalendarTime' toCalendarTime :: t -> CalendarTime+ toCalendarTimeWithTimeZone :: t -> TimeZone -> CalendarTime -- | Convert from a 'CalendarTime' fromCalendarTime :: CalendarTime -> Maybe t instance CalendarTimeConvertible CalendarTime where toCalendarTime = id+ toCalendarTimeWithTimeZone ct tz = ct { calendarTimeZone = tz } fromCalendarTime = Just . id -- | Convert to a 'Day'@@ -84,16 +86,20 @@ (TimeOfDay hh mm ss) = timeToTimeOfDay utcTime (y, m, d, weekDay, yearDay) = dayInfo utcDay + toCalendarTimeWithTimeZone utcTime tz | tz == utc = toCalendarTime utcTime+ | otherwise = error ("UTCTime.toCalendarTimeWithTimeZone cannot be represented with time zone " ++ show tz)+ fromCalendarTime t = do day <- toDay t time <- toTimeOfDay t return $ UTCTime day (timeOfDayToTime time) instance CalendarTimeConvertible LocalTime where- toCalendarTime (LocalTime day t) = CalendarTime (fromEnum $ todSec t) (todMin t) (todHour t) d (toEnum m) y weekDay yearDay tz+ toCalendarTime _ = error ("LocalTime.toCalendarTime cannot be represented without a time zone")++ toCalendarTimeWithTimeZone (LocalTime day t) tz = CalendarTime (fromEnum $ todSec t) (todMin t) (todHour t) d (toEnum m) y weekDay yearDay tz where (y, m, d, weekDay, yearDay) = dayInfo day- tz = unsafePerformIO getCurrentTimeZone fromCalendarTime t = do day <- toDay t@@ -104,6 +110,8 @@ toCalendarTime (ZonedTime (LocalTime day t) tz) = CalendarTime (fromEnum $ todSec t) (todMin t) (todHour t) d (toEnum m) y weekDay yearDay tz where (y, m, d, weekDay, yearDay) = dayInfo day++ toCalendarTimeWithTimeZone (ZonedTime lt _) tz = toCalendarTime (ZonedTime lt tz) fromCalendarTime t = do day <- toDay t
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.5.2+Version: 0.6 -- A short (one-line) description of the package. Synopsis: Generate recurring dates.@@ -81,7 +81,7 @@ -- Packages needed in order to build this package. Build-depends: base >= 4 && < 5,- time >= 1.2 && < 1.2.0.6,+ time >= 1.4.0.1 && < 1.5, data-ordlist >= 0.4 && < 0.4.5, mtl >= 2.0.1.0 && < 2.1 @@ -98,7 +98,7 @@ main-is: Tests.lhs ghc-options: -Wall -fno-warn-name-shadowing build-depends: base >= 4 && < 5,- time >= 1.2 && < 1.2.0.6,+ time >= 1.4.0.1 && < 1.5, data-ordlist >= 0.4 && < 0.4.5, mtl >= 2.0.1.0 && < 2.1, test-framework >= 0.4.0 && < 0.5,