--- a/dom/xul/templates/nsXULContentUtils.cpp
+++ b/dom/xul/templates/nsXULContentUtils.cpp
@@ -44,17 +44,16 @@
#include "nsRDFCID.h"
#include "nsString.h"
#include "nsXPIDLString.h"
#include "nsGkAtoms.h"
#include "mozilla/Logging.h"
#include "prtime.h"
#include "rdf.h"
#include "nsContentUtils.h"
-#include "nsIScriptableDateFormat.h"
#include "nsICollation.h"
#include "nsCollationCID.h"
#include "nsIConsoleService.h"
#include "nsEscape.h"
using namespace mozilla;
//------------------------------------------------------------------------
--- a/intl/build/nsI18nModule.cpp
+++ b/intl/build/nsI18nModule.cpp
@@ -39,49 +39,46 @@ NS_DEFINE_NAMED_CID(MOZ_OSPREFERENCES_CI
NS_DEFINE_NAMED_CID(NS_LBRK_CID);
NS_DEFINE_NAMED_CID(NS_WBRK_CID);
NS_DEFINE_NAMED_CID(NS_ENTITYCONVERTER_CID);
NS_DEFINE_NAMED_CID(NS_SAVEASCHARSET_CID);
NS_DEFINE_NAMED_CID(NS_UNICODE_NORMALIZER_CID);
NS_DEFINE_NAMED_CID(NS_STRINGBUNDLESERVICE_CID);
NS_DEFINE_NAMED_CID(NS_STRINGBUNDLETEXTOVERRIDE_CID);
NS_DEFINE_NAMED_CID(NS_COLLATIONFACTORY_CID);
-NS_DEFINE_NAMED_CID(NS_SCRIPTABLEDATEFORMAT_CID);
NS_DEFINE_NAMED_CID(NS_PLATFORMCHARSET_CID);
NS_DEFINE_NAMED_CID(NS_COLLATION_CID);
static const mozilla::Module::CIDEntry kIntlCIDs[] = {
{ &kMOZ_LOCALESERVICE_CID, false, nullptr, mozilla::intl::LocaleServiceConstructor },
{ &kMOZ_OSPREFERENCES_CID, false, nullptr, mozilla::intl::OSPreferencesConstructor },
{ &kNS_LBRK_CID, false, nullptr, nsJISx4051LineBreakerConstructor },
{ &kNS_WBRK_CID, false, nullptr, nsSampleWordBreakerConstructor },
{ &kNS_ENTITYCONVERTER_CID, false, nullptr, nsEntityConverterConstructor },
{ &kNS_SAVEASCHARSET_CID, false, nullptr, nsSaveAsCharsetConstructor },
{ &kNS_UNICODE_NORMALIZER_CID, false, nullptr, nsUnicodeNormalizerConstructor },
{ &kNS_STRINGBUNDLESERVICE_CID, false, nullptr, nsStringBundleServiceConstructor },
{ &kNS_STRINGBUNDLETEXTOVERRIDE_CID, false, nullptr, nsStringBundleTextOverrideConstructor },
{ &kNS_COLLATIONFACTORY_CID, false, nullptr, nsCollationFactoryConstructor },
- { &kNS_SCRIPTABLEDATEFORMAT_CID, false, nullptr, NS_NewScriptableDateFormat },
{ &kNS_PLATFORMCHARSET_CID, false, nullptr, nsPlatformCharsetConstructor },
{ &kNS_COLLATION_CID, false, nullptr, nsCollationConstructor },
{ nullptr }
};
static const mozilla::Module::ContractIDEntry kIntlContracts[] = {
{ MOZ_LOCALESERVICE_CONTRACTID, &kMOZ_LOCALESERVICE_CID },
{ MOZ_OSPREFERENCES_CONTRACTID, &kMOZ_OSPREFERENCES_CID },
{ NS_LBRK_CONTRACTID, &kNS_LBRK_CID },
{ NS_WBRK_CONTRACTID, &kNS_WBRK_CID },
{ NS_ENTITYCONVERTER_CONTRACTID, &kNS_ENTITYCONVERTER_CID },
{ NS_SAVEASCHARSET_CONTRACTID, &kNS_SAVEASCHARSET_CID },
{ NS_UNICODE_NORMALIZER_CONTRACTID, &kNS_UNICODE_NORMALIZER_CID },
{ NS_STRINGBUNDLE_CONTRACTID, &kNS_STRINGBUNDLESERVICE_CID },
{ NS_STRINGBUNDLETEXTOVERRIDE_CONTRACTID, &kNS_STRINGBUNDLETEXTOVERRIDE_CID },
{ NS_COLLATIONFACTORY_CONTRACTID, &kNS_COLLATIONFACTORY_CID },
- { NS_SCRIPTABLEDATEFORMAT_CONTRACTID, &kNS_SCRIPTABLEDATEFORMAT_CID },
{ NS_PLATFORMCHARSET_CONTRACTID, &kNS_PLATFORMCHARSET_CID },
{ NS_COLLATION_CONTRACTID, &kNS_COLLATION_CID },
{ nullptr }
};
static const mozilla::Module kIntlModule = {
mozilla::Module::kVersion,
kIntlCIDs,
--- a/intl/locale/DateTimeFormat.h
+++ b/intl/locale/DateTimeFormat.h
@@ -4,25 +4,43 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_DateTimeFormat_h
#define mozilla_DateTimeFormat_h
#include <time.h>
#include "gtest/MozGtestFriend.h"
-#include "nsIScriptableDateFormat.h"
#include "nsStringGlue.h"
#include "prtime.h"
#ifdef ENABLE_INTL_API
#include "unicode/udat.h"
#endif
namespace mozilla {
+enum nsDateFormatSelector : long
+{
+ // Do not change the order of the values below (see bug 1225696).
+ kDateFormatNone = 0, // do not include the date in the format string
+ kDateFormatLong, // provides the long date format for the given locale
+ kDateFormatShort, // provides the short date format for the given locale
+ kDateFormatYearMonth, // formats using only the year and month
+ kDateFormatWeekday, // week day (e.g. Mon, Tue)
+ kDateFormatYearMonthLong, // long version of kDateFormatYearMonth
+ kDateFormatMonthLong // long format of month name only
+};
+
+enum nsTimeFormatSelector : long
+{
+ kTimeFormatNone = 0, // don't include the time in the format string
+ kTimeFormatSeconds, // provides the time format with seconds in the given locale
+ kTimeFormatNoSeconds // provides the time format without seconds in the given locale
+};
+
class DateTimeFormat {
public:
// performs a locale sensitive date formatting operation on the time_t parameter
static nsresult FormatTime(const nsDateFormatSelector aDateFormatSelector,
const nsTimeFormatSelector aTimeFormatSelector,
const time_t aTimetTime,
nsAString& aStringOut);
--- a/intl/locale/moz.build
+++ b/intl/locale/moz.build
@@ -18,17 +18,16 @@ else:
DIRS += ['gtk']
elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
DIRS += ['android']
XPIDL_SOURCES += [
'mozILocaleService.idl',
'mozIOSPreferences.idl',
'nsICollation.idl',
- 'nsIScriptableDateFormat.idl',
]
XPIDL_MODULE = 'locale'
EXPORTS += [
'DateTimeFormat.h',
'nsCollationCID.h',
'nsIPlatformCharset.h',
@@ -40,17 +39,16 @@ EXPORTS.mozilla.intl += [
'LocaleService.h',
'OSPreferences.h',
]
UNIFIED_SOURCES += [
'LocaleService.cpp',
'nsCollationFactory.cpp',
'nsLanguageAtomService.cpp',
- 'nsScriptableDateFormat.cpp',
'nsUConvPropertySearch.cpp',
'OSPreferences.cpp',
]
if CONFIG['ENABLE_INTL_API']:
UNIFIED_SOURCES += [
'DateTimeFormat.cpp',
deleted file mode 100644
--- a/intl/locale/nsIScriptableDateFormat.idl
+++ /dev/null
@@ -1,179 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "nsISupports.idl"
-
-typedef long nsDateFormatSelector;
-%{ C++
-enum
-{
- // Do not change the order of the values below (see bug 1225696).
- kDateFormatNone = 0, // do not include the date in the format string
- kDateFormatLong, // provides the long date format for the given locale
- kDateFormatShort, // provides the short date format for the given locale
- kDateFormatYearMonth, // formats using only the year and month
- kDateFormatWeekday, // week day (e.g. Mon, Tue)
- kDateFormatYearMonthLong, // long version of kDateFormatYearMonth
- kDateFormatMonthLong // long format of month name only
-};
-%}
-
-typedef long nsTimeFormatSelector;
-%{ C++
-enum
-{
- kTimeFormatNone = 0, // don't include the time in the format string
- kTimeFormatSeconds, // provides the time format with seconds in the given locale
- kTimeFormatNoSeconds // provides the time format without seconds in the given locale
-};
-%}
-
-%{C++
-// Define Contractid and CID
-// {2EA2E7D0-4095-11d3-9144-006008A6EDF6}
-#define NS_SCRIPTABLEDATEFORMAT_CID \
-{ 0x2ea2e7d0, 0x4095, 0x11d3, { 0x91, 0x44, 0x0, 0x60, 0x8, 0xa6, 0xed, 0xf6 } }
-
-#define NS_SCRIPTABLEDATEFORMAT_CONTRACTID "@mozilla.org/intl/scriptabledateformat;1"
-
-extern nsresult
-NS_NewScriptableDateFormat(nsISupports* aOuter, REFNSIID aIID, void** aResult);
-%}
-
-/**
- * Format date and time in a human readable format.
- */
-[scriptable, uuid(0c89efb0-1aae-11d3-9141-006008a6edf6)]
-interface nsIScriptableDateFormat : nsISupports
-{
- /**
- * Do not include the date in the format string.
- */
- const long dateFormatNone = 0;
-
- /**
- * Provide the long date format.
- *
- * NOTE:
- * The original definitions of dateFormatLong and dateFormatShort are from
- * the Windows platform.
- * In US English dateFormatLong output will be like:
- * Wednesday, January 29, 2003 4:02:14 PM
- * In US English dateFormatShort output will be like:
- * 1/29/03 4:02:14 PM
- * On platforms like Linux, it is rather difficult to achieve exact
- * same output, and since we are aiming at human readers, it does not make
- * sense to achieve exact same result. We will do just enough as the
- * platform allow us to do.
- */
- const long dateFormatLong = 1;
-
- /**
- * Provide the short date format. See also dateFormatLong.
- */
- const long dateFormatShort = 2;
-
- /**
- * Format using only the year and month.
- */
- const long dateFormatYearMonth = 3;
-
- /**
- * Provide the Week day (e.g. Mo, Mon, Monday or similar).
- */
- const long dateFormatWeekday = 4;
-
- /**
- * Don't include the time in the format string.
- */
- const long timeFormatNone = 0;
-
- /**
- * Provide the time format with seconds.
- */
- const long timeFormatSeconds = 1;
-
- /**
- * Provide the time format without seconds.
- */
- const long timeFormatNoSeconds = 2;
-
- /**
- * Provide the time format with seconds, and force the time format to use
- * 24-hour clock, regardless of the locale conventions.
- */
- const long timeFormatSecondsForce24Hour = 3;
-
- /**
- * Provide the time format without seconds, and force the time format to use
- * 24-hour clock, regardless of the locale conventions.
- */
- const long timeFormatNoSecondsForce24Hour = 4;
-
- /**
- * Format the given date and time in a human readable format.
- *
- * The underlying operating system is used to format the date and time.
- *
- * Pass an empty string as the locale parameter to use the OS settings with
- * the preferred date and time formatting given by the user.
- *
- * Pass a locale code as described in nsILocaleService as the locale
- * parameter (e.g. en-US) to use a specific locale. If the given locale
- * is not available, a fallback will be used.
- *
- * NOTE: The output of this method depends on the operating system and user
- * settings. Even if you pass a locale code as the first parameter, there
- * are no guarantees about which locale and exact format the returned value
- * uses. Even if you know the locale, the format might be customized by the
- * user. Therefore you should not use the returned values in contexts where
- * you depend on any specific format or language.
- *
- * @param locale
- Ignored. If you want to use specific locale, use Intl API instead.
- * @param dateFormatSelector
- * Indicate which format should preferably be used for the date.
- * Use one of the dateFormat* constants.
- * @param timeFormatSelector
- * Indicate which format should preferably be used for the time.
- * Use one of the timeFormat* constants.
- * @param year, month, day, hour, minute and second
- * The date and time to be formatted, given in the computer's local
- * time zone.
- * @return The date and time formatted as human readable text according to
- * user preferences or the given locale.
- */
- wstring FormatDateTime(in wstring locale,
- in long dateFormatSelector,
- in long timeFormatSelector,
- in long year,
- in long month,
- in long day,
- in long hour,
- in long minute,
- in long second);
-
- /**
- * Format the given date in a human readable format.
- *
- * See FormatDateTime for details.
- */
- wstring FormatDate(in wstring locale,
- in long dateFormatSelector,
- in long year,
- in long month,
- in long day);
-
- /**
- * Format the given time in a human readable format.
- *
- * See FormatDateTime for details.
- */
- wstring FormatTime(in wstring locale,
- in long timeFormatSelector,
- in long hour,
- in long minute,
- in long second);
-};
--- a/intl/locale/nsLocaleConstructors.h
+++ b/intl/locale/nsLocaleConstructors.h
@@ -4,17 +4,16 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nsLocaleConstructors_h__
#define nsLocaleConstructors_h__
#include "nsCollation.h"
#include "nsCollationCID.h"
#include "mozilla/ModuleUtils.h"
-#include "nsIScriptableDateFormat.h"
#include "nsIServiceManager.h"
#include "nsPlatformCharset.h"
#include "LocaleService.h"
#include "OSPreferences.h"
#define NSLOCALE_MAKE_CTOR(ctor_, iface_, func_) \
static nsresult \
ctor_(nsISupports* aOuter, REFNSIID aIID, void** aResult) \
deleted file mode 100644
--- a/intl/locale/nsScriptableDateFormat.cpp
+++ /dev/null
@@ -1,125 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "DateTimeFormat.h"
-#include "mozilla/Sprintf.h"
-#include "nsIScriptableDateFormat.h"
-#include "nsCOMPtr.h"
-#include "nsServiceManagerUtils.h"
-
-class nsScriptableDateFormat final : public nsIScriptableDateFormat {
- public:
- NS_DECL_ISUPPORTS
-
- NS_IMETHOD FormatDateTime(const char16_t *locale,
- nsDateFormatSelector dateFormatSelector,
- nsTimeFormatSelector timeFormatSelector,
- int32_t year,
- int32_t month,
- int32_t day,
- int32_t hour,
- int32_t minute,
- int32_t second,
- char16_t **dateTimeString) override;
-
- NS_IMETHOD FormatDate(const char16_t *locale,
- nsDateFormatSelector dateFormatSelector,
- int32_t year,
- int32_t month,
- int32_t day,
- char16_t **dateString) override
- {return FormatDateTime(locale, dateFormatSelector, kTimeFormatNone,
- year, month, day, 0, 0, 0, dateString);}
-
- NS_IMETHOD FormatTime(const char16_t *locale,
- nsTimeFormatSelector timeFormatSelector,
- int32_t hour,
- int32_t minute,
- int32_t second,
- char16_t **timeString) override
- {return FormatDateTime(locale, kDateFormatNone, timeFormatSelector,
- 1999, 1, 1, hour, minute, second, timeString);}
-
- nsScriptableDateFormat() {}
-
-private:
- nsString mStringOut;
-
- virtual ~nsScriptableDateFormat() {}
-};
-
-NS_IMPL_ISUPPORTS(nsScriptableDateFormat, nsIScriptableDateFormat)
-
-NS_IMETHODIMP nsScriptableDateFormat::FormatDateTime(
- const char16_t *aLocale,
- nsDateFormatSelector dateFormatSelector,
- nsTimeFormatSelector timeFormatSelector,
- int32_t year,
- int32_t month,
- int32_t day,
- int32_t hour,
- int32_t minute,
- int32_t second,
- char16_t **dateTimeString)
-{
- // We can't have a valid date with the year, month or day
- // being lower than 1.
- if (year < 1 || month < 1 || day < 1)
- return NS_ERROR_INVALID_ARG;
-
- nsresult rv;
- *dateTimeString = nullptr;
-
- tm tmTime;
- time_t timetTime;
-
- memset(&tmTime, 0, sizeof(tmTime));
- tmTime.tm_year = year - 1900;
- tmTime.tm_mon = month - 1;
- tmTime.tm_mday = day;
- tmTime.tm_hour = hour;
- tmTime.tm_min = minute;
- tmTime.tm_sec = second;
- tmTime.tm_yday = tmTime.tm_wday = 0;
- tmTime.tm_isdst = -1;
- timetTime = mktime(&tmTime);
-
- if ((time_t)-1 != timetTime) {
- rv = mozilla::DateTimeFormat::FormatTime(dateFormatSelector, timeFormatSelector,
- timetTime, mStringOut);
- }
- else {
- // if mktime fails (e.g. year <= 1970), then try NSPR.
- PRTime prtime;
- char string[32];
- SprintfLiteral(string, "%.2d/%.2d/%d %.2d:%.2d:%.2d", month, day, year, hour, minute, second);
- if (PR_SUCCESS != PR_ParseTimeString(string, false, &prtime))
- return NS_ERROR_INVALID_ARG;
-
- rv = mozilla::DateTimeFormat::FormatPRTime(dateFormatSelector, timeFormatSelector,
- prtime, mStringOut);
- }
- if (NS_SUCCEEDED(rv))
- *dateTimeString = ToNewUnicode(mStringOut);
-
- return rv;
-}
-
-nsresult
-NS_NewScriptableDateFormat(nsISupports* aOuter, REFNSIID aIID, void** aResult)
-{
- if (aOuter)
- return NS_ERROR_NO_AGGREGATION;
-
- nsScriptableDateFormat* result = new nsScriptableDateFormat();
- if (! result)
- return NS_ERROR_OUT_OF_MEMORY;
-
- NS_ADDREF(result);
- nsresult rv = result->QueryInterface(aIID, aResult);
- NS_RELEASE(result);
-
- return rv;
-}
deleted file mode 100644
--- a/intl/locale/tests/unit/test_bug371611.js
+++ /dev/null
@@ -1,26 +0,0 @@
-var Cc = Components.classes;
-var Ci = Components.interfaces;
-var Cr = Components.results;
-
-function test_formatdatetime_return()
-{
- var dateConv = Cc["@mozilla.org/intl/scriptabledateformat;1"].
- getService(Ci.nsIScriptableDateFormat);
-
- /* Testing if we throw instead of crashing when we are passed 0s. */
- var x = false;
- try {
- dateConv.FormatDate("", Ci.nsIScriptableDateFormat.dateFormatLong,
- 0, 0, 0);
- }
- catch (e if (e.result == Cr.NS_ERROR_INVALID_ARG)) {
- x = true;
- }
- if (!x)
- do_throw("FormatDate didn't throw when passed 0 for its arguments.");
-}
-
-function run_test()
-{
- test_formatdatetime_return();
-}
deleted file mode 100644
--- a/intl/locale/tests/unit/test_bug374040.js
+++ /dev/null
@@ -1,39 +0,0 @@
-function test_full() {
- var date = new Date();
- var scriptableDateServ =
- Components.classes["@mozilla.org/intl/scriptabledateformat;1"].createInstance(Components.interfaces.nsIScriptableDateFormat);
-
- var dateStrXpcom = scriptableDateServ.FormatDateTime("",
- scriptableDateServ.dateFormatLong, scriptableDateServ.timeFormatSeconds,
- date.getFullYear(), date.getMonth()+1, date.getDate(), date.getHours(),
- date.getMinutes(), date.getSeconds());
-
- var dateStrJs = date.toLocaleString();
-
- do_check_eq(dateStrXpcom, dateStrJs);
-
-}
-
-function test_kTimeFormatSeconds() {
- var date = new Date();
- var scriptableDateServ =
- Components.classes["@mozilla.org/intl/scriptabledateformat;1"].createInstance(Components.interfaces.nsIScriptableDateFormat);
-
- var dateStrXpcom = scriptableDateServ.FormatDateTime("",
- scriptableDateServ.dateFormatLong, scriptableDateServ.timeFormatNone,
- date.getFullYear(), date.getMonth()+1, date.getDate(), date.getHours(),
- date.getMinutes(), date.getSeconds());
-
- var dateStrJs = date.toLocaleDateString()
-
- do_check_eq(dateStrXpcom, dateStrJs);
-
-}
-
-function run_test()
-{
- // XXX test disabled due to bug 421790
- return;
- test_full();
- test_kTimeFormatSeconds();
-}
--- a/intl/locale/tests/unit/xpcshell.ini
+++ b/intl/locale/tests/unit/xpcshell.ini
@@ -2,20 +2,16 @@
head =
support-files =
data/intl_on_workers_worker.js
data/chrome.manifest
[test_bug22310.js]
skip-if = toolkit != "windows" && toolkit != "cocoa"
-[test_bug371611.js]
-[test_bug374040.js]
-skip-if = toolkit == "windows" || toolkit == "cocoa"
-
[test_collation.js]
skip-if = toolkit == "android" # ICU might be turned off
[test_bug1086527.js]
[test_intl_on_workers.js]
skip-if = toolkit == "android" # bug 1309447
[test_pluralForm.js]
--- a/toolkit/components/filepicker/nsFileView.cpp
+++ b/toolkit/components/filepicker/nsFileView.cpp
@@ -720,17 +720,18 @@ nsFileView::GetCellText(int32_t aRow, ns
aCol->GetIdConst(&colID);
if (NS_LITERAL_STRING("FilenameColumn").Equals(colID)) {
curFile->GetLeafName(aCellText);
} else if (NS_LITERAL_STRING("LastModifiedColumn").Equals(colID)) {
PRTime lastModTime;
curFile->GetLastModifiedTime(&lastModTime);
// XXX FormatPRTime could take an nsAString&
nsAutoString temp;
- mozilla::DateTimeFormat::FormatPRTime(kDateFormatShort, kTimeFormatSeconds,
+ mozilla::DateTimeFormat::FormatPRTime(mozilla::kDateFormatShort,
+ mozilla::kTimeFormatSeconds,
lastModTime * 1000, temp);
aCellText = temp;
} else {
// file size
if (isDirectory)
aCellText.SetCapacity(0);
else {
int64_t fileSize;