Option to have ZonedDateTime perform lenient deserialization

33 views
Skip to first unread message

mfische...@gmail.com

unread,
Mar 8, 2020, 8:31:24 AM3/8/20
to Noda Time
Hello

We are currently using the DataContractSerializer for serializing ZonedDatime data (among a lot of other things) to disk. We are in the process of preparing our system for future time zone rule changes as we would otherwise risk ending up in situations where we cannot deserialize future ZonedDateTimes stored in our data.
Currently the IXmlSerializable implementation in ZonedDateTime enforces strict resolution of offset/timezone data when doing deserialization. We have investigated the possibility of modifying this behavior to allow for lenient resolution and this is possible without much of a code change in ZonedDateTime.

Obviously the current behavior should not be changed by default, but would it be possible/acceptable to build in a mechanism for controlling whether the IXmlSerializable deserialization in ZonedDateTime should work in a lenient or strict fashion?
Alternatively, would it be possible/acceptable to extend ZonedDateTime (and possibly other classes) with a mechanism allowing for controlling the inner workings of the IXmlSerializable implementation (e.g. by specifying custom serialization/deserialization actions that the ZonedDateTime class could call, if configured)?

We would be happy to work on this and submit a PR on this. We have very basic prototype code working that shows these things should be possible without changing default behavior. However, we would like to hear whether this is something that would have a chance of being accepted in the NodaTime source or not before we begin doing a lot of work on this.

Best regards,
Morten

Jon Skeet

unread,
Mar 8, 2020, 8:40:36 AM3/8/20
to Noda Time
Please file this as a feature request on https://github.com/nodatime/nodatime, but I don't expect to do this.

ZonedDateTime can't be extended - it's a struct, not a class. But you could potentially write your own wrapper struct which have the behavior you want, delegating to ZonedDateTime for almost everything.

Jon


--

---
You received this message because you are subscribed to the Google Groups "Noda Time" group.
To unsubscribe from this group and stop receiving emails from it, send an email to noda-time+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/noda-time/582fae3f-94b0-497f-83ab-59b900a7b573%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages