time-recurrence-0.4.2: Generate recurring dates.

Data.Time.Recurrence

Contents

Synopsis

The WeekDay type

data WeekDay Source

Symbolic week days.

Note: The first Day of the Week is Monday TODO: Move this to a more general library

The Month type

data Month Source

Symbolic months.

TODO: Move this to a more general library

The Moment type class

class Moment a whereSource

The Moment class is for representing a instance in time.

Instances of Moment can be derived for any user-defined datatype for which can satisfy the minimal complete definition.

Minimal complete definition: epoch, toDateTime, fromDateTime, scaleTime, scaleMonth, scaleYear, alterWeekNumber, alterYearDay

Methods

epoch :: aSource

Provide a default moment.

toDateTime :: a -> DateTimeSource

Convert a Moment into a DateTime

fromDateTime :: DateTime -> Maybe aSource

Convert a DateTime into a Moment

scaleTime :: a -> Integer -> aSource

Produce a new Moment offset by a given number of seconds.

scaleMonth :: a -> Integer -> aSource

Produce a new Moment offset by a given number of months.

scaleYear :: a -> Integer -> aSource

Produce a new Moment offset by a given number of years.

alterWeekNumber :: StartOfWeek -> a -> Int -> Maybe aSource

Possibly produce a new Moment shifted to a different week of the year.

alterYearDay :: a -> Int -> Maybe aSource

Possibly produce a new Moment shifted to a different day of the year.

alterSecond :: a -> Int -> Maybe aSource

The 'alter*' methods can potentially produce invalid dates.

For each user-defined Moment instance the definitions of toDateTime, fromDateTime, alterWeekNumber and alterYearDay will determine if an altered Moment that lands on an invalid date in the given calendar will be reduced to Nothing

Possibly produce a new Moment shifted to a different second of the day.

alterMinute :: a -> Int -> Maybe aSource

Possibly produce a new Moment shifted to a different minute of the day.

alterHour :: a -> Int -> Maybe aSource

Possibly produce a new Moment shifted to a different hour of the day.

alterDay :: a -> Int -> Maybe aSource

Possibly produce a new Moment shifted to a different day of the month.

alterMonth :: a -> Month -> Maybe aSource

Possibly produce a new Moment shifted to a different month of the year.

alterYear :: a -> Integer -> Maybe aSource

Possibly produce a new Moment shifted to a different year.

next :: Interval -> Frequency -> a -> aSource

Produce a new Moment in the future ocurring at (interval * freq)

prev :: Interval -> Frequency -> a -> aSource

Produce a new Moment in the past ocurring at (-interval * freq)

Instances

Moment UTCTime

Instance of the Moment class defined for the UTCTime datatype.

The DateTime type class

data DateTime Source

DateTime data type This is a componentized version of a time value simmilar to a 'struct tm'

Instances

The InitialMoment type

data InitialMoment a Source

The InitialMoment datatype

Constructors

InitialMoment 

Fields

frequency :: Frequency
 
interval :: Interval
 
startOfWeek :: StartOfWeek
 
moment :: a
 

Instances

toInterval :: Integer -> IntervalSource

toStartOfWeek :: WeekDay -> StartOfWeekSource

secondly :: Moment a => InitialMoment aSource

Default initial moments

secondlyUTC :: InitialMoment UTCTimeSource

InitialMoment defaults for UTCTime

Recurrence combinators

enumYear :: (Moment a, Ord a) => a -> RecurringSchedule aSource

enumYear produces all days in the year starting with m

enumMonth :: (Moment a, Ord a) => a -> RecurringSchedule aSource

enumMonth produces all days in the current month starting with m

enumWeek :: (Moment a, Ord a) => a -> RecurringSchedule aSource

enumWeek produces all days in the current week starting with m

restrict :: Moment a => (a -> Bool) -> Schedule a -> RecurringSchedule aSource

restrict, applied to a predicate and a Schedule, returns a Schedule of those moments that statisfy the predicate.

bySeconds :: Moment a => [Int] -> a -> BoolSource

byMinutes :: Moment a => [Int] -> a -> BoolSource

byHours :: Moment a => [Int] -> a -> BoolSource

byMonthDays :: Moment a => [Int] -> a -> BoolSource

byMonths :: Moment a => [Month] -> a -> BoolSource

byYearDays :: Moment a => [Int] -> a -> BoolSource

expand :: Moment a => (a -> Reader (InitialMoment a) [a]) -> Schedule a -> RecurringSchedule aSource

expand, takes an expansion function and a Schedule, and maps the expansion function over the moments. Each moment is then replaced with its expansions.

onMonths :: Moment a => [Month] -> a -> Reader (InitialMoment a) [a]Source

onMonthDays :: Moment a => [Int] -> a -> Reader (InitialMoment a) [a]Source

onYearDays :: Moment a => [Int] -> a -> Reader (InitialMoment a) [a]Source

onEachWeek :: (Moment a, Ord a) => a -> Reader (InitialMoment a) [a]Source

onEachMonth :: (Moment a, Ord a) => a -> Reader (InitialMoment a) [a]Source

onEachYear :: (Moment a, Ord a) => a -> Reader (InitialMoment a) [a]Source

repeatSchedule :: Moment a => InitialMoment a -> (Schedule a -> RecurringSchedule a) -> [a]Source

repeatSchedule runs a schedule with a given init and rule r

repeatSchedule' :: Moment a => InitialMoment a -> [a]Source

repeatSchedule' is like repeatSchedule but it takes no rules