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

Side by Side Diff: src/extensions/experimental/datetime-format.cc

Issue 7244008: Change timeType and dateType in i18n date format API into timeStyle and dateStyle to match the pr... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Regex fix. Created 9 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | src/extensions/experimental/i18n.js » ('j') | src/extensions/experimental/i18n.js » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 generator->getBestPattern(skeleton, status); 286 generator->getBestPattern(skeleton, status);
287 287
288 date_format = new icu::SimpleDateFormat(pattern, icu_locale, status); 288 date_format = new icu::SimpleDateFormat(pattern, icu_locale, status);
289 if (U_SUCCESS(status)) { 289 if (U_SUCCESS(status)) {
290 return date_format; 290 return date_format;
291 } else { 291 } else {
292 delete date_format; 292 delete date_format;
293 } 293 }
294 } 294 }
295 295
296 // Extract date type and time type from settings. 296 // Extract date style and time style from settings.
297 icu::UnicodeString date_type; 297 icu::UnicodeString date_style;
298 icu::DateFormat::EStyle date_style = icu::DateFormat::kNone; 298 icu::DateFormat::EStyle icu_date_style = icu::DateFormat::kNone;
299 if (I18NUtils::ExtractStringSetting(settings, "dateType", &date_type)) { 299 if (I18NUtils::ExtractStringSetting(settings, "dateStyle", &date_style)) {
300 date_style = GetDateTimeStyle(date_type); 300 icu_date_style = GetDateTimeStyle(date_style);
301 } 301 }
302 302
303 icu::UnicodeString time_type; 303 icu::UnicodeString time_style;
304 icu::DateFormat::EStyle time_style = icu::DateFormat::kNone; 304 icu::DateFormat::EStyle icu_time_style = icu::DateFormat::kNone;
305 if (I18NUtils::ExtractStringSetting(settings, "timeType", &time_type)) { 305 if (I18NUtils::ExtractStringSetting(settings, "timeStyle", &time_style)) {
306 time_style = GetDateTimeStyle(time_type); 306 icu_time_style = GetDateTimeStyle(time_style);
307 } 307 }
308 308
309 // Try all combinations of date/time types. 309 // Try all combinations of date/time styles.
310 if (date_style == icu::DateFormat::kNone && 310 if (icu_date_style == icu::DateFormat::kNone &&
311 time_style == icu::DateFormat::kNone) { 311 icu_time_style == icu::DateFormat::kNone) {
312 // Return default short date, short 312 // Return default short date, short
313 return icu::DateFormat::createDateTimeInstance( 313 return icu::DateFormat::createDateTimeInstance(
314 icu::DateFormat::kShort, icu::DateFormat::kShort, icu_locale); 314 icu::DateFormat::kShort, icu::DateFormat::kShort, icu_locale);
315 } else if (date_style != icu::DateFormat::kNone && 315 } else if (icu_date_style != icu::DateFormat::kNone &&
316 time_style != icu::DateFormat::kNone) { 316 icu_time_style != icu::DateFormat::kNone) {
317 return icu::DateFormat::createDateTimeInstance( 317 return icu::DateFormat::createDateTimeInstance(
318 date_style, time_style, icu_locale); 318 icu_date_style, icu_time_style, icu_locale);
319 } else if (date_style != icu::DateFormat::kNone) { 319 } else if (icu_date_style != icu::DateFormat::kNone) {
320 return icu::DateFormat::createDateInstance(date_style, icu_locale); 320 return icu::DateFormat::createDateInstance(icu_date_style, icu_locale);
321 } else { 321 } else {
322 // time_style != icu::DateFormat::kNone 322 // icu_time_style != icu::DateFormat::kNone
323 return icu::DateFormat::createTimeInstance(time_style, icu_locale); 323 return icu::DateFormat::createTimeInstance(icu_time_style, icu_locale);
324 } 324 }
325 } 325 }
326 326
327 // Creates a v8::Array of narrow, abbrev or wide symbols. 327 // Creates a v8::Array of narrow, abbrev or wide symbols.
328 static v8::Handle<v8::Value> GetSymbols(const v8::Arguments& args, 328 static v8::Handle<v8::Value> GetSymbols(const v8::Arguments& args,
329 const icu::UnicodeString* narrow, 329 const icu::UnicodeString* narrow,
330 int32_t narrow_count, 330 int32_t narrow_count,
331 const icu::UnicodeString* abbrev, 331 const icu::UnicodeString* abbrev,
332 int32_t abbrev_count, 332 int32_t abbrev_count,
333 const icu::UnicodeString* wide, 333 const icu::UnicodeString* wide,
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 } else if (type == UNICODE_STRING_SIMPLE("long")) { 375 } else if (type == UNICODE_STRING_SIMPLE("long")) {
376 return icu::DateFormat::kLong; 376 return icu::DateFormat::kLong;
377 } else if (type == UNICODE_STRING_SIMPLE("full")) { 377 } else if (type == UNICODE_STRING_SIMPLE("full")) {
378 return icu::DateFormat::kFull; 378 return icu::DateFormat::kFull;
379 } 379 }
380 380
381 return icu::DateFormat::kShort; 381 return icu::DateFormat::kShort;
382 } 382 }
383 383
384 } } // namespace v8::internal 384 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/extensions/experimental/i18n.js » ('j') | src/extensions/experimental/i18n.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698