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

Side by Side Diff: Source/core/platform/text/LocaleICU.cpp

Issue 22572005: Remove all uses of the ASCIILiteral class. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rm it from wtf Created 7 years, 4 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011,2012 Google Inc. All rights reserved. 2 * Copyright (C) 2011,2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 m_timeAMPMLabels = *timeAMPMLabels; 304 m_timeAMPMLabels = *timeAMPMLabels;
305 305
306 m_didCreateTimeFormat = true; 306 m_didCreateTimeFormat = true;
307 } 307 }
308 308
309 String LocaleICU::dateFormat() 309 String LocaleICU::dateFormat()
310 { 310 {
311 if (!m_dateFormat.isNull()) 311 if (!m_dateFormat.isNull())
312 return m_dateFormat; 312 return m_dateFormat;
313 if (!initializeShortDateFormat()) 313 if (!initializeShortDateFormat())
314 return ASCIILiteral("yyyy-MM-dd"); 314 return "yyyy-MM-dd";
315 m_dateFormat = getDateFormatPattern(m_shortDateFormat); 315 m_dateFormat = getDateFormatPattern(m_shortDateFormat);
316 return m_dateFormat; 316 return m_dateFormat;
317 } 317 }
318 318
319 static String getFormatForSkeleton(const char* locale, const String& skeleton) 319 static String getFormatForSkeleton(const char* locale, const String& skeleton)
320 { 320 {
321 String format = ASCIILiteral("yyyy-MM"); 321 String format = "yyyy-MM";
322 UErrorCode status = U_ZERO_ERROR; 322 UErrorCode status = U_ZERO_ERROR;
323 UDateTimePatternGenerator* patternGenerator = udatpg_open(locale, &status); 323 UDateTimePatternGenerator* patternGenerator = udatpg_open(locale, &status);
324 if (!patternGenerator) 324 if (!patternGenerator)
325 return format; 325 return format;
326 status = U_ZERO_ERROR; 326 status = U_ZERO_ERROR;
327 Vector<UChar> skeletonCharacters; 327 Vector<UChar> skeletonCharacters;
328 skeleton.appendTo(skeletonCharacters); 328 skeleton.appendTo(skeletonCharacters);
329 int32_t length = udatpg_getBestPattern(patternGenerator, skeletonCharacters. data(), skeletonCharacters.size(), 0, 0, &status); 329 int32_t length = udatpg_getBestPattern(patternGenerator, skeletonCharacters. data(), skeletonCharacters.size(), 0, 0, &status);
330 if (status == U_BUFFER_OVERFLOW_ERROR && length) { 330 if (status == U_BUFFER_OVERFLOW_ERROR && length) {
331 StringBuffer<UChar> buffer(length); 331 StringBuffer<UChar> buffer(length);
332 status = U_ZERO_ERROR; 332 status = U_ZERO_ERROR;
333 udatpg_getBestPattern(patternGenerator, skeletonCharacters.data(), skele tonCharacters.size(), buffer.characters(), length, &status); 333 udatpg_getBestPattern(patternGenerator, skeletonCharacters.data(), skele tonCharacters.size(), buffer.characters(), length, &status);
334 if (U_SUCCESS(status)) 334 if (U_SUCCESS(status))
335 format = String::adopt(buffer); 335 format = String::adopt(buffer);
336 } 336 }
337 udatpg_close(patternGenerator); 337 udatpg_close(patternGenerator);
338 return format; 338 return format;
339 } 339 }
340 340
341 String LocaleICU::monthFormat() 341 String LocaleICU::monthFormat()
342 { 342 {
343 if (!m_monthFormat.isNull()) 343 if (!m_monthFormat.isNull())
344 return m_monthFormat; 344 return m_monthFormat;
345 // Gets a format for "MMMM" because Windows API always provides formats for 345 // Gets a format for "MMMM" because Windows API always provides formats for
346 // "MMMM" in some locales. 346 // "MMMM" in some locales.
347 m_monthFormat = getFormatForSkeleton(m_locale.data(), ASCIILiteral("yyyyMMMM ")); 347 m_monthFormat = getFormatForSkeleton(m_locale.data(), "yyyyMMMM");
348 return m_monthFormat; 348 return m_monthFormat;
349 } 349 }
350 350
351 String LocaleICU::shortMonthFormat() 351 String LocaleICU::shortMonthFormat()
352 { 352 {
353 if (!m_shortMonthFormat.isNull()) 353 if (!m_shortMonthFormat.isNull())
354 return m_shortMonthFormat; 354 return m_shortMonthFormat;
355 m_shortMonthFormat = getFormatForSkeleton(m_locale.data(), ASCIILiteral("yyy yMMM")); 355 m_shortMonthFormat = getFormatForSkeleton(m_locale.data(), "yyyyMMM");
356 return m_shortMonthFormat; 356 return m_shortMonthFormat;
357 } 357 }
358 358
359 String LocaleICU::timeFormat() 359 String LocaleICU::timeFormat()
360 { 360 {
361 initializeDateTimeFormat(); 361 initializeDateTimeFormat();
362 return m_timeFormatWithSeconds; 362 return m_timeFormatWithSeconds;
363 } 363 }
364 364
365 String LocaleICU::shortTimeFormat() 365 String LocaleICU::shortTimeFormat()
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 } 425 }
426 426
427 const Vector<String>& LocaleICU::timeAMPMLabels() 427 const Vector<String>& LocaleICU::timeAMPMLabels()
428 { 428 {
429 initializeDateTimeFormat(); 429 initializeDateTimeFormat();
430 return m_timeAMPMLabels; 430 return m_timeAMPMLabels;
431 } 431 }
432 432
433 } // namespace WebCore 433 } // namespace WebCore
434 434
OLDNEW
« no previous file with comments | « Source/core/platform/text/DateTimeFormat.cpp ('k') | Source/core/platform/text/TextBreakIteratorICU.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698