
The Function Block STR2DT converts a date specified in English text form into a new date.
A date and time are passed to the input in DT# format.
Defines the string for calculating the date.
The input can define a date before 1970. For this, a format like "12/25/0000" must be passed. This corresponds to the first Christmas. The first number 12 is the month and the second 25 is the day. The year must be entered with four digits, otherwise only the value of the year 2000 can be assumed.
| Description | Format |
|---|---|
| Day Name | 'sunday' | 'monday' | 'tuesday' | 'wednesday' | 'thursday' | 'friday' | 'saturday' | 'sun' | 'mon' | 'tue' | 'wed' | 'thu' | 'fri' | 'sat' |
| Weekdays | 'weekday' | 'weekdays' |
| Number | [+-]?[0-9]+ |
| Ordinals | 'first' | 'second' | 'third' | 'fourth' | 'fifth' | 'sixth' | 'seventh' | 'eighth' | 'ninth' | 'tenth' | 'eleventh' | 'twelfth' | 'next' | 'last' | 'previous' | 'this' |
| Relative Texts | 'next' | 'last' | 'previous' | 'this' |
| Whitespace | [ \t]+ |
| Units | (('sec' | 'second' | 'min' | 'minute' | 'hour' | 'day' | 'fortnight' | 'forthnight' | 'month' | 'year') 's'?) | 'weeks' | daytext |
| Format | Description | Examples |
|---|---|---|
| 'yesterday' | Midnight of yesterday. | "yesterday 14:00" |
| 'midnight' | Time is set to 00:00:00 | |
| 'today' | Time is set to 00:00:00 | |
| 'now' | Is ignored. | |
| 'noon' | Time is set to 12:00:00 | "yesterday noon" |
| 'tomorrow' | Midnight of tomorrow. | |
| 'back of' hour | 15 minutes later from a specific time. | "back of 7pm", "back of 15" |
| 'front of' hour | 15 minutes earlier from a specific time. | "front of 5am", "front of 23" |
| 'first day of' | Sets the day to the first day of the month of the current month. This also works with a specified month and year. | "first day of January 2008" |
| 'last day of' | Sets the day to the last day of the month of the current month. This also works with a specified month and year. | "last day of next month" |
| ordinal space dayname space 'of' | Calculates the x'th weekday in the month. | "first sat of July 2008" |
| 'last' space dayname space 'of' | Calculates the last weekday in the month. | "last sat of July 2008" |
| number space? (unit | 'week') | Calculates a relative offset to the current date. | "+5 weeks", "12 day", "-7 weekdays" |
| ordinal space unit | Calculates the relative time to the specified unit. | "fifth day", "second month" |
| 'ago' | Calculates a point in time backwards. | "2 days ago", "8 days ago 14:00", "2 months 5 days ago", "2 months ago 5 days", "2 days ago" |
| dayname | Goes to the next weekday. | "Monday" |
| reltext space 'week' | Calculates the special format "weekday + last/this/next week". | "Monday next week" |
Returns the calculated date and time in DT# format.
The output is true in case of an error.