| 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 |
Data.HodaTime.CalendarDateTime
Contents
Description
This is the module for CalendarDateTime. A CalendarDateTime represents a date and time within the calendar system that is part of its type. It has no reference to a particular time zone and is therefor not
a globally unique value as June 3rd 2020 10:05pm occurred at different Instants around the world.
Construction
To construct one of these types you will need a CalendarDate and a LocalTime
Synopsis
- data CalendarDateTime calendar
- class IsCalendar cal
- class HasDate d
- type family DoW d
- type family MoY d
- day :: HasDate d => d -> DayOfMonth
- month :: HasDate d => d -> MoY d
- year :: HasDate d => d -> Year
- dayOfWeek :: HasDate d => d -> DoW d
- next :: HasDate d => Int -> DoW d -> d -> d
- previous :: HasDate d => Int -> DoW d -> d -> d
- yearMonthDay :: HasDate d => d -> (Year, MoY d, DayOfMonth)
- on :: LocalTime -> CalendarDate cal -> CalendarDateTime cal
- at :: Date cal -> LocalTime -> CalendarDateTime cal
- atStartOfDay :: CalendarDate cal -> CalendarDateTime cal
- withCalendar :: (IsCalendarDateTime a, IsCalendarDateTime b) => CalendarDateTime a -> CalendarDateTime b
Types
data CalendarDateTime calendar Source #
Represents a specific date and time within its calendar system. NOTE: a CalendarDateTime does *not* represent a specific time on the global time line because e.g. "10.March.2006 4pm" is a different instant in most time zones. Convert it to a ZonedDateTime first if you wish to convert to an instant (or use a convenience function).
Instances
class IsCalendar cal Source #
Minimal complete definition
fromDays, toDays, toYmd, calendarName, day', setDay', month', setMonthIndex', year', setYear', dayOfWeek', next', previous'
Instances
Minimal complete definition
day, setDay, month, setMonthIndex, year, setYear, dayOfWeek, next, previous
Instances
| IsCalendar cal => HasDate (CalendarDateTime cal) Source # | |
Defined in Data.HodaTime.CalendarDateTime.Internal Methods day :: CalendarDateTime cal -> DayOfMonth Source # setDay :: DayOfMonth -> CalendarDateTime cal -> CalendarDateTime cal month :: CalendarDateTime cal -> MoY (CalendarDateTime cal) Source # setMonthIndex :: Int -> CalendarDateTime cal -> CalendarDateTime cal year :: CalendarDateTime cal -> Year Source # setYear :: Year -> CalendarDateTime cal -> CalendarDateTime cal dayOfWeek :: CalendarDateTime cal -> DoW (CalendarDateTime cal) Source # next :: Int -> DoW (CalendarDateTime cal) -> CalendarDateTime cal -> CalendarDateTime cal Source # previous :: Int -> DoW (CalendarDateTime cal) -> CalendarDateTime cal -> CalendarDateTime cal Source # yearMonthDay :: CalendarDateTime cal -> (Year, MoY (CalendarDateTime cal), DayOfMonth) Source # | |
Instances
| type DoW (CalendarDateTime cal) Source # | |
Defined in Data.HodaTime.CalendarDateTime.Internal | |
Instances
| type MoY (CalendarDateTime cal) Source # | |
Defined in Data.HodaTime.CalendarDateTime.Internal | |
day :: HasDate d => d -> DayOfMonth Source #
Day-of-month component.
dayOfWeek :: HasDate d => d -> DoW d Source #
Accessor for the Day of the week enum of a HasDate, for example:
>>>dayOfWeek . fromJust $ Gregorian.calendarDate 31 January 2000Monday
yearMonthDay :: HasDate d => d -> (Year, MoY d, DayOfMonth) Source #
Access the year, month and day-of-month components together in a single call, returned as a
(year, month, day) tuple.
This is purely an access optimization for code that needs more than one date component at once. Reading the
components individually with year, month and day is perfectly correct, but for a packed representation
(such as the Gregorian Date, which stores a cycle/century/day-in-century triple) each of those accessors
independently decodes the stored value, so asking for all three separately decodes it three times.
yearMonthDay decodes once and hands back every component, which is noticeably cheaper on hot paths (for
example date formatting). For representations that already store the components separately (such as the Julian
Date) there is nothing to decode and this is simply the three field reads, so it is never slower than the
individual accessors and callers can use it unconditionally.
Constructors
on :: LocalTime -> CalendarDate cal -> CalendarDateTime cal Source #
Returns a CalendarDateTime at LocalTime on the given CalendarDate
at :: Date cal -> LocalTime -> CalendarDateTime cal Source #
Returns a CalendarDateTime of the CalendarDate at the given LocalTime
atStartOfDay :: CalendarDate cal -> CalendarDateTime cal Source #
Returns the first valid time in the day specified by CalendarDate within the given TimeZone
Conversion
withCalendar :: (IsCalendarDateTime a, IsCalendarDateTime b) => CalendarDateTime a -> CalendarDateTime b Source #
Re-express a CalendarDateTime in a different calendar, preserving the same instant on the absolute timeline
(including the time of day). The target calendar is chosen by the result type (via TypeApplications or a type
annotation).