hodatime
Copyright(C) 2017 Jason Johnson
LicenseBSD-style (see the file LICENSE)
MaintainerJason Johnson <jason.johnson.081@gmail.com>
Stabilityexperimental
PortabilityPOSIX, Windows
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.HodaTime.CalendarDateTime

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

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

Instances details
(IsCalendar cal, Show (Month cal)) => Show (CalendarDateTime cal) Source #

Renders a CalendarDateTime as the applicative construction that produces it, e.g. fromJust (at <$> Gregorian.calendarDate 31 March 2000 <*> localTime 4 30 0 0). A single fromJust wraps the whole thing because that is how one actually builds the value from the (partial) smart constructors.

Instance details

Defined in Data.HodaTime.CalendarDateTime.Internal

NFData (Date cal) => NFData (CalendarDateTime cal) Source # 
Instance details

Defined in Data.HodaTime.CalendarDateTime.Internal

Methods

rnf :: CalendarDateTime cal -> () #

Eq (Date cal) => Eq (CalendarDateTime cal) Source # 
Instance details

Defined in Data.HodaTime.CalendarDateTime.Internal

Ord (Date cal) => Ord (CalendarDateTime cal) Source # 
Instance details

Defined in Data.HodaTime.CalendarDateTime.Internal

Hashable (Date cal) => Hashable (CalendarDateTime cal) Source # 
Instance details

Defined in Data.HodaTime.CalendarDateTime.Internal

IsCalendar cal => HasDate (CalendarDateTime cal) Source # 
Instance details

Defined in Data.HodaTime.CalendarDateTime.Internal

Associated Types

type DoW (CalendarDateTime cal) Source #

type MoY (CalendarDateTime cal) Source #

IsCalendar cal => HasLocalTime (CalendarDateTime cal) Source # 
Instance details

Defined in Data.HodaTime.LocalTime.Internal

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

Defined in Data.HodaTime.Period

type DoW (CalendarDateTime cal) Source # 
Instance details

Defined in Data.HodaTime.CalendarDateTime.Internal

type DoW (CalendarDateTime cal) = DayOfWeek cal
type MoY (CalendarDateTime cal) Source # 
Instance details

Defined in Data.HodaTime.CalendarDateTime.Internal

type MoY (CalendarDateTime cal) = Month cal

class IsCalendar cal Source #

Minimal complete definition

fromDays, toDays, toYmd, calendarName, day', setDay', month', setMonthIndex', year', setYear', dayOfWeek', next', previous'

Instances

Instances details
IsCalendar Coptic Source # 
Instance details

Defined in Data.HodaTime.Calendar.Coptic

Associated Types

data Date Coptic

data DayOfWeek Coptic Source #

data Month Coptic Source #

Methods

fromDays :: Int32 -> Date Coptic

toDays :: Date Coptic -> Int32

toYmd :: Date Coptic -> (Int32, Word8, Word8)

calendarName :: Date Coptic -> String

day' :: Date Coptic -> DayOfMonth

setDay' :: DayOfMonth -> Date Coptic -> Date Coptic

month' :: Date Coptic -> Month Coptic

setMonthIndex' :: Int -> Date Coptic -> Date Coptic

year' :: Date Coptic -> Year

setYear' :: Year -> Date Coptic -> Date Coptic

dayOfWeek' :: Date Coptic -> DayOfWeek Coptic

next' :: Int -> DayOfWeek Coptic -> Date Coptic -> Date Coptic

previous' :: Int -> DayOfWeek Coptic -> Date Coptic -> Date Coptic

IsCalendar Gregorian Source # 
Instance details

Defined in Data.HodaTime.Calendar.Gregorian.Internal

Associated Types

data Date Gregorian

data DayOfWeek Gregorian Source #

data Month Gregorian Source #

IsCalendar Julian Source # 
Instance details

Defined in Data.HodaTime.Calendar.Julian

Associated Types

data Date Julian

data DayOfWeek Julian Source #

data Month Julian Source #

Methods

fromDays :: Int32 -> Date Julian

toDays :: Date Julian -> Int32

toYmd :: Date Julian -> (Int32, Word8, Word8)

calendarName :: Date Julian -> String

day' :: Date Julian -> DayOfMonth

setDay' :: DayOfMonth -> Date Julian -> Date Julian

month' :: Date Julian -> Month Julian

setMonthIndex' :: Int -> Date Julian -> Date Julian

year' :: Date Julian -> Year

setYear' :: Year -> Date Julian -> Date Julian

dayOfWeek' :: Date Julian -> DayOfWeek Julian

next' :: Int -> DayOfWeek Julian -> Date Julian -> Date Julian

previous' :: Int -> DayOfWeek Julian -> Date Julian -> Date Julian

IsCalendar Persian Source # 
Instance details

Defined in Data.HodaTime.Calendar.Persian

Associated Types

data Date Persian

