NodaTime Interval JSON Serialization

Is there a reason why the NodaTime JSON.net serializer does not use the ISO8601 Time Interval format to express the start and end instants?

Example ISO8601 Time Interval:

"2007-03-01T13:00:00Z/2008-05-11T15:30:00Z"

NodaTime Complex JSON:

{ Start: "2007-03-01T13:00:00Z", End: "2008-05-11T15:30:00Z" }

Is the ISO8601 format just not a good fit for the interval concept in NodaTime?

Jon Skeet
people
quotationmark

Is there a reason why the NodaTime JSON.net serializer does not use the ISO8601 Time Interval format to express the start and end instants?

Yes. I didn't spot it when reading ISO-8601. It's not a very good reason, but it's the correct one.

Is the ISO8601 format just not a good fit for the interval concept in NodaTime?

Nope, it's a perfectly good fit (as good as the rest of ISO-8601 is), and we should absolutely have used it. I don't think ISO-8601 specifies that the start is inclusive and the end is exclusive, but that doesn't need to be an issue.

I suspect the format we'd want to use would be the extended ISO format to include sub-second values, in line with everything else, but I suspect that sort of extension is fairly common.

We'll need to make this an option when configuring the JSON serializer, which is a slight nuisance, but we should definitely make it available.

I've opened feature request 270 to cover this.

people

See more on this question at Stackoverflow