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

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

Issue 2570253002: [MD History] Fix toolbar dates in grouped mode. (Closed)
Patch Set: use date interval format 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
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 };
jungshik at Google 2017/01/10 01:12:29 I have a mixed feeling about insulating callers fr
calamity 2017/01/16 02:49:25 I would prefer the ICU enums get hidden, just beca
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.
75 // "Monday, March 6, 2008". 87 // "Monday, March 6, 2008".
76 BASE_I18N_EXPORT string16 TimeFormatFriendlyDate(const Time& time); 88 BASE_I18N_EXPORT string16 TimeFormatFriendlyDate(const Time& time);
77 89
78 // Formats a time duration of hours and minutes into various formats, e.g., 90 // 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. 91 // "3:07" or "3 hours, 7 minutes". See DurationFormatWidth for details.
80 BASE_I18N_EXPORT string16 TimeDurationFormat(const TimeDelta& time, 92 BASE_I18N_EXPORT string16 TimeDurationFormat(const TimeDelta& time,
81 const DurationFormatWidth width); 93 const DurationFormatWidth width);
82 94
95 BASE_I18N_EXPORT string16 DateIntervalFormat(const Time& begin_time,
96 const Time& end_time,
97 DateFormat format);
98
83 // Gets the hour clock type of the current locale. e.g. 99 // Gets the hour clock type of the current locale. e.g.
84 // k12HourClock (en-US). 100 // k12HourClock (en-US).
85 // k24HourClock (en-GB). 101 // k24HourClock (en-GB).
86 BASE_I18N_EXPORT HourClockType GetHourClockType(); 102 BASE_I18N_EXPORT HourClockType GetHourClockType();
87 103
88 } // namespace base 104 } // namespace base
89 105
90 #endif // BASE_I18N_TIME_FORMATTING_H_ 106 #endif // BASE_I18N_TIME_FORMATTING_H_
OLDNEW
« no previous file with comments | « no previous file | base/i18n/time_formatting.cc » ('j') | chrome/browser/ui/webui/browsing_history_handler.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698