nodatime / nodatime

A better date and time API for .NET
https://nodatime.org
Apache License 2.0
2.81k stars 335 forks source link

Provide RFC9557 patterns #1799

Open cromefire opened 7 months ago

cromefire commented 7 months ago

Currently NodaTime provides ISO (and therefore RFC3339 compatible) patterns, but now RFC9557 is ratified and will also be used in JavaScripts upcoming Temporal API.

So it would be great if NodaTime would provide both a pattern to provide it to it's users in an easy way (including the JSON options like already present for ISO, although that probably needs a follow-up issue on that repo) and also (and here I haven't tested yet if it already works, but I don't think it does) be able to parse these dates out of the box.

RFC9557 is an extension of RFC3339, so it should mostly affect the ZonedDateTime, everything else should probably stay like it was in RFC3339.

jskeet commented 7 months ago

I can look at this, but it looks like it's probably going to be complex in terms of extended information.

cromefire commented 7 months ago

I think the most important things would be the time zone and the calendar, at least for my use case those 2 would be the most important metadata.

jskeet commented 7 months ago

Right, but we'd need to implement the overall parsing to handle extended information. If this is urgent for you, you're welcome to work on it yourself - but if it's left to me I think it's unlikely that I'd have anything ready to release until at least the end of June.

cromefire commented 7 months ago

I'm mostly interested in the serialization for now so maybe I'll give that a shot some time, but it's not that urgent for me either. Currently in the one project where I use Temporal (with a polyfill) and NodaTime, I just format it manually.

It has just been a standard for a few days now, but in the long run it'll hopefully be as ubiquitous as RFC3339 and serve as a common ground for the use of zoned date times, especially with web APIs, especially once Temporal becomes the standard for JS-based stuff.

jskeet commented 7 months ago

One issue with the calendar aspect is making sure everyone agrees on exactly what calendar we're talking about for any given identifier. I guess that's a CLDR issue more than anything else... I should probably add a CLDR ID property to CalendarSystem (and a reverse mapping).

RokeJulianLockhart commented 2 weeks ago

https://github.com/nodatime/nodatime/issues/1799#issuecomment-2082452778

@jskeet, I believe that you could implement a skeleton of the pattern correlator with support solely for ca-8601, until you have the calendar identifier mappings configured, because that entry exists specifically to bypass those concerns.