date

std.chrono.date

rec Date

pub rec Date;

没有一天中的时间和时区的日历日期

year:年份(例如 2025) month:月份 [1, 12] day:月中天数 [1, 31]

rec Datetime

pub rec Datetime;

带有时间和 UTC 偏移量的日历日期

year:年份(例如 2025) month:月份 [1, 12] day:月中天数 [1, 31] hour:小时 [0, 23] minute:分钟 [0, 59] second:秒 [0, 59] nsec:秒内的纳秒 [0, 999999999] offset:UTC 偏移量(以秒为单位,0 = UTC,3600 = +01:00,-18000 = -05:00)

fun is_leap_year

pub fun is_leap_year(year: i64) bool;

报告某一年是否为闰年

year:要测试的年份 ret:如果年份是闰年则为 true

fun days_in_month

pub fun days_in_month(year: i64, month: i64) i64;

返回给定月份中的天数

year:年份(二月份需要) month:月份 [1, 12] ret:该月的天数

fun date_from_time

pub fun date_from_time(t: Time) Date;

Time 中提取 UTC 日期

t:时间瞬间 ret:UTC 日历日期

fun datetime_from_time

pub fun datetime_from_time(t: Time) Datetime;

Time 中提取 UTC Datetime

t:时间瞬间 ret:UTC 日期时间

fun datetime_with_offset

pub fun datetime_with_offset(t: Time, offset: i64) Datetime;

带有 UTC 偏移量从 Time 中提取 Datetime

t:时间瞬间 offset:UTC 偏移量(以秒为单位) ret:调整到给定偏移量的日期时间

fun datetime_to_time

pub fun datetime_to_time(dt: Datetime) Time;

Datetime 转换回 Time 瞬间

dt:要转换的日期时间 ret:时间瞬间(UTC)

fun date_to_time

pub fun date_to_time(d: Date) Time;

Date 转换为 UTC 午夜的 Time

d:要转换的日期 ret:给定日期 UTC 00:00:00 的时间瞬间

fun floor_div

pub fun floor_div(a: i64, b: i64) i64;

fun civil_to_days

pub fun civil_to_days(y: i64, m: i64, d: i64) i64;