# 日期
¥Date
代表时间戳。
¥Represents timestamps.
Date API 仍处于初步阶段,仅实现了一部分属性和方法。请注意,通过 Date.now 获取当前日期需要从主机导入 Date 对象(如 Date)。
¥The Date API is still preliminary with only a subset of properties and methods implemented. Note that getting the current date, via Date.now, requires importing the Date object from the host (as Date).
警告
Date 目前不支持 UTC 以外的时区。因此,toString、toTimeString 等方法只能部分实现。
¥Date does not currently support timezones other than UTC. Therefore, methods such as toString and toTimeString can only be partially implemented.
# 构造函数
¥Constructor
- new Date(value: i64)- 从 UTC 时间戳(以毫秒为单位)构造一个新的日期对象。 - ¥Constructs a new date object from an UTC timestamp in milliseconds. 
# 静态成员
¥Static members
- function now(): i64- 返回当前 UTC 时间戳(以毫秒为单位)。要使用此功能,你必须从主机导入 - Date对象(作为- Date)。- ¥Returns the current UTC timestamp in milliseconds. To use this function you must import the - Dateobject from the host (as- Date).
- function UTC( year: i32, month?: i32, day?: i32, hour?: i32, minute?: i32, second?: i32, millisecond?: i64 ): i64- 返回指定日期的 UTC 时间戳(以毫秒为单位)。 - ¥Returns the UTC timestamp in milliseconds of the specified date. 
- function parse(dateString: string): Date- 从字符串中解析 Date 对象(仅限 ISO 8601 格式)。 - ¥Parses a Date object from a string (ISO 8601 format only). 
- function fromString(dateTimeString: string): Date- 从 ISO 8601 格式的字符串创建 Date 对象。 - ¥Creates a Date object from an ISO 8601 formatted string. 
# 实例成员
¥Instance members
- function getTime(): i64- 获取该日期的 UTC 时间戳(以毫秒为单位)。 - ¥Gets the UTC timestamp of this date in milliseconds. 
- function setTime(value: i64): i64- 设置该日期的 UTC 时间戳(以毫秒为单位)并返回时间戳。 - ¥Sets the UTC timestamp of this date in milliseconds and returns the timestamp. 
- function getUTCFullYear(): i32- 根据世界时间获取全年。 - ¥Gets the full year according to universal time. 
- function setUTCFullYear(value: i32): i32- 根据世界时间设置全年。 - ¥Sets the full year according to universal time. 
- function getUTCMonth(): i32- 根据通用时间获取(零索引)月份。 - ¥Gets the (zero indexed) month according to universal time. 
- function setUTCMonth(value: i32): i32- 根据世界时间设置(零索引)月份。 - ¥Sets the (zero indexed) month according to universal time. 
- function getUTCDate(): i32- 根据世界时间获取该月的某一天。 - ¥Gets the day of the month according to universal time. 
- function setUTCDate(value: i32): i32- 根据世界时间设置每月的某一天。 - ¥Sets the day of the month according to universal time. 
- function getUTCDay(): i32- 根据世界时间获取指定日期的星期几,其中 0 代表星期日。 - ¥Gets the day of the week in the specified date according to universal time, where 0 represents Sunday. 
- function getUTCHours(): i32- 根据世界时间获取小时。 - ¥Gets the hour according to universal time. 
- function setUTCHours(value: i32): i32- 根据世界时间设置小时。 - ¥Sets the hour according to universal time. 
- function getUTCMinutes(): i32- 根据世界时间获取分钟。 - ¥Gets the minute according to universal time. 
- function setUTCMinutes(value: i32): i32- 根据世界时间设置分钟。 - ¥Sets the minute according to universal time. 
- function getUTCSeconds(): i32- 根据世界时间获取秒。 - ¥Gets the second according to universal time. 
- function setUTCSeconds(value: i32): i32- 根据世界时间设置秒。 - ¥Sets the second according to universal time. 
- function getUTCMilliseconds(): i32- 根据世界时间获取毫秒。 - ¥Gets the millisecond according to universal time. 
- function setUTCMilliseconds(value: i32): i32- 根据世界时间设置毫秒。 - ¥Sets the millisecond according to universal time. 
- function toISOString(): string- 返回简化扩展 ISO 8601 格式的字符串。 - ¥Returns the a string in simplified extended ISO 8601 format. 
- function toUTCString(): string- 返回 RFC-1123 格式的字符串和 UTC 时区。 - ¥Returns the a string in RFC-1123 format and the UTC time zone. 
- function toDateString(): string- 返回人类可读形式的日期字符串,采用英语 WWW MMM DD YYYY 格式。 - ¥Returns the a date string in human readable form in English WWW MMM DD YYYY format. 
- function toTimeString(): string- 返回 HH:MM:SS 格式的时间字符串。 - ¥Returns the a time string in HH:MM:SS format. 
警告
目前 toTimeString 不输出时区并且不使用本地时区偏移!
¥At the moment toTimeString doesn't output time zone and doesn't use local time zone offset!
- function toString(): string- 返回人类可读形式的时间字符串,采用英语 WWW MMM DD YYYY HH:MM:SS 格式。 - ¥Returns the a time string in human readable form in English WWW MMM DD YYYY HH:MM:SS format. 
警告
目前 toString 不输出时区并且不使用本地时区偏移!
¥At the moment toString doesn't output time zone and doesn't use local time zone offset!