日期时间操作
138 个节点
本页内容 138
加上时间间隔
函数重载 1/4
加上时间间隔(值: 时间日期, 增量: TimeSpan) -> 时间日期
DateTime Add(DateTime value, TimeSpan delta)
给时间日期加上一段时间间隔。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | 时间日期 | — | |
| 增量 | TimeSpan | — |
返回
| 结果 | 时间日期 |
重载 2/4
加上时间间隔(值: TimeOnly, 增量: TimeSpan) -> TimeOnly
TimeOnly Add(TimeOnly value, TimeSpan delta)
给时刻加上一段时间间隔。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | TimeOnly | — | |
| 增量 | TimeSpan | — |
返回
| 结果 | TimeOnly |
重载 3/4
加上时间间隔 -> (结果: TimeOnly, 跨越天数: 整数)
值: TimeOnly
增量: TimeSpanTimeOnly Add(
TimeOnly value,
TimeSpan delta,
out int wrappedDays)给时刻加上一段时间间隔,越过午夜时绕回,并报告钟表绕过了几天。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | TimeOnly | — | The starting time of day. |
| 增量 | TimeSpan | — | The duration to add; negative moves back. |
返回
| 结果 | TimeOnly |
| 跨越天数 | 整数 |
重载 4/4
加上时间间隔(左侧: TimeSpan, 右侧: TimeSpan) -> TimeSpan
TimeSpan Add(TimeSpan left, TimeSpan right)
把两个时间间隔相加。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 左侧 | TimeSpan | — | |
| 右侧 | TimeSpan | — |
返回
| 结果 | TimeSpan |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
加天数
函数重载 1/2
加天数(值: 时间日期, 天数: 数字) -> 时间日期
DateTime AddDays(DateTime value, double days)
把时间日期按天数前后移动,天数可以是小数(0.5 即十二小时)。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | 时间日期 | — | The starting date and time; its kind is kept. |
| 天数 | 数字 | — | The number of days to add; negative moves back. |
返回
| 结果 | 时间日期 |
重载 2/2
加天数(值: DateOnly, 天数: 整数) -> DateOnly
DateOnly AddDays(DateOnly value, int days)
给日期加上若干天。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | DateOnly | — | |
| 天数 | 整数 | — |
返回
| 结果 | DateOnly |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
加小时数
函数重载 1/3
加小时数(值: 时间日期, 小时数: 数字) -> 时间日期
DateTime AddHours(DateTime value, double hours)
把时间日期按小时数前后移动,可以是小数。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | 时间日期 | — | The starting date and time; its kind is kept. |
| 小时数 | 数字 | — | The number of hours to add; negative moves back. |
返回
| 结果 | 时间日期 |
重载 2/3
加小时数(值: TimeOnly, 小时数: 数字) -> TimeOnly
TimeOnly AddHours(TimeOnly value, double hours)
把时刻按小时数前后移动,越过午夜时绕回(22:00 加 3 小时为 01:00)。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | TimeOnly | — | The starting time of day. |
| 小时数 | 数字 | — | The number of hours to add, which may be fractional or negative. |
返回
| 结果 | TimeOnly |
重载 3/3
加小时数 -> (结果: TimeOnly, 跨越天数: 整数)
值: TimeOnly
小时数: 数字TimeOnly AddHours(
TimeOnly value,
double hours,
out int wrappedDays)把时刻按小时数前后移动,越过午夜时绕回,并报告钟表绕过了几天。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | TimeOnly | — | The starting time of day. |
| 小时数 | 数字 | — | The number of hours to add, which may be fractional or negative. |
返回
| 结果 | TimeOnly |
| 跨越天数 | 整数 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
加微秒数
函数把时间日期按微秒数前后移动,可以是小数。
加微秒数(值: 时间日期, 微秒数: 数字) -> 时间日期
DateTime AddMicroseconds(DateTime value, double microseconds)
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | 时间日期 | — | The starting date and time; its kind is kept. |
| 微秒数 | 数字 | — | The number of microseconds to add; negative moves back. |
返回
| 结果 | 时间日期 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
加毫秒数
函数把时间日期按毫秒数前后移动,可以是小数。
加毫秒数(值: 时间日期, 毫秒数: 数字) -> 时间日期
DateTime AddMilliseconds(DateTime value, double milliseconds)
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | 时间日期 | — | The starting date and time; its kind is kept. |
| 毫秒数 | 数字 | — | The number of milliseconds to add; negative moves back. |
返回
| 结果 | 时间日期 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
加分钟数
函数重载 1/3
加分钟数(值: 时间日期, 分钟数: 数字) -> 时间日期
DateTime AddMinutes(DateTime value, double minutes)
把时间日期按分钟数前后移动,可以是小数。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | 时间日期 | — | The starting date and time; its kind is kept. |
| 分钟数 | 数字 | — | The number of minutes to add; negative moves back. |
返回
| 结果 | 时间日期 |
重载 2/3
加分钟数(值: TimeOnly, 分钟数: 数字) -> TimeOnly
TimeOnly AddMinutes(TimeOnly value, double minutes)
把时刻按分钟数前后移动,越过午夜时绕回。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | TimeOnly | — | The starting time of day. |
| 分钟数 | 数字 | — | The number of minutes to add, which may be fractional or negative. |
返回
| 结果 | TimeOnly |
重载 3/3
加分钟数 -> (结果: TimeOnly, 跨越天数: 整数)
值: TimeOnly
分钟数: 数字TimeOnly AddMinutes(
TimeOnly value,
double minutes,
out int wrappedDays)把时刻按分钟数前后移动,越过午夜时绕回,并报告钟表绕过了几天。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | TimeOnly | — | The starting time of day. |
| 分钟数 | 数字 | — | The number of minutes to add, which may be fractional or negative. |
返回
| 结果 | TimeOnly |
| 跨越天数 | 整数 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
加月数
函数重载 1/2
加月数(值: 时间日期, 月数: 整数) -> 时间日期
DateTime AddMonths(DateTime value, int months)
把时间日期按整月前后移动,时刻保持不变。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | 时间日期 | — | The starting date and time; its kind is kept. |
| 月数 | 整数 | — | The number of months to add, from -120000 to 120000; negative moves back. |
返回
| 结果 | 时间日期 |
备注
If the day does not exist in the target month it is clamped to that month's last day, so January 31 plus one month is February 28 (or 29 in a leap year).
重载 2/2
加月数(值: DateOnly, 月数: 整数) -> DateOnly
DateOnly AddMonths(DateOnly value, int months)
把日期按整月前后移动。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | DateOnly | — | The starting date. |
| 月数 | 整数 | — | The number of months to add; negative moves back. |
返回
| 结果 | DateOnly |
备注
If the day does not exist in the target month it is clamped to that month's last day, so January 31 plus one month is February 28 (or 29 in a leap year).
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
加秒数
函数把时间日期按秒数前后移动,可以是小数。
加秒数(值: 时间日期, 秒数: 数字) -> 时间日期
DateTime AddSeconds(DateTime value, double seconds)
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | 时间日期 | — | The starting date and time; its kind is kept. |
| 秒数 | 数字 | — | The number of seconds to add; negative moves back. |
返回
| 结果 | 时间日期 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
加计时周期数
函数把时间日期按计时周期数前后移动,一个计时周期为 100 纳秒。
加计时周期数(值: 时间日期, 计时周期数: 大整数) -> 时间日期
DateTime AddTicks(DateTime value, long ticks)
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | 时间日期 | — | The starting date and time; its kind is kept. |
| 计时周期数 | 大整数 | — | The number of ticks to add; negative moves back. |
返回
| 结果 | 时间日期 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
加年数
函数重载 1/2
加年数(值: 时间日期, 年数: 整数) -> 时间日期
DateTime AddYears(DateTime value, int years)
把时间日期按整年前后移动,月、日和时刻保持不变。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | 时间日期 | — | The starting date and time; its kind is kept. |
| 年数 | 整数 | — | The number of years to add; negative moves back. |
返回
| 结果 | 时间日期 |
备注
February 29 moved to a year that is not a leap year becomes February 28.
重载 2/2
加年数(值: DateOnly, 年数: 整数) -> DateOnly
DateOnly AddYears(DateOnly value, int years)
把日期按整年前后移动,月和日保持不变。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | DateOnly | — | The starting date. |
| 年数 | 整数 | — | The number of years to add; negative moves back. |
返回
| 结果 | DateOnly |
备注
February 29 moved to a year that is not a leap year becomes February 28.
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
比较
函数重载 1/4
比较(左侧: 时间日期, 右侧: 时间日期) -> 整数
int Compare(DateTime left, DateTime right)
比较两个时间日期。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 左侧 | 时间日期 | — | |
| 右侧 | 时间日期 | — |
返回
| 结果 | 整数 |
备注
The comparison uses the underlying tick values and does not convert values based on DateTime.Kind.
To compare actual points in time, convert both values to UTC first.
重载 2/4
比较(左侧: DateOnly, 右侧: DateOnly) -> 整数
int Compare(DateOnly left, DateOnly right)
比较两个日期。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 左侧 | DateOnly | — | |
| 右侧 | DateOnly | — |
返回
| 结果 | 整数 |
重载 3/4
比较(左侧: TimeOnly, 右侧: TimeOnly) -> 整数
int Compare(TimeOnly left, TimeOnly right)
比较两个时刻。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 左侧 | TimeOnly | — | |
| 右侧 | TimeOnly | — |
返回
| 结果 | 整数 |
重载 4/4
比较(左侧: TimeSpan, 右侧: TimeSpan) -> 整数
int Compare(TimeSpan left, TimeSpan right)
比较两个时间间隔。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 左侧 | TimeSpan | — | |
| 右侧 | TimeSpan | — |
返回
| 结果 | 整数 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
创建时间日期
函数重载 1/8
创建时间日期(计时周期数: 大整数) -> 时间日期
DateTime Create(long ticks)
用计时周期数创建时间日期。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 计时周期数 | 大整数 | — |
返回
| 结果 | 时间日期 |
重载 2/8
创建时间日期(计时周期数: 大整数, 种类: DateTimeKind) -> 时间日期
DateTime Create(long ticks, DateTimeKind kind)
用计时周期数创建时间日期,并标为本地时间、UTC 或未指定。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 计时周期数 | 大整数 | — | The number of 100-nanosecond ticks since 0001-01-01 00:00:00; must be between 0 and the ticks of DateTime.MaxValue, otherwise an System.ArgumentOutOfRangeException is thrown. |
| 种类 | DateTimeKind | — | Whether the value is local time, UTC or unspecified. |
返回
| 结果 | 时间日期 |
重载 3/8
创建时间日期(年: 整数, 月: 整数, 日: 整数) -> 时间日期
DateTime Create(int year, int month, int day)
创建给定日历日期午夜时分的时间日期。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 年 | 整数 | — | The year, from 1 to 9999. |
| 月 | 整数 | — | The month, from 1 to 12. |
| 日 | 整数 | — | The day of the month, from 1 to the number of days in that month. |
返回
| 结果 | 时间日期 |
重载 4/8
创建时间日期 -> 时间日期
年: 整数
月: 整数
日: 整数
时: 整数
分: 整数
第二个: 整数DateTime Create(
int year,
int month,
int day,
int hour,
int minute,
int second)用日历日期和精确到秒的时刻创建时间日期。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 年 | 整数 | — | The year, from 1 to 9999. |
| 月 | 整数 | — | The month, from 1 to 12. |
| 日 | 整数 | — | The day of the month, from 1 to the number of days in that month. |
| 时 | 整数 | — | The hour, from 0 to 23. |
| 分 | 整数 | — | The minute, from 0 to 59. |
| 第二个 | 整数 | — | The second, from 0 to 59. |
返回
| 结果 | 时间日期 |
重载 5/8
创建时间日期 -> 时间日期
年: 整数
月: 整数
日: 整数
时: 整数
分: 整数
第二个: 整数
种类: DateTimeKindDateTime Create(
int year,
int month,
int day,
int hour,
int minute,
int second,
DateTimeKind kind)用日历日期和精确到秒的时刻创建时间日期,并标为本地时间、UTC 或未指定。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 年 | 整数 | — | The year, from 1 to 9999. |
| 月 | 整数 | — | The month, from 1 to 12. |
| 日 | 整数 | — | The day of the month, from 1 to the number of days in that month. |
| 时 | 整数 | — | The hour, from 0 to 23. |
| 分 | 整数 | — | The minute, from 0 to 59. |
| 第二个 | 整数 | — | The second, from 0 to 59. |
| 种类 | DateTimeKind | — | Whether the value is local time, UTC or unspecified. |
返回
| 结果 | 时间日期 |
重载 6/8
创建时间日期 -> 时间日期
年: 整数
月: 整数
日: 整数
时: 整数
分: 整数
第二个: 整数
毫秒: 整数DateTime Create(
int year,
int month,
int day,
int hour,
int minute,
int second,
int millisecond)用日历日期和精确到毫秒的时刻创建时间日期。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 年 | 整数 | — | The year, from 1 to 9999. |
| 月 | 整数 | — | The month, from 1 to 12. |
| 日 | 整数 | — | The day of the month, from 1 to the number of days in that month. |
| 时 | 整数 | — | The hour, from 0 to 23. |
| 分 | 整数 | — | The minute, from 0 to 59. |
| 第二个 | 整数 | — | The second, from 0 to 59. |
| 毫秒 | 整数 | — | The millisecond, from 0 to 999. |
返回
| 结果 | 时间日期 |
重载 7/8
创建时间日期 -> 时间日期
年: 整数
月: 整数
日: 整数
时: 整数
分: 整数
第二个: 整数
毫秒: 整数
种类: DateTimeKindDateTime Create(
int year,
int month,
int day,
int hour,
int minute,
int second,
int millisecond,
DateTimeKind kind)用日历日期和精确到毫秒的时刻创建时间日期,并标为本地时间、UTC 或未指定。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 年 | 整数 | — | The year, from 1 to 9999. |
| 月 | 整数 | — | The month, from 1 to 12. |
| 日 | 整数 | — | The day of the month, from 1 to the number of days in that month. |
| 时 | 整数 | — | The hour, from 0 to 23. |
| 分 | 整数 | — | The minute, from 0 to 59. |
| 第二个 | 整数 | — | The second, from 0 to 59. |
| 毫秒 | 整数 | — | The millisecond, from 0 to 999. |
| 种类 | DateTimeKind | — | Whether the value is local time, UTC or unspecified. |
返回
| 结果 | 时间日期 |
重载 8/8
创建时间日期 -> 时间日期
年: 整数
月: 整数
日: 整数
时: 整数
分: 整数
第二个: 整数
毫秒: 整数
微秒: 整数
种类: DateTimeKindDateTime Create(
int year,
int month,
int day,
int hour,
int minute,
int second,
int millisecond,
int microsecond,
DateTimeKind kind = DateTimeKind.Unspecified)用日历日期和精确到微秒的时刻创建时间日期,可标为本地时间或 UTC。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 年 | 整数 | — | The year, from 1 to 9999. |
| 月 | 整数 | — | The month, from 1 to 12. |
| 日 | 整数 | — | The day of the month, from 1 to the number of days in that month. |
| 时 | 整数 | — | The hour, from 0 to 23. |
| 分 | 整数 | — | The minute, from 0 to 59. |
| 第二个 | 整数 | — | The second, from 0 to 59. |
| 毫秒 | 整数 | — | The millisecond, from 0 to 999. |
| 微秒 | 整数 | — | The microsecond, from 0 to 999. |
| 种类 | DateTimeKind | Unspecified | Whether the value is local time, UTC or unspecified; unspecified when left out. |
返回
| 结果 | 时间日期 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
创建日期
函数重载 1/2
创建日期(年: 整数, 月: 整数, 日: 整数) -> DateOnly
DateOnly CreateDateOnly(int year, int month, int day)
用年、月、日创建日期。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 年 | 整数 | — | |
| 月 | 整数 | — | |
| 日 | 整数 | — |
返回
| 结果 | DateOnly |
重载 2/2
创建日期 -> DateOnly
年: 整数
月: 整数
日: 整数
日历: CalendarDateOnly CreateDateOnly(
int year,
int month,
int day,
Calendar calendar)用另一种历法(如希伯来历或日本历)中的年、月、日创建日期。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 年 | 整数 | — | The year in Calendar. |
| 月 | 整数 | — | The month in Calendar. |
| 日 | 整数 | — | The day of the month in Calendar. |
| 日历 | Calendar | — | The calendar the year, month and day are expressed in; must not be null. |
返回
| 结果 | DateOnly |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
创建时刻
函数重载 1/4
创建时刻(时: 整数, 分: 整数) -> TimeOnly
TimeOnly CreateTimeOnly(int hour, int minute)
用时和分创建时刻。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 时 | 整数 | — | |
| 分 | 整数 | — |
返回
| 结果 | TimeOnly |
重载 2/4
创建时刻(时: 整数, 分: 整数, 第二个: 整数) -> TimeOnly
TimeOnly CreateTimeOnly(int hour, int minute, int second)
用时、分、秒创建时刻。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 时 | 整数 | — | The hour, from 0 to 23. |
| 分 | 整数 | — | The minute, from 0 to 59. |
| 第二个 | 整数 | — | The second, from 0 to 59. |
返回
| 结果 | TimeOnly |
重载 3/4
创建时刻 -> TimeOnly
时: 整数
分: 整数
第二个: 整数
毫秒: 整数TimeOnly CreateTimeOnly(
int hour,
int minute,
int second,
int millisecond)用时、分、秒、毫秒创建时刻。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 时 | 整数 | — | The hour, from 0 to 23. |
| 分 | 整数 | — | The minute, from 0 to 59. |
| 第二个 | 整数 | — | The second, from 0 to 59. |
| 毫秒 | 整数 | — | The millisecond, from 0 to 999. |
返回
| 结果 | TimeOnly |
重载 4/4
创建时刻 -> TimeOnly
时: 整数
分: 整数
第二个: 整数
毫秒: 整数
微秒: 整数TimeOnly CreateTimeOnly(
int hour,
int minute,
int second,
int millisecond,
int microsecond)用时、分、秒、毫秒、微秒创建时刻。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 时 | 整数 | — | The hour, from 0 to 23. |
| 分 | 整数 | — | The minute, from 0 to 59. |
| 第二个 | 整数 | — | The second, from 0 to 59. |
| 毫秒 | 整数 | — | The millisecond, from 0 to 999. |
| 微秒 | 整数 | — | The microsecond, from 0 to 999. |
返回
| 结果 | TimeOnly |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
创建时间间隔
函数重载 1/5
创建时间间隔(计时周期数: 大整数) -> TimeSpan
TimeSpan CreateTimeSpan(long ticks)
用计时周期数创建时间间隔。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 计时周期数 | 大整数 | — |
返回
| 结果 | TimeSpan |
重载 2/5
创建时间间隔(小时数: 整数, 分钟数: 整数, 秒数: 整数) -> TimeSpan
TimeSpan CreateTimeSpan(int hours, int minutes, int seconds)
用时、分、秒创建时间间隔。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 小时数 | 整数 | — | The number of hours. |
| 分钟数 | 整数 | — | The number of minutes. |
| 秒数 | 整数 | — | The number of seconds. |
返回
| 结果 | TimeSpan |
备注
The parts are added together, so they may exceed their usual ranges or be negative: 0 hours, 90 minutes and 0 seconds is one and a half hours. An System.ArgumentOutOfRangeException is thrown if the total is beyond TimeSpan.MaxValue or TimeSpan.MinValue.
重载 3/5
创建时间间隔 -> TimeSpan
天数: 整数
小时数: 整数
分钟数: 整数
秒数: 整数TimeSpan CreateTimeSpan(
int days,
int hours,
int minutes,
int seconds)用天、时、分、秒创建时间间隔。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 天数 | 整数 | — | The number of days. |
| 小时数 | 整数 | — | The number of hours. |
| 分钟数 | 整数 | — | The number of minutes. |
| 秒数 | 整数 | — | The number of seconds. |
返回
| 结果 | TimeSpan |
备注
The parts are added together, so they may exceed their usual ranges or be negative. An System.ArgumentOutOfRangeException is thrown if the total is beyond TimeSpan.MaxValue or TimeSpan.MinValue.
重载 4/5
创建时间间隔 -> TimeSpan
天数: 整数
小时数: 整数
分钟数: 整数
秒数: 整数
毫秒数: 整数TimeSpan CreateTimeSpan(
int days,
int hours,
int minutes,
int seconds,
int milliseconds)用天、时、分、秒、毫秒创建时间间隔。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 天数 | 整数 | — | The number of days. |
| 小时数 | 整数 | — | The number of hours. |
| 分钟数 | 整数 | — | The number of minutes. |
| 秒数 | 整数 | — | The number of seconds. |
| 毫秒数 | 整数 | — | The number of milliseconds. |
返回
| 结果 | TimeSpan |
备注
The parts are added together, so they may exceed their usual ranges or be negative. An System.ArgumentOutOfRangeException is thrown if the total is beyond TimeSpan.MaxValue or TimeSpan.MinValue.
重载 5/5
创建时间间隔 -> TimeSpan
天数: 整数
小时数: 整数
分钟数: 整数
秒数: 整数
毫秒数: 整数
微秒数: 整数TimeSpan CreateTimeSpan(
int days,
int hours,
int minutes,
int seconds,
int milliseconds,
int microseconds)用天、时、分、秒、毫秒、微秒创建时间间隔。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 天数 | 整数 | — | The number of days. |
| 小时数 | 整数 | — | The number of hours. |
| 分钟数 | 整数 | — | The number of minutes. |
| 秒数 | 整数 | — | The number of seconds. |
| 毫秒数 | 整数 | — | The number of milliseconds. |
| 微秒数 | 整数 | — | The number of microseconds. |
返回
| 结果 | TimeSpan |
备注
The parts are added together, so they may exceed their usual ranges or be negative. An System.ArgumentOutOfRangeException is thrown if the total is beyond TimeSpan.MaxValue or TimeSpan.MinValue.
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
日期部分
函数获取时间日期的日期部分。
日期部分(值: 时间日期) -> 时间日期
DateTime Date(DateTime value)
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | 时间日期 | — |
返回
| 结果 | 时间日期 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
从时间日期取日期
函数取时间日期的日历日期,去掉其时刻。
从时间日期取日期(值: 时间日期) -> DateOnly
DateOnly DateOnlyFromDateTime(DateTime value)
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | 时间日期 | — | The date and time to take the date from; its kind is ignored and no time-zone conversion is made. |
返回
| 结果 | DateOnly |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
从日序号取日期
函数用天数编号创建日期,即公历中自 0001-01-01 起的天数。
从日序号取日期(日序号: 整数) -> DateOnly
DateOnly DateOnlyFromDayNumber(int dayNumber)
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 日序号 | 整数 | — | The number of days since 0001-01-01, from 0 (0001-01-01) to 3652058 (9999-12-31); any other value throws an System.ArgumentOutOfRangeException. |
返回
| 结果 | DateOnly |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
日
函数重载 1/2
日(值: 时间日期) -> 整数
int Day(DateTime value)
获取时间日期是当月的第几天。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | 时间日期 | — | The date and time. |
返回
| 结果 | 整数 |
重载 2/2
日(值: DateOnly) -> 整数
int Day(DateOnly value)
获取日期是当月的第几天。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | DateOnly | — | The date. |
返回
| 结果 | 整数 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
日序号
函数把日期表示为一个天数编号,即自 0001-01-01 起的天数;两个天数编号相减即为两者相隔的天数。
日序号(值: DateOnly) -> 整数
int DayNumber(DateOnly value)
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | DateOnly | — | The date. |
返回
| 结果 | 整数 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
星期几
函数重载 1/2
星期几(值: 时间日期) -> DayOfWeek
DayOfWeek DayOfWeek(DateTime value)
获取时间日期是星期几。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | 时间日期 | — | The date and time. |
返回
| 结果 | DayOfWeek |
重载 2/2
星期几(值: DateOnly) -> DayOfWeek
DayOfWeek DayOfWeek(DateOnly value)
获取日期是星期几。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | DateOnly | — | The date. |
返回
| 结果 | DayOfWeek |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
一年中的第几天
函数重载 1/2
一年中的第几天(值: 时间日期) -> 整数
int DayOfYear(DateTime value)
获取时间日期是当年的第几天。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | 时间日期 | — | The date and time. |
返回
| 结果 | 整数 |
重载 2/2
一年中的第几天(值: DateOnly) -> 整数
int DayOfYear(DateOnly value)
获取日期是当年的第几天。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | DateOnly | — | The date. |
返回
| 结果 | 整数 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
天数
函数获取时间间隔的天数部分。
天数(值: TimeSpan) -> 整数
int Days(TimeSpan value)
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | TimeSpan | — |
返回
| 结果 | 整数 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
相隔天数
函数计算从一个日期到另一个日期相隔的日历天数。
相隔天数(左侧: DateOnly, 右侧: DateOnly) -> 整数
int DaysBetween(DateOnly left, DateOnly right)
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 左侧 | DateOnly | — | The later date. |
| 右侧 | DateOnly | — | The earlier date. |
返回
| 结果 | 整数 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
月份天数
函数给出公历中某年某月的天数,已考虑闰年。
月份天数(年: 整数, 月: 整数) -> 整数
int DaysInMonth(int year, int month)
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 年 | 整数 | — | The year, from 1 to 9999. |
| 月 | 整数 | — | The month, from 1 to 12; any other value throws an System.ArgumentOutOfRangeException. |
返回
| 结果 | 整数 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
分解
函数重载 1/5
分解(值: 时间日期) -> (年: 整数, 月: 整数, 日: 整数)
void Deconstruct(
DateTime value,
out int year,
out int month,
out int day)把时间日期拆分为年、月、日。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | 时间日期 | — |
返回
| 年 | 整数 |
| 月 | 整数 |
| 日 | 整数 |
重载 2/5
分解(值: 时间日期) -> (日期: DateOnly, 时间: TimeOnly)
void Deconstruct(
DateTime value,
out DateOnly date,
out TimeOnly time)把时间日期拆分为日历日期和时刻。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | 时间日期 | — | The date and time to split; its kind is dropped and no time-zone conversion is made. |
返回
| 日期 | DateOnly |
| 时间 | TimeOnly |
重载 3/5
分解(值: DateOnly) -> (年: 整数, 月: 整数, 日: 整数)
void Deconstruct(
DateOnly value,
out int year,
out int month,
out int day)把日期拆分为年、月、日三个数。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | DateOnly | — | The date to split. |
返回
| 年 | 整数 |
| 月 | 整数 |
| 日 | 整数 |
重载 4/5
分解(值: TimeOnly) -> (时: 整数, 分: 整数, 第二个: 整数)
void Deconstruct(
TimeOnly value,
out int hour,
out int minute,
out int second)把时刻拆分为时、分、秒;不足一秒的部分舍去。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | TimeOnly | — | The time of day to split. |
返回
| 时 | 整数 |
| 分 | 整数 |
| 第二个 | 整数 |
重载 5/5
分解(值: TimeSpan) -> (天数: 整数, 小时数: 整数, 分钟数: 整数, 秒数: 整数)
void Deconstruct(
TimeSpan value,
out int days,
out int hours,
out int minutes,
out int seconds)把时间间隔拆分为整天、时、分、秒;不足一秒的部分舍去,负的时间间隔各部分均为负。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | TimeSpan | — | The duration to split. |
返回
| 天数 | 整数 |
| 小时数 | 整数 |
| 分钟数 | 整数 |
| 秒数 | 整数 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
除以
函数重载 1/2
除以(值: TimeSpan, 除数: 数字) -> TimeSpan
TimeSpan Divide(TimeSpan value, double divisor)
用一个数去除时间间隔,例如把它等分。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | TimeSpan | — | The duration to divide. |
| 除数 | 数字 | — | The number to divide by; NaN throws an System.ArgumentException, and zero throws an System.OverflowException. |
返回
| 结果 | TimeSpan |
重载 2/2
除以(左侧: TimeSpan, 右侧: TimeSpan) -> 数字
double Divide(TimeSpan left, TimeSpan right)
给出两个时间间隔之比,例如一个能容纳几个另一个。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 左侧 | TimeSpan | — | The duration to divide. |
| 右侧 | TimeSpan | — | The duration to divide by; zero gives infinity, or NaN when Left is also zero, instead of an error. |
返回
| 结果 | 数字 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
绝对时长
函数取时间间隔的绝对长度,去掉其正负号。
绝对时长(值: TimeSpan) -> TimeSpan
TimeSpan Duration(TimeSpan value)
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | TimeSpan | — | The duration; TimeSpan.MinValue throws an System.OverflowException because its absolute value does not fit. |
返回
| 结果 | TimeSpan |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
相等
函数重载 1/4
相等(左侧: 时间日期, 右侧: 时间日期) -> 真否
bool Equals(DateTime left, DateTime right)
检查两个时间日期是否相同。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 左侧 | 时间日期 | — | The first date and time. |
| 右侧 | 时间日期 | — | The second date and time. |
返回
| 结果 | 真否 |
备注
Only the tick values are compared and DateTime.Kind is ignored, so a local and a UTC value with the same clock reading are equal. Convert both to UTC first to compare actual points in time.
重载 2/4
相等(左侧: DateOnly, 右侧: DateOnly) -> 真否
bool Equals(DateOnly left, DateOnly right)
检查两个日期是否是同一天。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 左侧 | DateOnly | — | The first date. |
| 右侧 | DateOnly | — | The second date. |
返回
| 结果 | 真否 |
重载 3/4
相等(左侧: TimeOnly, 右侧: TimeOnly) -> 真否
bool Equals(TimeOnly left, TimeOnly right)
检查两个时刻是否相同,精确到计时周期。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 左侧 | TimeOnly | — | The first time of day. |
| 右侧 | TimeOnly | — | The second time of day. |
返回
| 结果 | 真否 |
重载 4/4
相等(左侧: TimeSpan, 右侧: TimeSpan) -> 真否
bool Equals(TimeSpan left, TimeSpan right)
检查两个时间间隔是否一样长,精确到计时周期。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 左侧 | TimeSpan | — | The first duration. |
| 右侧 | TimeSpan | — | The second duration. |
返回
| 结果 | 真否 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
从二进制值还原
函数从“转为二进制值”生成的数字还原时间日期,连同其时间类型。
从二进制值还原(值: 大整数) -> 时间日期
DateTime FromBinary(long value)
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | 大整数 | — | The packed number; one that does not encode a valid date throws an System.ArgumentException. |
返回
| 结果 | 时间日期 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
由日期和时刻组合
函数重载 1/2
由日期和时刻组合(日期: DateOnly, 时间: TimeOnly) -> 时间日期
DateTime FromDateOnlyTimeOnly(DateOnly date, TimeOnly time)
把日期和时刻合成一个时间日期。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 日期 | DateOnly | — | |
| 时间 | TimeOnly | — |
返回
| 结果 | 时间日期 |
重载 2/2
由日期和时刻组合 -> 时间日期
日期: DateOnly
时间: TimeOnly
种类: DateTimeKindDateTime FromDateOnlyTimeOnly(
DateOnly date,
TimeOnly time,
DateTimeKind kind)把一个日期和一个时刻合成一个时间日期,并标为本地时间、UTC 或未指定。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 日期 | DateOnly | — | The calendar date. |
| 时间 | TimeOnly | — | The time of day on that date. |
| 种类 | DateTimeKind | — | Whether the result is local time, UTC or unspecified. |
返回
| 结果 | 时间日期 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
从文件时间转换
函数把 Windows 文件时间转换为本机所在时区的时间日期。
从文件时间转换(值: 大整数) -> 时间日期
DateTime FromFileTime(long value)
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | 大整数 | — | The number of 100-nanosecond intervals since 1601-01-01 00:00:00 UTC; a negative or too-large value throws an System.ArgumentOutOfRangeException. |
返回
| 结果 | 时间日期 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
从 UTC 文件时间转换
函数把 Windows 文件时间转换为 UTC 时间日期。
从 UTC 文件时间转换(值: 大整数) -> 时间日期
DateTime FromFileTimeUtc(long value)
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | 大整数 | — | The number of 100-nanosecond intervals since 1601-01-01 00:00:00 UTC; a negative or too-large value throws an System.ArgumentOutOfRangeException. |
返回
| 结果 | 时间日期 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
从 OLE 自动化日期转换
函数把 OLE 自动化日期(Excel 等 Office 应用表示日期所用的数字格式)转换为时间日期。
从 OLE 自动化日期转换(值: 数字) -> 时间日期
DateTime FromOADate(double value)
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | 数字 | — | The number of days since 1899-12-30, with the time of day as the fraction; values outside -657435 to 2958466 (exclusive) throw an System.ArgumentException. |
返回
| 结果 | 时间日期 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
从 Unix 毫秒时间戳转换
函数把 JavaScript 和许多 Web API 使用的毫秒级 Unix 时间戳转换回 UTC 时间日期。
从 Unix 毫秒时间戳转换(毫秒数: 大整数) -> 时间日期
DateTime FromUnixTimeMilliseconds(long milliseconds)
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 毫秒数 | 大整数 | — | The number of milliseconds since 1970-01-01 00:00:00 UTC, from -62135596800000 to 253402300799999; any other value throws an System.ArgumentOutOfRangeException. |
返回
| 结果 | 时间日期 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
从 Unix 秒时间戳转换
函数把秒级 Unix 时间戳转换回 UTC 时间日期。
从 Unix 秒时间戳转换(秒数: 大整数) -> 时间日期
DateTime FromUnixTimeSeconds(long seconds)
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 秒数 | 大整数 | — | The number of seconds since 1970-01-01 00:00:00 UTC, from -62135596800 to 253402300799; any other value throws an System.ArgumentOutOfRangeException. |
返回
| 结果 | 时间日期 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
日期最大值
函数Gets the largest possible value of System.DateOnly.
日期最大值() -> DateOnly
DateOnly DateOnlyMaxValue()
返回
| 结果 | DateOnly |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
日期最小值
函数Gets the smallest possible value of System.DateOnly.
日期最小值() -> DateOnly
DateOnly DateOnlyMinValue()
返回
| 结果 | DateOnly |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
最大值
函数Gets the largest possible value of System.DateTime.
最大值() -> 时间日期
DateTime MaxValue()
返回
| 结果 | 时间日期 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
最小值
函数Gets the smallest possible value of System.DateTime.
最小值() -> 时间日期
DateTime MinValue()
返回
| 结果 | 时间日期 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
每计时周期纳秒数
函数Gets the number of nanoseconds in one tick.
每计时周期纳秒数() -> 大整数
long NanosecondsPerTick()
返回
| 结果 | 大整数 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
现在
函数Gets the current local date and time.
现在() -> 时间日期
DateTime Now()
返回
| 结果 | 时间日期 |
备注
The returned System.DateTime has DateTime.Kind set to DateTimeKind.Local.
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
每天计时周期数
函数Gets the number of ticks in one day.
每天计时周期数() -> 大整数
long TicksPerDay()
返回
| 结果 | 大整数 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
每小时计时周期数
函数Gets the number of ticks in one hour.
每小时计时周期数() -> 大整数
long TicksPerHour()
返回
| 结果 | 大整数 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
每微秒计时周期数
函数Gets the number of ticks in one microsecond.
每微秒计时周期数() -> 大整数
long TicksPerMicrosecond()
返回
| 结果 | 大整数 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
每毫秒计时周期数
函数Gets the number of ticks in one millisecond.
每毫秒计时周期数() -> 大整数
long TicksPerMillisecond()
返回
| 结果 | 大整数 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
每分钟计时周期数
函数Gets the number of ticks in one minute.
每分钟计时周期数() -> 大整数
long TicksPerMinute()
返回
| 结果 | 大整数 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
每秒计时周期数
函数Gets the number of ticks in one second.
每秒计时周期数() -> 大整数
long TicksPerSecond()
返回
| 结果 | 大整数 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
时刻最大值
函数Gets the largest possible value of System.TimeOnly.
时刻最大值() -> TimeOnly
TimeOnly TimeOnlyMaxValue()
返回
| 结果 | TimeOnly |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
时刻最小值
函数Gets the smallest possible value of System.TimeOnly.
时刻最小值() -> TimeOnly
TimeOnly TimeOnlyMinValue()
返回
| 结果 | TimeOnly |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
时间间隔最大值
函数Gets the largest possible value of System.TimeSpan.
时间间隔最大值() -> TimeSpan
TimeSpan TimeSpanMaxValue()
返回
| 结果 | TimeSpan |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
时间间隔最小值
函数Gets the smallest possible value of System.TimeSpan.
时间间隔最小值() -> TimeSpan
TimeSpan TimeSpanMinValue()
返回
| 结果 | TimeSpan |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
零时间间隔
函数Gets a zero-length System.TimeSpan.
零时间间隔() -> TimeSpan
TimeSpan TimeSpanZero()
返回
| 结果 | TimeSpan |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
今天
函数Gets the current local date with the time set to midnight.
今天() -> 时间日期
DateTime Today()
返回
| 结果 | 时间日期 |
备注
The returned System.DateTime has DateTime.Kind set to DateTimeKind.Local.
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
Unix 纪元
函数Gets the Unix epoch date and time: 1970-01-01 00:00:00 UTC.
Unix 纪元() -> 时间日期
DateTime UnixEpoch()
返回
| 结果 | 时间日期 |
备注
The returned System.DateTime has DateTime.Kind set to DateTimeKind.Utc.
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
当前 UTC 时间
函数Gets the current UTC date and time.
当前 UTC 时间() -> 时间日期
DateTime UtcNow()
返回
| 结果 | 时间日期 |
备注
The returned System.DateTime has DateTime.Kind set to DateTimeKind.Utc.
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
获取时间日期格式
函数重载 1/4
获取时间日期格式(值: 时间日期) -> 文本数组
string[] GetDateTimeFormats(DateTime value)
用当前区域的每种标准格式写出时间日期,便于看出该选哪种格式。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | 时间日期 | — | The date and time to format. |
返回
| 结果 | 文本数组 |
重载 2/4
获取时间日期格式 -> 文本数组
值: 时间日期
提供者: IFormatProviderstring[] GetDateTimeFormats(
DateTime value,
IFormatProvider provider)用给定区域的每种标准格式写出时间日期。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | 时间日期 | — | The date and time to format. |
| 提供者 | IFormatProvider | — | The culture whose conventions to use, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
返回
| 结果 | 文本数组 |
重载 3/4
获取时间日期格式(值: 时间日期, 格式: Char) -> 文本数组
string[] GetDateTimeFormats(DateTime value, char format)
按当前区域中某一标准格式说明符的所有模式写出时间日期。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | 时间日期 | — | The date and time to format. |
| 格式 | Char | — | A standard format specifier such as 'd', 'D', 't' or 'G'; one that is not a standard specifier throws a System.FormatException. |
返回
| 结果 | 文本数组 |
重载 4/4
获取时间日期格式 -> 文本数组
值: 时间日期
格式: Char
提供者: IFormatProviderstring[] GetDateTimeFormats(
DateTime value,
char format,
IFormatProvider provider)按给定区域中某一标准格式说明符的所有模式写出时间日期。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | 时间日期 | — | The date and time to format. |
| 格式 | Char | — | A standard format specifier such as 'd', 'D', 't' or 'G'; one that is not a standard specifier throws a System.FormatException. |
| 提供者 | IFormatProvider | — | The culture whose conventions to use, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
返回
| 结果 | 文本数组 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
大于
函数重载 1/4
大于(左侧: 时间日期, 右侧: 时间日期) -> 真否
bool GreaterThan(DateTime left, DateTime right)
检查一个时间日期是否晚于另一个。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 左侧 | 时间日期 | — | The date and time to test. |
| 右侧 | 时间日期 | — | The date and time to compare against. |
返回
| 结果 | 真否 |
备注
Only the tick values are compared and DateTime.Kind is ignored.
重载 2/4
大于(左侧: DateOnly, 右侧: DateOnly) -> 真否
bool GreaterThan(DateOnly left, DateOnly right)
检查一个日期是否在另一个之后。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 左侧 | DateOnly | — | The date to test. |
| 右侧 | DateOnly | — | The date to compare against. |
返回
| 结果 | 真否 |
重载 3/4
大于(左侧: TimeOnly, 右侧: TimeOnly) -> 真否
bool GreaterThan(TimeOnly left, TimeOnly right)
检查一个时刻是否晚于另一个,从午夜算起,不绕回。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 左侧 | TimeOnly | — | The time of day to test. |
| 右侧 | TimeOnly | — | The time of day to compare against. |
返回
| 结果 | 真否 |
重载 4/4
大于(左侧: TimeSpan, 右侧: TimeSpan) -> 真否
bool GreaterThan(TimeSpan left, TimeSpan right)
检查一个时间间隔是否比另一个长;负的时间间隔视为比零还短。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 左侧 | TimeSpan | — | The duration to test. |
| 右侧 | TimeSpan | — | The duration to compare against. |
返回
| 结果 | 真否 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
大于或等于
函数重载 1/4
大于或等于(左侧: 时间日期, 右侧: 时间日期) -> 真否
bool GreaterThanOrEqual(DateTime left, DateTime right)
检查一个时间日期是否晚于或等于另一个。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 左侧 | 时间日期 | — | The date and time to test. |
| 右侧 | 时间日期 | — | The date and time to compare against. |
返回
| 结果 | 真否 |
备注
Only the tick values are compared and DateTime.Kind is ignored.
重载 2/4
大于或等于(左侧: DateOnly, 右侧: DateOnly) -> 真否
bool GreaterThanOrEqual(DateOnly left, DateOnly right)
检查一个日期是否在另一个之后或与其是同一天。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 左侧 | DateOnly | — | The date to test. |
| 右侧 | DateOnly | — | The date to compare against. |
返回
| 结果 | 真否 |
重载 3/4
大于或等于(左侧: TimeOnly, 右侧: TimeOnly) -> 真否
bool GreaterThanOrEqual(TimeOnly left, TimeOnly right)
检查一个时刻是否晚于或等于另一个,从午夜算起,不绕回。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 左侧 | TimeOnly | — | The time of day to test. |
| 右侧 | TimeOnly | — | The time of day to compare against. |
返回
| 结果 | 真否 |
重载 4/4
大于或等于(左侧: TimeSpan, 右侧: TimeSpan) -> 真否
bool GreaterThanOrEqual(TimeSpan left, TimeSpan right)
检查一个时间间隔是否长于或等于另一个;负的时间间隔视为比零还短。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 左侧 | TimeSpan | — | The duration to test. |
| 右侧 | TimeSpan | — | The duration to compare against. |
返回
| 结果 | 真否 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
小时
函数重载 1/2
小时(值: 时间日期) -> 整数
int Hour(DateTime value)
获取时间日期的小时(24 小时制)。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | 时间日期 | — | The date and time. |
返回
| 结果 | 整数 |
重载 2/2
小时(值: TimeOnly) -> 整数
int Hour(TimeOnly value)
获取时刻的小时部分。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | TimeOnly | — |
返回
| 结果 | 整数 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
小时数
函数获取时间间隔的小时部分,即去掉整天后剩下的部分;要得到整个时间间隔折合的小时数,请用“总小时数”。
小时数(值: TimeSpan) -> 整数
int Hours(TimeSpan value)
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | TimeSpan | — | The duration. |
返回
| 结果 | 整数 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
是否介于两者之间
函数检查时刻是否落在某个范围内,包括 22:00 到 06:00 这样跨过午夜的范围。
是否介于两者之间 -> 真否
值: TimeOnly
起点: TimeOnly
终点: TimeOnlybool IsBetween(TimeOnly value, TimeOnly start, TimeOnly end)
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | TimeOnly | — | The time of day to test. |
| 起点 | TimeOnly | — | The start of the range, included. |
| 终点 | TimeOnly | — | The end of the range, excluded; when earlier than Start the range runs through midnight. |
返回
| 结果 | 真否 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
是否为夏令时
函数检查时间日期是否处于本机所在时区的夏令时内。
是否为夏令时(值: 时间日期) -> 真否
bool IsDaylightSavingTime(DateTime value)
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | 时间日期 | — | The date and time; a UTC value always gives false, and a local or unspecified value is read as local time. |
返回
| 结果 | 真否 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
是否为闰年
函数判断给定年份是否为闰年。
是否为闰年(年: 整数) -> 真否
bool IsLeapYear(int year)
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 年 | 整数 | — |
返回
| 结果 | 真否 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
时间种类
函数说明时间日期被标为本地时间、UTC 还是未指定。
时间种类(值: 时间日期) -> DateTimeKind
DateTimeKind Kind(DateTime value)
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | 时间日期 | — | The date and time to inspect. |
返回
| 结果 | DateTimeKind |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
小于
函数重载 1/4
小于(左侧: 时间日期, 右侧: 时间日期) -> 真否
bool LessThan(DateTime left, DateTime right)
检查一个时间日期是否早于另一个。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 左侧 | 时间日期 | — | The date and time to test. |
| 右侧 | 时间日期 | — | The date and time to compare against. |
返回
| 结果 | 真否 |
备注
Only the tick values are compared and DateTime.Kind is ignored.
重载 2/4
小于(左侧: DateOnly, 右侧: DateOnly) -> 真否
bool LessThan(DateOnly left, DateOnly right)
检查一个日期是否在另一个之前。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 左侧 | DateOnly | — | The date to test. |
| 右侧 | DateOnly | — | The date to compare against. |
返回
| 结果 | 真否 |
重载 3/4
小于(左侧: TimeOnly, 右侧: TimeOnly) -> 真否
bool LessThan(TimeOnly left, TimeOnly right)
检查一个时刻是否早于另一个,从午夜算起,不绕回。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 左侧 | TimeOnly | — | The time of day to test. |
| 右侧 | TimeOnly | — | The time of day to compare against. |
返回
| 结果 | 真否 |
重载 4/4
小于(左侧: TimeSpan, 右侧: TimeSpan) -> 真否
bool LessThan(TimeSpan left, TimeSpan right)
检查一个时间间隔是否比另一个短;负的时间间隔视为比零还短。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 左侧 | TimeSpan | — | The duration to test. |
| 右侧 | TimeSpan | — | The duration to compare against. |
返回
| 结果 | 真否 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
小于或等于
函数重载 1/4
小于或等于(左侧: 时间日期, 右侧: 时间日期) -> 真否
bool LessThanOrEqual(DateTime left, DateTime right)
检查一个时间日期是否早于或等于另一个。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 左侧 | 时间日期 | — | The date and time to test. |
| 右侧 | 时间日期 | — | The date and time to compare against. |
返回
| 结果 | 真否 |
备注
Only the tick values are compared and DateTime.Kind is ignored.
重载 2/4
小于或等于(左侧: DateOnly, 右侧: DateOnly) -> 真否
bool LessThanOrEqual(DateOnly left, DateOnly right)
检查一个日期是否在另一个之前或与其是同一天。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 左侧 | DateOnly | — | The date to test. |
| 右侧 | DateOnly | — | The date to compare against. |
返回
| 结果 | 真否 |
重载 3/4
小于或等于(左侧: TimeOnly, 右侧: TimeOnly) -> 真否
bool LessThanOrEqual(TimeOnly left, TimeOnly right)
检查一个时刻是否早于或等于另一个,从午夜算起,不绕回。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 左侧 | TimeOnly | — | The time of day to test. |
| 右侧 | TimeOnly | — | The time of day to compare against. |
返回
| 结果 | 真否 |
重载 4/4
小于或等于(左侧: TimeSpan, 右侧: TimeSpan) -> 真否
bool LessThanOrEqual(TimeSpan left, TimeSpan right)
检查一个时间间隔是否短于或等于另一个;负的时间间隔视为比零还短。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 左侧 | TimeSpan | — | The duration to test. |
| 右侧 | TimeSpan | — | The duration to compare against. |
返回
| 结果 | 真否 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
微秒
函数重载 1/2
微秒(值: 时间日期) -> 整数
int Microsecond(DateTime value)
获取时间日期的微秒部分。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | 时间日期 | — | The date and time. |
返回
| 结果 | 整数 |
重载 2/2
微秒(值: TimeOnly) -> 整数
int Microsecond(TimeOnly value)
获取时刻的微秒部分。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | TimeOnly | — | The time of day. |
返回
| 结果 | 整数 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
微秒数
函数获取时间间隔的微秒部分,即去掉整毫秒后剩下的部分;要得到整个时间间隔折合的微秒数,请用“总微秒数”。
微秒数(值: TimeSpan) -> 整数
int Microseconds(TimeSpan value)
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | TimeSpan | — | The duration. |
返回
| 结果 | 整数 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
毫秒
函数重载 1/2
毫秒(值: 时间日期) -> 整数
int Millisecond(DateTime value)
获取时间日期的毫秒部分。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | 时间日期 | — | The date and time. |
返回
| 结果 | 整数 |
重载 2/2
毫秒(值: TimeOnly) -> 整数
int Millisecond(TimeOnly value)
获取时刻的毫秒部分。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | TimeOnly | — | The time of day. |
返回
| 结果 | 整数 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
毫秒数
函数获取时间间隔的毫秒部分,即去掉整秒后剩下的部分;要得到整个时间间隔折合的毫秒数,请用“总毫秒数”。
毫秒数(值: TimeSpan) -> 整数
int Milliseconds(TimeSpan value)
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | TimeSpan | — | The duration. |
返回
| 结果 | 整数 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
分
函数重载 1/2
分(值: 时间日期) -> 整数
int Minute(DateTime value)
获取时间日期的分钟。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | 时间日期 | — | The date and time. |
返回
| 结果 | 整数 |
重载 2/2
分(值: TimeOnly) -> 整数
int Minute(TimeOnly value)
获取时刻的分钟。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | TimeOnly | — | The time of day. |
返回
| 结果 | 整数 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
分钟数
函数获取时间间隔的分钟部分,即去掉整小时后剩下的部分;要得到整个时间间隔折合的分钟数,请用“总分钟数”。
分钟数(值: TimeSpan) -> 整数
int Minutes(TimeSpan value)
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | TimeSpan | — | The duration. |
返回
| 结果 | 整数 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
月
函数重载 1/2
月(值: 时间日期) -> 整数
int Month(DateTime value)
获取时间日期的月份。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | 时间日期 | — | The date and time. |
返回
| 结果 | 整数 |
重载 2/2
月(值: DateOnly) -> 整数
int Month(DateOnly value)
获取日期的月份。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | DateOnly | — | The date. |
返回
| 结果 | 整数 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
乘以
函数把时间间隔乘以一个倍数,例如求它的三倍或一半。
乘以(值: TimeSpan, 系数: 数字) -> TimeSpan
TimeSpan Multiply(TimeSpan value, double factor)
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | TimeSpan | — | The duration to scale. |
| 系数 | 数字 | — | The multiplier, which may be fractional or negative; NaN throws an System.ArgumentException. |
返回
| 结果 | TimeSpan |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
纳秒
函数重载 1/2
纳秒(值: 时间日期) -> 整数
int Nanosecond(DateTime value)
获取时间日期的纳秒部分。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | 时间日期 | — | The date and time. |
返回
| 结果 | 整数 |
重载 2/2
纳秒(值: TimeOnly) -> 整数
int Nanosecond(TimeOnly value)
获取时刻的纳秒部分。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | TimeOnly | — | The time of day. |
返回
| 结果 | 整数 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
纳秒数
函数获取时间间隔的纳秒部分,即去掉整微秒后剩下的部分。
纳秒数(值: TimeSpan) -> 整数
int Nanoseconds(TimeSpan value)
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | TimeSpan | — | The duration. |
返回
| 结果 | 整数 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
取反
函数取时间间隔的相反数:5 分钟变成 -5 分钟,反之亦然。
取反(值: TimeSpan) -> TimeSpan
TimeSpan Negate(TimeSpan value)
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | TimeSpan | — | The duration to negate; TimeSpan.MinValue throws an System.OverflowException because its negation does not fit. |
返回
| 结果 | TimeSpan |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
不相等
函数重载 1/4
不相等(左侧: 时间日期, 右侧: 时间日期) -> 真否
bool NotEquals(DateTime left, DateTime right)
检查两个时间日期是否不同。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 左侧 | 时间日期 | — | The first date and time. |
| 右侧 | 时间日期 | — | The second date and time. |
返回
| 结果 | 真否 |
备注
Only the tick values are compared and DateTime.Kind is ignored.
重载 2/4
不相等(左侧: DateOnly, 右侧: DateOnly) -> 真否
bool NotEquals(DateOnly left, DateOnly right)
检查两个日期是否不是同一天。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 左侧 | DateOnly | — | The first date. |
| 右侧 | DateOnly | — | The second date. |
返回
| 结果 | 真否 |
重载 3/4
不相等(左侧: TimeOnly, 右侧: TimeOnly) -> 真否
bool NotEquals(TimeOnly left, TimeOnly right)
检查两个时刻是否不同。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 左侧 | TimeOnly | — | The first time of day. |
| 右侧 | TimeOnly | — | The second time of day. |
返回
| 结果 | 真否 |
重载 4/4
不相等(左侧: TimeSpan, 右侧: TimeSpan) -> 真否
bool NotEquals(TimeSpan left, TimeSpan right)
检查两个时间间隔的长度是否不同。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 左侧 | TimeSpan | — | The first duration. |
| 右侧 | TimeSpan | — | The second duration. |
返回
| 结果 | 真否 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
解析时间日期
函数重载 1/3
解析时间日期(文本: 文本) -> 时间日期
DateTime Parse(string s)
把文本解析为时间日期。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 文本 | 文本 | — |
返回
| 结果 | 时间日期 |
重载 2/3
解析时间日期(文本: 文本, 提供者: IFormatProvider) -> 时间日期
DateTime Parse(string s, IFormatProvider provider)
按给定区域的写法从文本中读取时间日期。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 文本 | 文本 | — | The text to read; null throws an System.ArgumentNullException and text that is not a date and time throws a System.FormatException. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
返回
| 结果 | 时间日期 |
重载 3/3
解析时间日期 -> 时间日期
文本: 文本
提供者: IFormatProvider
样式: DateTimeStylesDateTime Parse(
string s,
IFormatProvider provider,
DateTimeStyles styles)按给定区域的写法从文本中读取时间日期,可设置如何处理空白和时区。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 文本 | 文本 | — | The text to read; null throws an System.ArgumentNullException and text that is not a date and time throws a System.FormatException. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
| 样式 | DateTimeStyles | — | Options such as DateTimeStyles.AdjustToUniversal or DateTimeStyles.AssumeUniversal; a contradictory combination throws an System.ArgumentException. |
返回
| 结果 | 时间日期 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
解析日期
函数重载 1/3
解析日期(文本: 文本) -> DateOnly
DateOnly ParseDateOnly(string s)
把文本解析为日期。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 文本 | 文本 | — |
返回
| 结果 | DateOnly |
重载 2/3
解析日期(文本: 文本, 提供者: IFormatProvider) -> DateOnly
DateOnly ParseDateOnly(string s, IFormatProvider provider)
按给定区域的写法从文本中读取日期;文本中不能含有时刻。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 文本 | 文本 | — | The text to read; null throws an System.ArgumentNullException and text that is not a date, or that includes a time, throws a System.FormatException. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
返回
| 结果 | DateOnly |
重载 3/3
解析日期 -> DateOnly
文本: 文本
提供者: IFormatProvider
样式: DateTimeStylesDateOnly ParseDateOnly(
string s,
IFormatProvider provider,
DateTimeStyles styles)按给定区域的写法从文本中读取日期,可设置如何处理空白。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 文本 | 文本 | — | The text to read; null throws an System.ArgumentNullException and text that is not a date, or that includes a time, throws a System.FormatException. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
| 样式 | DateTimeStyles | — | White-space options only, such as DateTimeStyles.AllowWhiteSpaces; any other style throws an System.ArgumentException. |
返回
| 结果 | DateOnly |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
按格式解析时间日期
函数重载 1/3
按格式解析时间日期 -> 时间日期
文本: 文本
格式: 文本
提供者: IFormatProviderDateTime ParseExact(
string s,
string format,
IFormatProvider provider)从必须完全符合某一格式(如 "yyyy-MM-dd HH:mm:ss")的文本中读取时间日期。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 文本 | 文本 | — | The text to read; null throws an System.ArgumentNullException and text that does not match the format throws a System.FormatException. |
| 格式 | 文本 | — | The standard or custom format the text must match. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
返回
| 结果 | 时间日期 |
重载 2/3
按格式解析时间日期 -> 时间日期
文本: 文本
格式: 文本
提供者: IFormatProvider
样式: DateTimeStylesDateTime ParseExact(
string s,
string format,
IFormatProvider provider,
DateTimeStyles styles)从必须完全符合某一格式的文本中读取时间日期,可设置如何处理空白和时区。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 文本 | 文本 | — | The text to read; null throws an System.ArgumentNullException and text that does not match the format throws a System.FormatException. |
| 格式 | 文本 | — | The standard or custom format the text must match. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
| 样式 | DateTimeStyles | — | Options such as DateTimeStyles.AllowWhiteSpaces or DateTimeStyles.AssumeUniversal; a contradictory combination throws an System.ArgumentException. |
返回
| 结果 | 时间日期 |
重载 3/3
按格式解析时间日期 -> 时间日期
文本: 文本
格式: 文本数组
提供者: IFormatProvider
样式: DateTimeStylesDateTime ParseExact(
string s,
string[] formats,
IFormatProvider provider,
DateTimeStyles styles)从必须完全符合若干格式之一的文本中读取时间日期,适用于输入有多种排布的情况。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 文本 | 文本 | — | The text to read; null throws an System.ArgumentNullException and text that matches none of the formats throws a System.FormatException. |
| 格式 | 文本数组 | — | The formats to try; the first that matches is used. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
| 样式 | DateTimeStyles | — | Options such as DateTimeStyles.AllowWhiteSpaces or DateTimeStyles.AssumeUniversal; a contradictory combination throws an System.ArgumentException. |
返回
| 结果 | 时间日期 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
按格式解析日期
函数重载 1/3
按格式解析日期 -> DateOnly
文本: 文本
格式: 文本
提供者: IFormatProviderDateOnly ParseExactDateOnly(
string s,
string format,
IFormatProvider provider)从必须完全符合某一格式(如 "yyyy-MM-dd")的文本中读取日期。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 文本 | 文本 | — | The text to read; null throws an System.ArgumentNullException and text that does not match the format throws a System.FormatException. |
| 格式 | 文本 | — | The standard or custom date format the text must match. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
返回
| 结果 | DateOnly |
重载 2/3
按格式解析日期 -> DateOnly
文本: 文本
格式: 文本
提供者: IFormatProvider
样式: DateTimeStylesDateOnly ParseExactDateOnly(
string s,
string format,
IFormatProvider provider,
DateTimeStyles styles)从必须完全符合某一格式的文本中读取日期,可设置如何处理空白。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 文本 | 文本 | — | The text to read; null throws an System.ArgumentNullException and text that does not match the format throws a System.FormatException. |
| 格式 | 文本 | — | The standard or custom date format the text must match. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
| 样式 | DateTimeStyles | — | White-space options only, such as DateTimeStyles.AllowWhiteSpaces; any other style throws an System.ArgumentException. |
返回
| 结果 | DateOnly |
重载 3/3
按格式解析日期 -> DateOnly
文本: 文本
格式: 文本数组
提供者: IFormatProvider
样式: DateTimeStylesDateOnly ParseExactDateOnly(
string s,
string[] formats,
IFormatProvider provider,
DateTimeStyles styles)从必须完全符合若干格式之一的文本中读取日期,适用于输入有多种排布的情况。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 文本 | 文本 | — | The text to read; null throws an System.ArgumentNullException and text that matches none of the formats throws a System.FormatException. |
| 格式 | 文本数组 | — | The date formats to try; the first that matches is used. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
| 样式 | DateTimeStyles | — | White-space options only, such as DateTimeStyles.AllowWhiteSpaces; any other style throws an System.ArgumentException. |
返回
| 结果 | DateOnly |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
按格式解析时刻
函数重载 1/3
按格式解析时刻 -> TimeOnly
文本: 文本
格式: 文本
提供者: IFormatProviderTimeOnly ParseExactTimeOnly(
string s,
string format,
IFormatProvider provider)从必须完全符合某一格式(如 "HH:mm:ss")的文本中读取时刻。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 文本 | 文本 | — | The text to read; null throws an System.ArgumentNullException and text that does not match the format throws a System.FormatException. |
| 格式 | 文本 | — | The standard or custom time format the text must match. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
返回
| 结果 | TimeOnly |
重载 2/3
按格式解析时刻 -> TimeOnly
文本: 文本
格式: 文本
提供者: IFormatProvider
样式: DateTimeStylesTimeOnly ParseExactTimeOnly(
string s,
string format,
IFormatProvider provider,
DateTimeStyles styles)从必须完全符合某一格式的文本中读取时刻,可设置如何处理空白。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 文本 | 文本 | — | The text to read; null throws an System.ArgumentNullException and text that does not match the format throws a System.FormatException. |
| 格式 | 文本 | — | The standard or custom time format the text must match. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
| 样式 | DateTimeStyles | — | White-space options only, such as DateTimeStyles.AllowWhiteSpaces; any other style throws an System.ArgumentException. |
返回
| 结果 | TimeOnly |
重载 3/3
按格式解析时刻 -> TimeOnly
文本: 文本
格式: 文本数组
提供者: IFormatProvider
样式: DateTimeStylesTimeOnly ParseExactTimeOnly(
string s,
string[] formats,
IFormatProvider provider,
DateTimeStyles styles)从必须完全符合若干格式之一的文本中读取时刻,适用于输入有多种排布的情况。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 文本 | 文本 | — | The text to read; null throws an System.ArgumentNullException and text that matches none of the formats throws a System.FormatException. |
| 格式 | 文本数组 | — | The time formats to try; the first that matches is used. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
| 样式 | DateTimeStyles | — | White-space options only, such as DateTimeStyles.AllowWhiteSpaces; any other style throws an System.ArgumentException. |
返回
| 结果 | TimeOnly |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
按格式解析时间间隔
函数重载 1/4
按格式解析时间间隔 -> TimeSpan
输入: 文本
格式: 文本
提供者: IFormatProviderTimeSpan ParseExactTimeSpan(
string input,
string format,
IFormatProvider provider)从必须完全符合某一格式(如 "c" 或 @"hh\:mm" 这样的自定义格式)的文本中读取时间间隔。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 输入 | 文本 | — | The text to read; null throws an System.ArgumentNullException, text that does not match throws a System.FormatException, and a value beyond the System.TimeSpan range throws an System.OverflowException. |
| 格式 | 文本 | — | The standard or custom format the text must match. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
返回
| 结果 | TimeSpan |
重载 2/4
按格式解析时间间隔 -> TimeSpan
输入: 文本
格式: 文本
提供者: IFormatProvider
样式: TimeSpanStylesTimeSpan ParseExactTimeSpan(
string input,
string format,
IFormatProvider provider,
TimeSpanStyles styles)从必须完全符合某一格式的文本中读取时间间隔,可选择将其视为负值。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 输入 | 文本 | — | The text to read; null throws an System.ArgumentNullException, text that does not match throws a System.FormatException, and a value beyond the System.TimeSpan range throws an System.OverflowException. |
| 格式 | 文本 | — | The standard or custom format the text must match. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
| 样式 | TimeSpanStyles | — | TimeSpanStyles.AssumeNegative makes a custom-format result negative; TimeSpanStyles.None leaves it as written. |
返回
| 结果 | TimeSpan |
重载 3/4
按格式解析时间间隔 -> TimeSpan
输入: 文本
格式: 文本数组
提供者: IFormatProviderTimeSpan ParseExactTimeSpan(
string input,
string[] formats,
IFormatProvider provider)从必须完全符合若干格式之一的文本中读取时间间隔,适用于输入有多种排布的情况。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 输入 | 文本 | — | The text to read; null throws an System.ArgumentNullException, text that matches none of the formats throws a System.FormatException, and a value beyond the System.TimeSpan range throws an System.OverflowException. |
| 格式 | 文本数组 | — | The formats to try; the first that matches is used. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
返回
| 结果 | TimeSpan |
重载 4/4
按格式解析时间间隔 -> TimeSpan
输入: 文本
格式: 文本数组
提供者: IFormatProvider
样式: TimeSpanStylesTimeSpan ParseExactTimeSpan(
string input,
string[] formats,
IFormatProvider provider,
TimeSpanStyles styles)从必须完全符合若干格式之一的文本中读取时间间隔,可选择将其视为负值。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 输入 | 文本 | — | The text to read; null throws an System.ArgumentNullException, text that matches none of the formats throws a System.FormatException, and a value beyond the System.TimeSpan range throws an System.OverflowException. |
| 格式 | 文本数组 | — | The formats to try; the first that matches is used. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
| 样式 | TimeSpanStyles | — | TimeSpanStyles.AssumeNegative makes a custom-format result negative; TimeSpanStyles.None leaves it as written. |
返回
| 结果 | TimeSpan |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
解析时刻
函数重载 1/3
解析时刻(文本: 文本) -> TimeOnly
TimeOnly ParseTimeOnly(string s)
把文本解析为时刻。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 文本 | 文本 | — |
返回
| 结果 | TimeOnly |
重载 2/3
解析时刻(文本: 文本, 提供者: IFormatProvider) -> TimeOnly
TimeOnly ParseTimeOnly(string s, IFormatProvider provider)
按给定区域的写法从文本中读取时刻;文本中不能含有日期。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 文本 | 文本 | — | The text to read; null throws an System.ArgumentNullException and text that is not a time, or that includes a date, throws a System.FormatException. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
返回
| 结果 | TimeOnly |
重载 3/3
解析时刻 -> TimeOnly
文本: 文本
提供者: IFormatProvider
样式: DateTimeStylesTimeOnly ParseTimeOnly(
string s,
IFormatProvider provider,
DateTimeStyles styles)按给定区域的写法从文本中读取时刻,可设置如何处理空白。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 文本 | 文本 | — | The text to read; null throws an System.ArgumentNullException and text that is not a time, or that includes a date, throws a System.FormatException. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
| 样式 | DateTimeStyles | — | White-space options only, such as DateTimeStyles.AllowWhiteSpaces; any other style throws an System.ArgumentException. |
返回
| 结果 | TimeOnly |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
解析时间间隔
函数重载 1/2
解析时间间隔(文本: 文本) -> TimeSpan
TimeSpan ParseTimeSpan(string s)
把文本解析为时间间隔。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 文本 | 文本 | — |
返回
| 结果 | TimeSpan |
重载 2/2
解析时间间隔(文本: 文本, 提供者: IFormatProvider) -> TimeSpan
TimeSpan ParseTimeSpan(string s, IFormatProvider provider)
从形如 [-][d.]hh:mm[:ss[.fffffff]] 的文本中读取时间间隔,例如 "1.02:30:00" 表示一天两个半小时,小数点按给定区域的写法。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 文本 | 文本 | — | The text to read; null throws an System.ArgumentNullException, text in the wrong form throws a System.FormatException, and a part out of range (such as 24 hours) or a total beyond the System.TimeSpan range throws an System.OverflowException. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
返回
| 结果 | TimeSpan |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
秒
函数重载 1/2
秒(值: 时间日期) -> 整数
int Second(DateTime value)
获取时间日期的秒。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | 时间日期 | — | The date and time. |
返回
| 结果 | 整数 |
重载 2/2
秒(值: TimeOnly) -> 整数
int Second(TimeOnly value)
获取时刻的秒。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | TimeOnly | — | The time of day. |
返回
| 结果 | 整数 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
秒数
函数获取时间间隔的秒部分,即去掉整分钟后剩下的部分;要得到整个时间间隔折合的秒数,请用“总秒数”。
秒数(值: TimeSpan) -> 整数
int Seconds(TimeSpan value)
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | TimeSpan | — | The duration. |
返回
| 结果 | 整数 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
指定时间种类
函数创建一个计时周期与给定值相同、但时间类型为指定类型的新时间日期。
指定时间种类(值: 时间日期, 种类: DateTimeKind) -> 时间日期
DateTime SpecifyKind(DateTime value, DateTimeKind kind)
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | 时间日期 | — | |
| 种类 | DateTimeKind | — |
返回
| 结果 | 时间日期 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
减去
函数重载 1/4
减去(左侧: 时间日期, 右侧: 时间日期) -> TimeSpan
TimeSpan Subtract(DateTime left, DateTime right)
计算从一个时间日期到另一个经过的时间。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 左侧 | 时间日期 | — | The later date and time. |
| 右侧 | 时间日期 | — | The earlier date and time. |
返回
| 结果 | TimeSpan |
备注
The tick values are subtracted directly and DateTime.Kind is ignored, so convert both values to UTC first if one is local and the other UTC.
重载 2/4
减去(值: 时间日期, 增量: TimeSpan) -> 时间日期
DateTime Subtract(DateTime value, TimeSpan delta)
把时间日期提前一段时间间隔。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | 时间日期 | — | The starting date and time; its kind is kept. |
| 增量 | TimeSpan | — | The duration to subtract; a negative duration moves forward. |
返回
| 结果 | 时间日期 |
重载 3/4
减去(左侧: TimeOnly, 右侧: TimeOnly) -> TimeSpan
TimeSpan Subtract(TimeOnly left, TimeOnly right)
计算钟表从一个时刻向前走到另一个时刻需要多久,必要时越过午夜。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 左侧 | TimeOnly | — | The time of day to reach. |
| 右侧 | TimeOnly | — | The time of day to start from. |
返回
| 结果 | TimeSpan |
备注
The result is never negative: from 23:00 to 01:00 is 2 hours, not -22 hours.
重载 4/4
减去(左侧: TimeSpan, 右侧: TimeSpan) -> TimeSpan
TimeSpan Subtract(TimeSpan left, TimeSpan right)
从一个时间间隔中减去另一个。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 左侧 | TimeSpan | — | The duration to subtract from. |
| 右侧 | TimeSpan | — | The duration to subtract. |
返回
| 结果 | TimeSpan |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
计时周期数
函数重载 1/3
计时周期数(值: 时间日期) -> 大整数
long Ticks(DateTime value)
把时间日期表示为一个计时周期数,便于存储或做精确运算。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | 时间日期 | — | The date and time. |
返回
| 结果 | 大整数 |
重载 2/3
计时周期数(值: TimeOnly) -> 大整数
long Ticks(TimeOnly value)
把时刻表示为自午夜起的计时周期数。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | TimeOnly | — | The time of day. |
返回
| 结果 | 大整数 |
重载 3/3
计时周期数(值: TimeSpan) -> 大整数
long Ticks(TimeSpan value)
把时间间隔表示为一个计时周期数,便于存储或做精确运算。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | TimeSpan | — | The duration. |
返回
| 结果 | 大整数 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
相隔时间
函数计算从一个日期到另一个日期的时间,结果是以整天计的时间间隔。
相隔时间(左侧: DateOnly, 右侧: DateOnly) -> TimeSpan
TimeSpan TimeBetween(DateOnly left, DateOnly right)
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 左侧 | DateOnly | — | The later date. |
| 右侧 | DateOnly | — | The earlier date. |
返回
| 结果 | TimeSpan |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
一天中的时刻
函数获取时间日期的时刻,表示为自午夜起的时间间隔。
一天中的时刻(值: 时间日期) -> TimeSpan
TimeSpan TimeOfDay(DateTime value)
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | 时间日期 | — | The date and time. |
返回
| 结果 | TimeSpan |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
从时间日期取时刻
函数取时间日期的时刻,去掉其日期。
从时间日期取时刻(值: 时间日期) -> TimeOnly
TimeOnly TimeOnlyFromDateTime(DateTime value)
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | 时间日期 | — | The date and time to take the time of day from; its kind is ignored and no time-zone conversion is made. |
返回
| 结果 | TimeOnly |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
从计时周期数取时刻
函数用自午夜起的计时周期数创建时刻。
从计时周期数取时刻(计时周期数: 大整数) -> TimeOnly
TimeOnly TimeOnlyFromTicks(long ticks)
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 计时周期数 | 大整数 | — | The number of 100-nanosecond ticks since midnight, from 0 to one less than TimeSpan.TicksPerDay; any other value throws an System.ArgumentOutOfRangeException. |
返回
| 结果 | TimeOnly |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
从时间间隔取时刻
函数把自午夜起的时间间隔转换为时刻,例如把 13 小时转换为 13:00。
从时间间隔取时刻(值: TimeSpan) -> TimeOnly
TimeOnly TimeOnlyFromTimeSpan(TimeSpan value)
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | TimeSpan | — | The time elapsed since midnight; must be at least zero and less than one day, otherwise an System.ArgumentOutOfRangeException is thrown. |
返回
| 结果 | TimeOnly |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
由天数生成时间间隔
函数用天数创建时间间隔,天数可以是小数或负数(1.5 即一天半)。
由天数生成时间间隔(天数: 数字) -> TimeSpan
TimeSpan TimeSpanFromDays(double days)
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 天数 | 数字 | — | The number of days; NaN throws an System.ArgumentException and a value beyond the System.TimeSpan range throws an System.OverflowException. |
返回
| 结果 | TimeSpan |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
由小时数生成时间间隔
函数用小时数创建时间间隔,可以是小数或负数。
由小时数生成时间间隔(小时数: 数字) -> TimeSpan
TimeSpan TimeSpanFromHours(double hours)
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 小时数 | 数字 | — | The number of hours; NaN throws an System.ArgumentException and a value beyond the System.TimeSpan range throws an System.OverflowException. |
返回
| 结果 | TimeSpan |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
由微秒数生成时间间隔
函数用微秒数创建时间间隔,可以是小数或负数。
由微秒数生成时间间隔(微秒数: 数字) -> TimeSpan
TimeSpan TimeSpanFromMicroseconds(double microseconds)
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 微秒数 | 数字 | — | The number of microseconds; NaN throws an System.ArgumentException and a value beyond the System.TimeSpan range throws an System.OverflowException. |
返回
| 结果 | TimeSpan |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
由毫秒数生成时间间隔
函数用毫秒数创建时间间隔,可以是小数或负数。
由毫秒数生成时间间隔(毫秒数: 数字) -> TimeSpan
TimeSpan TimeSpanFromMilliseconds(double milliseconds)
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 毫秒数 | 数字 | — | The number of milliseconds; NaN throws an System.ArgumentException and a value beyond the System.TimeSpan range throws an System.OverflowException. |
返回
| 结果 | TimeSpan |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
由分钟数生成时间间隔
函数用分钟数创建时间间隔,可以是小数或负数。
由分钟数生成时间间隔(分钟数: 数字) -> TimeSpan
TimeSpan TimeSpanFromMinutes(double minutes)
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 分钟数 | 数字 | — | The number of minutes; NaN throws an System.ArgumentException and a value beyond the System.TimeSpan range throws an System.OverflowException. |
返回
| 结果 | TimeSpan |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
由秒数生成时间间隔
函数用秒数创建时间间隔,可以是小数或负数。
由秒数生成时间间隔(秒数: 数字) -> TimeSpan
TimeSpan TimeSpanFromSeconds(double seconds)
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 秒数 | 数字 | — | The number of seconds; NaN throws an System.ArgumentException and a value beyond the System.TimeSpan range throws an System.OverflowException. |
返回
| 结果 | TimeSpan |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
由计时周期数生成时间间隔
函数用计时周期数创建时间间隔,一个计时周期为 100 纳秒。
由计时周期数生成时间间隔(计时周期数: 大整数) -> TimeSpan
TimeSpan TimeSpanFromTicks(long ticks)
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 计时周期数 | 大整数 | — | The number of ticks; may be negative. |
返回
| 结果 | TimeSpan |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
时间间隔转为时刻
函数把自午夜起的时间间隔转换为时刻,例如把 13 小时转换为 13:00。
时间间隔转为时刻(值: TimeSpan) -> TimeOnly
TimeOnly TimeSpanToTimeOnly(TimeSpan value)
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | TimeSpan | — | The time elapsed since midnight; must be at least zero and less than one day, otherwise an System.ArgumentOutOfRangeException is thrown. |
返回
| 结果 | TimeOnly |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
转为二进制值
函数把时间日期连同其时间类型打包成一个 64 位数字以便存储;“从二进制值还原”可把它还原。
转为二进制值(值: 时间日期) -> 大整数
long ToBinary(DateTime value)
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | 时间日期 | — | The date and time to pack. |
返回
| 结果 | 大整数 |
备注
A local value is stored as its UTC instant, so restoring it on a machine in another time zone gives the same moment in that machine's local time.
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
转为日期
函数取时间日期的日历日期,去掉其时刻。
转为日期(值: 时间日期) -> DateOnly
DateOnly ToDateOnly(DateTime value)
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | 时间日期 | — | The date and time to take the date from; its kind is ignored and no time-zone conversion is made. |
返回
| 结果 | DateOnly |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
转为时间日期
函数重载 1/2
转为时间日期(日期: DateOnly, 时间: TimeOnly) -> 时间日期
DateTime ToDateTime(DateOnly date, TimeOnly time)
把一个日期和一个时刻合成一个时间日期。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 日期 | DateOnly | — | The calendar date. |
| 时间 | TimeOnly | — | The time of day on that date. |
返回
| 结果 | 时间日期 |
重载 2/2
转为时间日期 -> 时间日期
日期: DateOnly
时间: TimeOnly
种类: DateTimeKindDateTime ToDateTime(
DateOnly date,
TimeOnly time,
DateTimeKind kind)把一个日期和一个时刻合成一个时间日期,并标为本地时间、UTC 或未指定。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 日期 | DateOnly | — | The calendar date. |
| 时间 | TimeOnly | — | The time of day on that date. |
| 种类 | DateTimeKind | — | Whether the result is local time, UTC or unspecified. |
返回
| 结果 | 时间日期 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
转为文件时间
函数把时间日期转换为 Windows 文件时间:自 1601-01-01 00:00:00 UTC 起经过的 100 纳秒间隔数。
转为文件时间(值: 时间日期) -> 大整数
long ToFileTime(DateTime value)
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | 时间日期 | — | The date and time; a local or unspecified value is treated as local time and converted to UTC first. |
返回
| 结果 | 大整数 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
转为 UTC 文件时间
函数把时间日期转换为 Windows 文件时间,未指定类型的值视为已是 UTC。
转为 UTC 文件时间(值: 时间日期) -> 大整数
long ToFileTimeUtc(DateTime value)
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | 时间日期 | — | The date and time; only a local value is converted to UTC first, while UTC and unspecified values are used as they are. |
返回
| 结果 | 大整数 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
转为本地时间
函数把时间日期转换为本地时间。
转为本地时间(值: 时间日期) -> 时间日期
DateTime ToLocalTime(DateTime value)
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | 时间日期 | — |
返回
| 结果 | 时间日期 |
备注
DateTime.ToLocalTime uses the DateTime.Kind value:
DateTimeKind.Utc is converted to local time, DateTimeKind.Local
is returned unchanged, and DateTimeKind.Unspecified is assumed to be UTC before conversion.
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
转为长日期文本
函数重载 1/2
转为长日期文本(值: 时间日期) -> 文本
string ToLongDateString(DateTime value)
按当前区域的长日期模式写出时间日期中的日期,例如美式英语中的 Saturday, June 15, 2024。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | 时间日期 | — | The date and time; its time of day is not shown. |
返回
| 结果 | 文本 |
重载 2/2
转为长日期文本(值: DateOnly) -> 文本
string ToLongDateString(DateOnly value)
按当前区域的长日期模式写出日期,例如美式英语中的 Saturday, June 15, 2024。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | DateOnly | — | The date to format. |
返回
| 结果 | 文本 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
转为长时间文本
函数重载 1/2
转为长时间文本(值: 时间日期) -> 文本
string ToLongTimeString(DateTime value)
按当前区域的长时间模式写出时间日期中的时间,通常包含时、分、秒。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | 时间日期 | — | The date and time; its date is not shown. |
返回
| 结果 | 文本 |
重载 2/2
转为长时间文本(值: TimeOnly) -> 文本
string ToLongTimeString(TimeOnly value)
按当前区域的长时间模式写出时刻,通常包含时、分、秒。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | TimeOnly | — | The time of day to format. |
返回
| 结果 | 文本 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
转为 OLE 自动化日期
函数把时间日期转换为 OLE 自动化日期,即 Excel 等 Office 应用表示日期所用的数字格式。
转为 OLE 自动化日期(值: 时间日期) -> 数字
double ToOADate(DateTime value)
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | 时间日期 | — | The date and time; DateTime.MinValue gives 0, and other dates before year 100 throw an System.OverflowException. |
返回
| 结果 | 数字 |
备注
The whole part counts days from 1899-12-30 and the fraction is the time of day, so 1.5 is 1899-12-31 12:00. The kind is ignored.
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
转为短日期文本
函数重载 1/2
转为短日期文本(值: 时间日期) -> 文本
string ToShortDateString(DateTime value)
按当前区域的短日期模式写出时间日期中的日期,例如美式英语中的 6/15/2024。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | 时间日期 | — | The date and time; its time of day is not shown. |
返回
| 结果 | 文本 |
重载 2/2
转为短日期文本(值: DateOnly) -> 文本
string ToShortDateString(DateOnly value)
按当前区域的短日期模式写出日期,例如美式英语中的 6/15/2024。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | DateOnly | — | The date to format. |
返回
| 结果 | 文本 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
转为短时间文本
函数重载 1/2
转为短时间文本(值: 时间日期) -> 文本
string ToShortTimeString(DateTime value)
按当前区域的短时间模式写出时间日期中的时间,通常包含时和分。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | 时间日期 | — | The date and time; its date is not shown. |
返回
| 结果 | 文本 |
重载 2/2
转为短时间文本(值: TimeOnly) -> 文本
string ToShortTimeString(TimeOnly value)
按当前区域的短时间模式写出时刻,通常包含时和分。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | TimeOnly | — | The time of day to format. |
返回
| 结果 | 文本 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
转为文本
函数重载 1/15
转为文本(值: 时间日期) -> 文本
string ToString(DateTime value)
把时间日期转换为文本。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | 时间日期 | — |
返回
| 结果 | 文本 |
重载 2/15
转为文本(值: 时间日期, 格式: 文本) -> 文本
string ToString(DateTime value, string format)
用某一格式把时间日期写成文本(不随机器的区域改变),格式如 "yyyy-MM-dd HH:mm",或标准格式说明符,如表示可往返 ISO 8601 的 "o"。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | 时间日期 | — | The date and time to format. |
| 格式 | 文本 | — | A standard or custom date and time format string; null or empty uses the general "G" format, and an invalid one throws a System.FormatException. |
返回
| 结果 | 文本 |
重载 3/15
转为文本(值: 时间日期, 提供者: IFormatProvider) -> 文本
string ToString(DateTime value, IFormatProvider provider)
按给定区域的常规“G”格式把时间日期写成文本。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | 时间日期 | — | The date and time to format. |
| 提供者 | IFormatProvider | — | The culture whose conventions to use, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
返回
| 结果 | 文本 |
重载 4/15
转为文本 -> 文本
值: 时间日期
格式: 文本
提供者: IFormatProviderstring ToString(
DateTime value,
string format,
IFormatProvider provider)按某一格式和给定区域的习惯把时间日期写成文本。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | 时间日期 | — | The date and time to format. |
| 格式 | 文本 | — | A standard or custom date and time format string; null or empty uses the general "G" format, and an invalid one throws a System.FormatException. |
| 提供者 | IFormatProvider | — | The culture whose conventions to use, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
返回
| 结果 | 文本 |
重载 5/15
转为文本(值: DateOnly) -> 文本
string ToString(DateOnly value)
把日期转换为文本。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | DateOnly | — |
返回
| 结果 | 文本 |
重载 6/15
转为文本(值: DateOnly, 格式: 文本) -> 文本
string ToString(DateOnly value, string format)
用某一格式把日期写成文本(不随机器的区域改变),格式如 "yyyy-MM-dd",或表示 ISO 8601 的 "o"。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | DateOnly | — | The date to format. |
| 格式 | 文本 | — | A standard or custom date format string; null or empty uses the short date "d" format, and an invalid one or one that asks for a time part throws a System.FormatException. |
返回
| 结果 | 文本 |
重载 7/15
转为文本(值: DateOnly, 提供者: IFormatProvider) -> 文本
string ToString(DateOnly value, IFormatProvider provider)
按给定区域的短日期模式把日期写成文本。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | DateOnly | — | The date to format. |
| 提供者 | IFormatProvider | — | The culture whose conventions to use, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
返回
| 结果 | 文本 |
重载 8/15
转为文本 -> 文本
值: DateOnly
格式: 文本
提供者: IFormatProviderstring ToString(
DateOnly value,
string format,
IFormatProvider provider)按某一格式和给定区域的习惯把日期写成文本。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | DateOnly | — | The date to format. |
| 格式 | 文本 | — | A standard or custom date format string; null or empty uses the short date "d" format, and an invalid one or one that asks for a time part throws a System.FormatException. |
| 提供者 | IFormatProvider | — | The culture whose conventions to use, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
返回
| 结果 | 文本 |
重载 9/15
转为文本(值: TimeOnly) -> 文本
string ToString(TimeOnly value)
把时刻转换为文本。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | TimeOnly | — |
返回
| 结果 | 文本 |
重载 10/15
转为文本(值: TimeOnly, 格式: 文本) -> 文本
string ToString(TimeOnly value, string format)
用某一格式把时刻写成文本(不随机器的区域改变),格式如 "HH:mm:ss",或表示 ISO 8601 的 "o"。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | TimeOnly | — | The time of day to format. |
| 格式 | 文本 | — | A standard or custom time format string; null or empty uses the short time "t" format, and an invalid one or one that asks for a date part throws a System.FormatException. |
返回
| 结果 | 文本 |
重载 11/15
转为文本(值: TimeOnly, 提供者: IFormatProvider) -> 文本
string ToString(TimeOnly value, IFormatProvider provider)
按给定区域的短时间模式把时刻写成文本。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | TimeOnly | — | The time of day to format. |
| 提供者 | IFormatProvider | — | The culture whose conventions to use, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
返回
| 结果 | 文本 |
重载 12/15
转为文本 -> 文本
值: TimeOnly
格式: 文本
提供者: IFormatProviderstring ToString(
TimeOnly value,
string format,
IFormatProvider provider)按某一格式和给定区域的习惯把时刻写成文本。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | TimeOnly | — | The time of day to format. |
| 格式 | 文本 | — | A standard or custom time format string; null or empty uses the short time "t" format, and an invalid one or one that asks for a date part throws a System.FormatException. |
| 提供者 | IFormatProvider | — | The culture whose conventions to use, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
返回
| 结果 | 文本 |
重载 13/15
转为文本(值: TimeSpan) -> 文本
string ToString(TimeSpan value)
把时间间隔转换为文本。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | TimeSpan | — |
返回
| 结果 | 文本 |
重载 14/15
转为文本(值: TimeSpan, 格式: 文本) -> 文本
string ToString(TimeSpan value, string format)
用某一格式把时间间隔写成文本:"c" 表示固定的 [-][d.]hh:mm:ss[.fffffff] 形式,"g" 或 "G" 表示随区域变化的短形式或长形式,也可以是 @"hh\:mm" 这样的自定义格式。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | TimeSpan | — | The duration to format. |
| 格式 | 文本 | — | The format string; null or empty uses "c", and an invalid one throws a System.FormatException. |
返回
| 结果 | 文本 |
重载 15/15
转为文本 -> 文本
值: TimeSpan
格式: 文本
提供者: IFormatProviderstring ToString(
TimeSpan value,
string format,
IFormatProvider provider)按某一格式和给定区域的习惯把时间间隔写成文本,区域会影响 "g" 和 "G" 格式。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | TimeSpan | — | The duration to format. |
| 格式 | 文本 | — | The format string, such as "c", "g", "G" or a custom pattern; null or empty uses "c", and an invalid one throws a System.FormatException. |
| 提供者 | IFormatProvider | — | The culture whose conventions to use, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
返回
| 结果 | 文本 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
总天数
函数获取时间间隔折合的天数,含小数部分(36 小时即 1.5)。
总天数(值: TimeSpan) -> 数字
double TotalDays(TimeSpan value)
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | TimeSpan | — | The duration. |
返回
| 结果 | 数字 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
总小时数
函数获取时间间隔折合的小时数,含小数部分(90 分钟即 1.5)。
总小时数(值: TimeSpan) -> 数字
double TotalHours(TimeSpan value)
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | TimeSpan | — | The duration. |
返回
| 结果 | 数字 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
总微秒数
函数获取时间间隔折合的微秒数,含小数部分。
总微秒数(值: TimeSpan) -> 数字
double TotalMicroseconds(TimeSpan value)
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | TimeSpan | — | The duration. |
返回
| 结果 | 数字 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
总毫秒数
函数获取时间间隔折合的毫秒数,含小数部分。
总毫秒数(值: TimeSpan) -> 数字
double TotalMilliseconds(TimeSpan value)
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | TimeSpan | — | The duration. |
返回
| 结果 | 数字 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
总分钟数
函数获取时间间隔折合的分钟数,含小数部分。
总分钟数(值: TimeSpan) -> 数字
double TotalMinutes(TimeSpan value)
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | TimeSpan | — | The duration. |
返回
| 结果 | 数字 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
总纳秒数
函数获取时间间隔折合的纳秒数。
总纳秒数(值: TimeSpan) -> 数字
double TotalNanoseconds(TimeSpan value)
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | TimeSpan | — | The duration. |
返回
| 结果 | 数字 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
总秒数
函数获取时间间隔折合的秒数,含小数部分。
总秒数(值: TimeSpan) -> 数字
double TotalSeconds(TimeSpan value)
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | TimeSpan | — | The duration. |
返回
| 结果 | 数字 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
转为时刻
函数取时间日期的时刻,去掉其日期。
转为时刻(值: 时间日期) -> TimeOnly
TimeOnly ToTimeOnly(DateTime value)
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | 时间日期 | — | The date and time to take the time of day from; its kind is ignored and no time-zone conversion is made. |
返回
| 结果 | TimeOnly |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
转为时间间隔
函数把时刻转换为自午夜起的时间间隔,例如把 13:30 转换为 13 小时 30 分钟。
转为时间间隔(值: TimeOnly) -> TimeSpan
TimeSpan ToTimeSpan(TimeOnly value)
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | TimeOnly | — | The time of day. |
返回
| 结果 | TimeSpan |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
转为 UTC 时间
函数把时间日期转换为协调世界时(UTC)。
转为 UTC 时间(值: 时间日期) -> 时间日期
DateTime ToUniversalTime(DateTime value)
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | 时间日期 | — |
返回
| 结果 | 时间日期 |
备注
DateTime.ToUniversalTime uses the DateTime.Kind value:
DateTimeKind.Local is converted to UTC, DateTimeKind.Utc
is returned unchanged, and DateTimeKind.Unspecified is assumed to be local time before conversion.
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
转为 Unix 毫秒时间戳
函数把时间日期转换为毫秒级 Unix 时间戳:自 1970-01-01 00:00:00 UTC 起经过的整毫秒数,JavaScript 和许多 Web API 使用这种形式。
转为 Unix 毫秒时间戳(值: 时间日期) -> 大整数
long ToUnixTimeMilliseconds(DateTime value)
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | 时间日期 | — | The date and time to convert. |
返回
| 结果 | 大整数 |
备注
A UTC value is used as it is; a local or unspecified value is treated as local time and converted to UTC using the local time zone. Times before the epoch give negative numbers, and fractions of a millisecond are discarded.
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
转为 Unix 秒时间戳
函数把时间日期转换为 Unix 时间戳:自 1970-01-01 00:00:00 UTC 起经过的整秒数。
转为 Unix 秒时间戳(值: 时间日期) -> 大整数
long ToUnixTimeSeconds(DateTime value)
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | 时间日期 | — | The date and time to convert. |
返回
| 结果 | 大整数 |
备注
A UTC value is used as it is; a local or unspecified value is treated as local time and converted to UTC using the local time zone. Times before the epoch give negative numbers, and fractions of a second are discarded.
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
尝试解析时间日期
函数重载 1/2
尝试解析时间日期(文本: 文本) -> (结果: 真否, 结果: 时间日期)
bool TryParse(string s, out DateTime result)
尝试从文本中读取时间日期(不随机器的区域改变),失败时报告失败而不是出错中止。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 文本 | 文本 | — | The text to read; null or unreadable text makes the node report failure. |
返回
| 结果 | 真否 |
| 结果 | 时间日期 |
重载 2/2
尝试解析时间日期 -> (结果: 真否, 结果: 时间日期)
文本: 文本
提供者: IFormatProvider
样式: DateTimeStylesbool TryParse(
string s,
IFormatProvider provider,
DateTimeStyles styles,
out DateTime result)尝试按给定区域的写法从文本中读取时间日期,失败时报告失败而不是出错中止。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 文本 | 文本 | — | The text to read; null or unreadable text makes the node report failure. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
| 样式 | DateTimeStyles | — | Options such as DateTimeStyles.AdjustToUniversal; a contradictory combination still throws an System.ArgumentException. |
返回
| 结果 | 真否 |
| 结果 | 时间日期 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
尝试解析日期
函数重载 1/2
尝试解析日期(文本: 文本) -> (结果: 真否, 结果: DateOnly)
bool TryParseDateOnly(string s, out DateOnly result)
尝试从文本中读取日期(不随机器的区域改变),失败时报告失败而不是出错中止。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 文本 | 文本 | — | The text to read; null, unreadable text or text that includes a time makes the node report failure. |
返回
| 结果 | 真否 |
| 结果 | DateOnly |
重载 2/2
尝试解析日期 -> (结果: 真否, 结果: DateOnly)
文本: 文本
提供者: IFormatProvider
样式: DateTimeStylesbool TryParseDateOnly(
string s,
IFormatProvider provider,
DateTimeStyles styles,
out DateOnly result)尝试按给定区域的写法从文本中读取日期,失败时报告失败而不是出错中止。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 文本 | 文本 | — | The text to read; null, unreadable text or text that includes a time makes the node report failure. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
| 样式 | DateTimeStyles | — | White-space options only, such as DateTimeStyles.AllowWhiteSpaces; any other style still throws an System.ArgumentException. |
返回
| 结果 | 真否 |
| 结果 | DateOnly |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
尝试按格式解析时间日期
函数重载 1/2
尝试按格式解析时间日期 -> (结果: 真否, 结果: 时间日期)
文本: 文本
格式: 文本
提供者: IFormatProvider
样式: DateTimeStylesbool TryParseExact(
string s,
string format,
IFormatProvider provider,
DateTimeStyles styles,
out DateTime result)尝试从必须完全符合某一格式的文本中读取时间日期,失败时报告失败而不是出错中止。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 文本 | 文本 | — | The text to read; null or text that does not match makes the node report failure. |
| 格式 | 文本 | — | The standard or custom format the text must match; null makes the node report failure. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
| 样式 | DateTimeStyles | — | Options such as DateTimeStyles.AllowWhiteSpaces; a contradictory combination still throws an System.ArgumentException. |
返回
| 结果 | 真否 |
| 结果 | 时间日期 |
重载 2/2
尝试按格式解析时间日期 -> (结果: 真否, 结果: 时间日期)
文本: 文本
格式: 文本数组
提供者: IFormatProvider
样式: DateTimeStylesbool TryParseExact(
string s,
string[] formats,
IFormatProvider provider,
DateTimeStyles styles,
out DateTime result)尝试从必须完全符合若干格式之一的文本中读取时间日期,失败时报告失败而不是出错中止。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 文本 | 文本 | — | The text to read; null or text that matches none of the formats makes the node report failure. |
| 格式 | 文本数组 | — | The formats to try; the first that matches is used. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
| 样式 | DateTimeStyles | — | Options such as DateTimeStyles.AllowWhiteSpaces; a contradictory combination still throws an System.ArgumentException. |
返回
| 结果 | 真否 |
| 结果 | 时间日期 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
尝试按格式解析日期
函数重载 1/2
尝试按格式解析日期 -> (结果: 真否, 结果: DateOnly)
文本: 文本
格式: 文本
提供者: IFormatProvider
样式: DateTimeStylesbool TryParseExactDateOnly(
string s,
string format,
IFormatProvider provider,
DateTimeStyles styles,
out DateOnly result)尝试从必须完全符合某一格式的文本中读取日期,失败时报告失败而不是出错中止。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 文本 | 文本 | — | The text to read; null or text that does not match makes the node report failure. |
| 格式 | 文本 | — | The standard or custom date format the text must match; null makes the node report failure. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
| 样式 | DateTimeStyles | — | White-space options only, such as DateTimeStyles.AllowWhiteSpaces; any other style still throws an System.ArgumentException. |
返回
| 结果 | 真否 |
| 结果 | DateOnly |
重载 2/2
尝试按格式解析日期 -> (结果: 真否, 结果: DateOnly)
文本: 文本
格式: 文本数组
提供者: IFormatProvider
样式: DateTimeStylesbool TryParseExactDateOnly(
string s,
string[] formats,
IFormatProvider provider,
DateTimeStyles styles,
out DateOnly result)尝试从必须完全符合若干格式之一的文本中读取日期,失败时报告失败而不是出错中止。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 文本 | 文本 | — | The text to read; null or text that matches none of the formats makes the node report failure. |
| 格式 | 文本数组 | — | The date formats to try; the first that matches is used. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
| 样式 | DateTimeStyles | — | White-space options only, such as DateTimeStyles.AllowWhiteSpaces; any other style still throws an System.ArgumentException. |
返回
| 结果 | 真否 |
| 结果 | DateOnly |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
尝试按格式解析时刻
函数重载 1/2
尝试按格式解析时刻 -> (结果: 真否, 结果: TimeOnly)
文本: 文本
格式: 文本
提供者: IFormatProvider
样式: DateTimeStylesbool TryParseExactTimeOnly(
string s,
string format,
IFormatProvider provider,
DateTimeStyles styles,
out TimeOnly result)尝试从必须完全符合某一格式的文本中读取时刻,失败时报告失败而不是出错中止。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 文本 | 文本 | — | The text to read; null or text that does not match makes the node report failure. |
| 格式 | 文本 | — | The standard or custom time format the text must match; null makes the node report failure. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
| 样式 | DateTimeStyles | — | White-space options only, such as DateTimeStyles.AllowWhiteSpaces; any other style still throws an System.ArgumentException. |
返回
| 结果 | 真否 |
| 结果 | TimeOnly |
重载 2/2
尝试按格式解析时刻 -> (结果: 真否, 结果: TimeOnly)
文本: 文本
格式: 文本数组
提供者: IFormatProvider
样式: DateTimeStylesbool TryParseExactTimeOnly(
string s,
string[] formats,
IFormatProvider provider,
DateTimeStyles styles,
out TimeOnly result)尝试从必须完全符合若干格式之一的文本中读取时刻,失败时报告失败而不是出错中止。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 文本 | 文本 | — | The text to read; null or text that matches none of the formats makes the node report failure. |
| 格式 | 文本数组 | — | The time formats to try; the first that matches is used. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
| 样式 | DateTimeStyles | — | White-space options only, such as DateTimeStyles.AllowWhiteSpaces; any other style still throws an System.ArgumentException. |
返回
| 结果 | 真否 |
| 结果 | TimeOnly |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
尝试按格式解析时间间隔
函数重载 1/4
尝试按格式解析时间间隔 -> (结果: 真否, 结果: TimeSpan)
输入: 文本
格式: 文本
提供者: IFormatProviderbool TryParseExactTimeSpan(
string input,
string format,
IFormatProvider provider,
out TimeSpan result)尝试从必须完全符合某一格式的文本中读取时间间隔,失败时报告失败而不是出错中止。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 输入 | 文本 | — | The text to read; null, text that does not match or a value out of range makes the node report failure. |
| 格式 | 文本 | — | The standard or custom format the text must match; null makes the node report failure. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
返回
| 结果 | 真否 |
| 结果 | TimeSpan |
重载 2/4
尝试按格式解析时间间隔 -> (结果: 真否, 结果: TimeSpan)
输入: 文本
格式: 文本
提供者: IFormatProvider
样式: TimeSpanStylesbool TryParseExactTimeSpan(
string input,
string format,
IFormatProvider provider,
TimeSpanStyles styles,
out TimeSpan result)尝试从必须完全符合某一格式的文本中读取时间间隔,可选择将其视为负值,失败时报告失败而不是出错中止。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 输入 | 文本 | — | The text to read; null, text that does not match or a value out of range makes the node report failure. |
| 格式 | 文本 | — | The standard or custom format the text must match; null makes the node report failure. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
| 样式 | TimeSpanStyles | — | TimeSpanStyles.AssumeNegative makes a custom-format result negative; TimeSpanStyles.None leaves it as written. |
返回
| 结果 | 真否 |
| 结果 | TimeSpan |
重载 3/4
尝试按格式解析时间间隔 -> (结果: 真否, 结果: TimeSpan)
输入: 文本
格式: 文本数组
提供者: IFormatProviderbool TryParseExactTimeSpan(
string input,
string[] formats,
IFormatProvider provider,
out TimeSpan result)尝试从必须完全符合若干格式之一的文本中读取时间间隔,失败时报告失败而不是出错中止。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 输入 | 文本 | — | The text to read; null, text that matches none of the formats or a value out of range makes the node report failure. |
| 格式 | 文本数组 | — | The formats to try; the first that matches is used. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
返回
| 结果 | 真否 |
| 结果 | TimeSpan |
重载 4/4
尝试按格式解析时间间隔 -> (结果: 真否, 结果: TimeSpan)
输入: 文本
格式: 文本数组
提供者: IFormatProvider
样式: TimeSpanStylesbool TryParseExactTimeSpan(
string input,
string[] formats,
IFormatProvider provider,
TimeSpanStyles styles,
out TimeSpan result)尝试从必须完全符合若干格式之一的文本中读取时间间隔,可选择将其视为负值,失败时报告失败而不是出错中止。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 输入 | 文本 | — | The text to read; null, text that matches none of the formats or a value out of range makes the node report failure. |
| 格式 | 文本数组 | — | The formats to try; the first that matches is used. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
| 样式 | TimeSpanStyles | — | TimeSpanStyles.AssumeNegative makes a custom-format result negative; TimeSpanStyles.None leaves it as written. |
返回
| 结果 | 真否 |
| 结果 | TimeSpan |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
尝试解析时刻
函数重载 1/2
尝试解析时刻(文本: 文本) -> (结果: 真否, 结果: TimeOnly)
bool TryParseTimeOnly(string s, out TimeOnly result)
尝试从文本中读取时刻(不随机器的区域改变),失败时报告失败而不是出错中止。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 文本 | 文本 | — | The text to read; null, unreadable text or text that includes a date makes the node report failure. |
返回
| 结果 | 真否 |
| 结果 | TimeOnly |
重载 2/2
尝试解析时刻 -> (结果: 真否, 结果: TimeOnly)
文本: 文本
提供者: IFormatProvider
样式: DateTimeStylesbool TryParseTimeOnly(
string s,
IFormatProvider provider,
DateTimeStyles styles,
out TimeOnly result)尝试按给定区域的写法从文本中读取时刻,失败时报告失败而不是出错中止。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 文本 | 文本 | — | The text to read; null, unreadable text or text that includes a date makes the node report failure. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
| 样式 | DateTimeStyles | — | White-space options only, such as DateTimeStyles.AllowWhiteSpaces; any other style still throws an System.ArgumentException. |
返回
| 结果 | 真否 |
| 结果 | TimeOnly |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
尝试解析时间间隔
函数重载 1/2
尝试解析时间间隔(文本: 文本) -> (结果: 真否, 结果: TimeSpan)
bool TryParseTimeSpan(string s, out TimeSpan result)
尝试从形如 [-][d.]hh:mm[:ss[.fffffff]] 的文本中读取时间间隔(不随机器的区域改变),失败时报告失败而不是出错中止。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 文本 | 文本 | — | The text to read; null, text in the wrong form or a value out of range makes the node report failure. |
返回
| 结果 | 真否 |
| 结果 | TimeSpan |
重载 2/2
尝试解析时间间隔 -> (结果: 真否, 结果: TimeSpan)
文本: 文本
提供者: IFormatProviderbool TryParseTimeSpan(
string s,
IFormatProvider provider,
out TimeSpan result)尝试按给定区域从形如 [-][d.]hh:mm[:ss[.fffffff]] 的文本中读取时间间隔,失败时报告失败而不是出错中止。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 文本 | 文本 | — | The text to read; null, text in the wrong form or a value out of range makes the node report failure. |
| 提供者 | IFormatProvider | — | The culture whose conventions to expect, such as a Globalization.CultureInfo; null uses the invariant culture, the same on every machine. |
返回
| 结果 | 真否 |
| 结果 | TimeSpan |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库
年
函数重载 1/2
年(值: 时间日期) -> 整数
int Year(DateTime value)
获取时间日期的年份。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | 时间日期 | — | The date and time. |
返回
| 结果 | 整数 |
重载 2/2
年(值: DateOnly) -> 整数
int Year(DateOnly value)
获取日期的年份。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| 值 | DateOnly | — |
返回
| 结果 | 整数 |
- 所属发行版
- 元编程(教育版)元编程(专业版)
- 可用的图种类
- 数据流 函数 事件 例程 蓝图 状态机状态
- 声明于
- 日期时间操作
- 所属包
- 标准库