Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add week-of-year to semantic skeletons #5643

Open
sffc opened this issue Oct 2, 2024 · 1 comment
Open

Add week-of-year to semantic skeletons #5643

sffc opened this issue Oct 2, 2024 · 1 comment
Labels
C-datetime Component: datetime, calendars, time zones

Comments

@sffc
Copy link
Member

sffc commented Oct 2, 2024

Week-of-year should be added to semantic skeletons, both in CLDR and in ICU4X.

Previous issue: #488

Week-of-year requires plurals support. Plurals are mostly supported in the data model already, so this should not require a breaking change.

The following fixture tests were going to be deleted in #5640, and they should be covered by this issue:

    {
        "description": "Date time example that includes a week-of for a locale with plural variants as well as one with non default WeekData",
        "input": {
            "locale": "en",
            "value": "2016-04-17T08:25:07.000+05:00",
            "options": {
                "components": {
                    "year": "numeric",
                    "week": "numeric-week-of-year",
                    "hour": "two-digit",
                    "minute": "two-digit",
                    "second": "two-digit",
                    "time_zone_name": "offset"
                }
            }
        },
        "output": {
            "values": {
                "en": "week 17 of 2016, 08:25:07 GMT+05:00",
                "en-AU": "week 16 of 2016, 08:25:07 GMT+05:00",
                "en-GB": "week 15 of 2016, 08:25:07 GMT+05:00",
                "fil": "linggo 17 ng 2016, 08:25:07 GMT+05:00",
                "en-ZA": "week 17 of 2016, 08:25:07 GMT+05:00"
            }
        }
    }
@sffc sffc added the C-datetime Component: datetime, calendars, time zones label Oct 2, 2024
@sffc sffc added this to the Priority Backlog ⟨P3⟩ milestone Oct 2, 2024
@sffc
Copy link
Member Author

sffc commented Oct 13, 2024

Previously, week-of-year was handled internally in the datetime formatter. However, in the semantic skeleton world and with flexible input types, I would rather move the week number calculations out into the input type. For example, I would rather have something such as

pub struct WeekDate<C: WeekCalendar> {
    inner: C::WeekDateInner
}

struct ArithmeticWeek {
    pub(crate) year: i32,
    pub(crate) week: u8,
    pub(crate) weekday: Weekday, // 1-7
}

pub struct GregorianWeekDateInner(pub(crate) ArithmeticWeek);

impl WeekCalendar for Gregorian {
    type WeekDateInner = GregorianWeekDateInner;
}

The functions for converting between Date and WeekDate involve data and locale preferences (i.e. WeekCalculator).

This has a number of advantages, including removing the dependence on the week calculator data from datetime (#4340).

(this is not a 2.0-issue, but CC @Manishearth @robertbastian @zbraniecki)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-datetime Component: datetime, calendars, time zones
Projects
None yet
Development

No branches or pull requests

1 participant