| OLD | NEW |
| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 return TimeFormat(formatter.get(), time); | 134 return TimeFormat(formatter.get(), time); |
| 135 } | 135 } |
| 136 | 136 |
| 137 string16 TimeFormatShortDateAndTimeWithTimeZone(const Time& time) { | 137 string16 TimeFormatShortDateAndTimeWithTimeZone(const Time& time) { |
| 138 std::unique_ptr<icu::DateFormat> formatter( | 138 std::unique_ptr<icu::DateFormat> formatter( |
| 139 icu::DateFormat::createDateTimeInstance(icu::DateFormat::kShort, | 139 icu::DateFormat::createDateTimeInstance(icu::DateFormat::kShort, |
| 140 icu::DateFormat::kLong)); | 140 icu::DateFormat::kLong)); |
| 141 return TimeFormat(formatter.get(), time); | 141 return TimeFormat(formatter.get(), time); |
| 142 } | 142 } |
| 143 | 143 |
| 144 string16 TimeFormatMonthAndYear(const Time& time) { |
| 145 icu::SimpleDateFormat formatter = CreateSimpleDateFormatter(UDAT_YEAR_MONTH); |
| 146 return TimeFormat(&formatter, time); |
| 147 } |
| 148 |
| 149 string16 TimeFormatWeekdayMonthAndDay(const Time& time) { |
| 150 icu::SimpleDateFormat formatter = |
| 151 CreateSimpleDateFormatter(UDAT_MONTH_WEEKDAY_DAY); |
| 152 return TimeFormat(&formatter, time); |
| 153 } |
| 154 |
| 144 string16 TimeFormatFriendlyDateAndTime(const Time& time) { | 155 string16 TimeFormatFriendlyDateAndTime(const Time& time) { |
| 145 std::unique_ptr<icu::DateFormat> formatter( | 156 std::unique_ptr<icu::DateFormat> formatter( |
| 146 icu::DateFormat::createDateTimeInstance(icu::DateFormat::kFull)); | 157 icu::DateFormat::createDateTimeInstance(icu::DateFormat::kFull)); |
| 147 return TimeFormat(formatter.get(), time); | 158 return TimeFormat(formatter.get(), time); |
| 148 } | 159 } |
| 149 | 160 |
| 150 string16 TimeFormatFriendlyDate(const Time& time) { | 161 string16 TimeFormatFriendlyDate(const Time& time) { |
| 151 std::unique_ptr<icu::DateFormat> formatter( | 162 std::unique_ptr<icu::DateFormat> formatter( |
| 152 icu::DateFormat::createDateInstance(icu::DateFormat::kFull)); | 163 icu::DateFormat::createDateInstance(icu::DateFormat::kFull)); |
| 153 return TimeFormat(formatter.get(), time); | 164 return TimeFormat(formatter.get(), time); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 // See http://userguide.icu-project.org/formatparse/datetime for details | 216 // See http://userguide.icu-project.org/formatparse/datetime for details |
| 206 // about the date/time format syntax. | 217 // about the date/time format syntax. |
| 207 if (pattern_unicode.indexOf('a') == -1) { | 218 if (pattern_unicode.indexOf('a') == -1) { |
| 208 return k24HourClock; | 219 return k24HourClock; |
| 209 } else { | 220 } else { |
| 210 return k12HourClock; | 221 return k12HourClock; |
| 211 } | 222 } |
| 212 } | 223 } |
| 213 | 224 |
| 214 } // namespace base | 225 } // namespace base |
| OLD | NEW |