DateTime encoding

Version 6 by Yan Tordoff
on Mar 07, 2010 11:49.

compared with
Current by Andrew Griffin
on Mar 18, 2010 12:26.

Key
This line was removed.
This word was removed. This word was added.
This line was added.

Changes (16)

View Page History
A time (time of day) is encoded as 8 bytes, holding data as follows:
||Bits ||Meaning ||Encoding ||
| 63 - 56 | Timezone offset | Offset from UTC in 15-minute intervals. Signed 8-bit integer. Special value -128 means no timezone information |
| 55 | Unused | |
| 545 - 52 | Accuracy | Enumerated value - see below |
| 51 - 32 | Seconds since midnight | Unsigned 20-bit integer |
| 51 - 49 | Unused | Set to zero |
| 48 - 32 | Seconds since midnight | Unsigned 17-bit integer* |
| 31 - 29 | Unused | Set to zero |
| 31 29 - 0 | Nanoseconds since the start of the second | Unsigned 32-bit integer 30-bit integer* |

* The valid ranges for seconds since midnight and nanoseconds since start of the second are encoded as unsigned values. They are aligned to 32 bit boundaries so an implementation may set the most significant bits to 0 and work with 32-bit signed integers internally if preferred.

Timezone examples:
| GMT | Greenwich Mean Time | London | UTC+0H | 0 |

Accuracy is an enumeration (ordered to follow the English semantics of "greater" precision meaning smaller):
* 0 = Hour Millennium
* 1 = Minute Century
* 2 = Second Year
* 3 = Millisecond Month
* 4 = Microsecond Day
* 5 = Nanosecond Hour
* 6 = Minute
* 7 = Second
* 8 = Millisecond
* 9 = Microsecond
* 10 = Nanosecond

Values of 0 through 4 are only valid for DateTime (see below).

{anchor:DateTime}
h2. Combined date and time

The combined date and time value is a 12-byte sequence - the 4-byte date as encoded above, followed by the 8-byte time as encoded above. Adding a time implies a minimum precision of an hour, and so the month and day fields of the date may not be 0.