scalendar-1.2.0: A library for handling calendars and resource availability over time.

Safe HaskellSafe
LanguageHaskell2010

Time.SCalendar.Types

Synopsis

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.

Constructors

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.

Constructors

Reservation 

Fields

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.

Constructors

Cancellation 

Fields

data SCalendar Source #

An SCalendar is the product of a set of identifiers, which point to a set of available resources, and a Calendar.

Constructors

SCalendar 

Fields

  • calUnits :: Set Text

    Set of resources which can be reserved for the TimePeriod covered by the root node of the Calendar.

  • calendar :: Calendar

    Calendar which covers the complete period of time over which a set of resources can be reserved.

data Calendar Source #

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

data Report Source #

A Report represents a summary of important facts related to an SCalendar.

Constructors

Report 

Fields

  • reportPeriod :: TimePeriod

    The TimePeriod which the report covers.

  • totalUnits :: Set Text

    The set of total identifiers reservable in the SCalendar this Report belongs to.

  • reservedUnits :: Set Text

    The set of total identifiers which have been reserved in a TimePeriod in the SCalendar related to this Report.

  • remainingUnits :: Set Text

    The set of total identifiers which are still available in a Time<Period in the SCalendar related to this Report.

Instances

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.

makeTimePeriod Source #

Arguments

:: Integer

Year.

-> Int

Month.

-> Int

Day.

-> Int

Number of days covered by TimePeriod.

-> Maybe TimePeriod 

Given a year, a month and a day this function creates a time period which covers the specified number of days.

makeReservation Source #

Arguments

:: 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.

makeCancellation Source #

Arguments

:: 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.

createCalendar Source #

Arguments

:: Integer

Year.

-> Int

Month.

-> Int

Day.

-> Int

Number of days covered by the Calendar.

-> Maybe Calendar 

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.

createSCalendar Source #

Arguments

:: 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.