nodatime / nodatime.serialization

Serialization projects for Noda Time

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Handling clients without lenient parsers

michaeltnguyen opened this issue · comments

Hi,

For Instant and Duration, this library uses an extended iso pattern with optional milliseconds and microseconds. This is flexible, but a lot of other languages don't have lenient parsers out-of-the-box. (Even JodaTime defaults to a strict format JodaOrg/joda-time#201)

It might be nice for a way to specify a strict format (aka always ss.SSS, for example). Is this something you would consider for inclusion in this library, or should I just write my own JsonConverters?

I can't think of a clean API that would support this, so maybe that's an indication I should just roll my own.

ConfigureForNodaTime(IDateTimeZoneProvider, FormatOptions)?

Michael

Will look at this in detail tomorrow, but IIRC it's not particularly hard to replace one converter with another, and it's easy to create a converter using NodaPatternConverter<T> to wrap an IPattern<T> that you'd create in the normal way.

Okay, I've had another look now, and ReplaceConverters is the code you'd need to copy at the moment so you can replace one converter with another. Given that there are various uses for that, I think I'll probably make that a public extension method (possibly renamed) in a future release. But you can easily use that code now.

Will do, thank you!