| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Chronos.Types
Description
Data types for representing different date and time-related information.
Internally, the types Int and Int64 are used to
represent everything. These are used even when negative
values are not appropriate and even if a smaller fixed-size
integer could hold the information. The only cases when
Int64 is used are when it is neccessary to represent values
with numbers 2^29 or higher. These are typically fields
that represent nanoseconds.
Unlike the types in the venerable time library, the types
here do not allow the user to work with all dates. Since this
library uses fixed-precision integral values instead of Integer,
all of the usual problems with overflow should be considered. Notably,
PosixTime and TaiTime can only be used to represent time between the years
1680 and 2260. All other types in this library correctly represent time
a million years before or after 1970.
The vector unbox instances store
data in a reasonably compact manner. For example, the instance
for Day has three unboxed vectors: Int for the year, Int8
for the month, and Int8 for the day. This only causes
corruption of data if the user is trying to use out-of-bounds
values for the month and the day. Users are advised to not
use the data types provided here to model non-existent times.
Synopsis
- newtype Day = Day {
- getDay :: Int
- newtype DayOfWeek = DayOfWeek {
- getDayOfWeek :: Int
- newtype DayOfMonth = DayOfMonth {
- getDayOfMonth :: Int
- newtype DayOfYear = DayOfYear {
- getDayOfYear :: Int
- newtype Month = Month {
- getMonth :: Int
- newtype Year = Year {
- getYear :: Int
- newtype Offset = Offset {
- getOffset :: Int
- newtype Time = Time {
- getTime :: Int64
- newtype DayOfWeekMatch a = DayOfWeekMatch {
- getDayOfWeekMatch :: Vector a
- newtype MonthMatch a = MonthMatch {
- getMonthMatch :: Vector a
- newtype UnboxedMonthMatch a = UnboxedMonthMatch {}
- newtype Timespan = Timespan {
- getTimespan :: Int64
- data SubsecondPrecision
- data Date = Date {}
- data OrdinalDate = OrdinalDate {}
- data MonthDate = MonthDate {}
- data Datetime = Datetime {
- datetimeDate :: !Date
- datetimeTime :: !TimeOfDay
- data OffsetDatetime = OffsetDatetime {}
- data TimeOfDay = TimeOfDay {
- timeOfDayHour :: !Int
- timeOfDayMinute :: !Int
- timeOfDayNanoseconds :: !Int64
- data DatetimeFormat = DatetimeFormat {
- datetimeFormatDateSeparator :: !(Maybe Char)
- datetimeFormatSeparator :: !(Maybe Char)
- datetimeFormatTimeSeparator :: !(Maybe Char)
- data OffsetFormat
- data DatetimeLocale a = DatetimeLocale {}
- data MeridiemLocale a = MeridiemLocale {
- meridiemLocaleAm :: !a
- meridiemLocalePm :: !a
- data TimeInterval = TimeInterval !Time !Time
Documentation
A day represented as the modified Julian date, the number of days since midnight on November 17, 1858.
Instances
| Enum Day # | |
| Eq Day # | |
| Ord Day # | |
| Read Day # | |
| Show Day # | |
| Hashable Day # | |
| ToJSON Day # | |
| FromJSON Day # | |
| Storable Day # | |
| Prim Day # | |
Defined in Chronos Methods alignment# :: Day -> Int# # indexByteArray# :: ByteArray# -> Int# -> Day # readByteArray# :: MutableByteArray# s -> Int# -> State# s -> (#State# s, Day#) # writeByteArray# :: MutableByteArray# s -> Int# -> Day -> State# s -> State# s # setByteArray# :: MutableByteArray# s -> Int# -> Int# -> Day -> State# s -> State# s # indexOffAddr# :: Addr# -> Int# -> Day # readOffAddr# :: Addr# -> Int# -> State# s -> (#State# s, Day#) # writeOffAddr# :: Addr# -> Int# -> Day -> State# s -> State# s # setOffAddr# :: Addr# -> Int# -> Int# -> Day -> State# s -> State# s # | |
| Torsor Day Int # | |
The day of the week.
Constructors
| DayOfWeek | |
Fields
| |
newtype DayOfMonth #
The day of the month.
Constructors
| DayOfMonth | |
Fields
| |
Instances
The day of the year.
Constructors
| DayOfYear | |
Fields
| |
Instances
| Eq DayOfYear # | |
| Ord DayOfYear # | |
Defined in Chronos | |
| Read DayOfYear # | |
| Show DayOfYear # | |
| Prim DayOfYear # | |
Defined in Chronos Methods sizeOf# :: DayOfYear -> Int# # alignment# :: DayOfYear -> Int# # indexByteArray# :: ByteArray# -> Int# -> DayOfYear # readByteArray# :: MutableByteArray# s -> Int# -> State# s -> (#State# s, DayOfYear#) # writeByteArray# :: MutableByteArray# s -> Int# -> DayOfYear -> State# s -> State# s # setByteArray# :: MutableByteArray# s -> Int# -> Int# -> DayOfYear -> State# s -> State# s # indexOffAddr# :: Addr# -> Int# -> DayOfYear # readOffAddr# :: Addr# -> Int# -> State# s -> (#State# s, DayOfYear#) # writeOffAddr# :: Addr# -> Int# -> DayOfYear -> State# s -> State# s # setOffAddr# :: Addr# -> Int# -> Int# -> DayOfYear -> State# s -> State# s # | |
The month of the year.
Instances
The number of years elapsed since the beginning of the Common Era.
A UTC offset.
POSIX time with nanosecond resolution.
Instances
| Bounded Time # | |
| Eq Time # | |
| Ord Time # | |
| Read Time # | |
| Show Time # | |
| Hashable Time # | |
| ToJSON Time # | |
| FromJSON Time # | |
| Storable Time # | |
Defined in Chronos | |
| Prim Time # | |
Defined in Chronos Methods alignment# :: Time -> Int# # indexByteArray# :: ByteArray# -> Int# -> Time # readByteArray# :: MutableByteArray# s -> Int# -> State# s -> (#State# s, Time#) # writeByteArray# :: MutableByteArray# s -> Int# -> Time -> State# s -> State# s # setByteArray# :: MutableByteArray# s -> Int# -> Int# -> Time -> State# s -> State# s # indexOffAddr# :: Addr# -> Int# -> Time # readOffAddr# :: Addr# -> Int# -> State# s -> (#State# s, Time#) # writeOffAddr# :: Addr# -> Int# -> Time -> State# s -> State# s # setOffAddr# :: Addr# -> Int# -> Int# -> Time -> State# s -> State# s # | |
| Torsor Time Timespan # | |
newtype DayOfWeekMatch a #
Match a DayOfWeek. By match, we mean that a DayOfWeekMatch
is a mapping from the integer value of a DayOfWeek to some value
of type a. You should construct a DayOfWeekMatch with
buildDayOfWeekMatch, and match it using caseDayOfWeek.
Constructors
| DayOfWeekMatch | |
Fields
| |
newtype MonthMatch a #
Match a Month. By match, we mean that a MonthMatch is
a mapping from the integer value of a Month to some value of
type a. You should construct a MonthMatch with
buildMonthMatch, and match it using caseMonth.
Constructors
| MonthMatch | |
Fields
| |
newtype UnboxedMonthMatch a #
Like MonthMatch, but the matched value can have an instance of
Unbox.
Constructors
| UnboxedMonthMatch | |
Fields | |
A timespan. This is represented internally as a number of nanoseconds.
Constructors
| Timespan | |
Fields
| |
data SubsecondPrecision #
The precision used when encoding seconds to a human-readable format.
Constructors
| SubsecondPrecisionAuto | Rounds to second, millisecond, microsecond, or nanosecond |
| SubsecondPrecisionFixed !Int | Specify number of places after decimal |
Instances
A date as represented by the Gregorian calendar.
data OrdinalDate #
An OrdinalDate is a Year and the number of days elapsed
since the Year began.
Constructors
| OrdinalDate | |
Fields | |
Instances
A month and the day of the month. This does not actually represent a specific date, since this recurs every year.
Constructors
| MonthDate | |
Fields
| |
Constructors
| Datetime | |
Fields
| |
data OffsetDatetime #
Constructors
| OffsetDatetime | |
Fields | |
Instances
| Eq OffsetDatetime # | |
Defined in Chronos Methods (==) :: OffsetDatetime -> OffsetDatetime -> Bool (/=) :: OffsetDatetime -> OffsetDatetime -> Bool | |
| Ord OffsetDatetime # | |
Defined in Chronos Methods compare :: OffsetDatetime -> OffsetDatetime -> Ordering (<) :: OffsetDatetime -> OffsetDatetime -> Bool (<=) :: OffsetDatetime -> OffsetDatetime -> Bool (>) :: OffsetDatetime -> OffsetDatetime -> Bool (>=) :: OffsetDatetime -> OffsetDatetime -> Bool max :: OffsetDatetime -> OffsetDatetime -> OffsetDatetime min :: OffsetDatetime -> OffsetDatetime -> OffsetDatetime | |
| Read OffsetDatetime # | |
Defined in Chronos Methods readsPrec :: Int -> ReadS OffsetDatetime # readList :: ReadS [OffsetDatetime] # readPrec :: ReadPrec OffsetDatetime # readListPrec :: ReadPrec [OffsetDatetime] # | |
| Show OffsetDatetime # | |
Defined in Chronos Methods showsPrec :: Int -> OffsetDatetime -> ShowS show :: OffsetDatetime -> String showList :: [OffsetDatetime] -> ShowS | |
A time of day with nanosecond resolution.
Constructors
| TimeOfDay | |
Fields
| |
data DatetimeFormat #
The format of a Datetime. In particular
this provides separators for parts of the Datetime
and nothing else.
Constructors
| DatetimeFormat | |
Fields
| |
Instances
| Eq DatetimeFormat # | |
Defined in Chronos Methods (==) :: DatetimeFormat -> DatetimeFormat -> Bool (/=) :: DatetimeFormat -> DatetimeFormat -> Bool | |
| Ord DatetimeFormat # | |
Defined in Chronos Methods compare :: DatetimeFormat -> DatetimeFormat -> Ordering (<) :: DatetimeFormat -> DatetimeFormat -> Bool (<=) :: DatetimeFormat -> DatetimeFormat -> Bool (>) :: DatetimeFormat -> DatetimeFormat -> Bool (>=) :: DatetimeFormat -> DatetimeFormat -> Bool max :: DatetimeFormat -> DatetimeFormat -> DatetimeFormat min :: DatetimeFormat -> DatetimeFormat -> DatetimeFormat | |
| Read DatetimeFormat # | |
Defined in Chronos Methods readsPrec :: Int -> ReadS DatetimeFormat # readList :: ReadS [DatetimeFormat] # readPrec :: ReadPrec DatetimeFormat # readListPrec :: ReadPrec [DatetimeFormat] # | |
| Show DatetimeFormat # | |
Defined in Chronos Methods showsPrec :: Int -> DatetimeFormat -> ShowS show :: DatetimeFormat -> String showList :: [DatetimeFormat] -> ShowS | |
data OffsetFormat #
Formatting settings for a timezone offset.
Constructors
| OffsetFormatColonOff |
|
| OffsetFormatColonOn |
|
| OffsetFormatSecondsPrecision |
|
| OffsetFormatColonAuto |
|
Instances
| Bounded OffsetFormat # | |
Defined in Chronos | |
| Enum OffsetFormat # | |
Defined in Chronos Methods succ :: OffsetFormat -> OffsetFormat pred :: OffsetFormat -> OffsetFormat toEnum :: Int -> OffsetFormat fromEnum :: OffsetFormat -> Int enumFrom :: OffsetFormat -> [OffsetFormat] enumFromThen :: OffsetFormat -> OffsetFormat -> [OffsetFormat] enumFromTo :: OffsetFormat -> OffsetFormat -> [OffsetFormat] enumFromThenTo :: OffsetFormat -> OffsetFormat -> OffsetFormat -> [OffsetFormat] | |
| Eq OffsetFormat # | |
Defined in Chronos | |
| Ord OffsetFormat # | |
Defined in Chronos Methods compare :: OffsetFormat -> OffsetFormat -> Ordering (<) :: OffsetFormat -> OffsetFormat -> Bool (<=) :: OffsetFormat -> OffsetFormat -> Bool (>) :: OffsetFormat -> OffsetFormat -> Bool (>=) :: OffsetFormat -> OffsetFormat -> Bool max :: OffsetFormat -> OffsetFormat -> OffsetFormat min :: OffsetFormat -> OffsetFormat -> OffsetFormat | |
| Read OffsetFormat # | |
Defined in Chronos Methods readsPrec :: Int -> ReadS OffsetFormat # readList :: ReadS [OffsetFormat] # readPrec :: ReadPrec OffsetFormat # readListPrec :: ReadPrec [OffsetFormat] # | |
| Show OffsetFormat # | |
Defined in Chronos Methods showsPrec :: Int -> OffsetFormat -> ShowS show :: OffsetFormat -> String showList :: [OffsetFormat] -> ShowS | |
| Generic OffsetFormat # | |
Defined in Chronos Associated Types type Rep OffsetFormat :: Type -> Type | |
| type Rep OffsetFormat # | |
Defined in Chronos type Rep OffsetFormat = D1 (MetaData "OffsetFormat" "Chronos" "chronos-1.0.7-BhVazY2rKvdBfduunCFQXE" False) ((C1 (MetaCons "OffsetFormatColonOff" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "OffsetFormatColonOn" PrefixI False) (U1 :: Type -> Type)) :+: (C1 (MetaCons "OffsetFormatSecondsPrecision" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "OffsetFormatColonAuto" PrefixI False) (U1 :: Type -> Type))) | |
data DatetimeLocale a #
Locale-specific formatting for weekdays and months. The
type variable will likely be instantiated to Text
or ByteString.
Constructors
| DatetimeLocale | |
Fields
| |
data MeridiemLocale a #
Locale-specific formatting for AM and PM.
Constructors
| MeridiemLocale | |
Fields
| |
Instances
data TimeInterval #
A TimeInterval represents a start and end time.
It can sometimes be more ergonomic than the Torsor API when
you only care about whether or not a Time is within a certain range.
To construct a TimeInterval, it is best to use timeIntervalBuilder,
which maintains the invariant that
(all functions that act on lowerBound interval <= upperBound intervalTimeIntervals assume this invariant).
Constructors
| TimeInterval !Time !Time |
Instances
| Bounded TimeInterval # | |
Defined in Chronos | |
| Eq TimeInterval # | |
Defined in Chronos | |
| Ord TimeInterval # | |
Defined in Chronos Methods compare :: TimeInterval -> TimeInterval -> Ordering (<) :: TimeInterval -> TimeInterval -> Bool (<=) :: TimeInterval -> TimeInterval -> Bool (>) :: TimeInterval -> TimeInterval -> Bool (>=) :: TimeInterval -> TimeInterval -> Bool max :: TimeInterval -> TimeInterval -> TimeInterval min :: TimeInterval -> TimeInterval -> TimeInterval | |
| Read TimeInterval # | |
Defined in Chronos Methods readsPrec :: Int -> ReadS TimeInterval # readList :: ReadS [TimeInterval] # readPrec :: ReadPrec TimeInterval # readListPrec :: ReadPrec [TimeInterval] # | |
| Show TimeInterval # | |
Defined in Chronos Methods showsPrec :: Int -> TimeInterval -> ShowS show :: TimeInterval -> String showList :: [TimeInterval] -> ShowS | |