| 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 |
| 11 #include "base/compiler_specific.h" |
| 11 #include "base/i18n/base_i18n_export.h" | 12 #include "base/i18n/base_i18n_export.h" |
| 12 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
| 13 | 14 |
| 14 namespace base { | 15 namespace base { |
| 15 | 16 |
| 16 class Time; | 17 class Time; |
| 17 class TimeDelta; | 18 class TimeDelta; |
| 18 | 19 |
| 19 // Argument type used to specify the hour clock type. | 20 // Argument type used to specify the hour clock type. |
| 20 enum HourClockType { | 21 enum HourClockType { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 | 70 |
| 70 // Formats a time in a friendly sentence format, e.g. | 71 // Formats a time in a friendly sentence format, e.g. |
| 71 // "Monday, March 6, 2008 2:44:30 PM". | 72 // "Monday, March 6, 2008 2:44:30 PM". |
| 72 BASE_I18N_EXPORT string16 TimeFormatFriendlyDateAndTime(const Time& time); | 73 BASE_I18N_EXPORT string16 TimeFormatFriendlyDateAndTime(const Time& time); |
| 73 | 74 |
| 74 // Formats a time in a friendly sentence format, e.g. | 75 // Formats a time in a friendly sentence format, e.g. |
| 75 // "Monday, March 6, 2008". | 76 // "Monday, March 6, 2008". |
| 76 BASE_I18N_EXPORT string16 TimeFormatFriendlyDate(const Time& time); | 77 BASE_I18N_EXPORT string16 TimeFormatFriendlyDate(const Time& time); |
| 77 | 78 |
| 78 // Formats a time duration of hours and minutes into various formats, e.g., | 79 // 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. | 80 // "3:07" or "3 hours, 7 minutes", and returns true on success. See |
| 81 // DurationFormatWidth for details. |
| 80 // | 82 // |
| 81 // Please don't use width = DURATION_WIDTH_NUMERIC when the time duration | 83 // 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 | 84 // can possibly be larger than 24h, as the hour value will be cut below 24 |
| 83 // after formatting. | 85 // after formatting. |
| 84 // TODO(chengx): fix function output when width = DURATION_WIDTH_NUMERIC | 86 // TODO(chengx): fix function output when width = DURATION_WIDTH_NUMERIC |
| 85 // (http://crbug.com/675791) | 87 // (http://crbug.com/675791) |
| 86 BASE_I18N_EXPORT string16 TimeDurationFormat(const TimeDelta time, | 88 BASE_I18N_EXPORT bool TimeDurationFormat(const TimeDelta time, |
| 87 const DurationFormatWidth width); | 89 const DurationFormatWidth width, |
| 90 string16* out) WARN_UNUSED_RESULT; |
| 88 | 91 |
| 89 // Formats a time duration of hours, minutes and seconds into various formats, | 92 // Formats a time duration of hours, minutes and seconds into various formats, |
| 90 // e.g., "3:07:30" or "3 hours, 7 minutes, 30 seconds". See DurationFormatWidth | 93 // e.g., "3:07:30" or "3 hours, 7 minutes, 30 seconds", and returns true on |
| 91 // for details. | 94 // success. See DurationFormatWidth for details. |
| 92 // | 95 // |
| 93 // Please don't use width = DURATION_WIDTH_NUMERIC when the time duration | 96 // Please don't use width = DURATION_WIDTH_NUMERIC when the time duration |
| 94 // can possibly be larger than 24h, as the hour value will be cut below 24 | 97 // can possibly be larger than 24h, as the hour value will be cut below 24 |
| 95 // after formatting. | 98 // after formatting. |
| 96 // TODO(chengx): fix function output when width = DURATION_WIDTH_NUMERIC | 99 // TODO(chengx): fix function output when width = DURATION_WIDTH_NUMERIC |
| 97 // (http://crbug.com/675791) | 100 // (http://crbug.com/675791) |
| 98 BASE_I18N_EXPORT string16 | 101 BASE_I18N_EXPORT bool TimeDurationFormatWithSeconds( |
| 99 TimeDurationFormatWithSeconds(const TimeDelta time, | 102 const TimeDelta time, |
| 100 const DurationFormatWidth width); | 103 const DurationFormatWidth width, |
| 104 string16* out) WARN_UNUSED_RESULT; |
| 101 | 105 |
| 102 // Gets the hour clock type of the current locale. e.g. | 106 // Gets the hour clock type of the current locale. e.g. |
| 103 // k12HourClock (en-US). | 107 // k12HourClock (en-US). |
| 104 // k24HourClock (en-GB). | 108 // k24HourClock (en-GB). |
| 105 BASE_I18N_EXPORT HourClockType GetHourClockType(); | 109 BASE_I18N_EXPORT HourClockType GetHourClockType(); |
| 106 | 110 |
| 107 } // namespace base | 111 } // namespace base |
| 108 | 112 |
| 109 #endif // BASE_I18N_TIME_FORMATTING_H_ | 113 #endif // BASE_I18N_TIME_FORMATTING_H_ |
| OLD | NEW |