blob: 3c2c5b1fa84f73f75989a8f3202a92ef23f1480b [file] [log] [blame]
satorux@chromium.orga0eb3022011-04-14 14:08:02 +09001// Copyright (c) 2011 The Chromium Authors. All rights reserved.
license.botf003cfe2008-08-24 09:55:55 +09002// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
tc@google.comc7328d82008-08-20 07:35:29 +09004
5// Basic time formatting methods. These methods use the current locale
6// formatting for displaying the time.
7
brettw@chromium.orga52632f2009-10-10 03:20:30 +09008#ifndef BASE_I18N_TIME_FORMATTING_H_
9#define BASE_I18N_TIME_FORMATTING_H_
thakis@chromium.org01d14522010-07-27 08:08:24 +090010#pragma once
tc@google.comc7328d82008-08-20 07:35:29 +090011
rvargas@google.comc4b016b2011-09-01 07:15:48 +090012#include "base/i18n/base_i18n_export.h"
avi@chromium.org20ac4622010-12-23 00:08:08 +090013#include "base/string16.h"
tc@google.comc7328d82008-08-20 07:35:29 +090014
tc@google.comc7328d82008-08-20 07:35:29 +090015namespace base {
16
dsh@google.com0f8dd262008-10-28 05:43:33 +090017class Time;
18
satorux@chromium.orga0eb3022011-04-14 14:08:02 +090019// Argument type used to specify the hour clock type.
20enum HourClockType {
21 k12HourClock, // Uses 1-12. e.g., "3:07 PM"
22 k24HourClock, // Uses 0-23. e.g., "15:07"
23};
24
kinaba@google.com7f3f2422011-05-30 20:45:43 +090025// Argument type used to specify whether or not to include AM/PM sign.
26enum AmPmClockType {
27 kDropAmPm, // Drops AM/PM sign. e.g., "3:07"
28 kKeepAmPm, // Keeps AM/PM sign. e.g., "3:07 PM"
29};
30
tc@google.comc7328d82008-08-20 07:35:29 +090031// Returns the time of day, e.g., "3:07 PM".
rvargas@google.comc4b016b2011-09-01 07:15:48 +090032BASE_I18N_EXPORT string16 TimeFormatTimeOfDay(const Time& time);
tc@google.comc7328d82008-08-20 07:35:29 +090033
satorux@chromium.orga0eb3022011-04-14 14:08:02 +090034// Returns the time of day in the specified hour clock type. e.g.
kinaba@google.com7f3f2422011-05-30 20:45:43 +090035// "3:07 PM" (type == k12HourClock, ampm == kKeepAmPm).
36// "3:07" (type == k12HourClock, ampm == kDropAmPm).
satorux@chromium.orga0eb3022011-04-14 14:08:02 +090037// "15:07" (type == k24HourClock).
rvargas@google.comc4b016b2011-09-01 07:15:48 +090038BASE_I18N_EXPORT string16 TimeFormatTimeOfDayWithHourClockType(
39 const Time& time,
40 HourClockType type,
41 AmPmClockType ampm);
satorux@chromium.orga0eb3022011-04-14 14:08:02 +090042
tc@google.comc7328d82008-08-20 07:35:29 +090043// Returns a shortened date, e.g. "Nov 7, 2007"
rvargas@google.comc4b016b2011-09-01 07:15:48 +090044BASE_I18N_EXPORT string16 TimeFormatShortDate(const Time& time);
tc@google.comc7328d82008-08-20 07:35:29 +090045
46// Returns a numeric date such as 12/13/52.
rvargas@google.comc4b016b2011-09-01 07:15:48 +090047BASE_I18N_EXPORT string16 TimeFormatShortDateNumeric(const Time& time);
tc@google.comc7328d82008-08-20 07:35:29 +090048
kinaba@google.com7f3f2422011-05-30 20:45:43 +090049// Returns a numeric date and time such as "12/13/52 2:44:30 PM".
rvargas@google.comc4b016b2011-09-01 07:15:48 +090050BASE_I18N_EXPORT string16 TimeFormatShortDateAndTime(const Time& time);
tc@google.comc7328d82008-08-20 07:35:29 +090051
52// Formats a time in a friendly sentence format, e.g.
53// "Monday, March 6, 2008 2:44:30 PM".
rvargas@google.comc4b016b2011-09-01 07:15:48 +090054BASE_I18N_EXPORT string16 TimeFormatFriendlyDateAndTime(const Time& time);
tc@google.comc7328d82008-08-20 07:35:29 +090055
56// Formats a time in a friendly sentence format, e.g.
57// "Monday, March 6, 2008".
rvargas@google.comc4b016b2011-09-01 07:15:48 +090058BASE_I18N_EXPORT string16 TimeFormatFriendlyDate(const Time& time);
tc@google.comc7328d82008-08-20 07:35:29 +090059
satorux@chromium.orga0eb3022011-04-14 14:08:02 +090060// Gets the hour clock type of the current locale. e.g.
61// k12HourClock (en-US).
62// k24HourClock (en-GB).
rvargas@google.comc4b016b2011-09-01 07:15:48 +090063BASE_I18N_EXPORT HourClockType GetHourClockType();
satorux@chromium.orga0eb3022011-04-14 14:08:02 +090064
tc@google.comc7328d82008-08-20 07:35:29 +090065} // namespace base
66
brettw@chromium.orga52632f2009-10-10 03:20:30 +090067#endif // BASE_I18N_TIME_FORMATTING_H_