DA.Date
This module provides a set of functions to manipulate Date values. The bounds for Date are 0001-01-01T00:00:00.000000Z and 9999-12-31T23:59:59.999999Z.Module Snapshot
Lifecycle
Stable.
Notices
Status:
active
Introduced in: 3.4.9
Removed in: -
Warnings: 0
Deprecations: 0
Deprecated since: -Data Types
data DayOfWeek
Constructors:
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday
- instance
SerializableDayOfWeek - instance
EqDayOfWeek - instance
OrdDayOfWeek - instance
BoundedDayOfWeek - instance
EnumDayOfWeek - instance
ShowDayOfWeek
data Month
The Month type represents a month in the Gregorian calendar.
Note that, while Month has an Enum instance, the toEnum and fromEnum
functions start counting at 0, i.e. toEnum 1 :: Month is Feb.
Constructors:
Jan
Feb
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
- instance
SerializableMonth - instance
EqMonth - instance
OrdMonth - instance
BoundedMonth - instance
EnumMonth - instance
ShowMonth
Functions
addDays
addDays : Date -> Int -> Date
Add the given number of days to a date.
subtractDays
subtractDays : Date -> Int -> Date
Subtract the given number of days from a date.
subtractDays d r is equivalent to addDays d (- r).
subDate
subDate : Date -> Date -> Int
Returns the number of days between the two given dates.
dayOfWeek
dayOfWeek : Date -> DayOfWeek
Returns the day of week for the given date.
fromGregorian
fromGregorian : (Int, Month, Int) -> Date
Constructs a Date from the triplet (year, month, days).
toGregorian
toGregorian : Date -> (Int, Month, Int)
Turn Date value into a (year, month, day) triple, according
to the Gregorian calendar.
date
date : Int -> Month -> Int -> Date
Given the three values (year, month, day), constructs a Date value.
date y m d turns the year y, month m, and day d into a Date value.
Raises an error if d is outside the range 1 .. monthDayCount y m.
isLeapYear
isLeapYear : Int -> Bool
Returns True if the given year is a leap year.
fromMonth
fromMonth : Month -> Int
Get the number corresponding to given month. For example, Jan corresponds
to 1, Feb corresponds to 2, and so on.
monthDayCount
monthDayCount : Int -> Month -> Int
Get number of days in the given month in the given year, according to Gregorian calendar.
This does not take historical calendar changes into account (for example, the
moves from Julian to Gregorian calendar), but does count leap years.
datetime
datetime : Int -> Month -> Int -> Int -> Int -> Int -> Time
Constructs an instant using year, month, day, hours, minutes, seconds.
toDateUTC
toDateUTC : Time -> Date
Extracts UTC date from UTC time.
This function will truncate Time to Date, but in many cases it will not return the date you really want.
The reason for this is that usually the source of Time would be getTime, and getTime returns UTC, and most likely
the date you want is something local to a location or an exchange. Consequently the date retrieved this way would be
yesterday if retrieved when the market opens in say Singapore.