12 Mapping of DataTypes

12.2 Primitive DataTypes

12.2.6 DateTime DataType

12.2.6.1 Overview 
The IODD data type TimeT is mapped to an OPC UA DataType DateTime.
The IODD data type TimeT has a length of 8 bytes, consisting of two 32-bit unsigned integers. The bytes 1 to 4 represent the seconds starting from 1900-01-01 0.00,00 (UTC) and the bytes 5 to 8 represent the fractional part of the current second in 1/ 2 32 seconds. Because the time range before 1984-01-01 0:00,00 (UTC) is in the past (where IO-Link did not exist), the time values (seconds) from 0x00000000 to 0x9DFF4400 (exclusive) are mapped to the time after 2036-02-07 6.28,16 (UTC). See IO-Link Specification for more details.
The OPC UA DataType DateTime consists of a 64-bit signed integer which represents the number of 100 nanosecond intervals (1/ 10 6 seconds) since January 1, 1601 (UTC).
The OPC UA DataType provides a larger range whereas the IO-Link data type provides a higher precision. Therefore, the following conversion rules shall apply (see OPC 10000-6). Implementers shall ensure that the time value mappings are done as exactly as possible.
12.2.6.2 Conversion from IO-Link TimeT to OPC UA DateTime 
Consider the borders of the IO-Link TimeT value range:
- If the IO-Link TimeT value is equal to the smallest possible IO-Link time value (1984-01-01 0:00,00 (UTC), seconds value: 0x9DFF4400, fractional seconds value: 0), the OPC UA DateTime value shall be 0.
-
If the IO-Link TimeT value is equal to the highest possible IO-Link time value (2120-02-07 6:28,15 (UTC), seconds value: 0x9DFF4399, fractional seconds value 0xFFFFFFFF), the OPC UA DateTime value shall be 0x7FFFFFFFFFFFFFFF (maximum value for 64-bit signed integer). If none of the rules above apply, the IO-Link TimeT rollover has to be considered:
- If the IO-Link TimeT value is smaller than (1984-01-01 0:00,00 (UTC), seconds value: 0x9DFF4400, fractional seconds value: 0), the time base offset has to be the difference between 1601-01-01 0:00:00 and 2036-02-07 6.28,16 (UTC).
- If the IO-Link TimeT value is bigger than (1984-01-01 0:00,00 (UTC)), the time base offset has to be the difference between 1601-01-01 0:00:00 (UTC) and 1901-01-01 0:00:00 (UTC). The time value conversion works according to the following formula:
OPC UA DateTime=IO-Link TimeT seconds∙ 10 6 + IOLink TimeT fractional seconds*∙ 10 6
2 32
+*time base offset
12.2.6.3 Conversion from OPC UA DateTime to IO-Link TimeT 
Consider the borders of the IO-Link TimeT value range:
- If the OPC UA DateTime value is equal or greater than 2120-02-07 6:28,15 (UTC), the IO-Link TimeT value shall be 2120-02-07 6:28,15 (UTC), seconds value: 0x9DFF4399, fractional seconds value 0xFFFFFFFF).
-
If the OPC UA DateTime value is equal or smaller than 1984-01-01 0:00,00 (UTC), the IO-Link TimeT value shall be 1984-01-01 0:00,00 (UTC), seconds value: 0x9DFF4400, fractional seconds value: 0). If none of the rules above apply, the IO-Link TimeT rollover has to be considered:
- If the OPC UA DateTime value is equal or greater than 2036-02-07 6.28,16 (UTC), the time base offset has to be the difference between 1601-01-01 0:00:00 and 2036-02-07 6.28,16 (UTC).
- If the OPC UA DateTime value is smaller than 2036-02-07 6.28,16 (UTC), the time base offset has to be the difference between 1601-01-01 0:00:00 and 1901-01-01 0:00:00 (UTC). The time value conversion works according to the following formulas:
IO-Link TimeT seconds= OPC UA DateTime−time base offset
10 6
IO-Link TimeT fractional seconds= ( OPC UA DateTime−time base offset) % *10 6
∙ 2 32
10 6*
12.2.6.4 Conversion of special values (Summary) 
Table 64 and Table 65 list some special values and their conversion to the other time data type. They can be used as a base set to test the conversion algorithm implementation (together with other input-output pairs).
Table 64 – OPC UA DateTime to IO-Link TimeT – Special values
Input (OPC UA DateTime) | Output (IO-Link TimeT) | |
---|---|---|
Seconds value | Description | Seconds value |
Date/time value before 1984/01/01 0:00:00,000AM (inclusive) | Date/time value is “truncated” | 1984/01/01 00:00:00,000AM |
Date/time value after 2120/02/07 06:28:15,999AM (inclusive) | Date/time value is “truncated” | 2120/02/07 06:28:15,999AM |
0 | Minimal OPC UA DateTime value = 1601/01/01 12:00:00,000AM | 1984/01/01 00:00:00,000AM |
INT64_MAX (0x7FFFFFFFFFFFFFFF) | Maximal OPC UA DateTime value = 9999/12/31 11:59:59,000PM | 2120/02/07 06:28:15,999AM |
Table 65 – IO-Link TimeT to OPC UA DateTime – Special values
Input (IO-Link TimeT) | Output (OPC UA DateTime) | |
---|---|---|
Seconds value | Description | Seconds value |
1984/01/01 00:00:00,000AM | Minimal IO-Link TimeT value | 0 |
2120/02/07 06:28:15,000AM | Maximal IO-Link TimeT value | INT64_MAX |
0 | First number after IO-Link TimeT rollover | 2036/02/07 06:28:17,000AM |
seconds = UINT32_MAX, fSeconds = UINT32_MAX | Last number before IO-Link TimeT rollover | 2036/02/07 06:28:16,999AM |