Time.FromText
根据本地和通用以及自定义时间格式创建时间。
Syntax
Time.FromText(
text as text,
optional options as any
) as time
Remarks
根据文本表示形式 text 创建 time 值。可以提供可选的 record 参数 options 来指定其他属性。record 可包含以下字段:
Format: 指示要使用的格式的text值。要了解更多详细信息,请转到 https://go.microsoft.com/fwlink/?linkid=2180104 和 https://go.microsoft.com/fwlink/?linkid=2180105。省略此字段或提供null将导致尽最大努力解析时间。Culture: 如果Format不为 null,则Culture将控制某些格式说明符。例如,在"en-US"中,"tt"是"AM" 或 "PM",而在"ar-EG"中,"tt"是"ص" 或 "م"。当Format为null时,Culture会控制要使用的默认格式。当Culture为null或省略时,将使用Culture.Current。
要支持旧版工作流,options 也可以是文本值。这与 options = [Format = null, Culture = options] 时的行为相同。
Examples
Example #1
将 "10:12:31am" 转换为时间值。
Time.FromText("10:12:31am")
Result:
#time(10, 12, 31)
Example #2
将 "1012" 转换为 Time 值。
Time.FromText("1012")
Result:
#time(10, 12, 00)
Example #3
将 "10" 转换为 Time 值。
Time.FromText("10")
Result:
#time(10, 00, 00)
Category
Time