date.week() 函数
date.week() 返回指定时间的ISO周数。
结果范围为 [1 - 53]。
函数类型签名
(t: A, ?location: {zone: string, offset: duration}) => int where A: Timeable
有关更多信息,请参见 Function type signatures。
参数
t
(必需) 操作所需的时间。
使用绝对时间、相对持续时间或整数。持续时间相对于 now()。
位置
用于确定时区的位置。 默认值是 location 选项。
示例
返回一年的周数
import "date"
date.week(t: 2020-02-11T12:21:03.29353494Z)// Returns 7
使用相对持续时间返回一年中的周数
import "date"
option now = () => 2020-02-11T12:21:03.29353494Z
date.week(t: -12d)// Returns 42
返回当前年份的周数
import "date"
date.week(t: now())