Home | History | Annotate | Download | only in i18n
      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.
      4 
      5 // Basic time formatting methods.  These methods use the current locale
      6 // formatting for displaying the time.
      7 
      8 #ifndef BASE_I18N_TIME_FORMATTING_H_
      9 #define BASE_I18N_TIME_FORMATTING_H_
     10 
     11 #include "base/i18n/base_i18n_export.h"
     12 #include "base/strings/string16.h"
     13 
     14 namespace base {
     15 
     16 class Time;
     17 
     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"
     22 };
     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 
     30 // Returns the time of day, e.g., "3:07 PM".
     31 BASE_I18N_EXPORT string16 TimeFormatTimeOfDay(const Time& time);
     32 
     33 // Returns the time of day in the specified hour clock type. e.g.
     34 // "3:07 PM" (type == k12HourClock, ampm == kKeepAmPm).
     35 // "3:07"    (type == k12HourClock, ampm == kDropAmPm).
     36 // "15:07"   (type == k24HourClock).
     37 BASE_I18N_EXPORT string16 TimeFormatTimeOfDayWithHourClockType(
     38     const Time& time,
     39     HourClockType type,
     40     AmPmClockType ampm);
     41 
     42 // Returns a shortened date, e.g. "Nov 7, 2007"
     43 BASE_I18N_EXPORT string16 TimeFormatShortDate(const Time& time);
     44 
     45 // Returns a numeric date such as 12/13/52.
     46 BASE_I18N_EXPORT string16 TimeFormatShortDateNumeric(const Time& time);
     47 
     48 // Returns a numeric date and time such as "12/13/52 2:44:30 PM".
     49 BASE_I18N_EXPORT string16 TimeFormatShortDateAndTime(const Time& time);
     50 
     51 // Formats a time in a friendly sentence format, e.g.
     52 // "Monday, March 6, 2008 2:44:30 PM".
     53 BASE_I18N_EXPORT string16 TimeFormatFriendlyDateAndTime(const Time& time);
     54 
     55 // Formats a time in a friendly sentence format, e.g.
     56 // "Monday, March 6, 2008".
     57 BASE_I18N_EXPORT string16 TimeFormatFriendlyDate(const Time& time);
     58 
     59 // Gets the hour clock type of the current locale. e.g.
     60 // k12HourClock (en-US).
     61 // k24HourClock (en-GB).
     62 BASE_I18N_EXPORT HourClockType GetHourClockType();
     63 
     64 }  // namespace base
     65 
     66 #endif  // BASE_I18N_TIME_FORMATTING_H_
     67