Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
- data TimePeriod
- data Reservation = Reservation {}
- data Cancellation = Cancellation {
- cancUnits :: Set Text
- cancPeriod :: TimePeriod
- data SCalendar = SCalendar {}
- data Calendar
- data Report = Report {}
- isIncluded :: TimePeriod -> TimePeriod -> Bool
- getFrom :: TimePeriod -> UTCTime
- getTo :: TimePeriod -> UTCTime
- toTimeUnit :: TimePeriod -> TimePeriod
- makeTimePeriod :: Integer -> Int -> Int -> Int -> Maybe TimePeriod
- makeReservation :: TimePeriod -> Set Text -> Maybe Reservation
- makeCancellation :: TimePeriod -> Set Text -> Maybe Cancellation
- createCalendar :: Integer -> Int -> Int -> Int -> Maybe Calendar
- createSCalendar :: Integer -> Int -> Int -> Int -> Set Text -> Maybe SCalendar
- oneDay :: NominalDiffTime
- powerOfTwo :: Int -> Int
Documentation
data TimePeriod Source #
This data type is either a TimeInterval of the form (start-date, end-date) or a TimeUnit which, in this case, is a nominal day. The time unit of this calendar library is a nominal day, that is, 86400 seconds. TimeIntervals as well as TimeUnits are stored as UTCTime so that it is easy to transform results to local time or store results in databases as timestamps.
TimeInterval UTCTime UTCTime | TimeIntervals represent the number of days that a node in a calendar covers from a start-date up to an end-date. |
TimeUnit UTCTime | TimeUnits are only encountered in the leaves of a calendar and represent a specific day of the calendar. |
data Reservation Source #
A Reservation is the product of a set of identifiers and a TimePeriod over which the resources identified by the set will be reserved.
Reservation | |
|
data Cancellation Source #
A Cancellation is the product of a set of identifiers which point to resources previously reserved in a Calendar and a TimePeriod over which those resources were reserved.
Cancellation | |
|
An SCalendar is the product of a set of identifiers, which point to a set of available resources, and a Calendar.
A Calendar is a recursive tree-structure whose nodes are TimePeriods representing the interval
of time covered by them. TimeUnits are only encountered in the leaves since they represent
specific days, or time units, of the Calendar. The unit of time of this Calendar library is a nominal
day (or 86400 seconds). Each node of a Calendar also carries additional data according to the
"top-nodes" algorithm: a Q
set and a QN
set. For more information about the meaning of these
sets visit: https://en.wikipedia.org/wiki/Top-nodes_algorithm
A Report represents a summary of important facts related to an SCalendar.
Report | |
|
isIncluded :: TimePeriod -> TimePeriod -> Bool Source #
Check if a time-period t1
is included in a time-period t2
. Note that neither a
TimeUnit can be included in another TimeUnit nor a TimeInterval can be included
in a TimeUnit. If two TimeIntervals are equal they are said to be included in
one another.
getFrom :: TimePeriod -> UTCTime Source #
Getter function to get the UTCTime start-date from a TimePeriod. For a TimeUnit the start-sate and the end-date are equal.
getTo :: TimePeriod -> UTCTime Source #
Getter function to fet the UTCTime end-date from a TimePeriod. Again, for a TimeUnit the start-sate and the end-date are equal.
toTimeUnit :: TimePeriod -> TimePeriod Source #
This function transforms a TimeInterval into a TimeUnit in case that the start-date and end-date of that TimeInterval are equal.
Given a year, a month and a day this function creates a time period which covers the specified number of days.
:: TimePeriod | TimePeriod which the rerservation will cover. |
-> Set Text | Set of identifiers which point to the resources to be reserved from an SCalendar. |
-> Maybe Reservation |
Given a TimePeriod and a set of identifiers this function creates a reservation.
:: TimePeriod | TimePeriod which the cancellation will cover. |
-> Set Text | Set of identifiers which point to the resources to be cancelled from an SCalendar. |
-> Maybe Cancellation |
Given a TimePeriod and a set of identifiers this function creates a cancellation.
Given a year, a month, and a day this function creates a Calendar which covers the specified number of days. The TimePeriod in the root node of a Calendar does not exactly span the number of days specified in the function, but a number of days which is a power of 2 and which is greater than or equal to the number of days specified.
:: Integer | Year. |
-> Int | Month. |
-> Int | Day. |
-> Int | Number of days covered by the Calendar. |
-> Set Text | Set of resources which can be reserved for the TimePeriod covered by the root node of the Calendar. |
-> Maybe SCalendar |
This constructor additionally attaches a set of identifiers, which point to the available resources of the calendar. Thus, this function creates an SCalendar which is basically a Calendar with a set of resources which can be reserved over the period of time determined by the root node of the Calendar.
powerOfTwo :: Int -> Int Source #