Back to index

lightning-sunbird  0.9+nobinonly
nsIScriptableDateFormat.idl
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either of the GNU General Public License Version 2 or later (the "GPL"),
00026  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00038 #include "nsISupports.idl"
00039 
00040 typedef long nsDateFormatSelector;
00041 %{ C++
00042 enum
00043 {
00044     kDateFormatNone = 0,            // do not include the date  in the format string
00045     kDateFormatLong,                // provides the long date format for the given locale
00046     kDateFormatShort,               // provides the short date format for the given locale
00047     kDateFormatYearMonth,           // formats using only the year and month 
00048     kDateFormatWeekday              // week day (e.g. Mon, Tue)
00049 };
00050 %}
00051 
00052 typedef long nsTimeFormatSelector;
00053 %{ C++
00054 enum
00055 {
00056     kTimeFormatNone = 0,            // don't include the time in the format string
00057     kTimeFormatSeconds,             // provides the time format with seconds in the  given locale 
00058     kTimeFormatNoSeconds,           // provides the time format without seconds in the given locale 
00059     kTimeFormatSecondsForce24Hour,  // forces the time format to use the 24 clock, regardless of the locale conventions
00060     kTimeFormatNoSecondsForce24Hour // forces the time format to use the 24 clock, regardless of the locale conventions
00061 };
00062 %}
00063 
00064 %{C++
00065 // Define Contractid and CID
00066 // {2EA2E7D0-4095-11d3-9144-006008A6EDF6}
00067 #define NS_SCRIPTABLEDATEFORMAT_CID \
00068 { 0x2ea2e7d0, 0x4095, 0x11d3, { 0x91, 0x44, 0x0, 0x60, 0x8, 0xa6, 0xed, 0xf6 } }
00069 
00070 #define NS_SCRIPTABLEDATEFORMAT_CONTRACTID "@mozilla.org/intl/scriptabledateformat;1"
00071 
00072 extern NS_IMETHODIMP
00073 NS_NewScriptableDateFormat(nsISupports* aOuter, REFNSIID aIID, void** aResult);
00074 %}
00075 
00076 [scriptable, uuid(0c89efb0-1aae-11d3-9141-006008a6edf6)]
00077 interface nsIScriptableDateFormat : nsISupports {
00078 
00079     const long dateFormatNone = 0;                 // do not include the date  in the format string
00080     const long dateFormatLong =1;                  // provides the long date format for the given locale
00081     const long dateFormatShort =2;                 // provides the short date format for the given locale
00082     const long dateFormatYearMonth =3;             // formats using only the year and month 
00083     const long dateFormatWeekday = 4;              // week day (e.g. Mon, Tue)
00084 
00085        // Notes:
00086        // The original definitions of dateFormatLong and dateFormatShort are from windows platform. 
00087        // dateFormatLong output will be like: Wednesday, January 29, 2003 4:02:14 PM
00088        // dateFormatShort output will be like: 1/29/03 4:02:14 PM
00089        // On platforms like Linux and OS2, it is rather difficult to achieve exact same output, and since we are aiming 
00090        // at human readers, it does not make sense to achieve exact same result. We should do just enough as the platform
00091        // allow us to do, unless there is other strong reasons for other approaches. 
00092 
00093     const long timeFormatNone = 0;                 // don't include the time in the format string
00094     const long timeFormatSeconds = 1;              // provides the time format with seconds in the  given locale 
00095     const long timeFormatNoSeconds = 2;            // provides the time format without seconds in the given locale
00096     const long timeFormatSecondsForce24Hour = 3;   // forces the time format to use the 24 clock, regardless of the locale conventions
00097     const long timeFormatNoSecondsForce24Hour = 4; // forces the time format to use the 24 clock, regardless of the locale conventions
00098 
00099     // format date and time, locale is language country pair (e.g. en-US) or empty string for application default
00100     wstring FormatDateTime(in wstring locale, 
00101                            in long dateFormatSelector, 
00102                            in long timeFormatSelector,
00103                            in long year, 
00104                            in long month, 
00105                            in long day, 
00106                            in long hour, 
00107                            in long minute, 
00108                            in long second);
00109     // format date, locale is language country pair (e.g. en-US) or empty string for application default
00110     wstring FormatDate(in wstring locale, 
00111                        in long dateFormatSelector, 
00112                        in long year, 
00113                        in long month, 
00114                        in long day);
00115     // format time, locale is language country pair (e.g. en-US) or empty string for application default
00116     wstring FormatTime(in wstring locale, 
00117                        in long timeFormatSelector,
00118                        in long hour, 
00119                        in long minute, 
00120                        in long second);
00121 };