Commit d67756a7 authored by littledan's avatar littledan Committed by Commit bot

Set the Gregorian changeover date to the beginning of time in Intl

ECMAScript dates act as if the Gregorian changeover happened at the
beginning of time. This patch fixes up internationalized date
formatting to set that changeover properly, as opposed to the ICU
default which is in the 16th century.

BUG=chromium:537382
R=adamk,cira
LOG=Y

Review URL: https://codereview.chromium.org/1501113002

Cr-Commit-Position: refs/heads/master@{#32669}
parent 0d4f8a91
......@@ -16,6 +16,7 @@
#include "unicode/decimfmt.h"
#include "unicode/dtfmtsym.h"
#include "unicode/dtptngen.h"
#include "unicode/gregocal.h"
#include "unicode/locid.h"
#include "unicode/numfmt.h"
#include "unicode/numsys.h"
......@@ -96,6 +97,16 @@ icu::SimpleDateFormat* CreateICUDateFormat(
icu::Calendar* calendar =
icu::Calendar::createInstance(tz, icu_locale, status);
if (calendar->getDynamicClassID() ==
icu::GregorianCalendar::getStaticClassID()) {
icu::GregorianCalendar* gc = (icu::GregorianCalendar*)calendar;
UErrorCode status = U_ZERO_ERROR;
// The beginning of ECMAScript time, namely -(2**53)
const double start_of_time = -9007199254740992;
gc->setGregorianChange(start_of_time, status);
DCHECK(U_SUCCESS(status));
}
// Make formatter from skeleton. Calendar and numbering system are added
// to the locale as Unicode extension (if they were specified at all).
icu::SimpleDateFormat* date_format = NULL;
......
......@@ -44,3 +44,7 @@ invalidValues.forEach(function(value) {
assertTrue(error !== undefined);
assertEquals('RangeError', error.name);
});
// https://code.google.com/p/chromium/issues/detail?id=537382
assertEquals('11/11/1500', dtf.format(new Date(1500,10,11,12,0,0)));
......@@ -404,10 +404,8 @@
'intl402/DateTimeFormat/12.1.2': [PASS, FAIL],
'intl402/DateTimeFormat/12.1.2.1_4': [FAIL],
'intl402/DateTimeFormat/12.2.3_b': [FAIL],
'intl402/DateTimeFormat/prototype/12.3.2_FDT_7_a_iv': [FAIL],
'intl402/DateTimeFormat/prototype/12.3.3': [FAIL],
'intl402/DateTimeFormat/prototype/12.3_a': [FAIL],
'intl402/DateTimeFormat/prototype/format/12.3.2_FDT_7_a_iv': [FAIL],
'intl402/Number/prototype/toLocaleString/13.2.1_5': [PASS, FAIL],
'intl402/NumberFormat/11.1.1_20_c': [FAIL],
'intl402/NumberFormat/11.1.1_a': [FAIL],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment