Skip to content

fix: Cache Intl.DateTimeFormat instances for better performance#4141

Open
TrevorBurnham wants to merge 2 commits into
cloudscape-design:mainfrom
TrevorBurnham:format-date-localized-caching
Open

fix: Cache Intl.DateTimeFormat instances for better performance#4141
TrevorBurnham wants to merge 2 commits into
cloudscape-design:mainfrom
TrevorBurnham:format-date-localized-caching

Conversation

@TrevorBurnham
Copy link
Copy Markdown
Contributor

Description

Currently, every call to formatDateLocalized (used in DateInput) allocates new Intl.DateTimeFormat instances, which have significant initialization overhead. This PR adds caching for those formatters so that they're only created the first time formatDateLocalized is called.

How has this been tested?

I've added thorough unit test coverage.

Review checklist

The following items are to be evaluated by the author(s) and the reviewer(s).

Correctness

  • Changes include appropriate documentation updates.
  • Changes are backward-compatible if not indicated, see CONTRIBUTING.md.
  • Changes do not include unsupported browser features, see CONTRIBUTING.md.
  • Changes were manually tested for accessibility, see accessibility guidelines.

Security

Testing

  • Changes are covered with new/existing unit tests?
  • Changes are covered with new/existing integration tests?

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@TrevorBurnham TrevorBurnham requested a review from a team as a code owner December 31, 2025 16:48
@TrevorBurnham TrevorBurnham requested review from amanabiy and removed request for a team December 31, 2025 16:48
@TrevorBurnham TrevorBurnham force-pushed the format-date-localized-caching branch from b4e5960 to 1bbc389 Compare January 2, 2026 15:14
@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 8, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.50%. Comparing base (5b6f833) to head (2d5c154).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4141   +/-   ##
=======================================
  Coverage   97.50%   97.50%           
=======================================
  Files         947      948    +1     
  Lines       30244    30260   +16     
  Branches    11017    11020    +3     
=======================================
+ Hits        29489    29505   +16     
+ Misses        748      708   -40     
- Partials        7       47   +40     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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