RESOLVED FIXED Bug 76714
implement Date.toLocaleString() using ICU
https://bugs.webkit.org/show_bug.cgi?id=76714
Summary implement Date.toLocaleString() using ICU
Eli Fidler
Reported 2012-01-20 10:21:13 PST
Some platforms don't localize strftime well, so use ICU to implement Date.toLocaleString()
Attachments
Patch (2.39 KB, patch)
2012-01-20 10:29 PST, Eli Fidler
no flags
Eli Fidler
Comment 1 2012-01-20 10:29:09 PST
Darin Adler
Comment 2 2012-01-20 11:29:13 PST
Comment on attachment 123341 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=123341&action=review > Source/JavaScriptCore/runtime/DatePrototype.cpp:210 > + UDateFormat* df = udat_open(timeStyle, dateStyle, 0, 0, -1, 0, 0, &status); Since the point of these functions is to format for the current locale, it seems critical to pass in a suitable locale string. See, for example, what is done for text break locales in the currentTextBreakLocaleID function. I’m surprised that is OK to pass 0 for the locale string.
Eli Fidler
Comment 3 2012-01-20 13:46:04 PST
0 is the "default locale". We rely on ICU for localization in many areas, so apps will have the default locale set appropriately to the desired locale. I guess that's not true for OSX or IOS, but there's a different path here for that. I could put the strftime path into HAVE(STRFTIME) or make a USE(ICU_DEFAULT_LOCALE) if you prefer.
Darin Adler
Comment 4 2012-01-21 19:02:02 PST
(In reply to comment #3) > 0 is the "default locale" Is that a general ICU feature, or one specific to RIM platforms? I ask because I don’t see it mentioned in ICU documentation. > We rely on ICU for localization in many areas Sure, OS X and iOS do too. My question is about how the ICU API works. > I could put the strftime path into HAVE(STRFTIME) or make a USE(ICU_DEFAULT_LOCALE) if you prefer. Since this code passes 0 for the locale it should be used only on platforms where that will do the right thing. To get the #if right we need to know how where that “0 means default locale” feature exists.
Alexey Proskuryakov
Comment 5 2012-01-22 16:51:10 PST
This may not be a regression from strftime, but the behavior would not be correct when locale changes at runtime, especially with WebKit2. In Mac Safari, output of (new Date).toLocaleString() changes immediately after a user changes the format in system preferences.
Eli Fidler
Comment 6 2012-01-23 09:45:21 PST
NULL for default locale is an ICU-standard feature: "Using the ICU C functions, NULL can be passed for a locale parameter to specify the default locale." from: http://userguide.icu-project.org/locale#TOC-Default-Locales For Alexey's point, Date.toLocaleString() will always use the current default locale. If that is changed using uloc_setDefault(), the new value should be immediately take effect.
WebKit Review Bot
Comment 7 2012-01-25 08:09:01 PST
Comment on attachment 123341 [details] Patch Rejecting attachment 123341 [details] from commit-queue. New failing tests: media/audio-garbage-collect.html Full output: http://queues.webkit.org/results/11342538
Eli Fidler
Comment 8 2012-01-25 15:54:07 PST
flaky test looks unrelated, so let's try cq+ again
WebKit Review Bot
Comment 9 2012-01-25 16:11:50 PST
Comment on attachment 123341 [details] Patch Clearing flags on attachment: 123341 Committed r105939: <http://trac.webkit.org/changeset/105939>
WebKit Review Bot
Comment 10 2012-01-25 16:11:54 PST
All reviewed patches have been landed. Closing bug.
Mark Rowe (bdash)
Comment 11 2012-01-25 16:41:40 PST
This broke all of the Mac builds on build.webkit.org as unicode/udat.h is not available.
Mark Rowe (bdash)
Comment 12 2012-01-25 16:48:19 PST
I checked in a fix in r105943 to try and fix the Mac builds.
Alexey Proskuryakov
Comment 13 2012-03-05 07:55:29 PST
This has reportedly caused a regression, bug 80262.
Note You need to log in before you can comment on or make changes to this bug.