| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Data.HodaTime.Period
Description
A Period is indexed by the type it can be applied to. Unit constructors
constrain that target, so combining date and time units with <> infers a
target that supports both sets of fields.
For example, a mixed period can be applied to a CalendarDateTime, while
either half can also be used independently with a date or time:
applyPeriod (months 5 <> hours 2) calendarDateTime applyPeriod (months 5) calendarDate applyPeriod (hours 2) localTime
A reusable top-level binding needs either a target annotation or
NoMonomorphismRestriction. With the latter, GHC generalizes
months 5 <> hours 2 to a period requiring both HasDate and
HasLocalTime.
Synopsis
- data Period target
- years :: HasDate target => Int -> Period target
- months :: HasDate target => Int -> Period target
- weeks :: HasDate target => Int -> Period target
- days :: HasDate target => Int -> Period target
- hours :: HasLocalTime target => Int -> Period target
- minutes :: HasLocalTime target => Int -> Period target
- seconds :: HasLocalTime target => Int -> Period target
- nanoseconds :: HasLocalTime target => Int -> Period target
- negatePeriod :: Period target -> Period target
- scalePeriod :: Int -> Period target -> Period target
- class ApplyPeriod target where
- applyPeriod :: Period target -> target -> target
Documentation
A calendar-relative amount applicable to target.
The constructor is hidden so the constraints introduced by the unit constructors cannot be bypassed.
years :: HasDate target => Int -> Period target Source #
Construct a period measured in calendar years.
months :: HasDate target => Int -> Period target Source #
Construct a period measured in calendar months.
Construct a period measured in calendar years.
weeks :: HasDate target => Int -> Period target Source #
Construct a period measured in seven-day calendar weeks.
Construct a period measured in calendar years.
days :: HasDate target => Int -> Period target Source #
Construct a period measured in calendar days.
Construct a period measured in calendar years.
minutes :: HasLocalTime target => Int -> Period target Source #
Construct a period measured in minutes.
Construct a period measured in hours.
seconds :: HasLocalTime target => Int -> Period target Source #
Construct a period measured in seconds.
Construct a period measured in hours.
nanoseconds :: HasLocalTime target => Int -> Period target Source #
Construct a period measured in nanoseconds.
Construct a period measured in hours.
negatePeriod :: Period target -> Period target Source #
Negate every component of a period.
scalePeriod :: Int -> Period target -> Period target Source #
Multiply every component of a period by an integer.
class ApplyPeriod target where Source #
Types to which periods can be applied.
Methods
applyPeriod :: Period target -> target -> target Source #
Instances
| ApplyPeriod LocalTime Source # | |
Defined in Data.HodaTime.Period | |
| (IsCalendar cal, Enum (Month cal)) => ApplyPeriod (CalendarDateTime cal) Source # | |
Defined in Data.HodaTime.Period Methods applyPeriod :: Period (CalendarDateTime cal) -> CalendarDateTime cal -> CalendarDateTime cal Source # | |