Copyright | (C) 2017 Jason Johnson |
---|---|
License | BSD-style (see the file LICENSE) |
Maintainer | Jason Johnson <jason.johnson.081@gmail.com> |
Stability | experimental |
Portability | POSIX, Windows |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
This is the module for CalendarDate
. A CalendarDate
represents a date within the calendar system that is part of its type. It has no reference to a particular time zone or time of day.
Construction
To construct one of these types, see the Calendar module you wish to construct the date in (typically Data.HodaTime.Calendar.Gregorian)
Synopsis
- data DayNth
- = FourthToLast
- | ThirdToLast
- | SecondToLast
- | Last
- | First
- | Second
- | Third
- | Fourth
- | Fifth
- type Year = Int
- type WeekNumber = Int
- type DayOfMonth = Int
- data CalendarDate calendar
- class HasDate d where
Documentation
Used by several smart constructors to chose a day relative to the start or end of the month.
type WeekNumber = Int Source #
type DayOfMonth = Int Source #
data CalendarDate calendar Source #
Instances
class HasDate d where Source #
day :: Functor f => (DayOfMonth -> f DayOfMonth) -> d -> f d Source #
Lens for the day component of a HasDate
. Please note that days are not clamped: if you add e.g. 400 days then the month and year will roll
Accessor for the Month component of a HasDate
.
monthl :: Functor f => (Int -> f Int) -> d -> f d Source #
Lens for interacting with the month component of a HasDate
. Please note that we convert the month to an Int so meaningful math can be done on it. Also
please note that the day will be unaffected except in the case of "end of month" days which may clamp. Note that this clamping will only occur as a final step,
so that
>>>
modify monthl (+ 2) <$> Gregorian.calendarDate 31 January 2000
Just (CalendarDate 31 March 2000)
and not 29th of March as would happen with some libraries.
year :: Functor f => (Year -> f Year) -> d -> f d Source #
Lens for the year component of a HasDate
. Please note that the rest of the date is left as is, with two exceptions: Feb 29 will clamp to 28 in a non-leapyear
and if the new year is earlier than the earliest supported year it will clamp back to that year
dayOfWeek :: d -> DoW d Source #
Accessor for the Day of the week enum of a HasDate
, for example:
>>>
dayOfWeek . fromJust $ Gregorian.calendarDate 31 January 2000
Monday