Promotic

Formatting rule for date and time (DateTime)

Formatting rule for time DateTime specifies the text (formatted) form of the time. A properly created formatting rule allows bidirectional conversion between a text representation and a value of the DateTime type without loss of information.
 
Formatting rule contains both constant items (e.g. separators inside time) and individual time items. The time items can be in any order. Each time item (day, hour, minute, etc.) has an identifier (character: D, H, M, etc.).
 
The time entry in the formatting rule is indicated by the percent sign %, thus distinguishing it from constant items (separators). This is followed by an optional number of digits (where the asterisk * means the minimum required size with no zeros from the left, e.g., instead of 01.01. it would be 1.1.). The time entry is terminated with the mandatory time entry identifier.
 
For example: "%Y.%m.%d %H:%M:%S.%T"
 
Syntax of one time item: %[*|1-9]id

Time items:
Y - year (e.g. 2023) [4 digits].
See the PmDateObject.GetYear method.
y - Only the last two digits of the year (e.g. 23) [2 digits].
m - month (1-12) [2 digits].
See the PmDateObject.GetMonth method.
d - day (1-31) [2 digits].
See the PmDateObject.GetDay method.
H - hour (0-23) [2 digits].
See the PmDateObject.GetHour method.
M - minute (0-59) [2 digits].
See the PmDateObject.GetMinute method.
S - second (0-59) [2 digits].
See the PmDateObject.GetSecond method.
T - millisecond (0-999) [3 digits].
The number of digits here means the precision after the decimal separator, so 1=tenths, 2=hundredths, and 3=thousandths.
See the PmDateObject.GetMillisecond method.
D - day of year (1-366) [3 digits].
It works only for conversion the time (DateTime) to the text form.
See the PmDateObject.GetDayOfYear method.
Wi - week of year (1-53) [2 digits] according to ISO 8601.
It works only for conversion the time (DateTime) to the text form.
See the PmDateObject.GetWeekOfYear method.
ws - day of the week starting on Sunday (0-6) [1 digit].
It works only for conversion the time (DateTime) to the text form.
See the PmDateObject.GetWeekday method.
wm - day of the week starting on Monday (1-7) [1 digit] according to ISO 8601.
It works only for conversion the time (DateTime) to the text form.

Note! Items do not all have to be entered. But then the information is lost in the text form.
When converting back from text to DateTime it must not miss items from the date part (year, month, day). Other missing items are considered to be 0.


Examples for DateTime 2023.07.01 09:03:01.500:
- "%Y.%m.%d %H:%M:%S.%T" will be "2023.07.01 09:03:01.500".
- "%Y.%m.%d %HT%M:%S.%T" will be "2023.07.01 09T03:01.500" (this notation conforms to ISO 8601)
- "%Y.%*m.%*d %*H:%*M:%*S.%T" will be "2023.7.1 9:3:1.500".
- "%Y%m%d%H%M%S%T" will be "20230701090301500".
- "%Y.%m.%d" will be "2023.07.01".
- "%Y/%Wi" will be "2023/26".

History:
Pm9.00.20:
- New option D = day of year.
- New option Wi = week of year.
- New option ws = day of the week (week starting on Sunday).
- New option wm = day of the week (week starting on Monday).
PROMOTIC 9.0.27 SCADA system documentation MICROSYS, spol. s r.o.

Send page remarkContact responsible person
© MICROSYS, spol. s r.o.