hodatime
Safe HaskellSafe-Inferred
LanguageHaskell2010

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

Documentation

data Period target Source #

A calendar-relative amount applicable to target.

The constructor is hidden so the constraints introduced by the unit constructors cannot be bypassed.

Instances

Instances details
Monoid (Period target) Source # 
Instance details

Defined in Data.HodaTime.Period

Methods

mempty :: Period target #

mappend :: Period target -> Period target -> Period target #

mconcat :: [Period target] -> Period target #

Semigroup (Period target) Source # 
Instance details

Defined in Data.HodaTime.Period

Methods

(<>) :: Period target -> Period target -> Period target #

sconcat :: NonEmpty (Period target) -> Period target #

stimes :: Integral b => b -> Period target -> Period target #

Show (Period target) Source # 
Instance details

Defined in Data.HodaTime.Period

Methods

showsPrec :: Int -> Period target -> ShowS #

show :: Period target -> String #

showList :: [Period target] -> ShowS #

Eq (Period target) Source # 
Instance details

Defined in Data.HodaTime.Period

Methods

(==) :: Period target -> Period target -> Bool #

(/=) :: Period target -> Period target -> Bool #

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.

hours :: HasLocalTime target => Int -> Period target Source #

Construct a period measured in hours.

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

Instances details
ApplyPeriod LocalTime Source # 
Instance details

Defined in Data.HodaTime.Period

(IsCalendar cal, Enum (Month cal)) => ApplyPeriod (CalendarDateTime cal) Source # 
Instance details

Defined in Data.HodaTime.Period