功能块 STR2DT

功能块 STR2DT 将以英文文本形式给出的任意日期转换为新的日期。

输入 IN

在输入处传递格式为 DT# 的日期和时间。

输入 STR

定义用于计算日期的字符串。

输入可以定义在 1970 年之前的日期。为此,需要传递格式为 "12/25/0000" 这样的格式。这对应于第一个圣诞节。其中第一个数字 12 是月份,第二个数字 25 是日期。年份必须输入四位数,否则只能假定为年份 2000 的值。

使用的符号
描述 格式
星期名称 'sunday' | 'monday' | 'tuesday' | 'wednesday' | 'thursday' | 'friday' | 'saturday' | 'sun' | 'mon' | 'tue' | 'wed' | 'thu' | 'fri' | 'sat'
工作日 'weekday' | 'weekdays'
数字 [+-]?[0-9]+
序数 'first' | 'second' | 'third' | 'fourth' | 'fifth' | 'sixth' | 'seventh' | 'eighth' | 'ninth' | 'tenth' | 'eleventh' | 'twelfth' | 'next' | 'last' | 'previous' | 'this'
相对文本 'next' | 'last' | 'previous' | 'this'
空格 [ \t]+
单位 (( 'sec' | 'second' | 'min' | 'minute' | 'hour' | 'day' | 'fortnight' | 'forthnight' | 'month' | 'year') 's'?) | 'weeks' | daytext
基于日期的表示法
格式 描述 示例
'yesterday' 昨天的午夜。 "yesterday 14:00"
'midnight' 时间设置为 00:00:00
'today' 时间设置为 00:00:00
'now' 被忽略。
'noon' 时间设置为 12:00:00 "yesterday noon"
'tomorrow' 明天的午夜。
'back of' hour 从特定时间开始后 15 分钟。 "back of 7pm", "back of 15"
'front of' hour 从特定时间开始前 15 分钟。 "front of 5am", "front of 23"
'first day of' 将日期设置为当前月份的第一天。这也适用于指定的月份和年份。 "first day of January 2008"
'last day of' 将日期设置为当前月份的最后一天。这也适用于指定的月份和年份。 "last day of next month"
ordinal space dayname space 'of' 计算该月的第 x 天。 "first sat of July 2008"
'last' space dayname space 'of' 计算该月的最后一天。 "last sat of July 2008"
number space? (unit | 'week') 计算相对于当前日期的相对偏移量。 "+5 weeks", "12 day", "-7 weekdays"
ordinal space unit 计算相对于指定单位的相对时间。 "fifth day", "second month"
'ago' 计算一个向后的时间点。 "2 days ago", "8 days ago 14:00", "2 months 5 days ago", "2 months ago 5 days", "2 days ago"
dayname 转到下一个工作日。 "Monday"
reltext space 'week' 计算特殊格式 "weekday + last/this/next week"。 "Monday next week"

输出 DT

返回以 DT# 格式给出的计算日期和时间。

输出 ERR

在错误情况下,输出为真。