Commit 32213cc
authored
tzset: Fix timezone extraction not working for all languages (#22250)
With certain language I've noticed that the timezone extraction
algorithm doesn't work. or example consider the following:
Test file:
```JavaScript
const date = new Date();
console.log(date.toLocaleTimeString(undefined, {hour12: false, timeZoneName: 'short'}))
```
Run test file with specific local such as `th-TH` or `ar-AE`
```bash
LC_ALL="th-TH" TZ="Asia/Bangkok" node test.js
# prints "15 นาฬิกา 53 นาที 54 วินาที GMT+7"
```
And so the current logic for extracting would fail and return "นาฬิกา" (second item when splitting by space)
In this PR, a new approach is proposed for extracting the timezone offset and tests are updated with new test-case
See #215961 parent 9a489b0 commit 32213cc
2 files changed
+27
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
657 | 657 | | |
658 | 658 | | |
659 | 659 | | |
660 | | - | |
661 | | - | |
662 | | - | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
663 | 674 | | |
664 | 675 | | |
665 | 676 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
| 39 | + | |
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| |||
5942 | 5942 | | |
5943 | 5943 | | |
5944 | 5944 | | |
5945 | | - | |
5946 | 5945 | | |
5947 | | - | |
| 5946 | + | |
5948 | 5947 | | |
5949 | | - | |
| 5948 | + | |
| 5949 | + | |
| 5950 | + | |
| 5951 | + | |
| 5952 | + | |
| 5953 | + | |
| 5954 | + | |
| 5955 | + | |
| 5956 | + | |
| 5957 | + | |
| 5958 | + | |
5950 | 5959 | | |
5951 | 5960 | | |
5952 | 5961 | | |
| |||
0 commit comments