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

Intl.DateTimeFormat #21152

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Draft

Intl.DateTimeFormat #21152

wants to merge 8 commits into from

Conversation

TorsteinHonsi
Copy link
Collaborator

@TorsteinHonsi TorsteinHonsi commented May 11, 2024

Implemented locale-aware datetime formats through the Intl.DateTimeFormat browser API. All default time formats are now respecting the browser locale.

To do

  • Decide where to set the locale option. Probably best as chart.locale.
  • Align the locale option with Intl. In type definitions, allow arrays and instances of Intl.Locale.
  • Add object defaults for all other time definitions except those of a non-locale nature like %Y-%m-%d.
  • Implement caching for DateTimeFormat instances.
  • Handle capitalization for standalone formats like x-axis labels and tooltip headers. Could be a custom option on the extended Intl.DateTimeFormatOptions. Or maybe a templating helper. Axis and current-date done via the simple call to Time.dateFormat. But tooltips need to be handled another way through a sentenceCase custom property, and abstraction of Intl.DateTimeFormat.
  • Handle extended or concatenated formats lik "Week from Monday, ..." and the to formats. Consider a custom prefix option on Intl.DateTimeFormatOptions. Which means we would need our own Time.DateTimeFormatOptions that extends Intl.
  • Consider template keys for the most common ones.
  • Consider localized defaults for lang.months, lang.weekdays etc. Will fix demos like gantt/current-date-indicator/demo.
  • Separate error handling between bad timezone and bad config, see comment.

@highsoft-bot
Copy link
Collaborator

highsoft-bot commented May 11, 2024

File size comparison

Sizes for compiled+gzipped (bold) and compiled files.

master candidate difference
highcharts.js 95.8 kB
270.2 kB
96.0 kB
271.2 kB
253 B
1059 B
highstock.js 128.6 kB
371.9 kB
128.9 kB
373.0 kB
296 B
1186 B
highmaps.js 121.6 kB
349.5 kB
121.9 kB
350.5 kB
250 B
1059 B
highcharts-gantt.js 133.8 kB
385.8 kB
134.1 kB
387.0 kB
309 B
1257 B
dashboards/dashboards.js 43.1 kB
148.4 kB
43.2 kB
149.0 kB
147 B
693 B
datagrid/datagrid.js 24.7 kB
76.8 kB
24.8 kB
77.5 kB
153 B
693 B

@highsoft-bot
Copy link
Collaborator

highsoft-bot commented May 11, 2024

Visual test results - Differences found

Found 113 diffing sample(s). Please review the differences.


Samples changed

Change type Sample
Modified samples/highcharts/studies/intl-datetimeformat/demo.js
Modified samples/highcharts/studies/intl-datetimeformat/demo.js
Modified samples/highcharts/studies/intl-datetimeformat/demo.js
Modified samples/highcharts/studies/intl-datetimeformat/demo.js
Modified samples/highcharts/studies/intl-datetimeformat/demo.js

@highsoft-bot
Copy link
Collaborator

highsoft-bot commented May 11, 2024

Benchmark report - Stock

benchmarks/Stock/Stock-DataGrouping.bench.ts

Sample size This PR avg (ms) master avg (ms) Diff Percent diff
1000000 1033.84 1031.46 2.38 0%
See all
Sample size This PR avg (ms) master avg (ms) Diff Percent diff
1000 244.96 246.22 -1.26 -1%
10000 259.07 256.44 2.63 1%
100000 393.44 383.38 10.05 3%
1000000 1033.84 1031.46 2.38 0%

benchmarks/Stock/Stock-Base.bench.ts

Sample size This PR avg (ms) master avg (ms) Diff Percent diff
1000000 6294.19 6209.5 84.68 1%
See all
Sample size This PR avg (ms) master avg (ms) Diff Percent diff
1000 263.11 250.39 12.72 5%
10000 348.57 343.37 5.21 2%
100000 905.77 906.26 -0.49 0%
1000000 6294.19 6209.5 84.68 1%

benchmarks/Stock/Stock-DataGrouping-Ordinal.bench.ts

Sample size This PR avg (ms) master avg (ms) Diff Percent diff
1000000 1404.53 1404.37 0.16 0%
See all
Sample size This PR avg (ms) master avg (ms) Diff Percent diff
1000 265.77 260.71 5.06 2%
10000 278.86 279.14 -0.28 0%
100000 494.01 495.44 -1.43 0%
1000000 1404.53 1404.37 0.16 0%

benchmarks/Stock/Stock-Ordinal.bench.ts

Sample size This PR avg (ms) master avg (ms) Diff Percent diff
1000000 1406.64 1402.03 4.61 0%
See all
Sample size This PR avg (ms) master avg (ms) Diff Percent diff
1000 258.01 259.4 -1.4 -1%
10000 279.78 276.96 2.82 1%
100000 490.45 493.58 -3.12 -1%
1000000 1406.64 1402.03 4.61 0%

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.

None yet

2 participants