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

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

Issue 2570253002: [MD History] Fix toolbar dates in grouped mode. (Closed)
Patch Set: rebase Created 3 years, 11 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
« no previous file with comments | « no previous file | base/i18n/time_formatting.cc » ('j') | 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 // 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 19 matching lines...) Expand all
30 30
31 // Should match UMeasureFormatWidth in measfmt.h; replicated here to avoid 31 // Should match UMeasureFormatWidth in measfmt.h; replicated here to avoid
32 // requiring third_party/icu dependencies with this file. 32 // requiring third_party/icu dependencies with this file.
33 enum DurationFormatWidth { 33 enum DurationFormatWidth {
34 DURATION_WIDTH_WIDE, // "3 hours, 7 minutes" 34 DURATION_WIDTH_WIDE, // "3 hours, 7 minutes"
35 DURATION_WIDTH_SHORT, // "3 hr, 7 min" 35 DURATION_WIDTH_SHORT, // "3 hr, 7 min"
36 DURATION_WIDTH_NARROW, // "3h 7m" 36 DURATION_WIDTH_NARROW, // "3h 7m"
37 DURATION_WIDTH_NUMERIC // "3:07" 37 DURATION_WIDTH_NUMERIC // "3:07"
38 }; 38 };
39 39
40 // Date formats from third_party/icu/source/i18n/unicode/udat.h. Add more as
41 // necessary.
42 enum DateFormat {
43 // November 2007
44 DATE_FORMAT_YEAR_MONTH,
45 // Tuesday, 7 November
46 DATE_FORMAT_MONTH_WEEKDAY_DAY,
47 };
48
40 // Returns the time of day, e.g., "3:07 PM". 49 // Returns the time of day, e.g., "3:07 PM".
41 BASE_I18N_EXPORT string16 TimeFormatTimeOfDay(const Time& time); 50 BASE_I18N_EXPORT string16 TimeFormatTimeOfDay(const Time& time);
42 51
43 // Returns the time of day in 24-hour clock format with millisecond accuracy, 52 // Returns the time of day in 24-hour clock format with millisecond accuracy,
44 // e.g., "15:07:30.568" 53 // e.g., "15:07:30.568"
45 BASE_I18N_EXPORT string16 TimeFormatTimeOfDayWithMilliseconds(const Time& time); 54 BASE_I18N_EXPORT string16 TimeFormatTimeOfDayWithMilliseconds(const Time& time);
46 55
47 // Returns the time of day in the specified hour clock type. e.g. 56 // Returns the time of day in the specified hour clock type. e.g.
48 // "3:07 PM" (type == k12HourClock, ampm == kKeepAmPm). 57 // "3:07 PM" (type == k12HourClock, ampm == kKeepAmPm).
49 // "3:07" (type == k12HourClock, ampm == kDropAmPm). 58 // "3:07" (type == k12HourClock, ampm == kDropAmPm).
50 // "15:07" (type == k24HourClock). 59 // "15:07" (type == k24HourClock).
51 BASE_I18N_EXPORT string16 TimeFormatTimeOfDayWithHourClockType( 60 BASE_I18N_EXPORT string16 TimeFormatTimeOfDayWithHourClockType(
52 const Time& time, 61 const Time& time,
53 HourClockType type, 62 HourClockType type,
54 AmPmClockType ampm); 63 AmPmClockType ampm);
55 64
56 // Returns a shortened date, e.g. "Nov 7, 2007" 65 // Returns a shortened date, e.g. "Nov 7, 2007"
57 BASE_I18N_EXPORT string16 TimeFormatShortDate(const Time& time); 66 BASE_I18N_EXPORT string16 TimeFormatShortDate(const Time& time);
58 67
59 // Returns a numeric date such as 12/13/52. 68 // Returns a numeric date such as 12/13/52.
60 BASE_I18N_EXPORT string16 TimeFormatShortDateNumeric(const Time& time); 69 BASE_I18N_EXPORT string16 TimeFormatShortDateNumeric(const Time& time);
61 70
62 // Returns a numeric date and time such as "12/13/52 2:44:30 PM". 71 // Returns a numeric date and time such as "12/13/52 2:44:30 PM".
63 BASE_I18N_EXPORT string16 TimeFormatShortDateAndTime(const Time& time); 72 BASE_I18N_EXPORT string16 TimeFormatShortDateAndTime(const Time& time);
64 73
74 // Returns a month and year, e.g. "November 2007"
75 BASE_I18N_EXPORT string16 TimeFormatMonthAndYear(const Time& time);
76
65 // Returns a numeric date and time with time zone such as 77 // Returns a numeric date and time with time zone such as
66 // "12/13/52 2:44:30 PM PST". 78 // "12/13/52 2:44:30 PM PST".
67 BASE_I18N_EXPORT string16 79 BASE_I18N_EXPORT string16
68 TimeFormatShortDateAndTimeWithTimeZone(const Time& time); 80 TimeFormatShortDateAndTimeWithTimeZone(const Time& time);
69 81
70 // Formats a time in a friendly sentence format, e.g. 82 // Formats a time in a friendly sentence format, e.g.
71 // "Monday, March 6, 2008 2:44:30 PM". 83 // "Monday, March 6, 2008 2:44:30 PM".
72 BASE_I18N_EXPORT string16 TimeFormatFriendlyDateAndTime(const Time& time); 84 BASE_I18N_EXPORT string16 TimeFormatFriendlyDateAndTime(const Time& time);
73 85
74 // Formats a time in a friendly sentence format, e.g. 86 // Formats a time in a friendly sentence format, e.g.
(...skipping 17 matching lines...) Expand all
92 // 104 //
93 // Please don't use width = DURATION_WIDTH_NUMERIC when the time duration 105 // 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 106 // can possibly be larger than 24h, as the hour value will be cut below 24
95 // after formatting. 107 // after formatting.
96 // TODO(chengx): fix function output when width = DURATION_WIDTH_NUMERIC 108 // TODO(chengx): fix function output when width = DURATION_WIDTH_NUMERIC
97 // (http://crbug.com/675791) 109 // (http://crbug.com/675791)
98 BASE_I18N_EXPORT string16 110 BASE_I18N_EXPORT string16
99 TimeDurationFormatWithSeconds(const TimeDelta time, 111 TimeDurationFormatWithSeconds(const TimeDelta time,
100 const DurationFormatWidth width); 112 const DurationFormatWidth width);
101 113
114 // Formats a date interval into various formats, e.g. "2 December - 4 December"
115 // or "March 2016 - December 2016". See DateFormat for details.
116 BASE_I18N_EXPORT string16 DateIntervalFormat(const Time& begin_time,
117 const Time& end_time,
118 DateFormat format);
119
102 // Gets the hour clock type of the current locale. e.g. 120 // Gets the hour clock type of the current locale. e.g.
103 // k12HourClock (en-US). 121 // k12HourClock (en-US).
104 // k24HourClock (en-GB). 122 // k24HourClock (en-GB).
105 BASE_I18N_EXPORT HourClockType GetHourClockType(); 123 BASE_I18N_EXPORT HourClockType GetHourClockType();
106 124
107 } // namespace base 125 } // namespace base
108 126
109 #endif // BASE_I18N_TIME_FORMATTING_H_ 127 #endif // BASE_I18N_TIME_FORMATTING_H_
OLDNEW
« no previous file with comments | « no previous file | base/i18n/time_formatting.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698