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 9 commits into
base: master
Choose a base branch
from
Draft

Intl.DateTimeFormat #21152

wants to merge 9 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.

This PR is related to the Time refactor PR, but with different concerns:

  • The Time refactor PR replaces all internal time zone handling with functions powered by Intl.DateTimeFormat
  • The Intl.DateTimeFormat opens up for using locale and DateTimeFormatOptions in Highcharts options.

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.0 kB
96.1 kB
271.1 kB
248 B
1059 B
highstock.js 128.7 kB
371.7 kB
129.0 kB
372.9 kB
290 B
1186 B
highmaps.js 121.9 kB
349.8 kB
122.1 kB
350.8 kB
247 B
1059 B
highcharts-gantt.js 133.9 kB
385.7 kB
134.2 kB
386.9 kB
309 B
1257 B
dashboards/dashboards.js 43.2 kB
148.6 kB
43.3 kB
149.3 kB
149 B
693 B
datagrid/datagrid.js 24.8 kB
76.9 kB
24.9 kB
77.6 kB
150 B
693 B

@highsoft-bot
Copy link
Collaborator

highsoft-bot commented May 11, 2024

Visual test results - Differences found

Found 338 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-Base.bench.ts

Sample size This PR avg (ms) master avg (ms) Diff Percent diff
1000000 6323.64 6269.48 54.16 1%
See all
Sample size This PR avg (ms) master avg (ms) Diff Percent diff
1000 265.92 260.38 5.54 2%
10000 355.11 354.48 0.63 0%
100000 916.24 906.97 9.27 1%
1000000 6323.64 6269.48 54.16 1%

benchmarks/Stock/Stock-Ordinal.bench.ts

Sample size This PR avg (ms) master avg (ms) Diff Percent diff
1000000 1427.44 1393.22 34.22 2%
See all
Sample size This PR avg (ms) master avg (ms) Diff Percent diff
1000 267.48 260.96 6.53 3%
10000 285.55 273.94 11.61 4%
100000 516.54 494.11 22.43 5%
1000000 1427.44 1393.22 34.22 2%

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

Sample size This PR avg (ms) master avg (ms) Diff Percent diff
1000000 1427.82 1412.66 15.16 1%
See all
Sample size This PR avg (ms) master avg (ms) Diff Percent diff
1000 270.61 274.5 -3.88 -1%
10000 292.96 281.76 11.2 4%
100000 503.68 499.85 3.83 1%
1000000 1427.82 1412.66 15.16 1%

benchmarks/Stock/Stock-DataGrouping.bench.ts

Sample size This PR avg (ms) master avg (ms) Diff Percent diff
1000000 1046.93 1037.81 9.12 1%
See all
Sample size This PR avg (ms) master avg (ms) Diff Percent diff
1000 252.47 249.58 2.89 1%
10000 272.7 258.85 13.85 5%
100000 401.09 383.08 18.01 5%
1000000 1046.93 1037.81 9.12 1%

@TorsteinHonsi TorsteinHonsi mentioned this pull request May 28, 2024
6 tasks
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