Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(190)

Side by Side Diff: src/i18n.cc

Issue 1501113002: Set the Gregorian changeover date to the beginning of time in Intl (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Replace a CHECK with DCHECK Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | test/intl/date-format/format-test.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 // limitations under the License. 4 // limitations under the License.
5 5
6 #include "src/i18n.h" 6 #include "src/i18n.h"
7 7
8 #include "src/api.h" 8 #include "src/api.h"
9 #include "src/factory.h" 9 #include "src/factory.h"
10 #include "src/isolate.h" 10 #include "src/isolate.h"
11 #include "unicode/brkiter.h" 11 #include "unicode/brkiter.h"
12 #include "unicode/calendar.h" 12 #include "unicode/calendar.h"
13 #include "unicode/coll.h" 13 #include "unicode/coll.h"
14 #include "unicode/curramt.h" 14 #include "unicode/curramt.h"
15 #include "unicode/dcfmtsym.h" 15 #include "unicode/dcfmtsym.h"
16 #include "unicode/decimfmt.h" 16 #include "unicode/decimfmt.h"
17 #include "unicode/dtfmtsym.h" 17 #include "unicode/dtfmtsym.h"
18 #include "unicode/dtptngen.h" 18 #include "unicode/dtptngen.h"
19 #include "unicode/gregocal.h"
19 #include "unicode/locid.h" 20 #include "unicode/locid.h"
20 #include "unicode/numfmt.h" 21 #include "unicode/numfmt.h"
21 #include "unicode/numsys.h" 22 #include "unicode/numsys.h"
22 #include "unicode/rbbi.h" 23 #include "unicode/rbbi.h"
23 #include "unicode/smpdtfmt.h" 24 #include "unicode/smpdtfmt.h"
24 #include "unicode/timezone.h" 25 #include "unicode/timezone.h"
25 #include "unicode/uchar.h" 26 #include "unicode/uchar.h"
26 #include "unicode/ucol.h" 27 #include "unicode/ucol.h"
27 #include "unicode/ucurr.h" 28 #include "unicode/ucurr.h"
28 #include "unicode/unum.h" 29 #include "unicode/unum.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 tz = icu::TimeZone::createTimeZone(timezone); 90 tz = icu::TimeZone::createTimeZone(timezone);
90 } else { 91 } else {
91 tz = icu::TimeZone::createDefault(); 92 tz = icu::TimeZone::createDefault();
92 } 93 }
93 94
94 // Create a calendar using locale, and apply time zone to it. 95 // Create a calendar using locale, and apply time zone to it.
95 UErrorCode status = U_ZERO_ERROR; 96 UErrorCode status = U_ZERO_ERROR;
96 icu::Calendar* calendar = 97 icu::Calendar* calendar =
97 icu::Calendar::createInstance(tz, icu_locale, status); 98 icu::Calendar::createInstance(tz, icu_locale, status);
98 99
100 if (calendar->getDynamicClassID() ==
101 icu::GregorianCalendar::getStaticClassID()) {
102 icu::GregorianCalendar* gc = (icu::GregorianCalendar*)calendar;
103 UErrorCode status = U_ZERO_ERROR;
104 // The beginning of ECMAScript time, namely -(2**53)
105 const double start_of_time = -9007199254740992;
106 gc->setGregorianChange(start_of_time, status);
107 DCHECK(U_SUCCESS(status));
108 }
109
99 // Make formatter from skeleton. Calendar and numbering system are added 110 // Make formatter from skeleton. Calendar and numbering system are added
100 // to the locale as Unicode extension (if they were specified at all). 111 // to the locale as Unicode extension (if they were specified at all).
101 icu::SimpleDateFormat* date_format = NULL; 112 icu::SimpleDateFormat* date_format = NULL;
102 icu::UnicodeString skeleton; 113 icu::UnicodeString skeleton;
103 if (ExtractStringSetting(isolate, options, "skeleton", &skeleton)) { 114 if (ExtractStringSetting(isolate, options, "skeleton", &skeleton)) {
104 icu::DateTimePatternGenerator* generator = 115 icu::DateTimePatternGenerator* generator =
105 icu::DateTimePatternGenerator::createInstance(icu_locale, status); 116 icu::DateTimePatternGenerator::createInstance(icu_locale, status);
106 icu::UnicodeString pattern; 117 icu::UnicodeString pattern;
107 if (U_SUCCESS(status)) { 118 if (U_SUCCESS(status)) {
108 pattern = generator->getBestPattern(skeleton, status); 119 pattern = generator->getBestPattern(skeleton, status);
(...skipping 853 matching lines...) Expand 10 before | Expand all | Expand 10 after
962 973
963 void BreakIterator::DeleteBreakIterator( 974 void BreakIterator::DeleteBreakIterator(
964 const v8::WeakCallbackData<v8::Value, void>& data) { 975 const v8::WeakCallbackData<v8::Value, void>& data) {
965 DeleteNativeObjectAt<icu::BreakIterator>(data, 0); 976 DeleteNativeObjectAt<icu::BreakIterator>(data, 0);
966 DeleteNativeObjectAt<icu::UnicodeString>(data, 1); 977 DeleteNativeObjectAt<icu::UnicodeString>(data, 1);
967 DestroyGlobalHandle(data); 978 DestroyGlobalHandle(data);
968 } 979 }
969 980
970 } // namespace internal 981 } // namespace internal
971 } // namespace v8 982 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/intl/date-format/format-test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698