Roll src/third_party/WebKit 4619053:6b63e20 (svn 201059:201060)
[chromium-blink-merge.git] / base / i18n / time_formatting.h
blobdf91f41beddd215764f5d0e054a0b8bab777d5bd
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
3 // found in the LICENSE file.
5 // Basic time formatting methods. These methods use the current locale
6 // formatting for displaying the time.
8 #ifndef BASE_I18N_TIME_FORMATTING_H_
9 #define BASE_I18N_TIME_FORMATTING_H_
11 #include "base/i18n/base_i18n_export.h"
12 #include "base/strings/string16.h"
14 namespace base {
16 class Time;
18 // Argument type used to specify the hour clock type.
19 enum HourClockType {
20 k12HourClock, // Uses 1-12. e.g., "3:07 PM"
21 k24HourClock, // Uses 0-23. e.g., "15:07"
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"
30 // Returns the time of day, e.g., "3:07 PM".
31 BASE_I18N_EXPORT string16 TimeFormatTimeOfDay(const Time& time);
33 // Returns the time of day in 24-hour clock format with millisecond accuracy,
34 // e.g., "15:07:30.568"
35 BASE_I18N_EXPORT string16 TimeFormatTimeOfDayWithMilliseconds(const Time& time);
37 // Returns the time of day in the specified hour clock type. e.g.
38 // "3:07 PM" (type == k12HourClock, ampm == kKeepAmPm).
39 // "3:07" (type == k12HourClock, ampm == kDropAmPm).
40 // "15:07" (type == k24HourClock).
41 BASE_I18N_EXPORT string16 TimeFormatTimeOfDayWithHourClockType(
42 const Time& time,
43 HourClockType type,
44 AmPmClockType ampm);
46 // Returns a shortened date, e.g. "Nov 7, 2007"
47 BASE_I18N_EXPORT string16 TimeFormatShortDate(const Time& time);
49 // Returns a numeric date such as 12/13/52.
50 BASE_I18N_EXPORT string16 TimeFormatShortDateNumeric(const Time& time);
52 // Returns a numeric date and time such as "12/13/52 2:44:30 PM".
53 BASE_I18N_EXPORT string16 TimeFormatShortDateAndTime(const Time& time);
55 // Returns a numeric date and time with time zone such as
56 // "12/13/52 2:44:30 PM PST".
57 BASE_I18N_EXPORT string16
58 TimeFormatShortDateAndTimeWithTimeZone(const Time& time);
60 // Formats a time in a friendly sentence format, e.g.
61 // "Monday, March 6, 2008 2:44:30 PM".
62 BASE_I18N_EXPORT string16 TimeFormatFriendlyDateAndTime(const Time& time);
64 // Formats a time in a friendly sentence format, e.g.
65 // "Monday, March 6, 2008".
66 BASE_I18N_EXPORT string16 TimeFormatFriendlyDate(const Time& time);
68 // Gets the hour clock type of the current locale. e.g.
69 // k12HourClock (en-US).
70 // k24HourClock (en-GB).
71 BASE_I18N_EXPORT HourClockType GetHourClockType();
73 } // namespace base
75 #endif // BASE_I18N_TIME_FORMATTING_H_