icu4x icon indicating copy to clipboard operation
icu4x copied to clipboard

Introduce a validated Month type

Open robertbastian opened this issue 2 months ago • 3 comments

Currently our APIs use MonthCode, which is a string using Temporal's string encoding. This means we have to handle invalid syntax in every month API. Instead, we should have a public validated type that can be constructed from the string, similar to other types like Language or TimeZone.

We deprecated the convenience constructors for lunisolar calendars in 2.1 because they used ordinal months (#7143); their replacement is blocked on this.

robertbastian avatar Oct 23 '25 09:10 robertbastian

Related #7043

robertbastian avatar Oct 23 '25 16:10 robertbastian

I'm okay adding a Month type that is similar to the internal type ValidMonthCode and using it in try_from_codes and potentially adding it to MonthInfo.

sffc avatar Oct 23 '25 16:10 sffc

#7147 landed. Things I'd like us to follow up on:

  • Constructors on the Month type
  • Range of months to allow in the Month type
  • Documentation around the new is_formatting_leap getter, and maybe the name of it

sffc avatar Nov 07 '25 23:11 sffc

Triage: Remains in the 2.2 milestone unless we decide that try_from_fields is no longer a headline release item.

Manishearth avatar Dec 19 '25 22:12 Manishearth