Chromium Code Reviews| 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 // Basic time formatting methods. These methods use the current locale | 5 // Basic time formatting methods. These methods use the current locale |
| 6 // formatting for displaying the time. | 6 // formatting for displaying the time. |
| 7 | 7 |
| 8 #ifndef BASE_I18N_TIME_FORMATTING_H_ | 8 #ifndef BASE_I18N_TIME_FORMATTING_H_ |
| 9 #define BASE_I18N_TIME_FORMATTING_H_ | 9 #define BASE_I18N_TIME_FORMATTING_H_ |
| 10 | 10 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 68 TimeFormatShortDateAndTimeWithTimeZone(const Time& time); | 68 TimeFormatShortDateAndTimeWithTimeZone(const Time& time); |
| 69 | 69 |
| 70 // Formats a time in a friendly sentence format, e.g. | 70 // Formats a time in a friendly sentence format, e.g. |
| 71 // "Monday, March 6, 2008 2:44:30 PM". | 71 // "Monday, March 6, 2008 2:44:30 PM". |
| 72 BASE_I18N_EXPORT string16 TimeFormatFriendlyDateAndTime(const Time& time); | 72 BASE_I18N_EXPORT string16 TimeFormatFriendlyDateAndTime(const Time& time); |
| 73 | 73 |
| 74 // Formats a time in a friendly sentence format, e.g. | 74 // Formats a time in a friendly sentence format, e.g. |
| 75 // "Monday, March 6, 2008". | 75 // "Monday, March 6, 2008". |
| 76 BASE_I18N_EXPORT string16 TimeFormatFriendlyDate(const Time& time); | 76 BASE_I18N_EXPORT string16 TimeFormatFriendlyDate(const Time& time); |
| 77 | 77 |
| 78 // Formats a time using a skeleton to produce a format for different locales | |
| 79 // when unusual time format is needed, e.g. | |
| 80 // "Feb. 2, 18:00". | |
| 81 // | |
| 82 // See http://userguide.icu-project.org/formatparse/datetime for details. | |
| 83 BASE_I18N_EXPORT string16 TimeFormatWithPattern(const Time& time, | |
| 84 const char* pattern); | |
|
jungshik at Google
2017/01/23 21:43:24
Perhaps, add a unit test?
jiahuiguo
2017/01/26 05:46:12
Done.
| |
| 85 | |
| 78 // Formats a time duration of hours and minutes into various formats, e.g., | 86 // Formats a time duration of hours and minutes into various formats, e.g., |
| 79 // "3:07" or "3 hours, 7 minutes". See DurationFormatWidth for details. | 87 // "3:07" or "3 hours, 7 minutes". See DurationFormatWidth for details. |
| 80 // | 88 // |
| 81 // Please don't use width = DURATION_WIDTH_NUMERIC when the time duration | 89 // Please don't use width = DURATION_WIDTH_NUMERIC when the time duration |
| 82 // can possibly be larger than 24h, as the hour value will be cut below 24 | 90 // can possibly be larger than 24h, as the hour value will be cut below 24 |
| 83 // after formatting. | 91 // after formatting. |
| 84 // TODO(chengx): fix function output when width = DURATION_WIDTH_NUMERIC | 92 // TODO(chengx): fix function output when width = DURATION_WIDTH_NUMERIC |
| 85 // (http://crbug.com/675791) | 93 // (http://crbug.com/675791) |
| 86 BASE_I18N_EXPORT string16 TimeDurationFormat(const TimeDelta time, | 94 BASE_I18N_EXPORT string16 TimeDurationFormat(const TimeDelta time, |
| 87 const DurationFormatWidth width); | 95 const DurationFormatWidth width); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 100 const DurationFormatWidth width); | 108 const DurationFormatWidth width); |
| 101 | 109 |
| 102 // Gets the hour clock type of the current locale. e.g. | 110 // Gets the hour clock type of the current locale. e.g. |
| 103 // k12HourClock (en-US). | 111 // k12HourClock (en-US). |
| 104 // k24HourClock (en-GB). | 112 // k24HourClock (en-GB). |
| 105 BASE_I18N_EXPORT HourClockType GetHourClockType(); | 113 BASE_I18N_EXPORT HourClockType GetHourClockType(); |
| 106 | 114 |
| 107 } // namespace base | 115 } // namespace base |
| 108 | 116 |
| 109 #endif // BASE_I18N_TIME_FORMATTING_H_ | 117 #endif // BASE_I18N_TIME_FORMATTING_H_ |
| OLD | NEW |