/* * Copyright (c) 2026, Tim Flynn * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include #include #include namespace Unicode { // 3.5.1 ISO Date Records, https://tc39.es/proposal-temporal/#sec-temporal-iso-date-records struct ISODate { i32 year { 0 }; u8 month { 0 }; u8 day { 0 }; }; // 12.2 Month Codes, https://tc39.es/proposal-temporal/#sec-temporal-month-codes struct MonthCode { u8 month_number { 0 }; bool is_leap_month { false }; }; // 14.3 The Year-Week Record Specification Type, https://tc39.es/proposal-temporal/#sec-year-week-record-specification-type struct YearWeek { Optional week; Optional year; }; // 12.3.1 Calendar Date Records, https://tc39.es/proposal-temporal/#sec-temporal-calendar-date-records struct CalendarDate { Optional era; Optional era_year; i32 year { 0 }; u8 month { 0 }; Utf16String month_code; u8 day { 0 }; u8 day_of_week { 0 }; u16 day_of_year { 0 }; YearWeek week_of_year; u8 days_in_week { 0 }; u8 days_in_month { 0 }; u16 days_in_year { 0 }; u8 months_in_year { 0 }; bool in_leap_year { false }; }; Optional parse_month_code(Utf16View month_code); Utf16String create_month_code(u8 month_number, bool is_leap_month); CalendarDate iso_date_to_calendar_date(StringView calendar, ISODate); Optional calendar_date_to_iso_date(StringView calendar, i32 year, u8 month, u8 day); Optional iso_year_and_month_code_to_iso_date(StringView calendar, i32 year, Utf16View month_code, u8 day); Optional calendar_year_and_month_code_to_iso_date(StringView calendar, i32 arithmetic_year, Utf16View month_code, u8 day); u8 calendar_months_in_year(StringView calendar, i32 arithmetic_year); u8 calendar_days_in_month(StringView calendar, i32 arithmetic_year, u8 ordinal_month); u8 calendar_max_days_in_month_code(StringView calendar, Utf16View month_code); bool calendar_year_contains_month_code(StringView calendar, i32 arithmetic_year, Utf16View month_code); }