data DayOfWeek Persian Source #

data Month Persian Source #

Methods

fromDays :: Int32 -> Date Persian

toDays :: Date Persian -> Int32

toYmd :: Date Persian -> (Int32, Word8, Word8)

calendarName :: Date Persian -> String

day' :: Date Persian -> DayOfMonth

setDay' :: DayOfMonth -> Date Persian -> Date Persian

month' :: Date Persian -> Month Persian

setMonthIndex' :: Int -> Date Persian -> Date Persian

year' :: Date Persian -> Year

setYear' :: Year -> Date Persian -> Date Persian

dayOfWeek' :: Date Persian -> DayOfWeek Persian

next' :: Int -> DayOfWeek Persian -> Date Persian -> Date Persian

previous' :: Int -> DayOfWeek Persian -> Date Persian -> Date Persian

KnownNumbering n => IsCalendar (Hebrew n) Source #

The Hebrew calendar. All field access and conversions run in numbering-independent calendar order; the numbering only selects how Month values are numbered by Enum.

Instance details

Defined in Data.HodaTime.Calendar.Hebrew

Associated Types

data Date (Hebrew n)

data DayOfWeek (Hebrew n) Source #

data Month (Hebrew n) Source #

Methods

fromDays :: Int32 -> Date (Hebrew n)

toDays :: Date (Hebrew n) -> Int32

toYmd :: Date (Hebrew n) -> (Int32, Word8, Word8)

calendarName :: Date (Hebrew n) -> String

day' :: Date (Hebrew n) -> DayOfMonth

setDay' :: DayOfMonth -> Date (Hebrew n) -> Date (Hebrew n)

month' :: Date (Hebrew n) -> Month (Hebrew n)

setMonthIndex' :: Int -> Date (Hebrew n) -> Date (Hebrew n)

year' :: Date (Hebrew n) -> Year

setYear' :: Year -> Date (Hebrew n) -> Date (Hebrew n)

dayOfWeek' :: Date (Hebrew n) -> DayOfWeek (Hebrew n)

next' :: Int -> DayOfWeek (Hebrew n) -> Date (Hebrew n) -> Date (Hebrew n)

previous' :: Int -> DayOfWeek (Hebrew n) -> Date (Hebrew n) -> Date (Hebrew n)

KnownLeap l => IsCalendar (Islamic l) Source # 
Instance details

Defined in Data.HodaTime.Calendar.Islamic

Associated Types

data Date (Islamic l)

data DayOfWeek (Islamic l) Source #

data Month (Islamic l) Source #

Methods

fromDays :: Int32 -> Date (Islamic l)

toDays :: Date (Islamic l) -> Int32

toYmd :: Date (Islamic l) -> (Int32, Word8, Word8)

calendarName :: Date (Islamic l) -> String

day' :: Date (Islamic l) -> DayOfMonth

setDay' :: DayOfMonth -> Date (Islamic l) -> Date (Islamic l)

month' :: Date (Islamic l) -> Month (Islamic l)

setMonthIndex' :: Int -> Date (Islamic l) -> Date (Islamic l)

year' :: Date (Islamic l) -> Year

setYear' :: Year -> Date (Islamic l) -> Date (Islamic l)

dayOfWeek' :: Date (Islamic l) -> DayOfWeek (Islamic l)

next' :: Int -> DayOfWeek (Islamic l) -> Date (Islamic l) -> Date (Islamic l)

previous' :: Int -> DayOfWeek (Islamic l) -> Date (Islamic l) -> Date (Islamic l)

type family DoW d Source #

Instances

Instances details
type DoW (CalendarDateTime cal) Source # 
Instance details

Defined in Data.HodaTime.CalendarDateTime.Internal

type DoW (CalendarDateTime cal) = DayOfWeek cal

type family MoY d Source #

Instances

Instances details
type MoY (CalendarDateTime cal) Source # 
Instance details

Defined in Data.HodaTime.CalendarDateTime.Internal

type MoY (CalendarDateTime cal) = Month cal

day :: HasDate d => d -> DayOfMonth Source #

Day-of-month component.

month :: HasDate d => d -> MoY d Source #

Accessor for the Month component of a HasDate.

year :: HasDate d => d -> Year Source #

Year 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 2000
Monday

next :: HasDate d => Int -> DoW d -> d -> d Source #

Returns a HasDate shifted to the nth next Day of Week from the current HasDate, for example:

>>> next 1 Monday . fromJust $ Gregorian.calendarDate 31 January 2000
fromJust (Gregorian.calendarDate 7 February 2000)

previous :: HasDate d => Int -> DoW d -> d -> d Source #

Returns a HasDate shifted to the nth previous Day of Week from the current HasDate, for example:

>>> previous 1 Monday . fromJust $ Gregorian.calendarDate 31 January 2000
fromJust (Gregorian.calendarDate 24 January 2000)

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

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