date.time() 函数
date.time() 返回指定相对持续时间或时间的时间值。
date.time 假设持续时间值相对于 now()。
函数类型签名
(t: A, ?location: {zone: string, offset: duration}) => time where A: Timeable
有关更多信息,请参见 Function type signatures。
参数
t
(必填) 持续时间或时间值。
使用绝对时间或相对持续时间。持续时间相对于 now()。
位置
用于确定时区的位置。 默认值是 location 选项。
示例
返回给定时间的时间
import "date"
date.time(t: 2020-02-11T12:21:03.29353494Z)// Returns 2020-02-11T12:21:03.293534940Z
返回给定相对持续时间的时间
import "date"
option now = () => 2022-01-01T00:00:00Z
date.time(t: -1h)// Returns 2021-12-31T23:00:00.000000000Z