RESOLVED WORKSFORME 230827
REGRESSION (iOS 15): Intl.DateTimeFormat returns 2 digit years when type is 'numeric'
https://bugs.webkit.org/show_bug.cgi?id=230827
Summary REGRESSION (iOS 15): Intl.DateTimeFormat returns 2 digit years when type is '...
David Webster
Reported 2021-09-27 05:22:11 PDT
This bug occurs in Safari on iOS 15. When Intl.DateTimeFormat is formatting a year, and the configuration for year is 'numeric', it returns a two-digit year. However, I expect the full year. Previous versions returned the full year, and other browsers (including Safari 15 on OSX) return the full year. Here's a code sample: const dtf = new Intl.DateTimeFormat('en-AU', { timeZone: 'Australia/Melbourne', year: 'numeric' }); const date = new Date(); const parts = dtf.formatToParts(date); const year = parts.find(part => part.type === 'year') console.log(year.value) // expected output is "2021", but in Safari 15 on iOS, it's "21". You can try this at https://jsfiddle.net/davidwebster/0b6qfu34/5/
Attachments
Kevin Neal
Comment 1 2021-09-29 09:10:49 PDT
Thank you for filing. What version of iOS 15 are you using? I was not able to reproduce the bug using the latest iOS 15 beta.
Radar WebKit Bug Importer
Comment 2 2021-09-29 09:10:57 PDT
David Webster
Comment 3 2021-09-29 17:42:35 PDT
I'm using version 15.0. I'm using the Simulator in XCode because I don't have a real iPhone to test on. I can't find any way to use the latest iOS 15 beta in the simulator.
Yusuke Suzuki
Comment 4 2021-10-02 14:10:40 PDT
Thank you for filing an issue! I tried it in iOS 15 device and iOS 15 simulator, but I cannot reproduce this issue. Both shows the "2021", expected behavior. For now, I'll just add that as a regression test.
Yusuke Suzuki
Comment 5 2021-10-02 14:24:39 PDT
Yusuke Suzuki
Comment 6 2021-10-02 14:25:24 PDT
Since we cannot reproduce this issue, we didn't change the code, but adding a test case to our stress tests to ensure that this is/will be happening. Thanks.
Matt Carroll
Comment 7 2021-10-07 15:28:19 PDT
Can this please be reopened. It seems the bug still exists. This test case passes: ``` const dtf = new Intl.DateTimeFormat('en-AU', { timeZone: 'Australia/Melbourne', year: 'numeric' }); const date = new Date(2021, 9, 2); const parts = dtf.formatToParts(date); const year = parts.find(part => part.type === 'year') shouldBe(year.value, "2021") ``` This test case will fail: ``` const dtf = new Intl.DateTimeFormat('en-AU', { timeZone: 'Australia/Melbourne', year: 'numeric', month: '2-digit', day: '2-digit' }); const date = new Date(2021, 9, 2); const parts = dtf.formatToParts(date); const year = parts.find(part => part.type === 'year') shouldBe(year.value, "2021") // actual is "21" ```
Yusuke Suzuki
Comment 8 2021-10-12 12:21:42 PDT
(In reply to Matt Carroll from comment #7) > Can this please be reopened. It seems the bug still exists. > > This test case passes: > > ``` > const dtf = new Intl.DateTimeFormat('en-AU', { timeZone: > 'Australia/Melbourne', year: 'numeric' }); > const date = new Date(2021, 9, 2); > const parts = dtf.formatToParts(date); > const year = parts.find(part => part.type === 'year') > shouldBe(year.value, "2021") > ``` > > > This test case will fail: > > ``` > const dtf = new Intl.DateTimeFormat('en-AU', { timeZone: > 'Australia/Melbourne', year: 'numeric', month: '2-digit', day: '2-digit' }); > const date = new Date(2021, 9, 2); > const parts = dtf.formatToParts(date); > const year = parts.find(part => part.type === 'year') > shouldBe(year.value, "2021") // actual is "21" > ``` Thanks. The updated test case can reproduce the issue. This looks like a data problem in AppleICU (not WebKit), and now tracked by AppleICU team at rdar://83597941. So closing this issue since the issue is in system ICU, not in WebKit code.
Yusuke Suzuki
Comment 9 2021-10-12 14:28:31 PDT
*** Bug 231545 has been marked as a duplicate of this bug. ***
Matt Carroll
Comment 10 2021-10-12 14:52:27 PDT
Is there an ETA on when this will be fixed in iOS?
Myles C. Maxfield
Comment 11 2021-10-12 14:53:39 PDT
(In reply to Matt Carroll from comment #10) > Is there an ETA on when this will be fixed in iOS? Apple does not comment on future products or releases.
Matt Carroll
Comment 12 2021-10-12 14:54:20 PDT
Ok, thank you.
Blake
Comment 13 2021-10-27 17:57:40 PDT
Has there been any update on this, we are still experiencing the issue?
Blake
Comment 14 2021-11-10 15:56:59 PST
Hi, this bug has been marked as resolved but we can see the error is still occurring. Is this being investigated further?
Wojciech Maj
Comment 15 2021-11-23 12:33:22 PST
I was also able to reproduce this bug on Safari 15.1 (17612.2.9.1.20) on macOS Monterey. So this is NOT exclusive to iOS.
Note You need to log in before you can comment on or make changes to this bug.