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

Side by Side Diff: src/i18n.cc

Issue 2273953003: Add support for DateTimeFormat.formatToParts (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: update test262.status Created 4 years, 3 months 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 | « src/heap-symbols.h ('k') | src/js/datetime-format-to-parts.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 <memory>
9
8 #include "src/api.h" 10 #include "src/api.h"
9 #include "src/factory.h" 11 #include "src/factory.h"
10 #include "src/isolate.h" 12 #include "src/isolate.h"
11 #include "unicode/brkiter.h" 13 #include "unicode/brkiter.h"
12 #include "unicode/calendar.h" 14 #include "unicode/calendar.h"
13 #include "unicode/coll.h" 15 #include "unicode/coll.h"
14 #include "unicode/curramt.h" 16 #include "unicode/curramt.h"
15 #include "unicode/dcfmtsym.h" 17 #include "unicode/dcfmtsym.h"
16 #include "unicode/decimfmt.h" 18 #include "unicode/decimfmt.h"
17 #include "unicode/dtfmtsym.h" 19 #include "unicode/dtfmtsym.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 const double start_of_time = -9007199254740992; 110 const double start_of_time = -9007199254740992;
109 gc->setGregorianChange(start_of_time, status); 111 gc->setGregorianChange(start_of_time, status);
110 DCHECK(U_SUCCESS(status)); 112 DCHECK(U_SUCCESS(status));
111 } 113 }
112 114
113 // Make formatter from skeleton. Calendar and numbering system are added 115 // Make formatter from skeleton. Calendar and numbering system are added
114 // to the locale as Unicode extension (if they were specified at all). 116 // to the locale as Unicode extension (if they were specified at all).
115 icu::SimpleDateFormat* date_format = NULL; 117 icu::SimpleDateFormat* date_format = NULL;
116 icu::UnicodeString skeleton; 118 icu::UnicodeString skeleton;
117 if (ExtractStringSetting(isolate, options, "skeleton", &skeleton)) { 119 if (ExtractStringSetting(isolate, options, "skeleton", &skeleton)) {
118 icu::DateTimePatternGenerator* generator = 120 std::unique_ptr<icu::DateTimePatternGenerator> generator(
119 icu::DateTimePatternGenerator::createInstance(icu_locale, status); 121 icu::DateTimePatternGenerator::createInstance(icu_locale, status));
120 icu::UnicodeString pattern; 122 icu::UnicodeString pattern;
121 if (U_SUCCESS(status)) { 123 if (U_SUCCESS(status))
122 pattern = generator->getBestPattern(skeleton, status); 124 pattern = generator->getBestPattern(skeleton, status);
123 delete generator;
124 }
125 125
126 date_format = new icu::SimpleDateFormat(pattern, icu_locale, status); 126 date_format = new icu::SimpleDateFormat(pattern, icu_locale, status);
127 if (U_SUCCESS(status)) { 127 if (U_SUCCESS(status)) {
128 date_format->adoptCalendar(calendar); 128 date_format->adoptCalendar(calendar);
129 } 129 }
130 } 130 }
131 131
132 if (U_FAILURE(status)) { 132 if (U_FAILURE(status)) {
133 delete calendar; 133 delete calendar;
134 delete date_format; 134 delete date_format;
135 date_format = NULL; 135 date_format = nullptr;
136 } 136 }
137 137
138 return date_format; 138 return date_format;
139 } 139 }
140 140
141 141
142 void SetResolvedDateSettings(Isolate* isolate, 142 void SetResolvedDateSettings(Isolate* isolate,
143 const icu::Locale& icu_locale, 143 const icu::Locale& icu_locale,
144 icu::SimpleDateFormat* date_format, 144 icu::SimpleDateFormat* date_format,
145 Handle<JSObject> resolved) { 145 Handle<JSObject> resolved) {
(...skipping 812 matching lines...) Expand 10 before | Expand all | Expand 10 after
958 958
959 void BreakIterator::DeleteBreakIterator( 959 void BreakIterator::DeleteBreakIterator(
960 const v8::WeakCallbackInfo<void>& data) { 960 const v8::WeakCallbackInfo<void>& data) {
961 delete reinterpret_cast<icu::BreakIterator*>(data.GetInternalField(0)); 961 delete reinterpret_cast<icu::BreakIterator*>(data.GetInternalField(0));
962 delete reinterpret_cast<icu::UnicodeString*>(data.GetInternalField(1)); 962 delete reinterpret_cast<icu::UnicodeString*>(data.GetInternalField(1));
963 GlobalHandles::Destroy(reinterpret_cast<Object**>(data.GetParameter())); 963 GlobalHandles::Destroy(reinterpret_cast<Object**>(data.GetParameter()));
964 } 964 }
965 965
966 } // namespace internal 966 } // namespace internal
967 } // namespace v8 967 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap-symbols.h ('k') | src/js/datetime-format-to-parts.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698