Skip to content

Rewrite dateTime.js to use current localeData#378

Draft
bearfriend wants to merge 9 commits into
dgleckler/build-lms-filesfrom
dgleckler/rewrite-dateTime
Draft

Rewrite dateTime.js to use current localeData#378
bearfriend wants to merge 9 commits into
dgleckler/build-lms-filesfrom
dgleckler/rewrite-dateTime

Conversation

@bearfriend

@bearfriend bearfriend commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

GAUD-9717: Rewrite intl/common and intl/dateTime to use contained data sets per locale

Run #1

  • Use new locale-data/
  • Do not modify tests

644 failed tests

Run #2

  • Refactor tests so they properly set the language between tests, including waiting for locale data to load
  • Fix documentLocaleSettings reset method so it runs listeners when it "resets" (changes) the language back to English. This is only used in tests.
  • Rename locale-data/ to match the CLDR source names and update how the files are matched for loading

304 failed tests

Run #3

  • Update tests with appropriate whitespace (no-break-space, rtl-mark etc.) to match new locale data. These changes will only improve UX without being disruptive.

242 failed tests

Run #4

  • Be more forgiving when relying on separators to parse dates and date formats since they may contain invisible whitespace (e.g. rtl-mark)
  • Support unicode symbols without a .NET equivalent
    • LLLL - Stand-alone month in year (e.g. Catalan: MMMM -> "d'abril", LLLL -> "abril")
    • cccc - Stand-alone day of week
    • K - Hour in day, 12 hour, 0-11 (e.g. "0:29 pm")

225 failed tests

Comment thread lib/dateTime.js
'AZT': '+0400',
'B': '+0200',
'BDST': '+0100',
'BDST': '+0200',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These were just mistakes you noticed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Mistakes" AI noticed, but I don't trust it understands the context. I'll make a story to review these, but will revert these from this PR.

Comment thread lib/dateTime.js
return convertJsDateToLocalDateTime(utcDate) || date;
}

function convertCldrDatePattern(pattern, forceFullYear) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe some unit tests for this guy?

Comment thread lib/dateTime.js
'short': convertCldrDatePattern(localeData.dateFormatItems.yMd, true),
'monthYear': convertCldrDatePattern(localeData.dateFormatItems.yMMMM, false),
'monthDay': convertCldrDatePattern(localeData.dateFormatItems.MMMMd, false),
'shortMonthDay': convertCldrDatePattern(localeData.dateFormatItems.MMMd, false),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This stuff ends up all being static eh? Wonder if it'd be useful doing these calculations at build-time instead of runtime and storing them in locale-data.js?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll look at this, but it's cached after the first run. I do want to avoid storing converted data in locale-data/ so we just have a clean source of truth. A lot of this may go away very soon too with the skeleton work coming up, so we can look at it again then.

Comment thread lib/dateTime.js
let weekendStartDay = 6;
let weekendEndDay = 0;

switch (baseLanguage) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! The fact that all the unit tests passed seems to indicate that the CLDR data was a match for what we were doing here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If only. I had a bad import reference so basically none of the ones that matter ran.

@bearfriend bearfriend force-pushed the dgleckler/rewrite-dateTime branch from fc0bc46 to b46a9c9 Compare July 6, 2026 23:15
@bearfriend bearfriend force-pushed the dgleckler/rewrite-dateTime branch 2 times, most recently from 2490e5a to be95d77 Compare July 7, 2026 00:46
@bearfriend bearfriend force-pushed the dgleckler/rewrite-dateTime branch from be95d77 to 22568a3 Compare July 7, 2026 00:50
@bearfriend bearfriend force-pushed the dgleckler/rewrite-dateTime branch from 6b3fda0 to 7a5b68a Compare July 7, 2026 01:28
@bearfriend bearfriend force-pushed the dgleckler/rewrite-dateTime branch from 7a5b68a to 164c714 Compare July 7, 2026 01:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants