| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Haspara.Internal.Date
Description
This module provides data definitions and functions for date values.
Synopsis
- newtype Date = MkDate Day
- fromDay :: Day -> Date
- fromYMD :: Integer -> Int -> Int -> Date
- fromString :: MonadFail m => String -> m Date
- fromFormattedString :: MonadFail m => String -> String -> m Date
- fromText :: MonadFail m => Text -> m Date
- fromFormattedText :: MonadFail m => String -> Text -> m Date
- toDay :: Date -> Day
- toYMD :: Date -> (Integer, Int, Int)
- toString :: Date -> String
- toFormattedString :: String -> Date -> String
- toText :: Date -> Text
- toFormattedText :: String -> Date -> Text
- addDays :: Integer -> Date -> Date
Data Definition
Type encoding for date values.
This is a convenience wrapper around Day type. It helps us to avoid
defining orphan instances.
Instances
| Enum Date Source # | |
| Eq Date Source # | |
| Ord Date Source # | |
| Read Date Source # |
|
| Show Date Source # |
|
| Hashable Date Source # | |
Defined in Haspara.Internal.Date | |
| ToJSON Date Source # |
|
Defined in Haspara.Internal.Date | |
| FromJSON Date Source # |
|
Constructors
fromDay :: Day -> Date Source #
Builds a Date from a given Day.
>>>fromDay (read "2021-01-01")2021-01-01
fromYMD :: Integer -> Int -> Int -> Date Source #
Builds a Date from a given year, month and day as in Gregorian calendar.
>>>fromYMD 2021 1 12021-01-01
Conversions
toYMD :: Date -> (Integer, Int, Int) Source #
Converts Date value to a 3-tuple of year, month and day.
>>>toYMD (read "2020-12-31")(2020,12,31)