intl/locale/idl/nsIScriptableDateFormat.idl

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/intl/locale/idl/nsIScriptableDateFormat.idl	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,179 @@
     1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#include "nsISupports.idl"
    1.10 +
    1.11 +typedef long nsDateFormatSelector;
    1.12 +%{ C++
    1.13 +enum
    1.14 +{
    1.15 +    kDateFormatNone = 0,            // do not include the date  in the format string
    1.16 +    kDateFormatLong,                // provides the long date format for the given locale
    1.17 +    kDateFormatShort,               // provides the short date format for the given locale
    1.18 +    kDateFormatYearMonth,           // formats using only the year and month 
    1.19 +    kDateFormatWeekday              // week day (e.g. Mon, Tue)
    1.20 +};
    1.21 +%}
    1.22 +
    1.23 +typedef long nsTimeFormatSelector;
    1.24 +%{ C++
    1.25 +enum
    1.26 +{
    1.27 +    kTimeFormatNone = 0,            // don't include the time in the format string
    1.28 +    kTimeFormatSeconds,             // provides the time format with seconds in the  given locale 
    1.29 +    kTimeFormatNoSeconds,           // provides the time format without seconds in the given locale 
    1.30 +    kTimeFormatSecondsForce24Hour,  // forces the time format to use the 24 clock, regardless of the locale conventions
    1.31 +    kTimeFormatNoSecondsForce24Hour // forces the time format to use the 24 clock, regardless of the locale conventions
    1.32 +};
    1.33 +%}
    1.34 +
    1.35 +%{C++
    1.36 +// Define Contractid and CID
    1.37 +// {2EA2E7D0-4095-11d3-9144-006008A6EDF6}
    1.38 +#define NS_SCRIPTABLEDATEFORMAT_CID \
    1.39 +{ 0x2ea2e7d0, 0x4095, 0x11d3, { 0x91, 0x44, 0x0, 0x60, 0x8, 0xa6, 0xed, 0xf6 } }
    1.40 +
    1.41 +#define NS_SCRIPTABLEDATEFORMAT_CONTRACTID "@mozilla.org/intl/scriptabledateformat;1"
    1.42 +
    1.43 +extern nsresult
    1.44 +NS_NewScriptableDateFormat(nsISupports* aOuter, REFNSIID aIID, void** aResult);
    1.45 +%}
    1.46 +
    1.47 +/**
    1.48 + * Format date and time in a human readable format.
    1.49 + */
    1.50 +[scriptable, uuid(0c89efb0-1aae-11d3-9141-006008a6edf6)]
    1.51 +interface nsIScriptableDateFormat : nsISupports
    1.52 +{
    1.53 +    /**
    1.54 +     * Do not include the date in the format string.
    1.55 +     */
    1.56 +    const long dateFormatNone = 0;
    1.57 +
    1.58 +    /**
    1.59 +     * Provide the long date format.
    1.60 +     *
    1.61 +     * NOTE:
    1.62 +     * The original definitions of dateFormatLong and dateFormatShort are from
    1.63 +     * the Windows platform. 
    1.64 +     * In US English dateFormatLong output will be like:
    1.65 +     *     Wednesday, January 29, 2003 4:02:14 PM
    1.66 +     * In US English dateFormatShort output will be like:
    1.67 +     *     1/29/03 4:02:14 PM
    1.68 +     * On platforms like Linux, it is rather difficult to achieve exact
    1.69 +     * same output, and since we are aiming at human readers, it does not make
    1.70 +     * sense to achieve exact same result. We will do just enough as the
    1.71 +     * platform allow us to do. 
    1.72 +     */
    1.73 +    const long dateFormatLong = 1;
    1.74 +
    1.75 +    /**
    1.76 +     * Provide the short date format. See also dateFormatLong.
    1.77 +     */
    1.78 +    const long dateFormatShort = 2;
    1.79 +
    1.80 +    /**
    1.81 +     * Format using only the year and month.
    1.82 +     */
    1.83 +    const long dateFormatYearMonth = 3;
    1.84 +
    1.85 +    /**
    1.86 +     * Provide the Week day (e.g. Mo, Mon, Monday or similar).
    1.87 +     */
    1.88 +    const long dateFormatWeekday = 4;
    1.89 +
    1.90 +    /**
    1.91 +     * Don't include the time in the format string.
    1.92 +     */
    1.93 +    const long timeFormatNone = 0;
    1.94 +
    1.95 +    /**
    1.96 +     * Provide the time format with seconds.
    1.97 +     */
    1.98 +    const long timeFormatSeconds = 1;
    1.99 +
   1.100 +    /**
   1.101 +     * Provide the time format without seconds.
   1.102 +     */
   1.103 +    const long timeFormatNoSeconds = 2;
   1.104 +
   1.105 +    /**
   1.106 +     * Provide the time format with seconds, and force the time format to use
   1.107 +     * 24-hour clock, regardless of the locale conventions.
   1.108 +     */
   1.109 +    const long timeFormatSecondsForce24Hour = 3;
   1.110 +
   1.111 +    /**
   1.112 +     * Provide the time format without seconds, and force the time format to use
   1.113 +     * 24-hour clock, regardless of the locale conventions.
   1.114 +     */
   1.115 +    const long timeFormatNoSecondsForce24Hour = 4;
   1.116 +
   1.117 +    /**
   1.118 +     * Format the given date and time in a human readable format.
   1.119 +     *
   1.120 +     * The underlying operating system is used to format the date and time.
   1.121 +     *
   1.122 +     * Pass an empty string as the locale parameter to use the OS settings with
   1.123 +     * the preferred date and time formatting given by the user.
   1.124 +     *
   1.125 +     * Pass a locale code as described in nsILocale as the locale parameter
   1.126 +     * (e.g. en-US) to use a specific locale. If the given locale is not
   1.127 +     * available, a fallback will be used.
   1.128 +     *
   1.129 +     * NOTE: The output of this method depends on the operating system and user
   1.130 +     * settings. Even if you pass a locale code as the first parameter, there
   1.131 +     * are no guarantees about which locale and exact format the returned value
   1.132 +     * uses. Even if you know the locale, the format might be customized by the
   1.133 +     * user. Therefore you should not use the returned values in contexts where
   1.134 +     * you depend on any specific format or language.
   1.135 +     *
   1.136 +     * @param locale
   1.137 +     *        Locale code of locale used to format the date or an empty string
   1.138 +     *        to follow user preference.
   1.139 +     * @param dateFormatSelector
   1.140 +     *        Indicate which format should preferably be used for the date.
   1.141 +     *        Use one of the dateFormat* constants.
   1.142 +     * @param timeFormatSelector
   1.143 +     *        Indicate which format should preferably be used for the time.
   1.144 +     *        Use one of the timeFormat* constants.
   1.145 +     * @param year, month, day, hour, minute and second
   1.146 +     *        The date and time to be formatted, given in the computer's local
   1.147 +     *        time zone.
   1.148 +     * @return The date and time formatted as human readable text according to
   1.149 +     *         user preferences or the given locale.
   1.150 +     */
   1.151 +    wstring FormatDateTime(in wstring locale, 
   1.152 +                           in long dateFormatSelector, 
   1.153 +                           in long timeFormatSelector,
   1.154 +                           in long year, 
   1.155 +                           in long month, 
   1.156 +                           in long day, 
   1.157 +                           in long hour, 
   1.158 +                           in long minute, 
   1.159 +                           in long second);
   1.160 +
   1.161 +    /**
   1.162 +     * Format the given date in a human readable format.
   1.163 +     *
   1.164 +     * See FormatDateTime for details.
   1.165 +     */
   1.166 +    wstring FormatDate(in wstring locale, 
   1.167 +                       in long dateFormatSelector, 
   1.168 +                       in long year, 
   1.169 +                       in long month, 
   1.170 +                       in long day);
   1.171 +
   1.172 +    /**
   1.173 +     * Format the given time in a human readable format.
   1.174 +     *
   1.175 +     * See FormatDateTime for details.
   1.176 +     */
   1.177 +    wstring FormatTime(in wstring locale, 
   1.178 +                       in long timeFormatSelector,
   1.179 +                       in long hour, 
   1.180 +                       in long minute, 
   1.181 +                       in long second);
   1.182 +};

mercurial