DA.Date
Daml 标准库模块 DA.Date 参考文档。
DA.日期
该模块提供了一组操作日期值的函数。
日期的界限是 0001-01-01T00:00:00.000000Z 和
9999-12-31T23:59:59.999999Z。
模块快照
数据类型
data DayOfWeek
构造函数:
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday
实例:
instance Eq DayOfWeekinstance Ord DayOfWeekinstance Bounded DayOfWeekinstance Enum DayOfWeekinstance Show DayOfWeek
data Month
Month 类型代表公历中的月份。
请注意,虽然Month有一个Enum实例,但toEnum和fromEnum
函数从 0 开始计数,即 toEnum 1 :: Month 是 Feb。
构造函数:
Jan
Feb
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
实例:
instance Eq Monthinstance Ord Monthinstance Bounded Monthinstance Enum Monthinstance Show Month
函数
addDays
addDays : Date -> Int -> Date
将给定的天数添加到日期中。
subtractDays
subtractDays : Date -> Int -> Date
从日期中减去给定的天数。
subtractDays d r相当于addDays d (- r)。
subDate
subDate : Date -> Date -> Int
返回两个给定日期之间的天数。
dayOfWeek
dayOfWeek : Date -> DayOfWeek
返回给定日期是星期几。
fromGregorian
fromGregorian : (Int, Month, Int) -> Date
从三元组(year, month, days)构造一个Date。
toGregorian
toGregorian : Date -> (Int, Month, Int)
将 Date 值转换为 (year, month, day) 三倍,根据
到公历。
date
date : Int -> Month -> Int -> Date
给定三个值(年、月、日),构造一个 Date 值。
date y m d 将年 y、月 m 和日 d 转换为 Date 值。
如果 d 超出范围 1 .. monthDayCount y m,则会引发错误。
isLeapYear
isLeapYear : Int -> Bool
如果给定年份是闰年,则返回 True。
`fromMonth````haskell theme={“theme”:{“light”:“github-light”,“dark”:“github-dark”}}
fromMonth : Month -> Int
获取给定月份对应的数字。例如`Jan`对应
`1`,`Feb`对应`2`,依此类推。
<span id="function-da-date-monthdaycount-59295" />
### `monthDayCount`
```haskell theme={"theme":{"light":"github-light","dark":"github-dark"}}
monthDayCount : Int -> Month -> Int
根据公历获取给定年份中给定月份的天数。 这没有考虑历史日历更改(例如, 从儒略历改为公历),但确实计算闰年。
datetime
datetime : Int -> Month -> Int -> Int -> Int -> Int -> Time
使用 year、month、day、hours、minutes、seconds 构造一个实例。
toDateUTC
toDateUTC : Time -> Date
从 UTC 时间提取 UTC 日期。
此函数将截断“Time to Date”,但在许多情况下它不会返回您真正想要的日期。 原因是,通常 Time 的来源是 getTime,而 getTime 返回 UTC,并且很可能 您想要的日期是某个地点或交易所的本地日期。因此,以这种方式检索的日期将是 昨天如果在新加坡开市时检索。
孤立类型类实例
-
instance Eq DayOfWeek -
instance Ord DayOfWeek -
instance Show DayOfWeek -
instance Enum DayOfWeek -
instance Bounded DayOfWeek -
instance Eq Month -
instance Ord Month -
instance Show Month -
instance Enum Month -
instance Bounded Month -
instance Enum Date -
instance Bounded Date
本文由 CC Privacy Club 根据 Canton Network 官方文档(CC-BY-4.0)整理翻译,仅供学习;实现细节以官方最新版本为准。