Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #include "nsISupports.idl" |
michael@0 | 7 | |
michael@0 | 8 | typedef long nsDateFormatSelector; |
michael@0 | 9 | %{ C++ |
michael@0 | 10 | enum |
michael@0 | 11 | { |
michael@0 | 12 | kDateFormatNone = 0, // do not include the date in the format string |
michael@0 | 13 | kDateFormatLong, // provides the long date format for the given locale |
michael@0 | 14 | kDateFormatShort, // provides the short date format for the given locale |
michael@0 | 15 | kDateFormatYearMonth, // formats using only the year and month |
michael@0 | 16 | kDateFormatWeekday // week day (e.g. Mon, Tue) |
michael@0 | 17 | }; |
michael@0 | 18 | %} |
michael@0 | 19 | |
michael@0 | 20 | typedef long nsTimeFormatSelector; |
michael@0 | 21 | %{ C++ |
michael@0 | 22 | enum |
michael@0 | 23 | { |
michael@0 | 24 | kTimeFormatNone = 0, // don't include the time in the format string |
michael@0 | 25 | kTimeFormatSeconds, // provides the time format with seconds in the given locale |
michael@0 | 26 | kTimeFormatNoSeconds, // provides the time format without seconds in the given locale |
michael@0 | 27 | kTimeFormatSecondsForce24Hour, // forces the time format to use the 24 clock, regardless of the locale conventions |
michael@0 | 28 | kTimeFormatNoSecondsForce24Hour // forces the time format to use the 24 clock, regardless of the locale conventions |
michael@0 | 29 | }; |
michael@0 | 30 | %} |
michael@0 | 31 | |
michael@0 | 32 | %{C++ |
michael@0 | 33 | // Define Contractid and CID |
michael@0 | 34 | // {2EA2E7D0-4095-11d3-9144-006008A6EDF6} |
michael@0 | 35 | #define NS_SCRIPTABLEDATEFORMAT_CID \ |
michael@0 | 36 | { 0x2ea2e7d0, 0x4095, 0x11d3, { 0x91, 0x44, 0x0, 0x60, 0x8, 0xa6, 0xed, 0xf6 } } |
michael@0 | 37 | |
michael@0 | 38 | #define NS_SCRIPTABLEDATEFORMAT_CONTRACTID "@mozilla.org/intl/scriptabledateformat;1" |
michael@0 | 39 | |
michael@0 | 40 | extern nsresult |
michael@0 | 41 | NS_NewScriptableDateFormat(nsISupports* aOuter, REFNSIID aIID, void** aResult); |
michael@0 | 42 | %} |
michael@0 | 43 | |
michael@0 | 44 | /** |
michael@0 | 45 | * Format date and time in a human readable format. |
michael@0 | 46 | */ |
michael@0 | 47 | [scriptable, uuid(0c89efb0-1aae-11d3-9141-006008a6edf6)] |
michael@0 | 48 | interface nsIScriptableDateFormat : nsISupports |
michael@0 | 49 | { |
michael@0 | 50 | /** |
michael@0 | 51 | * Do not include the date in the format string. |
michael@0 | 52 | */ |
michael@0 | 53 | const long dateFormatNone = 0; |
michael@0 | 54 | |
michael@0 | 55 | /** |
michael@0 | 56 | * Provide the long date format. |
michael@0 | 57 | * |
michael@0 | 58 | * NOTE: |
michael@0 | 59 | * The original definitions of dateFormatLong and dateFormatShort are from |
michael@0 | 60 | * the Windows platform. |
michael@0 | 61 | * In US English dateFormatLong output will be like: |
michael@0 | 62 | * Wednesday, January 29, 2003 4:02:14 PM |
michael@0 | 63 | * In US English dateFormatShort output will be like: |
michael@0 | 64 | * 1/29/03 4:02:14 PM |
michael@0 | 65 | * On platforms like Linux, it is rather difficult to achieve exact |
michael@0 | 66 | * same output, and since we are aiming at human readers, it does not make |
michael@0 | 67 | * sense to achieve exact same result. We will do just enough as the |
michael@0 | 68 | * platform allow us to do. |
michael@0 | 69 | */ |
michael@0 | 70 | const long dateFormatLong = 1; |
michael@0 | 71 | |
michael@0 | 72 | /** |
michael@0 | 73 | * Provide the short date format. See also dateFormatLong. |
michael@0 | 74 | */ |
michael@0 | 75 | const long dateFormatShort = 2; |
michael@0 | 76 | |
michael@0 | 77 | /** |
michael@0 | 78 | * Format using only the year and month. |
michael@0 | 79 | */ |
michael@0 | 80 | const long dateFormatYearMonth = 3; |
michael@0 | 81 | |
michael@0 | 82 | /** |
michael@0 | 83 | * Provide the Week day (e.g. Mo, Mon, Monday or similar). |
michael@0 | 84 | */ |
michael@0 | 85 | const long dateFormatWeekday = 4; |
michael@0 | 86 | |
michael@0 | 87 | /** |
michael@0 | 88 | * Don't include the time in the format string. |
michael@0 | 89 | */ |
michael@0 | 90 | const long timeFormatNone = 0; |
michael@0 | 91 | |
michael@0 | 92 | /** |
michael@0 | 93 | * Provide the time format with seconds. |
michael@0 | 94 | */ |
michael@0 | 95 | const long timeFormatSeconds = 1; |
michael@0 | 96 | |
michael@0 | 97 | /** |
michael@0 | 98 | * Provide the time format without seconds. |
michael@0 | 99 | */ |
michael@0 | 100 | const long timeFormatNoSeconds = 2; |
michael@0 | 101 | |
michael@0 | 102 | /** |
michael@0 | 103 | * Provide the time format with seconds, and force the time format to use |
michael@0 | 104 | * 24-hour clock, regardless of the locale conventions. |
michael@0 | 105 | */ |
michael@0 | 106 | const long timeFormatSecondsForce24Hour = 3; |
michael@0 | 107 | |
michael@0 | 108 | /** |
michael@0 | 109 | * Provide the time format without seconds, and force the time format to use |
michael@0 | 110 | * 24-hour clock, regardless of the locale conventions. |
michael@0 | 111 | */ |
michael@0 | 112 | const long timeFormatNoSecondsForce24Hour = 4; |
michael@0 | 113 | |
michael@0 | 114 | /** |
michael@0 | 115 | * Format the given date and time in a human readable format. |
michael@0 | 116 | * |
michael@0 | 117 | * The underlying operating system is used to format the date and time. |
michael@0 | 118 | * |
michael@0 | 119 | * Pass an empty string as the locale parameter to use the OS settings with |
michael@0 | 120 | * the preferred date and time formatting given by the user. |
michael@0 | 121 | * |
michael@0 | 122 | * Pass a locale code as described in nsILocale as the locale parameter |
michael@0 | 123 | * (e.g. en-US) to use a specific locale. If the given locale is not |
michael@0 | 124 | * available, a fallback will be used. |
michael@0 | 125 | * |
michael@0 | 126 | * NOTE: The output of this method depends on the operating system and user |
michael@0 | 127 | * settings. Even if you pass a locale code as the first parameter, there |
michael@0 | 128 | * are no guarantees about which locale and exact format the returned value |
michael@0 | 129 | * uses. Even if you know the locale, the format might be customized by the |
michael@0 | 130 | * user. Therefore you should not use the returned values in contexts where |
michael@0 | 131 | * you depend on any specific format or language. |
michael@0 | 132 | * |
michael@0 | 133 | * @param locale |
michael@0 | 134 | * Locale code of locale used to format the date or an empty string |
michael@0 | 135 | * to follow user preference. |
michael@0 | 136 | * @param dateFormatSelector |
michael@0 | 137 | * Indicate which format should preferably be used for the date. |
michael@0 | 138 | * Use one of the dateFormat* constants. |
michael@0 | 139 | * @param timeFormatSelector |
michael@0 | 140 | * Indicate which format should preferably be used for the time. |
michael@0 | 141 | * Use one of the timeFormat* constants. |
michael@0 | 142 | * @param year, month, day, hour, minute and second |
michael@0 | 143 | * The date and time to be formatted, given in the computer's local |
michael@0 | 144 | * time zone. |
michael@0 | 145 | * @return The date and time formatted as human readable text according to |
michael@0 | 146 | * user preferences or the given locale. |
michael@0 | 147 | */ |
michael@0 | 148 | wstring FormatDateTime(in wstring locale, |
michael@0 | 149 | in long dateFormatSelector, |
michael@0 | 150 | in long timeFormatSelector, |
michael@0 | 151 | in long year, |
michael@0 | 152 | in long month, |
michael@0 | 153 | in long day, |
michael@0 | 154 | in long hour, |
michael@0 | 155 | in long minute, |
michael@0 | 156 | in long second); |
michael@0 | 157 | |
michael@0 | 158 | /** |
michael@0 | 159 | * Format the given date in a human readable format. |
michael@0 | 160 | * |
michael@0 | 161 | * See FormatDateTime for details. |
michael@0 | 162 | */ |
michael@0 | 163 | wstring FormatDate(in wstring locale, |
michael@0 | 164 | in long dateFormatSelector, |
michael@0 | 165 | in long year, |
michael@0 | 166 | in long month, |
michael@0 | 167 | in long day); |
michael@0 | 168 | |
michael@0 | 169 | /** |
michael@0 | 170 | * Format the given time in a human readable format. |
michael@0 | 171 | * |
michael@0 | 172 | * See FormatDateTime for details. |
michael@0 | 173 | */ |
michael@0 | 174 | wstring FormatTime(in wstring locale, |
michael@0 | 175 | in long timeFormatSelector, |
michael@0 | 176 | in long hour, |
michael@0 | 177 | in long minute, |
michael@0 | 178 | in long second); |
michael@0 | 179 | }; |