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 #pragma once | 10 #pragma once |
11 | 11 |
12 #include "base/string16.h" | 12 #include "base/string16.h" |
13 | 13 |
14 namespace base { | 14 namespace base { |
15 | 15 |
16 class Time; | 16 class Time; |
17 | 17 |
18 // Argument type used to specify the hour clock type. | 18 // Argument type used to specify the hour clock type. |
19 enum HourClockType { | 19 enum HourClockType { |
20 k12HourClock, // Uses 1-12. e.g., "3:07 PM" | 20 k12HourClock, // Uses 1-12. e.g., "3:07 PM" |
21 k24HourClock, // Uses 0-23. e.g., "15:07" | 21 k24HourClock, // Uses 0-23. e.g., "15:07" |
22 }; | 22 }; |
23 | 23 |
| 24 // Argument type used to specify whether or not to include AM/PM sign. |
| 25 enum AmPmClockType { |
| 26 kDropAmPm, // Drops AM/PM sign. e.g., "3:07" |
| 27 kKeepAmPm, // Keeps AM/PM sign. e.g., "3:07 PM" |
| 28 }; |
| 29 |
24 // Returns the time of day, e.g., "3:07 PM". | 30 // Returns the time of day, e.g., "3:07 PM". |
25 string16 TimeFormatTimeOfDay(const Time& time); | 31 string16 TimeFormatTimeOfDay(const Time& time); |
26 | 32 |
27 // Returns the time of day in the specified hour clock type. e.g. | 33 // Returns the time of day in the specified hour clock type. e.g. |
28 // "3:07 PM" (type == k12HourClock). | 34 // "3:07 PM" (type == k12HourClock, ampm == kKeepAmPm). |
| 35 // "3:07" (type == k12HourClock, ampm == kDropAmPm). |
29 // "15:07" (type == k24HourClock). | 36 // "15:07" (type == k24HourClock). |
30 string16 TimeFormatTimeOfDayWithHourClockType(const Time& time, | 37 string16 TimeFormatTimeOfDayWithHourClockType(const Time& time, |
31 HourClockType type); | 38 HourClockType type, |
| 39 AmPmClockType ampm); |
32 | 40 |
33 // Returns a shortened date, e.g. "Nov 7, 2007" | 41 // Returns a shortened date, e.g. "Nov 7, 2007" |
34 string16 TimeFormatShortDate(const Time& time); | 42 string16 TimeFormatShortDate(const Time& time); |
35 | 43 |
36 // Returns a numeric date such as 12/13/52. | 44 // Returns a numeric date such as 12/13/52. |
37 string16 TimeFormatShortDateNumeric(const Time& time); | 45 string16 TimeFormatShortDateNumeric(const Time& time); |
38 | 46 |
39 // Formats a time in a friendly sentence format, e.g. | 47 // Returns a numeric date and time such as "12/13/52 2:44:30 PM". |
40 // "Monday, March 6, 2008 2:44:30 PM". | |
41 string16 TimeFormatShortDateAndTime(const Time& time); | 48 string16 TimeFormatShortDateAndTime(const Time& time); |
42 | 49 |
43 // Formats a time in a friendly sentence format, e.g. | 50 // Formats a time in a friendly sentence format, e.g. |
44 // "Monday, March 6, 2008 2:44:30 PM". | 51 // "Monday, March 6, 2008 2:44:30 PM". |
45 string16 TimeFormatFriendlyDateAndTime(const Time& time); | 52 string16 TimeFormatFriendlyDateAndTime(const Time& time); |
46 | 53 |
47 // Formats a time in a friendly sentence format, e.g. | 54 // Formats a time in a friendly sentence format, e.g. |
48 // "Monday, March 6, 2008". | 55 // "Monday, March 6, 2008". |
49 string16 TimeFormatFriendlyDate(const Time& time); | 56 string16 TimeFormatFriendlyDate(const Time& time); |
50 | 57 |
51 // Gets the hour clock type of the current locale. e.g. | 58 // Gets the hour clock type of the current locale. e.g. |
52 // k12HourClock (en-US). | 59 // k12HourClock (en-US). |
53 // k24HourClock (en-GB). | 60 // k24HourClock (en-GB). |
54 HourClockType GetHourClockType(); | 61 HourClockType GetHourClockType(); |
55 | 62 |
56 } // namespace base | 63 } // namespace base |
57 | 64 |
58 #endif // BASE_I18N_TIME_FORMATTING_H_ | 65 #endif // BASE_I18N_TIME_FORMATTING_H_ |
OLD | NEW |