Bug 230827 - REGRESSION (iOS 15): Intl.DateTimeFormat returns 2 digit years when type is 'numeric'
Summary: REGRESSION (iOS 15): Intl.DateTimeFormat returns 2 digit years when type is '...
Status: RESOLVED WORKSFORME
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: Other
Hardware: iPhone / iPad Other
: P2 Normal
Assignee: Yusuke Suzuki
URL: https://jsfiddle.net/davidwebster/0b6...
Keywords: InRadar
: 231545 (view as bug list)
Depends on:
Blocks:
 
Reported: 2021-09-27 05:22 PDT by David Webster
Modified: 2021-11-23 12:33 PST (History)
8 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Webster 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/
Comment 1 Kevin Neal 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.
Comment 2 Radar WebKit Bug Importer 2021-09-29 09:10:57 PDT
<rdar://problem/83673541>
Comment 3 David Webster 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.
Comment 4 Yusuke Suzuki 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.
Comment 5 Yusuke Suzuki 2021-10-02 14:24:39 PDT
Committed r283446 (242433@main): <https://commits.webkit.org/242433@main>
Comment 6 Yusuke Suzuki 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.
Comment 7 Matt Carroll 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"
```
Comment 8 Yusuke Suzuki 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.
Comment 9 Yusuke Suzuki 2021-10-12 14:28:31 PDT
*** Bug 231545 has been marked as a duplicate of this bug. ***
Comment 10 Matt Carroll 2021-10-12 14:52:27 PDT
Is there an ETA on when this will be fixed in iOS?
Comment 11 Myles C. Maxfield 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.
Comment 12 Matt Carroll 2021-10-12 14:54:20 PDT
Ok, thank you.
Comment 13 Blake 2021-10-27 17:57:40 PDT
Has there been any update on this, we are still experiencing the issue?
Comment 14 Blake 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?
Comment 15 Wojciech Maj 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.