82 | NodaTime type | Serialization format |
83 | Instant | When an Instant is serialized, like LocalDateTime and LocalDate, it goes to timestamp format. Depending on the value of the Instant, it will fall into either timestamp 32, 64, or 96 format, as explained above under the Timestamp heading. |
84 | LocalDate | Once a LocalDate is serialized it is in timestamp format. Depending on the value of the LocalDate, it will fall into either timestamp 32, 64 or 96. LocalDate has no time values. |
85 | LocalDateTime | Once a LocalDate is serialized it is in timestamp format. This means an extension type of -1 will be received by MessagePack. LocalDateTime can be deserialized into a LocalDate if it has no time part. |
86 | LocalTime | LocalTime is serialized into an int64 (64 bit int). The int64 contains the LocalTime value in nanoseconds. |
87 | Offset | Offset is serialized into an int32 (32 bit int). The int32 contains the Offset value in seconds. |
88 | OffsetDateTime | When an Offset is serialized, it is split up into into the LocalDateTime and Offset parts.
89 | They are then serialized using there respective formatters.
90 | This means the serialized OffsetDateTime will be put into an array of 2 elements which looks like [timestamp, int32].
91 | The Offset and LocalDateTime serialization is explained in the headings above. |
92 | Period | When the NodaTime type Period is serialized, it is split into a 'fixarray'.
93 | For a Period we have a 10 element array of four int32 amd six int64 respectively, represented in the order of →
94 | Years, Months, Weeks, Days, Hours, Minutes, Seconds, Milliseconds, Ticks, Nanoseconds. |
95 | ZonedDateTime | A ZonedDateTime is split up into LocalDateTime, an Offset and a string representing a Zone, during serialization.
96 | This means the ZonedDateTime is put into an array of 3 elements.
97 | Each NodaTime type is serialized using there respective formatters,
98 | while the string is serialized using the MessagePack base class into a 'fixstr'. |
99 |
100 |
101 | ## Limitations
102 | ### Nanoseconds
103 | While NodaTime supports nanoseconds accuracy, we currently do not. The lowest common level of precision between us and NodaTime is ticks. This means our serialization and deserialization process truncates at 100 nanoseconds because 100ns = 1 tick.
104 | Below are two examples explaining this:
105 | ```csharp
106 | LocalDateTime ldt = new LocalDateTime(2016, 08, 21, 0, 0, 0, 0).PlusNanoseconds(1)
107 |
108 | var localDateTimeBinary = MessagePackSerializer.Serialize(ldt);
109 | var result MessagePackSerializer.Deserialize