-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A performant time library -- -- Chronos is a performance-oriented time library for Haskell, with a -- straightforward API. The main differences between this and the -- time library are: * Chronos uses machine integers where -- possible. This means that time-related arithmetic should be faster, -- with the drawback that the types are incapable of representing times -- that are very far in the future or the past (because Chronos provides -- nanosecond, rather than picosecond, resolution). For most users, this -- is not a hindrance. * Chronos provides 'ToJSON'/'FromJSON' instances -- for serialisation. * Chronos provides Unbox instances for -- working with unboxed vectors. * Chronos provides Prim instances -- for working with byte arrays/primitive arrays. * Chronos uses normal -- non-overloaded haskell functions for encoding and decoding time. It -- provides attoparsec parsers for both Text and -- ByteString. Additionally, Chronos provides functions for -- encoding time to Text or ByteString. The -- http://hackage.haskell.org/package/time time> library -- accomplishes these with the Data.Time.Format module, which uses -- UNIX-style datetime format strings. The approach taken by Chronos is -- faster and catches more mistakes at compile time, at the cost of being -- less expressive. @package chronos @version 1.1 -- | Chronos is a performance-oriented time library for Haskell, with a -- straightforward API. The main differences between this and the -- time library are: -- --
-- >>> datetimeFromYmdhms 2014 2 26 17 58 52
-- Datetime {datetimeDate = Date {dateYear = Year {getYear = 2014}, dateMonth = Month {getMonth = 1}, dateDay = DayOfMonth {getDayOfMonth = 26}}, datetimeTime = TimeOfDay {timeOfDayHour = 17, timeOfDayMinute = 58, timeOfDayNanoseconds = 52000000000}}
--
datetimeFromYmdhms :: Int -> Int -> Int -> Int -> Int -> Int -> Datetime
-- | Construct a Time from year, month, day, hour, minute, second:
--
--
-- >>> timeFromYmdhms 2014 2 26 17 58 52
-- Time {getTime = 1393437532000000000}
--
timeFromYmdhms :: Int -> Int -> Int -> Int -> Int -> Int -> Time
-- | Convert Time to Datetime.
--
-- -- \(t :: Time) -> (datetimeToTime (timeToDatetime t)) == t --timeToDatetime :: Time -> Datetime -- | Convert Datetime to Time. -- --
-- \(d :: Datetime) -> timeToDatetime (datetimeToTime d) == d --datetimeToTime :: Datetime -> Time -- | Convert Time to OffsetDatetime by providing an -- Offset. timeToOffsetDatetime :: Offset -> Time -> OffsetDatetime -- | Convert OffsetDatetime to Time. offsetDatetimeToTime :: OffsetDatetime -> Time -- | Convert Time to Day. This function is lossy; -- consequently, it does not roundtrip with dayToTimeMidnight. timeToDayTruncate :: Time -> Day -- | Convert midnight of the given Day to Time. dayToTimeMidnight :: Day -> Time -- | Convert Day to a Date. -- --
-- \(d :: Day) -> dateToDay (dayToDate d) == d --dayToDate :: Day -> Date -- | Convert a Date to a Day. -- --
-- \(d :: Date) -> dayToDate (dateToDay d) == d --dateToDay :: Date -> Day -- | Convert a Day to an OrdinalDate. dayToOrdinalDate :: Day -> OrdinalDate -- | Convert an OrdinalDate to a Day. ordinalDateToDay :: OrdinalDate -> Day -- | Convert a MonthDate to a DayOfYear. monthDateToDayOfYear :: Bool -> MonthDate -> DayOfYear -- | Convert a DayOfYear to a MonthDate. dayOfYearToMonthDay :: Bool -> DayOfYear -> MonthDate -- | A Timespan representing a single second. second :: Timespan -- | A Timespan representing a single minute. minute :: Timespan -- | A Timespan representing a single hour. hour :: Timespan -- | A Timespan representing a single day. day :: Timespan -- | A Timespan representing a single week. week :: Timespan -- | Build a DayOfWeekMatch from seven (7) values. buildDayOfWeekMatch :: a -> a -> a -> a -> a -> a -> a -> DayOfWeekMatch a -- | Build a MonthMatch from twelve (12) values. buildMonthMatch :: a -> a -> a -> a -> a -> a -> a -> a -> a -> a -> a -> a -> MonthMatch a -- | Build an UnboxedMonthMatch from twelve (12) values. buildUnboxedMonthMatch :: Unbox a => a -> a -> a -> a -> a -> a -> a -> a -> a -> a -> a -> a -> UnboxedMonthMatch a -- | Match a DayOfWeek against a DayOfWeekMatch. caseDayOfWeek :: DayOfWeekMatch a -> DayOfWeek -> a -- | Match a Month against a MonthMatch. caseMonth :: MonthMatch a -> Month -> a -- | Match a Month against an UnboxedMonthMatch. caseUnboxedMonth :: Unbox a => UnboxedMonthMatch a -> Month -> a -- | The W3C DatetimeFormat. -- --
-- >>> encode_YmdHMS SubsecondPrecisionAuto w3c (timeToDatetime (timeFromYmdhms 2014 2 26 17 58 52)) -- "2014-02-26T17:58:52" ---- --
-- \(s :: SubsecondPrecision) (dt :: Datetime) -> isJust (decode_YmdHMS w3c (encode_YmdHMS s w3c dt)) --w3c :: DatetimeFormat -- | A DatetimeFormat that separates the members of the Date -- by slashes. -- --
-- >>> encode_YmdHMS SubsecondPrecisionAuto slash (timeToDatetime (timeFromYmdhms 2014 2 26 17 58 52)) -- "2014/02/26 17:58:52" ---- --
-- \(s :: SubsecondPrecision) (dt :: Datetime) -> isJust (decode_YmdHMS slash (encode_YmdHMS s slash dt)) --slash :: DatetimeFormat -- | A DatetimeFormat that separates the members of the Date -- by hyphens. -- --
-- >>> encode_YmdHMS SubsecondPrecisionAuto hyphen (timeToDatetime (timeFromYmdhms 2014 2 26 17 58 52)) -- "2014-02-26 17:58:52" ---- --
-- \(s :: SubsecondPrecision) (dt :: Datetime) -> isJust (decode_YmdHMS hyphen (encode_YmdHMS s hyphen dt)) --hyphen :: DatetimeFormat -- | A DatetimeFormat with no separators, except for a T -- between the Date and Time. -- --
-- >>> encode_YmdHMS SubsecondPrecisionAuto compact (timeToDatetime (timeFromYmdhms 2014 2 26 17 58 52)) -- "20140226T175852" ---- --
-- \(s :: SubsecondPrecision) (dt :: Datetime) -> isJust (decode_YmdHMS compact (encode_YmdHMS s compact dt)) --compact :: DatetimeFormat -- | Deconstruct a Time into its TimeParts. timeParts :: Offset -> Time -> TimeParts -- | The Month of January. january :: Month -- | The Month of February. february :: Month -- | The Month of March. march :: Month -- | The Month of April. april :: Month -- | The Month of May. may :: Month -- | The Month of June. june :: Month -- | The Month of July. july :: Month -- | The Month of August. august :: Month -- | The Month of September. september :: Month -- | The Month of October. october :: Month -- | The Month of November. november :: Month -- | The Month of December. december :: Month -- | The DayOfWeek Sunday. sunday :: DayOfWeek -- | The DayOfWeek Monday. monday :: DayOfWeek -- | The DayOfWeek Tuesday. tuesday :: DayOfWeek -- | The DayOfWeek Wednesday. wednesday :: DayOfWeek -- | The DayOfWeek Thursday. thursday :: DayOfWeek -- | The DayOfWeek Friday. friday :: DayOfWeek -- | The DayOfWeek Saturday. saturday :: DayOfWeek -- | Return the number of days in a given month. daysInMonth :: Bool -> Month -> Int -- | Is the Year a leap year? -- --
-- >>> isLeapYear (Year 1996) -- True ---- --
-- >>> isLeapYear (Year 2019) -- False --isLeapYear :: Year -> Bool -- | All UTC time offsets. See List of UTC time offsets. observedOffsets :: Vector Offset -- | Given a Date and a separator, construct a Text -- Builder corresponding to Year/Month/Day encoding. builder_Ymd :: Maybe Char -> Date -> Builder -- | Given a Date and a separator, construct a Text -- Builder corresponding to a Day/Month/Year encoding. builder_Dmy :: Maybe Char -> Date -> Builder -- | Given a SubsecondPrecision and a separator, construct a -- Text Builder corresponding to an Hour/Minute/Second -- encoding. builder_HMS :: SubsecondPrecision -> Maybe Char -> TimeOfDay -> Builder -- | Parse a Year/Month/Day-encoded Date that uses the given -- separator. parser_Ymd :: Maybe Char -> Parser Date -- | Parse a Month/Day/Year-encoded Date that uses the given -- separator. parser_Mdy :: Maybe Char -> Parser Date -- | Parse a Day/Month/Year-encoded Date that uses the given -- separator. parser_Dmy :: Maybe Char -> Parser Date -- | Given a Date and a separator, construct a ByteString -- Builder corresponding to a Day/Month/Year encoding. builderUtf8_Ymd :: Maybe Char -> Date -> Builder -- | Parse a Year/Month/Day-encoded Date that uses the given -- separator. parserUtf8_Ymd :: Maybe Char -> Parser Date -- | Given a MeridiemLocale, a SubsecondPrecision, and a -- separator, construct a Text Builder according to an IMS -- encoding. -- -- This differs from builder_IMSp in that their is a space between -- the seconds and locale. builder_IMS_p :: MeridiemLocale Text -> SubsecondPrecision -> Maybe Char -> TimeOfDay -> Builder -- | Given a MeridiemLocale, a SubsecondPrecision, and a -- separator, construct a Text Builder according to an IMS -- encoding. builder_IMSp :: MeridiemLocale Text -> SubsecondPrecision -> Maybe Char -> TimeOfDay -> Builder -- | Parse an Hour/Minute/Second-encoded TimeOfDay that uses the -- given separator. parser_HMS :: Maybe Char -> Parser TimeOfDay -- | Parses text that is formatted as either of the following: -- --
%H:%M
%H:%M:%S
%H:%M
%H:%M:%S
%H:%M
%H:%M:%S
%H:%M
%H:%M:%S
%H:%M
%H:%M:%S
%H:%M
%H:%M:%S
%H:%M
%H:%M:%S
%H:%M
%H:%M:%S
-- \(t :: Time) -> within t whole --whole :: TimeInterval -- | The singleton (degenerate) TimeInterval. singleton :: Time -> TimeInterval -- | Get the lower bound of the TimeInterval. lowerBound :: TimeInterval -> Time -- | Get the upper bound of the TimeInterval. upperBound :: TimeInterval -> Time -- | The width of the TimeInterval. This is equivalent to -- timeIntervalToTimespan. width :: TimeInterval -> Timespan -- | A smart constructor for TimeInterval. In general, you should -- prefer using this over the TimeInterval constructor, since it -- maintains the invariant that lowerBound interval -- <= upperBound interval. timeIntervalBuilder :: Time -> Time -> TimeInterval -- | An infix timeIntervalBuilder. (...) :: Time -> Time -> TimeInterval infix 3 ... -- | A day represented as the modified Julian date, the number of days -- since midnight on November 17, 1858. newtype Day Day :: Int -> Day [getDay] :: Day -> Int -- | The day of the week. newtype DayOfWeek DayOfWeek :: Int -> DayOfWeek [getDayOfWeek] :: DayOfWeek -> Int -- | The day of the month. newtype DayOfMonth DayOfMonth :: Int -> DayOfMonth [getDayOfMonth] :: DayOfMonth -> Int -- | The day of the year. newtype DayOfYear DayOfYear :: Int -> DayOfYear [getDayOfYear] :: DayOfYear -> Int -- | The month of the year. newtype Month Month :: Int -> Month [getMonth] :: Month -> Int -- | The number of years elapsed since the beginning of the Common Era. newtype Year Year :: Int -> Year [getYear] :: Year -> Int -- | A UTC offset. newtype Offset Offset :: Int -> Offset [getOffset] :: Offset -> Int -- | POSIX time with nanosecond resolution. newtype Time Time :: Int64 -> Time [getTime] :: Time -> Int64 -- | 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. newtype DayOfWeekMatch a DayOfWeekMatch :: Vector a -> DayOfWeekMatch a [getDayOfWeekMatch] :: DayOfWeekMatch a -> Vector 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. newtype MonthMatch a MonthMatch :: Vector a -> MonthMatch a [getMonthMatch] :: MonthMatch a -> Vector a -- | Like MonthMatch, but the matched value can have an instance of -- Unbox. newtype UnboxedMonthMatch a UnboxedMonthMatch :: Vector a -> UnboxedMonthMatch a [getUnboxedMonthMatch] :: UnboxedMonthMatch a -> Vector a -- | A timespan. This is represented internally as a number of nanoseconds. newtype Timespan Timespan :: Int64 -> Timespan [getTimespan] :: Timespan -> Int64 -- | The precision used when encoding seconds to a human-readable format. data SubsecondPrecision -- | Rounds to second, millisecond, microsecond, or nanosecond SubsecondPrecisionAuto :: SubsecondPrecision -- | Specify number of places after decimal SubsecondPrecisionFixed :: {-# UNPACK #-} !Int -> SubsecondPrecision -- | A date as represented by the Gregorian calendar. data Date Date :: {-# UNPACK #-} !Year -> {-# UNPACK #-} !Month -> {-# UNPACK #-} !DayOfMonth -> Date [dateYear] :: Date -> {-# UNPACK #-} !Year [dateMonth] :: Date -> {-# UNPACK #-} !Month [dateDay] :: Date -> {-# UNPACK #-} !DayOfMonth -- | An OrdinalDate is a Year and the number of days elapsed -- since the Year began. data OrdinalDate OrdinalDate :: {-# UNPACK #-} !Year -> {-# UNPACK #-} !DayOfYear -> OrdinalDate [ordinalDateYear] :: OrdinalDate -> {-# UNPACK #-} !Year [ordinalDateDayOfYear] :: OrdinalDate -> {-# UNPACK #-} !DayOfYear -- | A month and the day of the month. This does not actually represent a -- specific date, since this recurs every year. data MonthDate MonthDate :: {-# UNPACK #-} !Month -> {-# UNPACK #-} !DayOfMonth -> MonthDate [monthDateMonth] :: MonthDate -> {-# UNPACK #-} !Month [monthDateDay] :: MonthDate -> {-# UNPACK #-} !DayOfMonth -- | A Date as represented by the Gregorian calendar and a -- TimeOfDay. data Datetime Datetime :: {-# UNPACK #-} !Date -> {-# UNPACK #-} !TimeOfDay -> Datetime [datetimeDate] :: Datetime -> {-# UNPACK #-} !Date [datetimeTime] :: Datetime -> {-# UNPACK #-} !TimeOfDay -- | A Datetime with a time zone Offset. data OffsetDatetime OffsetDatetime :: {-# UNPACK #-} !Datetime -> {-# UNPACK #-} !Offset -> OffsetDatetime [offsetDatetimeDatetime] :: OffsetDatetime -> {-# UNPACK #-} !Datetime [offsetDatetimeOffset] :: OffsetDatetime -> {-# UNPACK #-} !Offset -- | A time of day with nanosecond resolution. data TimeOfDay TimeOfDay :: {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int64 -> TimeOfDay [timeOfDayHour] :: TimeOfDay -> {-# UNPACK #-} !Int [timeOfDayMinute] :: TimeOfDay -> {-# UNPACK #-} !Int [timeOfDayNanoseconds] :: TimeOfDay -> {-# UNPACK #-} !Int64 -- | The format of a Datetime. In particular this provides -- separators for parts of the Datetime and nothing else. data DatetimeFormat DatetimeFormat :: !Maybe Char -> !Maybe Char -> !Maybe Char -> DatetimeFormat -- | Separator in the date [datetimeFormatDateSeparator] :: DatetimeFormat -> !Maybe Char -- | Separator between date and time [datetimeFormatSeparator] :: DatetimeFormat -> !Maybe Char -- | Separator in the time [datetimeFormatTimeSeparator] :: DatetimeFormat -> !Maybe Char -- | Formatting settings for a timezone offset. data OffsetFormat -- | %z (e.g., -0400) OffsetFormatColonOff :: OffsetFormat -- | %:z (e.g., -04:00) OffsetFormatColonOn :: OffsetFormat -- | %::z (e.g., -04:00:00) OffsetFormatSecondsPrecision :: OffsetFormat -- | %:::z (e.g., -04, +05:30) OffsetFormatColonAuto :: OffsetFormat -- | Locale-specific formatting for weekdays and months. The type variable -- will likely be instantiated to Text or ByteString. data DatetimeLocale a DatetimeLocale :: !DayOfWeekMatch a -> !DayOfWeekMatch a -> !MonthMatch a -> !MonthMatch a -> DatetimeLocale a -- | full weekdays starting with Sunday, 7 elements [datetimeLocaleDaysOfWeekFull] :: DatetimeLocale a -> !DayOfWeekMatch a -- | abbreviated weekdays starting with Sunday, 7 elements [datetimeLocaleDaysOfWeekAbbreviated] :: DatetimeLocale a -> !DayOfWeekMatch a -- | full months starting with January, 12 elements [datetimeLocaleMonthsFull] :: DatetimeLocale a -> !MonthMatch a -- | abbreviated months starting with January, 12 elements [datetimeLocaleMonthsAbbreviated] :: DatetimeLocale a -> !MonthMatch a -- | Locale-specific formatting for AM and PM. data MeridiemLocale a MeridiemLocale :: !a -> !a -> MeridiemLocale a [meridiemLocaleAm] :: MeridiemLocale a -> !a [meridiemLocalePm] :: MeridiemLocale a -> !a -- | 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 -- lowerBound interval <= upperBound -- interval (all functions that act on TimeIntervals assume -- this invariant). data TimeInterval TimeInterval :: {-# UNPACK #-} !Time -> {-# UNPACK #-} !Time -> TimeInterval -- | Holds all of the parts encoded by a Time. Can be used for -- formatting if what is presently in the API does not suffice. data TimeParts TimeParts :: !Int -> !Int -> !Int -> !Int -> !Int -> !Int -> !Int -> !Int -> TimeParts -- | days 0-31 [timePartsDay] :: TimeParts -> !Int -- | months 0-11 [timePartsMonth] :: TimeParts -> !Int [timePartsYear] :: TimeParts -> !Int -- | hours 0-23 [timePartsHour] :: TimeParts -> !Int -- | minutes 0-59 [timePartsMinute] :: TimeParts -> !Int -- | seconds 0-59 [timePartsSecond] :: TimeParts -> !Int -- | fraction of a second with nanosecond resolution [timePartsSubsecond] :: TimeParts -> !Int [timePartsOffset] :: TimeParts -> !Int instance GHC.Show.Show Chronos.TimeParts instance GHC.Read.Read Chronos.TimeParts instance GHC.Classes.Eq Chronos.TimeParts instance GHC.Classes.Ord a => GHC.Classes.Ord (Chronos.MeridiemLocale a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Chronos.MeridiemLocale a) instance GHC.Show.Show a => GHC.Show.Show (Chronos.MeridiemLocale a) instance GHC.Read.Read a => GHC.Read.Read (Chronos.MeridiemLocale a) instance GHC.Enum.Bounded Chronos.TimeInterval instance GHC.Classes.Ord Chronos.TimeInterval instance GHC.Classes.Eq Chronos.TimeInterval instance GHC.Show.Show Chronos.TimeInterval instance GHC.Read.Read Chronos.TimeInterval instance GHC.Generics.Generic Chronos.OffsetFormat instance GHC.Enum.Bounded Chronos.OffsetFormat instance GHC.Enum.Enum Chronos.OffsetFormat instance GHC.Classes.Ord Chronos.OffsetFormat instance GHC.Classes.Eq Chronos.OffsetFormat instance GHC.Read.Read Chronos.OffsetFormat instance GHC.Show.Show Chronos.OffsetFormat instance GHC.Classes.Ord Chronos.DatetimeFormat instance GHC.Classes.Eq Chronos.DatetimeFormat instance GHC.Read.Read Chronos.DatetimeFormat instance GHC.Show.Show Chronos.DatetimeFormat instance GHC.Classes.Ord Chronos.OffsetDatetime instance GHC.Classes.Eq Chronos.OffsetDatetime instance GHC.Read.Read Chronos.OffsetDatetime instance GHC.Show.Show Chronos.OffsetDatetime instance GHC.Classes.Ord Chronos.Datetime instance GHC.Classes.Eq Chronos.Datetime instance GHC.Read.Read Chronos.Datetime instance GHC.Show.Show Chronos.Datetime instance GHC.Classes.Ord Chronos.TimeOfDay instance GHC.Classes.Eq Chronos.TimeOfDay instance GHC.Read.Read Chronos.TimeOfDay instance GHC.Show.Show Chronos.TimeOfDay instance GHC.Classes.Ord Chronos.MonthDate instance GHC.Classes.Eq Chronos.MonthDate instance GHC.Read.Read Chronos.MonthDate instance GHC.Show.Show Chronos.MonthDate instance GHC.Classes.Ord Chronos.OrdinalDate instance GHC.Classes.Eq Chronos.OrdinalDate instance GHC.Read.Read Chronos.OrdinalDate instance GHC.Show.Show Chronos.OrdinalDate instance GHC.Classes.Ord Chronos.Date instance GHC.Classes.Eq Chronos.Date instance GHC.Read.Read Chronos.Date instance GHC.Show.Show Chronos.Date instance GHC.Read.Read Chronos.SubsecondPrecision instance GHC.Show.Show Chronos.SubsecondPrecision instance GHC.Classes.Ord Chronos.SubsecondPrecision instance GHC.Classes.Eq Chronos.SubsecondPrecision instance Torsor.Additive Chronos.Timespan instance Data.Aeson.Types.FromJSON.FromJSON Chronos.Timespan instance Data.Aeson.Types.ToJSON.ToJSON Chronos.Timespan instance GHC.Classes.Ord Chronos.Timespan instance GHC.Classes.Eq Chronos.Timespan instance GHC.Read.Read Chronos.Timespan instance GHC.Show.Show Chronos.Timespan instance GHC.Enum.Bounded Chronos.Time instance Data.Primitive.Types.Prim Chronos.Time instance Foreign.Storable.Storable Chronos.Time instance GHC.Read.Read Chronos.Time instance GHC.Show.Show Chronos.Time instance GHC.Classes.Ord Chronos.Time instance GHC.Classes.Eq Chronos.Time instance Data.Hashable.Class.Hashable Chronos.Time instance Data.Aeson.Types.ToJSON.ToJSON Chronos.Time instance Data.Aeson.Types.FromJSON.FromJSON Chronos.Time instance GHC.Enum.Enum Chronos.Offset instance GHC.Classes.Ord Chronos.Offset instance GHC.Classes.Eq Chronos.Offset instance GHC.Read.Read Chronos.Offset instance GHC.Show.Show Chronos.Offset instance GHC.Classes.Ord Chronos.Year instance GHC.Classes.Eq Chronos.Year instance GHC.Read.Read Chronos.Year instance GHC.Show.Show Chronos.Year instance Data.Primitive.Types.Prim Chronos.Month instance GHC.Classes.Ord Chronos.Month instance GHC.Classes.Eq Chronos.Month instance GHC.Read.Read Chronos.Month instance GHC.Show.Show Chronos.Month instance Data.Primitive.Types.Prim Chronos.DayOfYear instance GHC.Classes.Ord Chronos.DayOfYear instance GHC.Classes.Eq Chronos.DayOfYear instance GHC.Read.Read Chronos.DayOfYear instance GHC.Show.Show Chronos.DayOfYear instance GHC.Enum.Enum Chronos.DayOfMonth instance Data.Primitive.Types.Prim Chronos.DayOfMonth instance GHC.Classes.Ord Chronos.DayOfMonth instance GHC.Classes.Eq Chronos.DayOfMonth instance GHC.Read.Read Chronos.DayOfMonth instance GHC.Show.Show Chronos.DayOfMonth instance Data.Hashable.Class.Hashable Chronos.DayOfWeek instance GHC.Classes.Ord Chronos.DayOfWeek instance GHC.Classes.Eq Chronos.DayOfWeek instance GHC.Read.Read Chronos.DayOfWeek instance GHC.Show.Show Chronos.DayOfWeek instance Data.Primitive.Types.Prim Chronos.Day instance Foreign.Storable.Storable Chronos.Day instance Data.Aeson.Types.FromJSON.FromJSON Chronos.Day instance Data.Aeson.Types.ToJSON.ToJSON Chronos.Day instance GHC.Enum.Enum Chronos.Day instance Data.Hashable.Class.Hashable Chronos.Day instance GHC.Classes.Ord Chronos.Day instance GHC.Classes.Eq Chronos.Day instance GHC.Read.Read Chronos.Day instance GHC.Show.Show Chronos.Day instance Data.Aeson.Types.ToJSON.ToJSON Chronos.Offset instance Data.Aeson.Types.ToJSON.ToJSONKey Chronos.Offset instance Data.Aeson.Types.ToJSON.ToJSON Chronos.Datetime instance Torsor.Torsor Chronos.OrdinalDate GHC.Types.Int instance GHC.Enum.Enum Chronos.OrdinalDate instance Torsor.Torsor Chronos.Date GHC.Types.Int instance GHC.Enum.Enum Chronos.Date instance GHC.Base.Semigroup Chronos.Timespan instance GHC.Base.Monoid Chronos.Timespan instance Torsor.Torsor Chronos.Time Chronos.Timespan instance Torsor.Scaling Chronos.Timespan GHC.Int.Int64 instance Torsor.Torsor Chronos.Offset GHC.Types.Int instance Data.Aeson.Types.FromJSON.FromJSON Chronos.Offset instance Data.Aeson.Types.FromJSON.FromJSONKey Chronos.Offset instance GHC.Enum.Enum Chronos.Month instance GHC.Enum.Bounded Chronos.Month instance Data.Vector.Unboxed.Base.Unbox Chronos.Month instance Data.Vector.Generic.Mutable.Base.MVector Data.Vector.Unboxed.Base.MVector Chronos.Month instance Data.Vector.Generic.Base.Vector Data.Vector.Unboxed.Base.Vector Chronos.Month instance Data.Vector.Unboxed.Base.Unbox Chronos.DayOfMonth instance Data.Vector.Generic.Mutable.Base.MVector Data.Vector.Unboxed.Base.MVector Chronos.DayOfMonth instance Data.Vector.Generic.Base.Vector Data.Vector.Unboxed.Base.Vector Chronos.DayOfMonth instance Torsor.Torsor Chronos.Day GHC.Types.Int -- | 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. module Chronos.Types -- | A day represented as the modified Julian date, the number of days -- since midnight on November 17, 1858. newtype Day Day :: Int -> Day [getDay] :: Day -> Int -- | The day of the week. newtype DayOfWeek DayOfWeek :: Int -> DayOfWeek [getDayOfWeek] :: DayOfWeek -> Int -- | The day of the month. newtype DayOfMonth DayOfMonth :: Int -> DayOfMonth [getDayOfMonth] :: DayOfMonth -> Int -- | The day of the year. newtype DayOfYear DayOfYear :: Int -> DayOfYear [getDayOfYear] :: DayOfYear -> Int -- | The month of the year. newtype Month Month :: Int -> Month [getMonth] :: Month -> Int -- | The number of years elapsed since the beginning of the Common Era. newtype Year Year :: Int -> Year [getYear] :: Year -> Int -- | A UTC offset. newtype Offset Offset :: Int -> Offset [getOffset] :: Offset -> Int -- | POSIX time with nanosecond resolution. newtype Time Time :: Int64 -> Time [getTime] :: Time -> Int64 -- | 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. newtype DayOfWeekMatch a DayOfWeekMatch :: Vector a -> DayOfWeekMatch a [getDayOfWeekMatch] :: DayOfWeekMatch a -> Vector 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. newtype MonthMatch a MonthMatch :: Vector a -> MonthMatch a [getMonthMatch] :: MonthMatch a -> Vector a -- | Like MonthMatch, but the matched value can have an instance of -- Unbox. newtype UnboxedMonthMatch a UnboxedMonthMatch :: Vector a -> UnboxedMonthMatch a [getUnboxedMonthMatch] :: UnboxedMonthMatch a -> Vector a -- | A timespan. This is represented internally as a number of nanoseconds. newtype Timespan Timespan :: Int64 -> Timespan [getTimespan] :: Timespan -> Int64 -- | The precision used when encoding seconds to a human-readable format. data SubsecondPrecision -- | Rounds to second, millisecond, microsecond, or nanosecond SubsecondPrecisionAuto :: SubsecondPrecision -- | Specify number of places after decimal SubsecondPrecisionFixed :: {-# UNPACK #-} !Int -> SubsecondPrecision -- | A date as represented by the Gregorian calendar. data Date Date :: {-# UNPACK #-} !Year -> {-# UNPACK #-} !Month -> {-# UNPACK #-} !DayOfMonth -> Date [dateYear] :: Date -> {-# UNPACK #-} !Year [dateMonth] :: Date -> {-# UNPACK #-} !Month [dateDay] :: Date -> {-# UNPACK #-} !DayOfMonth -- | An OrdinalDate is a Year and the number of days elapsed -- since the Year began. data OrdinalDate OrdinalDate :: {-# UNPACK #-} !Year -> {-# UNPACK #-} !DayOfYear -> OrdinalDate [ordinalDateYear] :: OrdinalDate -> {-# UNPACK #-} !Year [ordinalDateDayOfYear] :: OrdinalDate -> {-# UNPACK #-} !DayOfYear -- | A month and the day of the month. This does not actually represent a -- specific date, since this recurs every year. data MonthDate MonthDate :: {-# UNPACK #-} !Month -> {-# UNPACK #-} !DayOfMonth -> MonthDate [monthDateMonth] :: MonthDate -> {-# UNPACK #-} !Month [monthDateDay] :: MonthDate -> {-# UNPACK #-} !DayOfMonth -- | A Date as represented by the Gregorian calendar and a -- TimeOfDay. data Datetime Datetime :: {-# UNPACK #-} !Date -> {-# UNPACK #-} !TimeOfDay -> Datetime [datetimeDate] :: Datetime -> {-# UNPACK #-} !Date [datetimeTime] :: Datetime -> {-# UNPACK #-} !TimeOfDay -- | A Datetime with a time zone Offset. data OffsetDatetime OffsetDatetime :: {-# UNPACK #-} !Datetime -> {-# UNPACK #-} !Offset -> OffsetDatetime [offsetDatetimeDatetime] :: OffsetDatetime -> {-# UNPACK #-} !Datetime [offsetDatetimeOffset] :: OffsetDatetime -> {-# UNPACK #-} !Offset -- | A time of day with nanosecond resolution. data TimeOfDay TimeOfDay :: {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int64 -> TimeOfDay [timeOfDayHour] :: TimeOfDay -> {-# UNPACK #-} !Int [timeOfDayMinute] :: TimeOfDay -> {-# UNPACK #-} !Int [timeOfDayNanoseconds] :: TimeOfDay -> {-# UNPACK #-} !Int64 -- | The format of a Datetime. In particular this provides -- separators for parts of the Datetime and nothing else. data DatetimeFormat DatetimeFormat :: !Maybe Char -> !Maybe Char -> !Maybe Char -> DatetimeFormat -- | Separator in the date [datetimeFormatDateSeparator] :: DatetimeFormat -> !Maybe Char -- | Separator between date and time [datetimeFormatSeparator] :: DatetimeFormat -> !Maybe Char -- | Separator in the time [datetimeFormatTimeSeparator] :: DatetimeFormat -> !Maybe Char -- | Formatting settings for a timezone offset. data OffsetFormat -- | %z (e.g., -0400) OffsetFormatColonOff :: OffsetFormat -- | %:z (e.g., -04:00) OffsetFormatColonOn :: OffsetFormat -- | %::z (e.g., -04:00:00) OffsetFormatSecondsPrecision :: OffsetFormat -- | %:::z (e.g., -04, +05:30) OffsetFormatColonAuto :: OffsetFormat -- | Locale-specific formatting for weekdays and months. The type variable -- will likely be instantiated to Text or ByteString. data DatetimeLocale a DatetimeLocale :: !DayOfWeekMatch a -> !DayOfWeekMatch a -> !MonthMatch a -> !MonthMatch a -> DatetimeLocale a -- | full weekdays starting with Sunday, 7 elements [datetimeLocaleDaysOfWeekFull] :: DatetimeLocale a -> !DayOfWeekMatch a -- | abbreviated weekdays starting with Sunday, 7 elements [datetimeLocaleDaysOfWeekAbbreviated] :: DatetimeLocale a -> !DayOfWeekMatch a -- | full months starting with January, 12 elements [datetimeLocaleMonthsFull] :: DatetimeLocale a -> !MonthMatch a -- | abbreviated months starting with January, 12 elements [datetimeLocaleMonthsAbbreviated] :: DatetimeLocale a -> !MonthMatch a -- | Locale-specific formatting for AM and PM. data MeridiemLocale a MeridiemLocale :: !a -> !a -> MeridiemLocale a [meridiemLocaleAm] :: MeridiemLocale a -> !a [meridiemLocalePm] :: MeridiemLocale a -> !a -- | 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 -- lowerBound interval <= upperBound -- interval (all functions that act on TimeIntervals assume -- this invariant). data TimeInterval TimeInterval :: {-# UNPACK #-} !Time -> {-# UNPACK #-} !Time -> TimeInterval -- | Holds all of the parts encoded by a Time. Can be used for -- formatting if what is presently in the API does not suffice. data TimeParts TimeParts :: !Int -> !Int -> !Int -> !Int -> !Int -> !Int -> !Int -> !Int -> TimeParts -- | days 0-31 [timePartsDay] :: TimeParts -> !Int -- | months 0-11 [timePartsMonth] :: TimeParts -> !Int [timePartsYear] :: TimeParts -> !Int -- | hours 0-23 [timePartsHour] :: TimeParts -> !Int -- | minutes 0-59 [timePartsMinute] :: TimeParts -> !Int -- | seconds 0-59 [timePartsSecond] :: TimeParts -> !Int -- | fraction of a second with nanosecond resolution [timePartsSubsecond] :: TimeParts -> !Int [timePartsOffset] :: TimeParts -> !Int -- | This module provides some english locale helpers. It is very -- incomplete. Please send a pull request to -- https://github.com/andrewthad/chronos if you need additions to -- this API. module Chronos.Locale.English -- | Lowercase "am"/"pm". lower :: MeridiemLocale Text -- | Uppercase AM/PM. upper :: MeridiemLocale Text -- | Lowercase "a.m."/"p.m." lowerDots :: MeridiemLocale Text -- | Uppercase "A.M."/"P.M." upperDots :: MeridiemLocale Text -- | Abbreviated Months of the year. -- --
-- >>> caseMonth abbreviated october -- "Oct" ---- --
-- >>> caseMonth abbreviated august -- "Aug" --abbreviated :: MonthMatch Text -- | Unabbreviated Months of the year. -- --
-- >>> caseMonth unabbreviated january -- "January" ---- --
-- >>> caseMonth unabbreviated december -- "December" --unabbreviated :: MonthMatch Text