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

Side by Side Diff: base/i18n/time_formatting.cc

Issue 7082038: Fix memory leak of base/i18n/time_formatter.cc (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium 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 4
5 #include "base/i18n/time_formatting.h" 5 #include "base/i18n/time_formatting.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "base/time.h" 10 #include "base/time.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 HourClockType default_type = GetHourClockType(); 66 HourClockType default_type = GetHourClockType();
67 if (default_type == type && (type == k24HourClock || ampm == kKeepAmPm)) { 67 if (default_type == type && (type == k24HourClock || ampm == kKeepAmPm)) {
68 return TimeFormatTimeOfDay(time); 68 return TimeFormatTimeOfDay(time);
69 } 69 }
70 70
71 // Generate a locale-dependent format pattern. The generator will take 71 // Generate a locale-dependent format pattern. The generator will take
72 // care of locale-dependent formatting issues like which separator to 72 // care of locale-dependent formatting issues like which separator to
73 // use (some locales use '.' instead of ':'), and where to put the am/pm 73 // use (some locales use '.' instead of ':'), and where to put the am/pm
74 // marker. 74 // marker.
75 UErrorCode status = U_ZERO_ERROR; 75 UErrorCode status = U_ZERO_ERROR;
76 icu::DateTimePatternGenerator *generator = 76 scoped_ptr<icu::DateTimePatternGenerator> generator(
77 icu::DateTimePatternGenerator::createInstance(status); 77 icu::DateTimePatternGenerator::createInstance(status));
78 CHECK(U_SUCCESS(status)); 78 CHECK(U_SUCCESS(status));
79 const char* base_pattern = (type == k12HourClock ? "ahm" : "Hm"); 79 const char* base_pattern = (type == k12HourClock ? "ahm" : "Hm");
80 icu::UnicodeString generated_pattern = 80 icu::UnicodeString generated_pattern =
81 generator->getBestPattern(icu::UnicodeString(base_pattern), status); 81 generator->getBestPattern(icu::UnicodeString(base_pattern), status);
82 CHECK(U_SUCCESS(status)); 82 CHECK(U_SUCCESS(status));
83 83
84 // Then, format the time using the generated pattern. 84 // Then, format the time using the generated pattern.
85 icu::SimpleDateFormat formatter(generated_pattern, status); 85 icu::SimpleDateFormat formatter(generated_pattern, status);
86 CHECK(U_SUCCESS(status)); 86 CHECK(U_SUCCESS(status));
87 if (ampm == kKeepAmPm) { 87 if (ampm == kKeepAmPm) {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 // See http://userguide.icu-project.org/formatparse/datetime for details 155 // See http://userguide.icu-project.org/formatparse/datetime for details
156 // about the date/time format syntax. 156 // about the date/time format syntax.
157 if (pattern_unicode.indexOf('a') == -1) { 157 if (pattern_unicode.indexOf('a') == -1) {
158 return k24HourClock; 158 return k24HourClock;
159 } else { 159 } else {
160 return k12HourClock; 160 return k12HourClock;
161 } 161 }
162 } 162 }
163 163
164 } // namespace base 164 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698