-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
sap.ui.core.format.DateFormat format for 31.12.2018 is not correct in German language #2370
Comments
Use it with yyyy instead of YYYY, because of the way calendar years are taken by the specific format string |
Great. Thanks for the quick support @stephania87 |
Hi, The more detailed answer I have from the dev team is as follows: According the Unicode LDML Date Format notation (https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table ) the year format YYYY is corresponding to: Year in “Week of Year” based calendars in which the year transition occurs on a week boundary; may differ from calendar year ‘y’ near a year transition. This numeric year designation is used in conjunction with pattern character ‘w’ in the ISO year-week calendar as defined by ISO 8601, but can be used in non-Gregorian based calendar systems where week date processing is desired. The field length is interpreted in the same was as for ‘y’; that is, “yy” specifies use of the two low-order year digits, while any other field length specifies a minimum number of digits to display. To receive the expected year please replace "YYYY" with "yyyy". |
OpenUI5 version:
1.52.9
Browser/version (+device/version):
Desktop/Win 10/Chrome Version 71.0.3578.98
Any other tested browsers/devices(OK/FAIL):
Fail on all other PC & browser.
Steps to reproduce the problem:
Create a date using: Date(2018,11,31) (date: 31.12.2018 in German)
var oDate = new Date(2018,11,31);
Create a format instance from sap.ui.core:
sFromatedDate
What is the expected result?
sFromatedDate should show the formatted date in the local language.
E.g.:
What happens instead?
The formatted date for English is correct.
But for German it is incorrect. The year changed to 2019:
E.g.:
Any other information? (attach a screenshot if possible)
I've debugged into sap.ui.core.format library's code, and found out that the date 31.12.2018 is calculated (in German) as the first date of the first week of the new year 2019, instead of the last date in 2018. The getWeekByDate function returned an object:
{year: 2019, week: 0}
Which may be correct in German date format somehow. But in our production, it's not correct, since we only show formatted date in
dd.mm.yyyy
, without the week number.I will attach the screenshot for debugging code.
You can see the value of variable of the right side of each code line.
(I'm using Chrome's debugger)
Code in get year function:
![2019-01-15_13h57_27](https://user-images.githubusercontent.com/19721878/51164978-51bbbb80-18d1-11e9-9e7d-58ec0fbe2997.png)
Code in get week number function: (root cause of the problem here)
![2019-01-15_14h05_35](https://user-images.githubusercontent.com/19721878/51164980-51bbbb80-18d1-11e9-8021-e358285719b4.png)
The text was updated successfully, but these errors were encountered: