Promotic

Formatting rule for time-span (TimeSpan)

Formatting rule for the time-span (TimeSpan) specifies the text (formatted) form of time-span. A properly created formatting rule allows bidirectional conversion between a text expression and a value of the TimeSpan type without loss of information.
 
Formatting rule contains both constant items (e.g. separators inside the time-span) and individual time-span items. The time-span items must be in a mandatory order from the largest item (day) to the smallest item (millisecond). Each time-span item (day, hour, minute, etc.) has its own identifier (character: D, H, M, etc.).
 
The time-span item shall be indicated in the formatting rule by the percent sign %, this distinguishes it from constant items (separators). This is followed by an optional number of characters (where the asterisk * indicates the minimum required size with no zeros from the left, e.g., instead of 01.01. it would be 1.1.). This is followed by the mandatory identifier of time-span item.
 
For example: "%N%d/%H:%M:%S.%T"
 
Syntax of one time-span item: %[*|1-9]id
 
Time-span items:
N - The sign (+/-) [1 character]. The number of characters 1 (default) displays + or - , while the number of characters 0 will display - or nothing.
d - day (1-31) [2 digits].
H - hour (0-23) [2 digits].
M - minute (0-59) [2 difits].
S - second (0-59) [2 digits].
T - millisecond (0-999) [3 digits]. The number of characters here means the precision after the decimal separator, so 1=tenths, 2=hundredths, and 3=thousandths.
 
Note! The order of time-span items must be listed from the largest (day) to the smallest item (millisecond). However, it does not have to start with day, but with any of the other items. The first (largest) time-span item found:
1) will be incremented by the recalculated missing higher items.
2) It will have: default number of characters = *, so as needed.
 
Note! Items of time-span do not need be listed down to the smallest items either. It may end with any item. But then the information is lost in the text form. When converting back from text form to TimeSpan form, these missing items are considered to be 0.

Examples for TimeSpan 41/09:03:01.500:
"%N%d/%H:%M:%S.%T" will be "+41/09:03:01.500"
"%*N%*d/%H:%M:%S.%T" will be "41/09:03:01.500"
"%N%3d%H%M%S%T" will be "+041090301500"
"%N%H:%M:%S.%T" will be "+993:03:01.500" (993 = 41*24 + 9)
"%N%H:%M:%S" will be "+993:03:01" (993 = 41*24 + 9)
PROMOTIC 9.0.22 SCADA system documentation - MICROSYS, spol. s r.o.

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