Bug 1301640 - Replaced per-platform variants of nsIDateTimeFormat with single, ICU-backed version that has static c++ callers. r=emk
authorGregory Moore <olucafont6@yahoo.com>
Mon, 21 Nov 2016 15:58:37 -0800
changeset 327037 7e747433d1c9fae8a0acb4090f61335fcc165e4c
parent 327036 698b5719c9ee8cefe0a894c37c1ef865e34d0769
child 327038 8717bea884c99079359f7cfcc1e1ecea46b61ed9
push id85086
push userVYV03354@nifty.ne.jp
push dateFri, 23 Dec 2016 00:13:01 +0000
treeherdermozilla-inbound@7e747433d1c9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemk
bugs1301640
milestone53.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1301640 - Replaced per-platform variants of nsIDateTimeFormat with single, ICU-backed version that has static c++ callers. r=emk Also removed unused format selectors and removed option to pass in a locale. Changed all callers to use new version. MozReview-Commit-ID: Gq0b1c3C1eO
dom/base/nsDocument.cpp
dom/xul/templates/nsXULContentUtils.cpp
dom/xul/templates/nsXULContentUtils.h
intl/build/nsI18nModule.cpp
intl/locale/DateTimeFormat.h
intl/locale/DateTimeFormatICU.cpp
intl/locale/DateTimeFormatUnix.cpp
intl/locale/mac/moz.build
intl/locale/mac/nsDateTimeFormatMac.cpp
intl/locale/mac/nsDateTimeFormatMac.h
intl/locale/moz.build
intl/locale/nsDateTimeFormatCID.h
intl/locale/nsIDateTimeFormat.cpp
intl/locale/nsIDateTimeFormat.h
intl/locale/nsLocaleConstructors.h
intl/locale/nsScriptableDateFormat.cpp
intl/locale/unix/moz.build
intl/locale/unix/nsDateTimeFormatUnix.cpp
intl/locale/unix/nsDateTimeFormatUnix.h
intl/locale/windows/moz.build
intl/locale/windows/nsDateTimeFormatWin.cpp
intl/locale/windows/nsDateTimeFormatWin.h
layout/build/nsLayoutStatics.cpp
layout/generic/nsSimplePageSequenceFrame.cpp
layout/generic/nsSimplePageSequenceFrame.h
netwerk/streamconv/converters/nsIndexedToHTML.cpp
netwerk/streamconv/converters/nsIndexedToHTML.h
security/manager/ssl/TransportSecurityInfo.cpp
security/manager/ssl/nsNSSCertHelper.cpp
security/manager/ssl/nsNSSCertValidity.cpp
security/manager/ssl/nsNSSCertValidity.h
toolkit/components/filepicker/nsFileView.cpp
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -126,18 +126,16 @@
 #include "nsIDOMHTMLFormElement.h"
 #include "nsIRequest.h"
 #include "nsHostObjectProtocolHandler.h"
 
 #include "nsCharsetSource.h"
 #include "nsIParser.h"
 #include "nsIContentSink.h"
 
-#include "nsDateTimeFormatCID.h"
-#include "nsIDateTimeFormat.h"
 #include "mozilla/EventDispatcher.h"
 #include "mozilla/EventStates.h"
 #include "mozilla/InternalMutationEvent.h"
 #include "nsDOMCID.h"
 
 #include "jsapi.h"
 #include "nsIXPConnect.h"
 #include "xpcpublic.h"
--- a/dom/xul/templates/nsXULContentUtils.cpp
+++ b/dom/xul/templates/nsXULContentUtils.cpp
@@ -22,16 +22,17 @@
 /*
 
   A package of routines shared by the XUL content code.
 
  */
 
 #include "mozilla/ArrayUtils.h"
 
+#include "DateTimeFormat.h"
 #include "nsCOMPtr.h"
 #include "nsIContent.h"
 #include "nsIDocument.h"
 #include "nsIDOMElement.h"
 #include "nsIDOMXULCommandDispatcher.h"
 #include "nsIDOMXULDocument.h"
 #include "nsIRDFNode.h"
 #include "nsIRDFService.h"
@@ -43,31 +44,29 @@
 #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 "nsIDateTimeFormat.h"
 #include "nsIScriptableDateFormat.h"
 #include "nsICollation.h"
 #include "nsCollationCID.h"
 #include "nsILocale.h"
 #include "nsILocaleService.h"
 #include "nsIConsoleService.h"
 #include "nsEscape.h"
 
 using namespace mozilla;
 
 //------------------------------------------------------------------------
 
 nsIRDFService* nsXULContentUtils::gRDF;
-nsIDateTimeFormat* nsXULContentUtils::gFormat;
 nsICollation *nsXULContentUtils::gCollation;
 
 extern LazyLogModule gXULTemplateLog;
 
 #define XUL_RESOURCE(ident, uri) nsIRDFResource* nsXULContentUtils::ident
 #define XUL_LITERAL(ident, val) nsIRDFLiteral* nsXULContentUtils::ident
 #include "nsXULResourceList.h"
 #undef XUL_RESOURCE
@@ -97,37 +96,31 @@ nsXULContentUtils::Init()
    rv = gRDF->GetLiteral(val, &(ident));                          \
    if (NS_FAILED(rv)) return rv;                                  \
   PR_END_MACRO
 
 #include "nsXULResourceList.h"
 #undef XUL_RESOURCE
 #undef XUL_LITERAL
 
-    gFormat = nsIDateTimeFormat::Create().take();
-    if (!gFormat) {
-        return NS_ERROR_FAILURE;
-    }
-
     return NS_OK;
 }
 
 
 nsresult
 nsXULContentUtils::Finish()
 {
     NS_IF_RELEASE(gRDF);
 
 #define XUL_RESOURCE(ident, uri) NS_IF_RELEASE(ident)
 #define XUL_LITERAL(ident, val) NS_IF_RELEASE(ident)
 #include "nsXULResourceList.h"
 #undef XUL_RESOURCE
 #undef XUL_LITERAL
 
-    NS_IF_RELEASE(gFormat);
     NS_IF_RELEASE(gCollation);
 
     return NS_OK;
 }
 
 nsICollation*
 nsXULContentUtils::GetCollation()
 {
@@ -209,21 +202,21 @@ nsXULContentUtils::GetTextForNode(nsIRDF
 
     nsCOMPtr<nsIRDFDate> dateLiteral = do_QueryInterface(aNode);
     if (dateLiteral) {
         PRTime value;
         rv = dateLiteral->GetValue(&value);
         if (NS_FAILED(rv)) return rv;
 
         nsAutoString str;
-        rv = gFormat->FormatPRTime(nullptr /* nsILocale* locale */,
-                                  kDateFormatShort,
-                                  kTimeFormatSeconds,
-                                  value,
-                                  str);
+        rv = DateTimeFormat::FormatPRTime(kDateFormatShort,
+                                          kTimeFormatSeconds,
+                                          value,
+                                          str);
+
         aResult.Assign(str);
 
         if (NS_FAILED(rv)) return rv;
 
         return NS_OK;
     }
 
     nsCOMPtr<nsIRDFInt> intLiteral = do_QueryInterface(aNode);
--- a/dom/xul/templates/nsXULContentUtils.h
+++ b/dom/xul/templates/nsXULContentUtils.h
@@ -16,17 +16,16 @@
 
 class nsIAtom;
 class nsIContent;
 class nsIDocument;
 class nsIRDFNode;
 class nsIRDFResource;
 class nsIRDFLiteral;
 class nsIRDFService;
-class nsIDateTimeFormat;
 class nsICollation;
 
 // errors to pass to LogTemplateError
 #define ERROR_TEMPLATE_INVALID_QUERYPROCESSOR                           \
         "querytype attribute doesn't specify a valid query processor"
 #define ERROR_TEMPLATE_INVALID_QUERYSET                                 \
         "unexpected <queryset> element"
 #define ERROR_TEMPLATE_NO_MEMBERVAR                                     \
@@ -81,17 +80,16 @@ class nsICollation;
         "the type of a query parameter is wrong"
 #define ERROR_TEMPLATE_STORAGE_QUERY_PARAMETER_NOT_BOUND                \
         "a query parameter cannot be bound to the SQL query"
 
 class nsXULContentUtils
 {
 protected:
     static nsIRDFService* gRDF;
-    static nsIDateTimeFormat* gFormat;
     static nsICollation *gCollation;
 
     static bool gDisableXULCache;
 
     static int
     DisableXULCacheChangedCallback(const char* aPrefName, void* aClosure);
 
 public:
--- a/intl/build/nsI18nModule.cpp
+++ b/intl/build/nsI18nModule.cpp
@@ -56,25 +56,22 @@ NS_DEFINE_NAMED_CID(NS_STRINGBUNDLESERVI
 NS_DEFINE_NAMED_CID(NS_STRINGBUNDLETEXTOVERRIDE_CID);
 NS_DEFINE_NAMED_CID(NS_LOCALESERVICE_CID);
 NS_DEFINE_NAMED_CID(NS_COLLATIONFACTORY_CID);
 NS_DEFINE_NAMED_CID(NS_SCRIPTABLEDATEFORMAT_CID);
 NS_DEFINE_NAMED_CID(NS_LANGUAGEATOMSERVICE_CID);
 NS_DEFINE_NAMED_CID(NS_PLATFORMCHARSET_CID);
 #ifdef XP_WIN
 NS_DEFINE_NAMED_CID(NS_COLLATION_CID);
-NS_DEFINE_NAMED_CID(NS_DATETIMEFORMAT_CID);
 #endif
 #ifdef USE_UNIX_LOCALE
 NS_DEFINE_NAMED_CID(NS_COLLATION_CID);
-NS_DEFINE_NAMED_CID(NS_DATETIMEFORMAT_CID);
 #endif
 #ifdef USE_MAC_LOCALE
 NS_DEFINE_NAMED_CID(NS_COLLATION_CID);
-NS_DEFINE_NAMED_CID(NS_DATETIMEFORMAT_CID);
 #endif
 
 static const mozilla::Module::CIDEntry kIntlCIDs[] = {
     { &kNS_LBRK_CID, false, nullptr, nsJISx4051LineBreakerConstructor },
     { &kNS_WBRK_CID, false, nullptr, nsSampleWordBreakerConstructor },
     { &kNS_SEMANTICUNITSCANNER_CID, false, nullptr, nsSemanticUnitScannerConstructor },
     { &kNS_UNICHARUTIL_CID, false, nullptr, nsCaseConversionImp2Constructor },
     { &kNS_UNICHARCATEGORY_CID, false, nullptr, nsCategoryImpConstructor },
@@ -85,25 +82,22 @@ static const mozilla::Module::CIDEntry k
     { &kNS_STRINGBUNDLETEXTOVERRIDE_CID, false, nullptr, nsStringBundleTextOverrideConstructor },
     { &kNS_LOCALESERVICE_CID, false, nullptr, CreateLocaleService },
     { &kNS_COLLATIONFACTORY_CID, false, nullptr, nsCollationFactoryConstructor },
     { &kNS_SCRIPTABLEDATEFORMAT_CID, false, nullptr, NS_NewScriptableDateFormat },
     { &kNS_LANGUAGEATOMSERVICE_CID, false, nullptr, nsLanguageAtomServiceConstructor },
     { &kNS_PLATFORMCHARSET_CID, false, nullptr, nsPlatformCharsetConstructor },
 #ifdef XP_WIN
     { &kNS_COLLATION_CID, false, nullptr, nsCollationWinConstructor },
-    { &kNS_DATETIMEFORMAT_CID, false, nullptr, nsDateTimeFormatWinConstructor },
 #endif
 #ifdef USE_UNIX_LOCALE
     { &kNS_COLLATION_CID, false, nullptr, nsCollationUnixConstructor },
-    { &kNS_DATETIMEFORMAT_CID, false, nullptr, nsDateTimeFormatUnixConstructor },
 #endif
 #ifdef USE_MAC_LOCALE
     { &kNS_COLLATION_CID, false, nullptr, nsCollationMacUCConstructor },
-    { &kNS_DATETIMEFORMAT_CID, false, nullptr, nsDateTimeFormatMacConstructor },
 #endif
     { nullptr }
 };
 
 static const mozilla::Module::ContractIDEntry kIntlContracts[] = {
     { NS_LBRK_CONTRACTID, &kNS_LBRK_CID },
     { NS_WBRK_CONTRACTID, &kNS_WBRK_CID },
     { NS_SEMANTICUNITSCANNER_CONTRACTID, &kNS_SEMANTICUNITSCANNER_CID },
@@ -116,25 +110,22 @@ static const mozilla::Module::ContractID
     { NS_STRINGBUNDLETEXTOVERRIDE_CONTRACTID, &kNS_STRINGBUNDLETEXTOVERRIDE_CID },
     { NS_LOCALESERVICE_CONTRACTID, &kNS_LOCALESERVICE_CID },
     { NS_COLLATIONFACTORY_CONTRACTID, &kNS_COLLATIONFACTORY_CID },
     { NS_SCRIPTABLEDATEFORMAT_CONTRACTID, &kNS_SCRIPTABLEDATEFORMAT_CID },
     { NS_LANGUAGEATOMSERVICE_CONTRACTID, &kNS_LANGUAGEATOMSERVICE_CID },
     { NS_PLATFORMCHARSET_CONTRACTID, &kNS_PLATFORMCHARSET_CID },
 #ifdef XP_WIN
     { NS_COLLATION_CONTRACTID, &kNS_COLLATION_CID },
-    { NS_DATETIMEFORMAT_CONTRACTID, &kNS_DATETIMEFORMAT_CID },
 #endif
 #ifdef USE_UNIX_LOCALE
     { NS_COLLATION_CONTRACTID, &kNS_COLLATION_CID },
-    { NS_DATETIMEFORMAT_CONTRACTID, &kNS_DATETIMEFORMAT_CID },
 #endif
 #ifdef USE_MAC_LOCALE
     { NS_COLLATION_CONTRACTID, &kNS_COLLATION_CID },
-    { NS_DATETIMEFORMAT_CONTRACTID, &kNS_DATETIMEFORMAT_CID },
 #endif
     { nullptr }
 };
 
 static const mozilla::Module kIntlModule = {
     mozilla::Module::kVersion,
     kIntlCIDs,
     kIntlContracts,
new file mode 100644
--- /dev/null
+++ b/intl/locale/DateTimeFormat.h
@@ -0,0 +1,68 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+ *
+ * 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/. */
+
+#ifndef mozilla_DateTimeFormat_h
+#define mozilla_DateTimeFormat_h
+
+#include <time.h>
+#include "nsIScriptableDateFormat.h"
+#include "nsStringGlue.h"
+#include "prtime.h"
+
+#ifndef ENABLE_INTL_API
+#include "nsCOMPtr.h"
+#include "nsIUnicodeDecoder.h"
+#endif
+
+namespace mozilla {
+
+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);
+
+  // performs a locale sensitive date formatting operation on the PRTime parameter
+  static nsresult FormatPRTime(const nsDateFormatSelector aDateFormatSelector,
+                               const nsTimeFormatSelector aTimeFormatSelector,
+                               const PRTime aPrTime,
+                               nsAString& aStringOut);
+
+  // performs a locale sensitive date formatting operation on the PRExplodedTime parameter
+  static nsresult FormatPRExplodedTime(const nsDateFormatSelector aDateFormatSelector,
+                                       const nsTimeFormatSelector aTimeFormatSelector,
+                                       const PRExplodedTime* aExplodedTime,
+                                       nsAString& aStringOut);
+
+  static void Shutdown();
+
+private:
+  DateTimeFormat() = delete;
+
+  static nsresult Initialize();
+
+#ifdef ENABLE_INTL_API
+  static nsCString* mLocale;
+#else
+  // performs a locale sensitive date formatting operation on the struct tm parameter
+  static nsresult FormatTMTime(const nsDateFormatSelector aDateFormatSelector,
+                               const nsTimeFormatSelector aTimeFormatSelector,
+                               const struct tm* aTmTime,
+                               nsAString& aStringOut);
+
+  static void LocalePreferred24hour();
+
+  static bool mLocalePreferred24hour;                       // true if 24 hour format is preferred by current locale
+  static bool mLocaleAMPMfirst;                             // true if AM/PM string is preferred before the time
+  static nsCOMPtr<nsIUnicodeDecoder> mDecoder;
+#endif
+};
+
+}
+
+#endif  /* mozilla_DateTimeFormat_h */
new file mode 100644
--- /dev/null
+++ b/intl/locale/DateTimeFormatICU.cpp
@@ -0,0 +1,161 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+ *
+ * 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 "nsCOMPtr.h"
+#include "nsIServiceManager.h"
+#include "nsILocaleService.h"
+#include "unicode/udat.h"
+
+namespace mozilla {
+
+nsCString* DateTimeFormat::mLocale = nullptr;
+
+/*static*/ nsresult
+DateTimeFormat::Initialize()
+{
+  nsAutoString localeStr;
+  nsresult rv = NS_OK;
+
+  if (!mLocale) {
+    mLocale = new nsCString();
+  } else if (!mLocale->IsEmpty()) {
+    return NS_OK;
+  }
+
+  nsCOMPtr<nsILocaleService> localeService =
+           do_GetService(NS_LOCALESERVICE_CONTRACTID, &rv);
+  if (NS_SUCCEEDED(rv)) {
+    nsCOMPtr<nsILocale> appLocale;
+    rv = localeService->GetApplicationLocale(getter_AddRefs(appLocale));
+    if (NS_SUCCEEDED(rv)) {
+      rv = appLocale->GetCategory(NS_LITERAL_STRING("NSILOCALE_TIME"), localeStr);
+      if (NS_SUCCEEDED(rv) && !localeStr.IsEmpty()) {
+        *mLocale = NS_LossyConvertUTF16toASCII(localeStr); // cache locale name
+      }
+    }
+  }
+
+  return rv;
+}
+
+// performs a locale sensitive date formatting operation on the time_t parameter
+/*static*/ nsresult
+DateTimeFormat::FormatTime(const nsDateFormatSelector aDateFormatSelector,
+                           const nsTimeFormatSelector aTimeFormatSelector,
+                           const time_t aTimetTime,
+                           nsAString& aStringOut)
+{
+  return FormatPRTime(aDateFormatSelector, aTimeFormatSelector, (aTimetTime * PR_USEC_PER_SEC), aStringOut);
+}
+
+// performs a locale sensitive date formatting operation on the PRTime parameter
+/*static*/ nsresult
+DateTimeFormat::FormatPRTime(const nsDateFormatSelector aDateFormatSelector,
+                             const nsTimeFormatSelector aTimeFormatSelector,
+                             const PRTime aPrTime,
+                             nsAString& aStringOut)
+{
+#define DATETIME_FORMAT_INITIAL_LEN 127
+  int32_t dateTimeLen = 0;
+  nsresult rv = NS_OK;
+
+  // return, nothing to format
+  if (aDateFormatSelector == kDateFormatNone && aTimeFormatSelector == kTimeFormatNone) {
+    aStringOut.Truncate();
+    return NS_OK;
+  }
+
+  // set up locale data
+  rv = Initialize();
+
+  if (NS_FAILED(rv)) {
+    return rv;
+  }
+
+  UDate timeUDate = aPrTime / PR_USEC_PER_MSEC;
+
+  // Get the date style for the formatter:
+  UDateFormatStyle dateStyle;
+  switch (aDateFormatSelector) {
+    case kDateFormatLong:
+      dateStyle = UDAT_LONG;
+      break;
+    case kDateFormatShort:
+      dateStyle = UDAT_SHORT;
+      break;
+    case kDateFormatNone:
+      dateStyle = UDAT_NONE;
+      break;
+    default:
+      NS_ERROR("Unknown nsDateFormatSelector");
+      return NS_ERROR_ILLEGAL_VALUE;
+  }
+
+  // Get the time style for the formatter:
+  UDateFormatStyle timeStyle;
+  switch (aTimeFormatSelector) {
+    case kTimeFormatSeconds:
+      timeStyle = UDAT_MEDIUM;
+      break;
+    case kTimeFormatNoSeconds:
+      timeStyle = UDAT_SHORT;
+      break;
+    case kTimeFormatNone:
+      timeStyle = UDAT_NONE;
+      break;
+    default:
+      NS_ERROR("Unknown nsTimeFormatSelector");
+      return NS_ERROR_ILLEGAL_VALUE;
+  }
+
+  // generate date/time string
+
+  UErrorCode status = U_ZERO_ERROR;
+
+  UDateFormat* dateTimeFormat = udat_open(timeStyle, dateStyle, mLocale->get(), nullptr, -1, nullptr, -1, &status);
+
+  if (U_SUCCESS(status) && dateTimeFormat) {
+    aStringOut.SetLength(DATETIME_FORMAT_INITIAL_LEN);
+    dateTimeLen = udat_format(dateTimeFormat, timeUDate, reinterpret_cast<UChar*>(aStringOut.BeginWriting()), DATETIME_FORMAT_INITIAL_LEN, nullptr, &status);
+    aStringOut.SetLength(dateTimeLen);
+
+    if (status == U_BUFFER_OVERFLOW_ERROR) {
+      status = U_ZERO_ERROR;
+      udat_format(dateTimeFormat, timeUDate, reinterpret_cast<UChar*>(aStringOut.BeginWriting()), dateTimeLen, nullptr, &status);
+    }
+  }
+
+  if (U_FAILURE(status)) {
+    rv = NS_ERROR_FAILURE;
+  }
+
+  if (dateTimeFormat) {
+    udat_close(dateTimeFormat);
+  }
+
+  return rv;
+}
+
+// performs a locale sensitive date formatting operation on the PRExplodedTime parameter
+/*static*/ nsresult
+DateTimeFormat::FormatPRExplodedTime(const nsDateFormatSelector aDateFormatSelector,
+                                     const nsTimeFormatSelector aTimeFormatSelector,
+                                     const PRExplodedTime* aExplodedTime,
+                                     nsAString& aStringOut)
+{
+  return FormatPRTime(aDateFormatSelector, aTimeFormatSelector, PR_ImplodeTime(aExplodedTime), aStringOut);
+}
+
+/*static*/ void
+DateTimeFormat::Shutdown()
+{
+  if (mLocale) {
+    delete mLocale;
+  }
+}
+
+}
rename from intl/locale/unix/nsDateTimeFormatUnix.cpp
rename to intl/locale/DateTimeFormatUnix.cpp
--- a/intl/locale/unix/nsDateTimeFormatUnix.cpp
+++ b/intl/locale/DateTimeFormatUnix.cpp
@@ -1,284 +1,239 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* 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 <locale.h>
+#include "DateTimeFormat.h"
 #include "plstr.h"
 #include "nsIServiceManager.h"
-#include "nsDateTimeFormatUnix.h"
-#include "nsIComponentManager.h"
 #include "nsILocaleService.h"
 #include "nsIPlatformCharset.h"
-#include "nsPosixLocale.h"
-#include "nsCRT.h"
-#include "nsReadableUtils.h"
-#include "nsUnicharUtils.h"
 #include "mozilla/dom/EncodingUtils.h"
 
 using mozilla::dom::EncodingUtils;
 
-NS_IMPL_ISUPPORTS(nsDateTimeFormatUnix, nsIDateTimeFormat)
+namespace mozilla {
 
-// init this interface to a specified locale
-nsresult nsDateTimeFormatUnix::Initialize(nsILocale* locale)
+bool DateTimeFormat::mLocalePreferred24hour;
+bool DateTimeFormat::mLocaleAMPMfirst;
+nsCOMPtr<nsIUnicodeDecoder> DateTimeFormat::mDecoder;
+
+/*static*/ nsresult
+DateTimeFormat::Initialize()
 {
   nsAutoString localeStr;
-  NS_NAMED_LITERAL_STRING(aCategory, "NSILOCALE_TIME##PLATFORM");
-  nsresult res = NS_OK;
+  nsAutoCString charset;
+  nsresult rv = NS_OK;
+
+  if (mDecoder) {
+    return NS_OK;
+  }
+
+  charset.AssignLiteral("windows-1252");
 
-  // use cached info if match with stored locale
-  if (!locale) {
-    if (!mLocale.IsEmpty() &&
-        mLocale.Equals(mAppLocale, nsCaseInsensitiveStringComparator())) {
-      return NS_OK;
+  nsCOMPtr<nsILocaleService> localeService =
+    do_GetService(NS_LOCALESERVICE_CONTRACTID, &rv);
+  if (NS_SUCCEEDED(rv)) {
+    nsCOMPtr<nsILocale> appLocale;
+    rv = localeService->GetApplicationLocale(getter_AddRefs(appLocale));
+    if (NS_SUCCEEDED(rv)) {
+      rv = appLocale->GetCategory(NS_LITERAL_STRING("NSILOCALE_TIME##PLATFORM"), localeStr);
+      NS_ASSERTION(NS_SUCCEEDED(rv), "failed to get app locale info");
     }
   }
-  else {
-    res = locale->GetCategory(aCategory, localeStr);
-    if (NS_SUCCEEDED(res) && !localeStr.IsEmpty()) {
-      if (!mLocale.IsEmpty() &&
-          mLocale.Equals(localeStr,
-                         nsCaseInsensitiveStringComparator())) {
-        return NS_OK;
+
+  if (NS_SUCCEEDED(rv) && !localeStr.IsEmpty()) {
+    nsCOMPtr<nsIPlatformCharset> platformCharset = do_GetService(NS_PLATFORMCHARSET_CONTRACTID, &rv);
+    if (NS_SUCCEEDED(rv)) {
+      nsAutoCString mappedCharset;
+      rv = platformCharset->GetDefaultCharsetForLocale(localeStr, mappedCharset);
+      if (NS_SUCCEEDED(rv)) {
+        charset = mappedCharset;
       }
     }
   }
 
-  mCharset.AssignLiteral("windows-1252");
-  mPlatformLocale.AssignLiteral("en_US");
-
-  // get locale name string, use app default if no locale specified
-  if (!locale) {
-    nsCOMPtr<nsILocaleService> localeService = 
-             do_GetService(NS_LOCALESERVICE_CONTRACTID, &res);
-    if (NS_SUCCEEDED(res)) {
-      nsCOMPtr<nsILocale> appLocale;
-      res = localeService->GetApplicationLocale(getter_AddRefs(appLocale));
-      if (NS_SUCCEEDED(res)) {
-        res = appLocale->GetCategory(aCategory, localeStr);
-        if (NS_SUCCEEDED(res) && !localeStr.IsEmpty()) {
-          NS_ASSERTION(NS_SUCCEEDED(res), "failed to get app locale info");
-          mAppLocale = localeStr; // cache app locale name
-        }
-      }
-    }
-  }
-  else {
-    res = locale->GetCategory(aCategory, localeStr);
-    NS_ASSERTION(NS_SUCCEEDED(res), "failed to get locale info");
-  }
-
-  if (NS_SUCCEEDED(res) && !localeStr.IsEmpty()) {
-    mLocale = localeStr; // cache locale name
-
-    nsPosixLocale::GetPlatformLocale(mLocale, mPlatformLocale);
-
-    nsCOMPtr <nsIPlatformCharset> platformCharset = do_GetService(NS_PLATFORMCHARSET_CONTRACTID, &res);
-    if (NS_SUCCEEDED(res)) {
-      nsAutoCString mappedCharset;
-      res = platformCharset->GetDefaultCharsetForLocale(mLocale, mappedCharset);
-      if (NS_SUCCEEDED(res)) {
-        mCharset = mappedCharset;
-      }
-    }
-  }
-
-  mDecoder = EncodingUtils::DecoderForEncoding(mCharset);
+  mDecoder = EncodingUtils::DecoderForEncoding(charset);
 
   LocalePreferred24hour();
 
-  return res;
+  return rv;
 }
 
-void nsDateTimeFormatUnix::LocalePreferred24hour()
+/*static*/ void
+DateTimeFormat::LocalePreferred24hour()
 {
   char str[100];
   time_t tt;
   struct tm *tmc;
   int i;
 
   tt = time(nullptr);
   tmc = localtime(&tt);
 
   tmc->tm_hour=22;    // put the test sample hour to 22:00 which is 10PM
   tmc->tm_min=0;      // set the min & sec other number than '2'
   tmc->tm_sec=0;
 
-  char *temp = setlocale(LC_TIME, mPlatformLocale.get());
   strftime(str, (size_t)99, "%X", (struct tm *)tmc);
 
-  (void) setlocale(LC_TIME, temp);
-
   mLocalePreferred24hour = false;
   for (i=0; str[i]; i++) {
     if (str[i] == '2') {    // if there is any '2', that locale use 0-23 time format
-        mLocalePreferred24hour = true;
-        break;
+      mLocalePreferred24hour = true;
+      break;
     }
   }
 
   mLocaleAMPMfirst = true;
   if (mLocalePreferred24hour == false) {
     if (str[0] && str[0] == '1') { // if the first character is '1' of 10:00,
 			           // AMPM string is located after 10:00
       mLocaleAMPMfirst = false;
     }
   }
 }
 
-nsresult nsDateTimeFormatUnix::FormatTime(nsILocale* locale, 
-                                      const nsDateFormatSelector  dateFormatSelector, 
-                                      const nsTimeFormatSelector timeFormatSelector, 
-                                      const time_t  timetTime, 
-                                      nsAString& stringOut) 
+/*static*/ nsresult
+DateTimeFormat::FormatTime(const nsDateFormatSelector aDateFormatSelector,
+                           const nsTimeFormatSelector aTimeFormatSelector,
+                           const time_t aTimetTime,
+                           nsAString& aStringOut)
 {
   struct tm tmTime;
-  memcpy(&tmTime, localtime(&timetTime), sizeof(struct tm));
-  return FormatTMTime(locale, dateFormatSelector, timeFormatSelector, &tmTime, stringOut);
+  memcpy(&tmTime, localtime(&aTimetTime), sizeof(struct tm));
+  return FormatTMTime(aDateFormatSelector, aTimeFormatSelector, &tmTime, aStringOut);
 }
 
 // performs a locale sensitive date formatting operation on the struct tm parameter
-nsresult nsDateTimeFormatUnix::FormatTMTime(nsILocale* locale, 
-                                        const nsDateFormatSelector  dateFormatSelector, 
-                                        const nsTimeFormatSelector timeFormatSelector, 
-                                        const struct tm*  tmTime, 
-                                        nsAString& stringOut) 
+/*static*/ nsresult
+DateTimeFormat::FormatTMTime(const nsDateFormatSelector aDateFormatSelector,
+                             const nsTimeFormatSelector aTimeFormatSelector,
+                             const struct tm* aTmTime,
+                             nsAString& aStringOut)
 {
-#define NSDATETIME_FORMAT_BUFFER_LEN  80
+#define NSDATETIME_FORMAT_BUFFER_LEN 80
   char strOut[NSDATETIME_FORMAT_BUFFER_LEN*2];  // buffer for date and time
   char fmtD[NSDATETIME_FORMAT_BUFFER_LEN], fmtT[NSDATETIME_FORMAT_BUFFER_LEN];
   nsresult rv;
 
-  
   // set up locale data
-  (void) Initialize(locale);
+  (void) Initialize();
   NS_ENSURE_TRUE(mDecoder, NS_ERROR_NOT_INITIALIZED);
 
   // set date format
-  if (dateFormatSelector == kDateFormatLong && timeFormatSelector == kTimeFormatSeconds) {
+  if (aDateFormatSelector == kDateFormatLong && aTimeFormatSelector == kTimeFormatSeconds) {
     PL_strncpy(fmtD, "%c", NSDATETIME_FORMAT_BUFFER_LEN);
-    PL_strncpy(fmtT, "", NSDATETIME_FORMAT_BUFFER_LEN); 
+    PL_strncpy(fmtT, "", NSDATETIME_FORMAT_BUFFER_LEN);
   } else {
 
-    switch (dateFormatSelector) {
+    switch (aDateFormatSelector) {
       case kDateFormatNone:
         PL_strncpy(fmtD, "", NSDATETIME_FORMAT_BUFFER_LEN);
-        break; 
+        break;
       case kDateFormatLong:
       case kDateFormatShort:
         PL_strncpy(fmtD, "%x", NSDATETIME_FORMAT_BUFFER_LEN);
-        break; 
-      case kDateFormatYearMonth:
-        PL_strncpy(fmtD, "%Y/%m", NSDATETIME_FORMAT_BUFFER_LEN);
-        break; 
-      case kDateFormatWeekday:
-        PL_strncpy(fmtD, "%a", NSDATETIME_FORMAT_BUFFER_LEN);
         break;
       default:
-        PL_strncpy(fmtD, "", NSDATETIME_FORMAT_BUFFER_LEN); 
+        PL_strncpy(fmtD, "", NSDATETIME_FORMAT_BUFFER_LEN);
     }
 
     // set time format
-    switch (timeFormatSelector) {
+    switch (aTimeFormatSelector) {
       case kTimeFormatNone:
-        PL_strncpy(fmtT, "", NSDATETIME_FORMAT_BUFFER_LEN); 
+        PL_strncpy(fmtT, "", NSDATETIME_FORMAT_BUFFER_LEN);
         break;
       case kTimeFormatSeconds:
         PL_strncpy(fmtT, "%X", NSDATETIME_FORMAT_BUFFER_LEN);
         break;
       case kTimeFormatNoSeconds:
-        PL_strncpy(fmtT, 
-                   mLocalePreferred24hour ? "%H:%M" : mLocaleAMPMfirst ? "%p %I:%M" : "%I:%M %p", 
+        PL_strncpy(fmtT,
+                   mLocalePreferred24hour ? "%H:%M" : mLocaleAMPMfirst ? "%p %I:%M" : "%I:%M %p",
                    NSDATETIME_FORMAT_BUFFER_LEN);
         break;
-      case kTimeFormatSecondsForce24Hour:
-        PL_strncpy(fmtT, "%H:%M:%S", NSDATETIME_FORMAT_BUFFER_LEN);
-        break;
-      case kTimeFormatNoSecondsForce24Hour:
-        PL_strncpy(fmtT, "%H:%M", NSDATETIME_FORMAT_BUFFER_LEN);
-        break;
       default:
-        PL_strncpy(fmtT, "", NSDATETIME_FORMAT_BUFFER_LEN); 
+        PL_strncpy(fmtT, "", NSDATETIME_FORMAT_BUFFER_LEN);
     }
   }
 
-  // generate data/time string
-  char *old_locale = setlocale(LC_TIME, nullptr);
-  (void) setlocale(LC_TIME, mPlatformLocale.get());
+  // generate date/time string
   if (strlen(fmtD) && strlen(fmtT)) {
     PL_strncat(fmtD, " ", NSDATETIME_FORMAT_BUFFER_LEN);
     PL_strncat(fmtD, fmtT, NSDATETIME_FORMAT_BUFFER_LEN);
-    strftime(strOut, NSDATETIME_FORMAT_BUFFER_LEN, fmtD, tmTime);
-  }
-  else if (strlen(fmtD) && !strlen(fmtT)) {
-    strftime(strOut, NSDATETIME_FORMAT_BUFFER_LEN, fmtD, tmTime);
-  }
-  else if (!strlen(fmtD) && strlen(fmtT)) {
-    strftime(strOut, NSDATETIME_FORMAT_BUFFER_LEN, fmtT, tmTime);
-  }
-  else {
+    strftime(strOut, NSDATETIME_FORMAT_BUFFER_LEN, fmtD, aTmTime);
+  } else if (strlen(fmtD) && !strlen(fmtT)) {
+    strftime(strOut, NSDATETIME_FORMAT_BUFFER_LEN, fmtD, aTmTime);
+  } else if (!strlen(fmtD) && strlen(fmtT)) {
+    strftime(strOut, NSDATETIME_FORMAT_BUFFER_LEN, fmtT, aTmTime);
+  } else {
     PL_strncpy(strOut, "", NSDATETIME_FORMAT_BUFFER_LEN);
   }
-  (void) setlocale(LC_TIME, old_locale);
 
   // convert result to unicode
   int32_t srcLength = (int32_t) strlen(strOut);
   int32_t unicharLength = NSDATETIME_FORMAT_BUFFER_LEN*2;
   char16_t unichars[NSDATETIME_FORMAT_BUFFER_LEN*2];   // buffer for date and time
 
   rv = mDecoder->Convert(strOut, &srcLength, unichars, &unicharLength);
-  if (NS_FAILED(rv))
+  if (NS_FAILED(rv)) {
     return rv;
-  stringOut.Assign(unichars, unicharLength);
+  }
+  aStringOut.Assign(unichars, unicharLength);
 
   return rv;
 }
 
 // performs a locale sensitive date formatting operation on the PRTime parameter
-nsresult nsDateTimeFormatUnix::FormatPRTime(nsILocale* locale, 
-                                           const nsDateFormatSelector  dateFormatSelector, 
-                                           const nsTimeFormatSelector timeFormatSelector, 
-                                           const PRTime  prTime, 
-                                           nsAString& stringOut)
+/*static*/ nsresult
+DateTimeFormat::FormatPRTime(const nsDateFormatSelector aDateFormatSelector,
+                             const nsTimeFormatSelector aTimeFormatSelector,
+                             const PRTime aPrTime,
+                             nsAString& aStringOut)
 {
   PRExplodedTime explodedTime;
-  PR_ExplodeTime(prTime, PR_LocalTimeParameters, &explodedTime);
+  PR_ExplodeTime(aPrTime, PR_LocalTimeParameters, &explodedTime);
 
-  return FormatPRExplodedTime(locale, dateFormatSelector, timeFormatSelector, &explodedTime, stringOut);
+  return FormatPRExplodedTime(aDateFormatSelector, aTimeFormatSelector, &explodedTime, aStringOut);
 }
 
 // performs a locale sensitive date formatting operation on the PRExplodedTime parameter
-nsresult nsDateTimeFormatUnix::FormatPRExplodedTime(nsILocale* locale, 
-                                                   const nsDateFormatSelector  dateFormatSelector, 
-                                                   const nsTimeFormatSelector timeFormatSelector, 
-                                                   const PRExplodedTime*  explodedTime, 
-                                                   nsAString& stringOut)
+/*static*/ nsresult
+DateTimeFormat::FormatPRExplodedTime(const nsDateFormatSelector aDateFormatSelector,
+                                     const nsTimeFormatSelector aTimeFormatSelector,
+                                     const PRExplodedTime* aExplodedTime,
+                                     nsAString& aStringOut)
 {
   struct tm  tmTime;
   /* be safe and set all members of struct tm to zero
    *
    * there are other fields in the tm struct that we aren't setting
    * (tm_isdst, tm_gmtoff, tm_zone, should we set these?) and since
    * tmTime is on the stack, it may be filled with garbage, but
    * the garbage may vary.  (this may explain why some saw bug #10412, and
    * others did not.
    *
-   * when tmTime is passed to strftime() with garbage bad things may happen. 
+   * when tmTime is passed to strftime() with garbage bad things may happen.
    * see bug #10412
    */
   memset( &tmTime, 0, sizeof(tmTime) );
 
-  tmTime.tm_yday = explodedTime->tm_yday;
-  tmTime.tm_wday = explodedTime->tm_wday;
-  tmTime.tm_year = explodedTime->tm_year;
+  tmTime.tm_yday = aExplodedTime->tm_yday;
+  tmTime.tm_wday = aExplodedTime->tm_wday;
+  tmTime.tm_year = aExplodedTime->tm_year;
   tmTime.tm_year -= 1900;
-  tmTime.tm_mon = explodedTime->tm_month;
-  tmTime.tm_mday = explodedTime->tm_mday;
-  tmTime.tm_hour = explodedTime->tm_hour;
-  tmTime.tm_min = explodedTime->tm_min;
-  tmTime.tm_sec = explodedTime->tm_sec;
+  tmTime.tm_mon = aExplodedTime->tm_month;
+  tmTime.tm_mday = aExplodedTime->tm_mday;
+  tmTime.tm_hour = aExplodedTime->tm_hour;
+  tmTime.tm_min = aExplodedTime->tm_min;
+  tmTime.tm_sec = aExplodedTime->tm_sec;
 
-  return FormatTMTime(locale, dateFormatSelector, timeFormatSelector, &tmTime, stringOut);
+  return FormatTMTime(aDateFormatSelector, aTimeFormatSelector, &tmTime, aStringOut);
 }
 
+/*static*/ void
+DateTimeFormat::Shutdown()
+{
+}
+
+}
--- a/intl/locale/mac/moz.build
+++ b/intl/locale/mac/moz.build
@@ -1,16 +1,15 @@
 # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # 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/.
 
 UNIFIED_SOURCES += [
     'nsCollationMacUC.cpp',
-    'nsDateTimeFormatMac.cpp',
     'nsMacCharset.cpp',
 ]
 
 FINAL_LIBRARY = 'xul'
 LOCAL_INCLUDES += [
     '..',
 ]
deleted file mode 100644
--- a/intl/locale/mac/nsDateTimeFormatMac.cpp
+++ /dev/null
@@ -1,266 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* 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 <CoreFoundation/CoreFoundation.h>
-#include "nsIServiceManager.h"
-#include "nsDateTimeFormatMac.h"
-#include <CoreFoundation/CFDateFormatter.h>
-#include "nsIComponentManager.h"
-#include "nsILocaleService.h"
-#include "nsCRT.h"
-#include "plstr.h"
-#include "nsUnicharUtils.h"
-#include "nsTArray.h"
-
-
-NS_IMPL_ISUPPORTS(nsDateTimeFormatMac, nsIDateTimeFormat)
-
-nsresult nsDateTimeFormatMac::Initialize(nsILocale* locale)
-{
-  nsAutoString localeStr;
-  nsAutoString category(NS_LITERAL_STRING("NSILOCALE_TIME"));
-  nsresult res;
-
-  // use cached info if match with stored locale
-  if (nullptr == locale) {
-    if (!mLocale.IsEmpty() &&
-        mLocale.Equals(mAppLocale, nsCaseInsensitiveStringComparator())) {
-      return NS_OK;
-    }
-  }
-  else {
-    res = locale->GetCategory(category, localeStr);
-    if (NS_SUCCEEDED(res) && !localeStr.IsEmpty()) {
-      if (!mLocale.IsEmpty() &&
-          mLocale.Equals(localeStr,
-                         nsCaseInsensitiveStringComparator())) {
-        return NS_OK;
-      }
-    }
-  }
-
-  // get application locale
-  nsCOMPtr<nsILocaleService> localeService = 
-           do_GetService(NS_LOCALESERVICE_CONTRACTID, &res);
-  if (NS_SUCCEEDED(res)) {
-    nsCOMPtr<nsILocale> appLocale;
-    res = localeService->GetApplicationLocale(getter_AddRefs(appLocale));
-    if (NS_SUCCEEDED(res)) {
-      res = appLocale->GetCategory(category, localeStr);
-      if (NS_SUCCEEDED(res) && !localeStr.IsEmpty()) {
-        mAppLocale = localeStr; // cache app locale name
-      }
-    }
-  }
-  
-  // use app default if no locale specified
-  if (nullptr == locale) {
-    mUseDefaultLocale = true;
-  }
-  else {
-    mUseDefaultLocale = false;
-    res = locale->GetCategory(category, localeStr);
-  }
-    
-  if (NS_SUCCEEDED(res) && !localeStr.IsEmpty()) {
-    mLocale.Assign(localeStr); // cache locale name
-  }
-
-  return res;
-}
-
-// performs a locale sensitive date formatting operation on the time_t parameter
-nsresult nsDateTimeFormatMac::FormatTime(nsILocale* locale, 
-                                      const nsDateFormatSelector  dateFormatSelector, 
-                                      const nsTimeFormatSelector timeFormatSelector, 
-                                      const time_t  timetTime, 
-                                      nsAString& stringOut)
-{
-  struct tm tmTime;
-  return FormatTMTime(locale, dateFormatSelector, timeFormatSelector, localtime_r(&timetTime, &tmTime), stringOut);
-}
-
-// performs a locale sensitive date formatting operation on the struct tm parameter
-nsresult nsDateTimeFormatMac::FormatTMTime(nsILocale* locale, 
-                                           const nsDateFormatSelector  dateFormatSelector, 
-                                           const nsTimeFormatSelector timeFormatSelector, 
-                                           const struct tm*  tmTime, 
-                                           nsAString& stringOut)
-{
-  nsresult res = NS_OK;
-
-  // set up locale data
-  (void) Initialize(locale);
-  
-  // return, nothing to format
-  if (dateFormatSelector == kDateFormatNone && timeFormatSelector == kTimeFormatNone) {
-    stringOut.Truncate();
-    return NS_OK;
-  }
-
-  NS_ASSERTION(tmTime->tm_mon >= 0, "tm is not set correctly");
-  NS_ASSERTION(tmTime->tm_mday >= 1, "tm is not set correctly");
-  NS_ASSERTION(tmTime->tm_hour >= 0, "tm is not set correctly");
-  NS_ASSERTION(tmTime->tm_min >= 0, "tm is not set correctly");
-  NS_ASSERTION(tmTime->tm_sec >= 0, "tm is not set correctly");
-  NS_ASSERTION(tmTime->tm_wday >= 0, "tm is not set correctly");
-
-  // Got the locale for the formatter:
-  CFLocaleRef formatterLocale;
-  if (!locale) {
-    formatterLocale = CFLocaleCopyCurrent();
-  } else {
-    CFStringRef localeStr = CFStringCreateWithCharacters(nullptr,
-                                                         reinterpret_cast<const UniChar*>(mLocale.get()),
-                                                         mLocale.Length());
-    formatterLocale = CFLocaleCreate(nullptr, localeStr);
-    CFRelease(localeStr);
-  }
-
-  // Get the date style for the formatter:  
-  CFDateFormatterStyle dateStyle;
-  switch (dateFormatSelector) {
-    case kDateFormatLong:
-      dateStyle = kCFDateFormatterLongStyle;
-      break;
-    case kDateFormatShort:
-      dateStyle = kCFDateFormatterShortStyle;
-      break;
-    case kDateFormatYearMonth:
-    case kDateFormatWeekday:
-      dateStyle = kCFDateFormatterNoStyle; // formats handled below
-      break;
-    case kDateFormatNone:
-      dateStyle = kCFDateFormatterNoStyle;
-      break;
-    default:
-      NS_ERROR("Unknown nsDateFormatSelector");
-      res = NS_ERROR_FAILURE;
-      dateStyle = kCFDateFormatterNoStyle;
-  }
-  
-  // Get the time style for the formatter:
-  CFDateFormatterStyle timeStyle;
-  switch (timeFormatSelector) {
-    case kTimeFormatSeconds:
-    case kTimeFormatSecondsForce24Hour: // 24 hour part fixed below
-      timeStyle = kCFDateFormatterMediumStyle;
-      break;
-    case kTimeFormatNoSeconds:
-    case kTimeFormatNoSecondsForce24Hour: // 24 hour part fixed below
-      timeStyle = kCFDateFormatterShortStyle;
-      break;
-    case kTimeFormatNone:
-      timeStyle = kCFDateFormatterNoStyle;
-      break;
-    default:
-      NS_ERROR("Unknown nsTimeFormatSelector");
-      res = NS_ERROR_FAILURE;
-      timeStyle = kCFDateFormatterNoStyle;
-  }
-  
-  // Create the formatter and fix up its formatting as necessary:
-  CFDateFormatterRef formatter =
-    CFDateFormatterCreate(nullptr, formatterLocale, dateStyle, timeStyle);
-  
-  CFRelease(formatterLocale);
-  
-  if (dateFormatSelector == kDateFormatYearMonth ||
-      dateFormatSelector == kDateFormatWeekday) {
-    CFStringRef dateFormat =
-      dateFormatSelector == kDateFormatYearMonth ? CFSTR("yyyy/MM ") : CFSTR("EEE ");
-    
-    CFStringRef oldFormat = CFDateFormatterGetFormat(formatter);
-    CFMutableStringRef newFormat = CFStringCreateMutableCopy(nullptr, 0, oldFormat);
-    CFStringInsert(newFormat, 0, dateFormat);
-    CFDateFormatterSetFormat(formatter, newFormat);
-    CFRelease(newFormat); // note we don't own oldFormat
-  }
-  
-  if (timeFormatSelector == kTimeFormatSecondsForce24Hour ||
-      timeFormatSelector == kTimeFormatNoSecondsForce24Hour) {
-    // Replace "h" with "H", and remove "a":
-    CFStringRef oldFormat = CFDateFormatterGetFormat(formatter);
-    CFMutableStringRef newFormat = CFStringCreateMutableCopy(nullptr, 0, oldFormat);
-    CFIndex replaceCount = CFStringFindAndReplace(newFormat,
-                                                  CFSTR("h"), CFSTR("H"),
-                                                  CFRangeMake(0, CFStringGetLength(newFormat)),	
-                                                  0);
-    NS_ASSERTION(replaceCount <= 2, "Unexpected number of \"h\" occurrences");
-    replaceCount = CFStringFindAndReplace(newFormat,
-                                          CFSTR("a"), CFSTR(""),
-                                          CFRangeMake(0, CFStringGetLength(newFormat)),	
-                                          0);
-    NS_ASSERTION(replaceCount <= 1, "Unexpected number of \"a\" occurrences");
-    CFDateFormatterSetFormat(formatter, newFormat);
-    CFRelease(newFormat); // note we don't own oldFormat
-  }
-  
-  // Now get the formatted date:
-  CFGregorianDate date;
-  date.second = tmTime->tm_sec;
-  date.minute = tmTime->tm_min;
-  date.hour = tmTime->tm_hour;
-  date.day = tmTime->tm_mday;      // Mac is 1-based, tm is 1-based
-  date.month = tmTime->tm_mon + 1; // Mac is 1-based, tm is 0-based
-  date.year = tmTime->tm_year + 1900;
-
-  CFTimeZoneRef timeZone = CFTimeZoneCopySystem(); // tmTime is in local time
-  CFAbsoluteTime absTime = CFGregorianDateGetAbsoluteTime(date, timeZone);
-  CFRelease(timeZone);
-
-  CFStringRef formattedDate = CFDateFormatterCreateStringWithAbsoluteTime(nullptr,
-                                                                          formatter,
-                                                                          absTime);
-
-  CFIndex stringLen = CFStringGetLength(formattedDate);
-
-  AutoTArray<UniChar, 256> stringBuffer;
-  stringBuffer.SetLength(stringLen + 1);
-  CFStringGetCharacters(formattedDate, CFRangeMake(0, stringLen), stringBuffer.Elements());
-  stringOut.Assign(reinterpret_cast<char16_t*>(stringBuffer.Elements()), stringLen);
-
-  CFRelease(formattedDate);
-  CFRelease(formatter);
-
-  return res;
-}
-
-// performs a locale sensitive date formatting operation on the PRTime parameter
-nsresult nsDateTimeFormatMac::FormatPRTime(nsILocale* locale, 
-                                           const nsDateFormatSelector  dateFormatSelector, 
-                                           const nsTimeFormatSelector timeFormatSelector, 
-                                           const PRTime  prTime, 
-                                           nsAString& stringOut)
-{
-  PRExplodedTime explodedTime;
-  PR_ExplodeTime(prTime, PR_LocalTimeParameters, &explodedTime);
-
-  return FormatPRExplodedTime(locale, dateFormatSelector, timeFormatSelector, &explodedTime, stringOut);
-}
-
-// performs a locale sensitive date formatting operation on the PRExplodedTime parameter
-nsresult nsDateTimeFormatMac::FormatPRExplodedTime(nsILocale* locale, 
-                                                   const nsDateFormatSelector  dateFormatSelector, 
-                                                   const nsTimeFormatSelector timeFormatSelector, 
-                                                   const PRExplodedTime*  explodedTime, 
-                                                   nsAString& stringOut)
-{
-  struct tm  tmTime;
-  memset( &tmTime, 0, sizeof(tmTime) );
-
-  tmTime.tm_yday = explodedTime->tm_yday;
-  tmTime.tm_wday = explodedTime->tm_wday;
-  tmTime.tm_year = explodedTime->tm_year;
-  tmTime.tm_year -= 1900;
-  tmTime.tm_mon = explodedTime->tm_month;
-  tmTime.tm_mday = explodedTime->tm_mday;
-  tmTime.tm_hour = explodedTime->tm_hour;
-  tmTime.tm_min = explodedTime->tm_min;
-  tmTime.tm_sec = explodedTime->tm_sec;
-
-  return FormatTMTime(locale, dateFormatSelector, timeFormatSelector, &tmTime, stringOut);
-}
-
deleted file mode 100644
--- a/intl/locale/mac/nsDateTimeFormatMac.h
+++ /dev/null
@@ -1,61 +0,0 @@
-
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- *
- * 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/. */
-#ifndef nsDateTimeFormatMac_h__
-#define nsDateTimeFormatMac_h__
-
-
-#include "nsCOMPtr.h"
-#include "nsIDateTimeFormat.h"
-
-
-class nsDateTimeFormatMac : public nsIDateTimeFormat {
-
-public: 
-  NS_DECL_THREADSAFE_ISUPPORTS 
-
-  // performs a locale sensitive date formatting operation on the time_t parameter
-  NS_IMETHOD FormatTime(nsILocale* locale, 
-                        const nsDateFormatSelector  dateFormatSelector, 
-                        const nsTimeFormatSelector timeFormatSelector, 
-                        const time_t  timetTime, 
-                        nsAString& stringOut) override; 
-
-  // performs a locale sensitive date formatting operation on the struct tm parameter
-  NS_IMETHOD FormatTMTime(nsILocale* locale, 
-                          const nsDateFormatSelector  dateFormatSelector, 
-                          const nsTimeFormatSelector timeFormatSelector, 
-                          const struct tm*  tmTime, 
-                          nsAString& stringOut) override; 
-  // performs a locale sensitive date formatting operation on the PRTime parameter
-  NS_IMETHOD FormatPRTime(nsILocale* locale, 
-                          const nsDateFormatSelector  dateFormatSelector, 
-                          const nsTimeFormatSelector timeFormatSelector, 
-                          const PRTime  prTime, 
-                          nsAString& stringOut) override;
-
-  // performs a locale sensitive date formatting operation on the PRExplodedTime parameter
-  NS_IMETHOD FormatPRExplodedTime(nsILocale* locale, 
-                                  const nsDateFormatSelector  dateFormatSelector, 
-                                  const nsTimeFormatSelector timeFormatSelector, 
-                                  const PRExplodedTime*  explodedTime, 
-                                  nsAString& stringOut) override; 
-
-  nsDateTimeFormatMac() {}
-
-protected:
-  virtual ~nsDateTimeFormatMac() {}
-
-private:
-  // init this interface to a specified locale
-  NS_IMETHOD Initialize(nsILocale* locale);
-
-  nsString    mLocale;
-  nsString    mAppLocale;
-  bool        mUseDefaultLocale;
-};
-
-#endif  /* nsDateTimeFormatMac_h__ */
--- a/intl/locale/moz.build
+++ b/intl/locale/moz.build
@@ -20,37 +20,44 @@ XPIDL_SOURCES += [
     'nsILocale.idl',
     'nsILocaleService.idl',
     'nsIScriptableDateFormat.idl',
 ]
 
 XPIDL_MODULE = 'locale'
 
 EXPORTS += [
+    'DateTimeFormat.h',
     'nsCollation.h',
     'nsCollationCID.h',
-    'nsDateTimeFormatCID.h',
-    'nsIDateTimeFormat.h',
     'nsILanguageAtomService.h',
     'nsIPlatformCharset.h',
     'nsPosixLocale.h',
     'nsUConvPropertySearch.h',
     'nsWin32Locale.h',
 ]
 
 UNIFIED_SOURCES += [
     'nsCollation.cpp',
-    'nsIDateTimeFormat.cpp',
     'nsLanguageAtomService.cpp',
     'nsLocale.cpp',
     'nsLocaleService.cpp',
     'nsScriptableDateFormat.cpp',
     'nsUConvPropertySearch.cpp',
 ]
 
+if CONFIG['ENABLE_INTL_API']:
+    UNIFIED_SOURCES += [
+        'DateTimeFormatICU.cpp',
+    ]
+else:
+    UNIFIED_SOURCES += [
+        'DateTimeFormatUnix.cpp',
+    ]
+
 EXTRA_JS_MODULES += [
     'PluralForm.jsm',
 ]
 
 FINAL_LIBRARY = 'xul'
 
 LOCAL_INCLUDES += [
     '/intl/uconv',
deleted file mode 100644
--- a/intl/locale/nsDateTimeFormatCID.h
+++ /dev/null
@@ -1,20 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* 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/. */
-#ifndef nsDateTimeFormatCID_h__
-#define nsDateTimeFormatCID_h__
-
-
-#include "nscore.h"
-#include "nsISupports.h"
-
-#define NS_DATETIMEFORMAT_CONTRACTID "@mozilla.org/intl/datetimeformat;1"
-
-// {0704E7C0-A758-11d2-9119-006008A6EDF6}
-#define NS_DATETIMEFORMAT_CID \
-{ 0x704e7c0, 0xa758, 0x11d2, \
-{ 0x91, 0x19, 0x0, 0x60, 0x8, 0xa6, 0xed, 0xf6 } }
-
-#endif  // nsDateTimeFormatCID_h__
-
deleted file mode 100644
--- a/intl/locale/nsIDateTimeFormat.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* 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 "nsIDateTimeFormat.h"
-#include "mozilla/RefPtr.h"
-
-#if defined(XP_MACOSX)
-#define USE_MAC_LOCALE
-#elif defined(XP_UNIX)
-#define USE_UNIX_LOCALE
-#endif
-
-#ifdef XP_WIN
-#include "windows/nsDateTimeFormatWin.h"
-#endif
-#ifdef USE_UNIX_LOCALE
-#include "unix/nsDateTimeFormatUnix.h"
-#endif
-#ifdef USE_MAC_LOCALE
-#include "mac/nsDateTimeFormatMac.h"
-#endif
-
-using mozilla::MakeAndAddRef;
-
-/*static*/ already_AddRefed<nsIDateTimeFormat>
-nsIDateTimeFormat::Create()
-{
-#ifdef XP_WIN
-  return MakeAndAddRef<nsDateTimeFormatWin>();
-#elif defined(USE_UNIX_LOCALE)
-  return MakeAndAddRef<nsDateTimeFormatUnix>();
-#elif defined(USE_MAC_LOCALE)
-  return MakeAndAddRef<nsDateTimeFormatMac>();
-#else
-  return nullptr;
-#endif
-}
deleted file mode 100644
--- a/intl/locale/nsIDateTimeFormat.h
+++ /dev/null
@@ -1,69 +0,0 @@
-
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- *
- * 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/. */
-#ifndef nsIDateTimeFormat_h__
-#define nsIDateTimeFormat_h__
-
-
-#include "nsISupports.h"
-#include "nscore.h"
-#include "nsStringGlue.h"
-#include "nsILocale.h"
-#include "nsIScriptableDateFormat.h"
-#include "prtime.h"
-#include <time.h>
-
-
-// {2BBAA0B0-A591-11d2-9119-006008A6EDF6}
-#define NS_IDATETIMEFORMAT_IID \
-{ 0x2bbaa0b0, 0xa591, 0x11d2, \
-{ 0x91, 0x19, 0x0, 0x60, 0x8, 0xa6, 0xed, 0xf6 } }
-
-
-// Locale sensitive date and time format interface
-// 
-class nsIDateTimeFormat : public nsISupports {
-protected:
-  nsIDateTimeFormat() {}
-  virtual ~nsIDateTimeFormat() {}
-
-public: 
-  NS_DECLARE_STATIC_IID_ACCESSOR(NS_IDATETIMEFORMAT_IID)
-
-  static already_AddRefed<nsIDateTimeFormat> Create();
-
-  // performs a locale sensitive date formatting operation on the time_t parameter
-  NS_IMETHOD FormatTime(nsILocale* locale, 
-                        const nsDateFormatSelector  dateFormatSelector, 
-                        const nsTimeFormatSelector timeFormatSelector, 
-                        const time_t  timetTime,
-                        nsAString& stringOut) = 0; 
-
-  // performs a locale sensitive date formatting operation on the struct tm parameter
-  NS_IMETHOD FormatTMTime(nsILocale* locale, 
-                          const nsDateFormatSelector  dateFormatSelector, 
-                          const nsTimeFormatSelector timeFormatSelector, 
-                          const struct tm*  tmTime, 
-                          nsAString& stringOut) = 0; 
-
-  // performs a locale sensitive date formatting operation on the PRTime parameter
-  NS_IMETHOD FormatPRTime(nsILocale* locale, 
-                          const nsDateFormatSelector  dateFormatSelector, 
-                          const nsTimeFormatSelector timeFormatSelector, 
-                          const PRTime  prTime, 
-                          nsAString& stringOut) = 0;
-
-  // performs a locale sensitive date formatting operation on the PRExplodedTime parameter
-  NS_IMETHOD FormatPRExplodedTime(nsILocale* locale, 
-                                  const nsDateFormatSelector  dateFormatSelector, 
-                                  const nsTimeFormatSelector timeFormatSelector, 
-                                  const PRExplodedTime*  explodedTime, 
-                                  nsAString& stringOut) = 0; 
-};
-
-NS_DEFINE_STATIC_IID_ACCESSOR(nsIDateTimeFormat, NS_IDATETIMEFORMAT_IID)
-
-#endif  /* nsIDateTimeFormat_h__ */
--- a/intl/locale/nsLocaleConstructors.h
+++ b/intl/locale/nsLocaleConstructors.h
@@ -2,17 +2,16 @@
 /* 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/. */
 
 #ifndef nsLocaleConstructors_h__
 #define nsLocaleConstructors_h__
 
 #include "nsCollationCID.h"
-#include "nsDateTimeFormatCID.h"
 #include "mozilla/ModuleUtils.h"
 #include "nsILocaleService.h"
 #include "nsIScriptableDateFormat.h"
 #include "nsIServiceManager.h"
 #include "nsLanguageAtomService.h"
 #include "nsPlatformCharset.h"
 
 #if defined(XP_MACOSX)
@@ -20,27 +19,24 @@
 #endif
 
 #if defined(XP_UNIX) && !defined(XP_MACOSX)
 #define USE_UNIX_LOCALE
 #endif
 
 #ifdef XP_WIN
 #include "windows/nsCollationWin.h"
-#include "windows/nsDateTimeFormatWin.h"
 #endif
 
 #ifdef USE_MAC_LOCALE
 #include "mac/nsCollationMacUC.h"
-#include "mac/nsDateTimeFormatMac.h"
 #endif
 
 #ifdef USE_UNIX_LOCALE
 #include "unix/nsCollationUnix.h"
-#include "unix/nsDateTimeFormatUnix.h"
 #endif
 
 #define NSLOCALE_MAKE_CTOR(ctor_, iface_, func_)          \
 static nsresult                                           \
 ctor_(nsISupports* aOuter, REFNSIID aIID, void** aResult) \
 {                                                         \
   *aResult = nullptr;                                      \
   if (aOuter)                                             \
@@ -58,22 +54,19 @@ ctor_(nsISupports* aOuter, REFNSIID aIID
 NSLOCALE_MAKE_CTOR(CreateLocaleService, nsILocaleService, NS_NewLocaleService)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsCollationFactory)
 //NS_GENERIC_FACTORY_CONSTRUCTOR(nsScriptableDateTimeFormat)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsLanguageAtomService)
 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPlatformCharset, Init)
 
 #ifdef XP_WIN
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsCollationWin)
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsDateTimeFormatWin)
 #endif
 
 #ifdef USE_UNIX_LOCALE
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsCollationUnix)
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsDateTimeFormatUnix)
 #endif  
 
 #ifdef USE_MAC_LOCALE
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsCollationMacUC)
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsDateTimeFormatMac)
 #endif  
 
 #endif
--- a/intl/locale/nsScriptableDateFormat.cpp
+++ b/intl/locale/nsScriptableDateFormat.cpp
@@ -1,23 +1,21 @@
 /* -*- 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 "nsILocaleService.h"
-#include "nsDateTimeFormatCID.h"
-#include "nsIDateTimeFormat.h"
 #include "nsIScriptableDateFormat.h"
 #include "nsCOMPtr.h"
 #include "nsServiceManagerUtils.h"
 
 static NS_DEFINE_CID(kLocaleServiceCID, NS_LOCALESERVICE_CID);
-static NS_DEFINE_CID(kDateTimeFormatCID, NS_DATETIMEFORMAT_CID);
 
 class nsScriptableDateFormat : public nsIScriptableDateFormat {
  public: 
   NS_DECL_ISUPPORTS 
 
   NS_IMETHOD FormatDateTime(const char16_t *locale, 
                             nsDateFormatSelector dateFormatSelector, 
                             nsTimeFormatSelector timeFormatSelector, 
@@ -84,47 +82,44 @@ NS_IMETHODIMP nsScriptableDateFormat::Fo
     // get locale service
     nsCOMPtr<nsILocaleService> localeService(do_GetService(kLocaleServiceCID, &rv));
     NS_ENSURE_SUCCESS(rv, rv);
     // get locale
     rv = localeService->NewLocale(localeName, getter_AddRefs(locale));
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
-  nsCOMPtr<nsIDateTimeFormat> dateTimeFormat(do_CreateInstance(kDateTimeFormatCID, &rv));
-  NS_ENSURE_SUCCESS(rv, rv);
-
   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 = dateTimeFormat->FormatTime(locale, dateFormatSelector, timeFormatSelector, 
-                                     timetTime, mStringOut);
+    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 = dateTimeFormat->FormatPRTime(locale, dateFormatSelector, timeFormatSelector, 
-                                      prtime, mStringOut);
+    rv = mozilla::DateTimeFormat::FormatPRTime(dateFormatSelector, timeFormatSelector,
+                                               prtime, mStringOut);
   }
   if (NS_SUCCEEDED(rv))
     *dateTimeString = ToNewUnicode(mStringOut);
 
   return rv;
 }
 
 nsresult
--- a/intl/locale/unix/moz.build
+++ b/intl/locale/unix/moz.build
@@ -1,17 +1,16 @@
 # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # 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/.
 
 SOURCES += [
     'nsCollationUnix.cpp',
-    'nsDateTimeFormatUnix.cpp',
     'nsPosixLocale.cpp',
 ]
 
 if CONFIG['OS_TARGET'] == 'Android':
     SOURCES += [
         'nsAndroidCharset.cpp',
     ]
 else:
deleted file mode 100644
--- a/intl/locale/unix/nsDateTimeFormatUnix.h
+++ /dev/null
@@ -1,70 +0,0 @@
-
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- *
- * 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/. */
-#ifndef nsDateTimeFormatUnix_h__
-#define nsDateTimeFormatUnix_h__
-
-
-#include "nsCOMPtr.h"
-#include "nsIDateTimeFormat.h"
-#include "nsIUnicodeDecoder.h"
-
-#define kPlatformLocaleLength 64
-
-class nsDateTimeFormatUnix : public nsIDateTimeFormat {
-
-public: 
-  NS_DECL_THREADSAFE_ISUPPORTS 
-
-  // performs a locale sensitive date formatting operation on the time_t parameter
-  NS_IMETHOD FormatTime(nsILocale* locale, 
-                        const nsDateFormatSelector  dateFormatSelector, 
-                        const nsTimeFormatSelector timeFormatSelector, 
-                        const time_t  timetTime, 
-                        nsAString& stringOut) override;
-
-  // performs a locale sensitive date formatting operation on the struct tm parameter
-  NS_IMETHOD FormatTMTime(nsILocale* locale, 
-                        const nsDateFormatSelector  dateFormatSelector, 
-                        const nsTimeFormatSelector timeFormatSelector, 
-                        const struct tm*  tmTime, 
-                        nsAString& stringOut) override;
-
-  // performs a locale sensitive date formatting operation on the PRTime parameter
-  NS_IMETHOD FormatPRTime(nsILocale* locale, 
-                          const nsDateFormatSelector  dateFormatSelector, 
-                          const nsTimeFormatSelector timeFormatSelector, 
-                          const PRTime  prTime, 
-                          nsAString& stringOut) override;
-
-  // performs a locale sensitive date formatting operation on the PRExplodedTime parameter
-  NS_IMETHOD FormatPRExplodedTime(nsILocale* locale, 
-                                  const nsDateFormatSelector  dateFormatSelector, 
-                                  const nsTimeFormatSelector timeFormatSelector, 
-                                  const PRExplodedTime*  explodedTime, 
-                                  nsAString& stringOut) override;
-
-
-  nsDateTimeFormatUnix() {mLocale.Truncate();mAppLocale.Truncate();}
-
-private:
-  virtual ~nsDateTimeFormatUnix() {}
-
-  // init this interface to a specified locale
-  NS_IMETHOD Initialize(nsILocale* locale);
-
-  void LocalePreferred24hour();
-
-  nsString    mLocale;
-  nsString    mAppLocale;
-  nsCString   mCharset;        // in order to convert API result to unicode
-  nsCString   mPlatformLocale; // for setlocale
-  bool        mLocalePreferred24hour;                       // true if 24 hour format is preferred by current locale
-  bool        mLocaleAMPMfirst;                             // true if AM/PM string is preferred before the time
-  nsCOMPtr <nsIUnicodeDecoder>   mDecoder;
-};
-
-#endif  /* nsDateTimeFormatUnix_h__ */
--- a/intl/locale/windows/moz.build
+++ b/intl/locale/windows/moz.build
@@ -1,17 +1,16 @@
 # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # 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/.
 
 SOURCES += [
     'nsCollationWin.cpp',
-    'nsDateTimeFormatWin.cpp',
     'nsWin32Locale.cpp',
     'nsWinCharset.cpp',
 ]
 
 FINAL_LIBRARY = 'xul'
 
 GENERATED_FILES = [
     'wincharset.properties.h',
deleted file mode 100644
--- a/intl/locale/windows/nsDateTimeFormatWin.cpp
+++ /dev/null
@@ -1,253 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* 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 "nsDateTimeFormatWin.h"
-#include "nsIServiceManager.h"
-#include "nsIComponentManager.h"
-#include "nsILocaleService.h"
-#include "nsWin32Locale.h"
-#include "nsUnicharUtils.h"
-#include "nsCRT.h"
-#include "nsCOMPtr.h"
-
-
-#define NSDATETIMEFORMAT_BUFFER_LEN  80
-
-NS_IMPL_ISUPPORTS(nsDateTimeFormatWin, nsIDateTimeFormat)
-
-
-// init this interface to a specified locale
-nsresult nsDateTimeFormatWin::Initialize(nsILocale* locale)
-{
-  nsAutoString localeStr;
-  nsresult res = NS_OK;
-
-  // use cached info if match with stored locale
-  if (!locale) {
-    if (!mLocale.IsEmpty() && 
-        mLocale.Equals(mAppLocale, nsCaseInsensitiveStringComparator())) {
-      return NS_OK;
-    }
-  }
-  else {
-    res = locale->GetCategory(NS_LITERAL_STRING("NSILOCALE_TIME"), localeStr);
-    if (NS_SUCCEEDED(res) && !localeStr.IsEmpty()) {
-      if (!mLocale.IsEmpty() && 
-          mLocale.Equals(localeStr, nsCaseInsensitiveStringComparator())) {
-        return NS_OK;
-      }
-    }
-  }
-
-  // default LCID (en-US)
-  mLCID = 1033;
-
-  // get locale string, use app default if no locale specified
-  if (!locale) {
-    nsCOMPtr<nsILocaleService> localeService = 
-             do_GetService(NS_LOCALESERVICE_CONTRACTID);
-    if (localeService) {
-      nsCOMPtr<nsILocale> appLocale;
-      res = localeService->GetApplicationLocale(getter_AddRefs(appLocale));
-      if (NS_SUCCEEDED(res)) {
-        res = appLocale->GetCategory(NS_LITERAL_STRING("NSILOCALE_TIME"), 
-			             localeStr);
-        if (NS_SUCCEEDED(res) && !localeStr.IsEmpty()) {
-          mAppLocale.Assign(localeStr); // cache app locale name
-        }
-      }
-    }
-  }
-  else {
-    res = locale->GetCategory(NS_LITERAL_STRING("NSILOCALE_TIME"), localeStr);
-  }
-
-  // Get LCID and charset name from locale, if available
-  if (NS_SUCCEEDED(res) && !localeStr.IsEmpty()) {
-    mLocale.Assign(localeStr); // cache locale name
-    res = nsWin32Locale::GetPlatformLocale(mLocale, (LCID *) &mLCID);
-  }
-
-  return res;
-}
-
-// performs a locale sensitive date formatting operation on the time_t parameter
-nsresult nsDateTimeFormatWin::FormatTime(nsILocale* locale, 
-                                         const nsDateFormatSelector  dateFormatSelector, 
-                                         const nsTimeFormatSelector timeFormatSelector, 
-                                         const time_t  timetTime, 
-                                         nsAString& stringOut)
-{
-  return FormatTMTime(locale, dateFormatSelector, timeFormatSelector, localtime( &timetTime ), stringOut);
-}
-
-// performs a locale sensitive date formatting operation on the struct tm parameter
-nsresult nsDateTimeFormatWin::FormatTMTime(nsILocale* locale, 
-                                           const nsDateFormatSelector  dateFormatSelector, 
-                                           const nsTimeFormatSelector timeFormatSelector, 
-                                           const struct tm*  tmTime, 
-                                           nsAString& stringOut)
-{
-  SYSTEMTIME system_time;
-  DWORD dwFlags_Date = 0, dwFlags_Time = 0;
-  int dateLen, timeLen;
-  char16_t dateBuffer[NSDATETIMEFORMAT_BUFFER_LEN], timeBuffer[NSDATETIMEFORMAT_BUFFER_LEN];
-
-  // set up locale data
-  (void) Initialize(locale);
-
-  // Map tm to SYSTEMTIME
-  system_time.wYear = 1900 + tmTime->tm_year;
-  system_time.wMonth = tmTime->tm_mon + 1;
-  system_time.wDayOfWeek = tmTime->tm_wday;
-  system_time.wDay = tmTime->tm_mday;
-  system_time.wHour = tmTime->tm_hour;
-  system_time.wMinute = tmTime->tm_min;
-  system_time.wSecond = tmTime->tm_sec;
-  system_time.wMilliseconds = 0;
-
-  // Map to WinAPI date format
-  switch (dateFormatSelector) {
-  case kDateFormatLong:
-    dwFlags_Date = DATE_LONGDATE;
-    break;
-  case kDateFormatShort:
-    dwFlags_Date = DATE_SHORTDATE;
-    break;
-  case kDateFormatWeekday:
-    dwFlags_Date = 0;
-    break;
-  case kDateFormatYearMonth:
-    dwFlags_Date = 0;     // TODO:only availabe NT5
-    break;
-  }
-
-  // Map to WinAPI time format
-  switch (timeFormatSelector) {
-  case kTimeFormatSeconds:
-    dwFlags_Time = 0;
-    break;
-  case kTimeFormatNoSeconds:
-    dwFlags_Time = TIME_NOSECONDS;
-    break;
-  case kTimeFormatSecondsForce24Hour:
-    dwFlags_Time = TIME_FORCE24HOURFORMAT;
-    break;
-  case kTimeFormatNoSecondsForce24Hour:
-    dwFlags_Time = TIME_NOSECONDS + TIME_FORCE24HOURFORMAT;
-    break;
-  }
-
-  // Call GetDateFormatW
-  if (dateFormatSelector == kDateFormatNone) {
-    dateLen = 0;
-  }
-  else {
-    if (dateFormatSelector == kDateFormatYearMonth) {
-      dateLen = nsGetDateFormatW(0, &system_time, "yyyy/MM", 
-                                 dateBuffer, NSDATETIMEFORMAT_BUFFER_LEN);
-    }
-    else if (dateFormatSelector == kDateFormatWeekday) {
-      dateLen = nsGetDateFormatW(0, &system_time, "ddd", 
-                                 dateBuffer, NSDATETIMEFORMAT_BUFFER_LEN);
-    }
-    else {
-      dateLen = nsGetDateFormatW(dwFlags_Date, &system_time, nullptr,
-                                 dateBuffer, NSDATETIMEFORMAT_BUFFER_LEN);
-    }
-    if (dateLen != 0) {
-      dateLen--;  // Since the count includes the terminating null.
-    }
-  }
-
-  // Call GetTimeFormatW
-  if (timeFormatSelector == kTimeFormatNone) {
-    timeLen = 0;
-  }
-  else {
-    timeLen = nsGetTimeFormatW(dwFlags_Time, &system_time, nullptr, 
-                               timeBuffer, NSDATETIMEFORMAT_BUFFER_LEN);
-    if (timeLen != 0) {
-      timeLen--;  // Since the count includes the terminating null.
-    }
-  }
-
-  NS_ASSERTION(NSDATETIMEFORMAT_BUFFER_LEN >= (uint32_t) (dateLen + 1), "internal date buffer is not large enough");
-  NS_ASSERTION(NSDATETIMEFORMAT_BUFFER_LEN >= (uint32_t) (timeLen + 1), "internal time buffer is not large enough");
-
-  // Copy the result
-  stringOut.Truncate();
-  if (dateLen != 0 && timeLen != 0) {
-    stringOut.Assign(dateBuffer, dateLen);
-    stringOut.Append((char16_t *)(L" "), 1);
-    stringOut.Append(timeBuffer, timeLen);
-  }
-  else if (dateLen != 0 && timeLen == 0) {
-    stringOut.Assign(dateBuffer, dateLen);
-  }
-  else if (dateLen == 0 && timeLen != 0) {
-    stringOut.Assign(timeBuffer, timeLen);
-  }
-
-  return NS_OK;
-}
-
-// performs a locale sensitive date formatting operation on the PRTime parameter
-nsresult nsDateTimeFormatWin::FormatPRTime(nsILocale* locale, 
-                                           const nsDateFormatSelector  dateFormatSelector, 
-                                           const nsTimeFormatSelector timeFormatSelector, 
-                                           const PRTime  prTime, 
-                                           nsAString& stringOut)
-{
-  PRExplodedTime explodedTime;
-  PR_ExplodeTime(prTime, PR_LocalTimeParameters, &explodedTime);
-
-  return FormatPRExplodedTime(locale, dateFormatSelector, timeFormatSelector, &explodedTime, stringOut);
-}
-
-// performs a locale sensitive date formatting operation on the PRExplodedTime parameter
-nsresult nsDateTimeFormatWin::FormatPRExplodedTime(nsILocale* locale, 
-                                                   const nsDateFormatSelector  dateFormatSelector, 
-                                                   const nsTimeFormatSelector timeFormatSelector, 
-                                                   const PRExplodedTime*  explodedTime, 
-                                                   nsAString& stringOut)
-{
-  struct tm  tmTime;
-  memset( &tmTime, 0, sizeof(tmTime) );
-
-  tmTime.tm_yday = explodedTime->tm_yday;
-  tmTime.tm_wday = explodedTime->tm_wday;
-  tmTime.tm_year = explodedTime->tm_year;
-  tmTime.tm_year -= 1900;
-  tmTime.tm_mon = explodedTime->tm_month;
-  tmTime.tm_mday = explodedTime->tm_mday;
-  tmTime.tm_hour = explodedTime->tm_hour;
-  tmTime.tm_min = explodedTime->tm_min;
-  tmTime.tm_sec = explodedTime->tm_sec;
-
-  return FormatTMTime(locale, dateFormatSelector, timeFormatSelector, &tmTime, stringOut);
-}
-
-int nsDateTimeFormatWin::nsGetTimeFormatW(DWORD dwFlags, const SYSTEMTIME *lpTime,
-                                          const char* format, char16_t *timeStr, int cchTime)
-{
-  int len = 0;
-  len = GetTimeFormatW(mLCID, dwFlags, lpTime, 
-                       format ?
-                       NS_ConvertASCIItoUTF16(format).get() :
-                       nullptr,
-                       (LPWSTR) timeStr, cchTime);
-  return len;
-}
-
-int nsDateTimeFormatWin::nsGetDateFormatW(DWORD dwFlags, const SYSTEMTIME *lpDate,
-                                          const char* format, char16_t *dateStr, int cchDate)
-{
-  int len = 0;
-  len = GetDateFormatW(mLCID, dwFlags, lpDate, 
-                       format ? NS_ConvertASCIItoUTF16(format).get() : nullptr,
-                       (LPWSTR) dateStr, cchDate);
-  return len;
-}
deleted file mode 100644
--- a/intl/locale/windows/nsDateTimeFormatWin.h
+++ /dev/null
@@ -1,71 +0,0 @@
-
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- *
- * 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/. */
-#ifndef nsDateTimeFormatWin_h__
-#define nsDateTimeFormatWin_h__
-
-
-#include "nsIDateTimeFormat.h"
-#include <windows.h>
-
-
-// Locale sensitive date and time format interface
-// 
-class nsDateTimeFormatWin : public nsIDateTimeFormat {
-  virtual ~nsDateTimeFormatWin() {}
-
-public: 
-  NS_DECL_THREADSAFE_ISUPPORTS 
-
-  // performs a locale sensitive date formatting operation on the time_t parameter
-  NS_IMETHOD FormatTime(nsILocale* locale, 
-                        const nsDateFormatSelector  dateFormatSelector, 
-                        const nsTimeFormatSelector timeFormatSelector, 
-                        const time_t  timetTime, 
-                        nsAString& stringOut); 
-
-  // performs a locale sensitive date formatting operation on the struct tm parameter
-  NS_IMETHOD FormatTMTime(nsILocale* locale, 
-                          const nsDateFormatSelector  dateFormatSelector, 
-                          const nsTimeFormatSelector timeFormatSelector, 
-                          const struct tm*  tmTime, 
-                          nsAString& stringOut); 
-
-  // performs a locale sensitive date formatting operation on the PRTime parameter
-  NS_IMETHOD FormatPRTime(nsILocale* locale, 
-                          const nsDateFormatSelector  dateFormatSelector, 
-                          const nsTimeFormatSelector timeFormatSelector, 
-                          const PRTime  prTime, 
-                          nsAString& stringOut);
-
-  // performs a locale sensitive date formatting operation on the PRExplodedTime parameter
-  NS_IMETHOD FormatPRExplodedTime(nsILocale* locale, 
-                                  const nsDateFormatSelector  dateFormatSelector, 
-                                  const nsTimeFormatSelector timeFormatSelector, 
-                                  const PRExplodedTime*  explodedTime, 
-                                  nsAString& stringOut); 
-
-  nsDateTimeFormatWin() {mLocale.SetLength(0);mAppLocale.SetLength(0);}
-
-
-private:
-  // init this interface to a specified locale
-  NS_IMETHOD Initialize(nsILocale* locale);
-
-  // call GetTimeFormatW or TimeFormatA
-  int nsGetTimeFormatW(DWORD dwFlags, const SYSTEMTIME *lpTime,
-                    const char* format, char16_t *timeStr, int cchTime);
-
-  // call GetDateFormatW or GetDateFormatA
-  int nsGetDateFormatW(DWORD dwFlags, const SYSTEMTIME *lpDate,
-                       const char* format, char16_t *dateStr, int cchDate);
-
-  nsString    mLocale;
-  nsString    mAppLocale;
-  uint32_t    mLCID;             // Windows platform locale ID
-};
-
-#endif  /* nsDateTimeFormatWin_h__ */
--- a/layout/build/nsLayoutStatics.cpp
+++ b/layout/build/nsLayoutStatics.cpp
@@ -2,16 +2,17 @@
  * 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 "base/basictypes.h"
 
 #include "nsLayoutStatics.h"
 #include "nscore.h"
 
+#include "DateTimeFormat.h"
 #include "nsAttrValue.h"
 #include "nsAutoCopyListener.h"
 #include "nsColorNames.h"
 #include "nsComputedDOMStyle.h"
 #include "nsContentDLF.h"
 #include "nsContentUtils.h"
 #include "nsCSSAnonBoxes.h"
 #include "mozilla/css/ErrorReporter.h"
@@ -418,16 +419,18 @@ nsLayoutStatics::Shutdown()
 
   HTMLInputElement::DestroyUploadLastDir();
 
   nsLayoutUtils::Shutdown();
 
   nsHyphenationManager::Shutdown();
   nsDOMMutationObserver::Shutdown();
 
+  DateTimeFormat::Shutdown();
+
   ContentParent::ShutDown();
 
   DisplayItemClip::Shutdown();
 
   CustomElementRegistry::XPCOMShutdown();
 
   CacheObserver::Shutdown();
 
--- a/layout/generic/nsSimplePageSequenceFrame.cpp
+++ b/layout/generic/nsSimplePageSequenceFrame.cpp
@@ -1,15 +1,16 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* 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 "nsSimplePageSequenceFrame.h"
 
+#include "DateTimeFormat.h"
 #include "nsCOMPtr.h"
 #include "nsDeviceContext.h"
 #include "nsPresContext.h"
 #include "gfxContext.h"
 #include "nsRenderingContext.h"
 #include "nsGkAtoms.h"
 #include "nsIPresShell.h"
 #include "nsIPrintSettings.h"
@@ -17,17 +18,16 @@
 #include "nsSubDocumentFrame.h"
 #include "nsRegion.h"
 #include "nsCSSFrameConstructor.h"
 #include "nsContentUtils.h"
 #include "nsDisplayList.h"
 #include "nsHTMLCanvasFrame.h"
 #include "mozilla/dom/HTMLCanvasElement.h"
 #include "nsICanvasRenderingContextInternal.h"
-#include "nsIDateTimeFormat.h"
 #include "nsServiceManagerUtils.h"
 #include <algorithm>
 
 #define OFFSET_NOT_SET -1
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
@@ -294,28 +294,20 @@ nsSimplePageSequenceFrame::Reflow(nsPres
     MOZ_ASSERT(e.get()->GetType() == nsGkAtoms::pageFrame,
                "only expecting nsPageFrame children. Other children will make "
                "this static_cast bogus & probably violate other assumptions");
     nsPageFrame* pf = static_cast<nsPageFrame*>(e.get());
     pf->SetPageNumInfo(pageNum, pageTot);
     pageNum++;
   }
 
-  // Create current Date/Time String
-  if (!mDateFormatter) {
-    mDateFormatter = nsIDateTimeFormat::Create();
-  }
-  if (!mDateFormatter) {
-    return;
-  }
   nsAutoString formattedDateString;
   time_t ltime;
   time( &ltime );
-  if (NS_SUCCEEDED(mDateFormatter->FormatTime(nullptr /* nsILocale* locale */,
-                                              kDateFormatShort,
+  if (NS_SUCCEEDED(DateTimeFormat::FormatTime(kDateFormatShort,
                                               kTimeFormatNoSeconds,
                                               ltime,
                                               formattedDateString))) {
     SetDateTimeStr(formattedDateString);
   }
 
   // Return our desired size
   // Adjust the reflow size by PrintPreviewScale so the scrollbars end up the
--- a/layout/generic/nsSimplePageSequenceFrame.h
+++ b/layout/generic/nsSimplePageSequenceFrame.h
@@ -5,18 +5,16 @@
 #ifndef nsSimplePageSequenceFrame_h___
 #define nsSimplePageSequenceFrame_h___
 
 #include "mozilla/Attributes.h"
 #include "nsIPageSequenceFrame.h"
 #include "nsContainerFrame.h"
 #include "nsIPrintSettings.h"
 
-class nsIDateTimeFormat;
-
 namespace mozilla {
 namespace dom {
 
 class HTMLCanvasElement;
 
 } // namespace dom
 } // namespace mozilla
 
@@ -134,19 +132,16 @@ protected:
                                  const nsMargin& aChildPhysicalMargin);
 
 
   void DetermineWhetherToPrintPage();
   nsIFrame* GetCurrentPageFrame();
 
   nsMargin mMargin;
 
-  // I18N date formatter service which we'll want to cache locally.
-  nsCOMPtr<nsIDateTimeFormat> mDateFormatter;
-
   nsSize       mSize;
   nsSharedPageData* mPageData; // data shared by all the nsPageFrames
 
   // Asynch Printing
   int32_t      mPageNum;
   int32_t      mTotalPages;
   int32_t      mPrintRangeType;
   int32_t      mFromPageNum;
--- a/netwerk/streamconv/converters/nsIndexedToHTML.cpp
+++ b/netwerk/streamconv/converters/nsIndexedToHTML.cpp
@@ -1,29 +1,29 @@
 /* -*- 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 "nsIndexedToHTML.h"
 #include "mozilla/dom/EncodingUtils.h"
 #include "nsNetUtil.h"
 #include "netCore.h"
 #include "nsStringStream.h"
 #include "nsIFile.h"
 #include "nsIFileURL.h"
 #include "nsEscape.h"
 #include "nsIDirIndex.h"
 #include "nsURLHelper.h"
 #include "nsIPlatformCharset.h"
 #include "nsIPrefService.h"
 #include "nsIPrefBranch.h"
 #include "nsIPrefLocalizedString.h"
 #include "nsIChromeRegistry.h"
-#include "nsIDateTimeFormat.h"
 #include "nsIStringBundle.h"
 #include "nsITextToSubURI.h"
 #include "nsXPIDLString.h"
 #include <algorithm>
 #include "nsIChannel.h"
 
 NS_IMPL_ISUPPORTS(nsIndexedToHTML,
                   nsIDirIndexListener,
@@ -64,20 +64,16 @@ nsIndexedToHTML::Create(nsISupports *aOu
 }
 
 nsresult
 nsIndexedToHTML::Init(nsIStreamListener* aListener) {
     nsresult rv = NS_OK;
 
     mListener = aListener;
 
-    mDateTime = nsIDateTimeFormat::Create();
-    if (!mDateTime)
-      return NS_ERROR_FAILURE;
-
     nsCOMPtr<nsIStringBundleService> sbs =
         do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
     if (NS_FAILED(rv)) return rv;
     rv = sbs->CreateBundle(NECKO_MSGS_URL, getter_AddRefs(mBundle));
 
     mExpectAbsLoc = false;
 
     return rv;
@@ -830,28 +826,26 @@ nsIndexedToHTML::OnIndexAvailable(nsIReq
 
     if (t == -1LL) {
         pushBuffer.AppendLiteral("></td>\n <td>");
     } else {
         pushBuffer.AppendLiteral(" sortable-data=\"");
         pushBuffer.AppendInt(static_cast<int64_t>(t));
         pushBuffer.AppendLiteral("\">");
         nsAutoString formatted;
-        mDateTime->FormatPRTime(nullptr,
-                                kDateFormatShort,
-                                kTimeFormatNone,
-                                t,
-                                formatted);
+        mozilla::DateTimeFormat::FormatPRTime(kDateFormatShort,
+                                              kTimeFormatNone,
+                                              t,
+                                              formatted);
         AppendNonAsciiToNCR(formatted, pushBuffer);
         pushBuffer.AppendLiteral("</td>\n <td>");
-        mDateTime->FormatPRTime(nullptr,
-                                kDateFormatNone,
-                                kTimeFormatSeconds,
-                                t,
-                                formatted);
+        mozilla::DateTimeFormat::FormatPRTime(kDateFormatNone,
+                                              kTimeFormatSeconds,
+                                              t,
+                                              formatted);
         // use NCR to show date in any doc charset
         AppendNonAsciiToNCR(formatted, pushBuffer);
     }
 
     pushBuffer.AppendLiteral("</td>\n</tr>");
 
     return SendToListener(aRequest, aCtxt, pushBuffer);
 }
--- a/netwerk/streamconv/converters/nsIndexedToHTML.h
+++ b/netwerk/streamconv/converters/nsIndexedToHTML.h
@@ -9,17 +9,16 @@
 #include "nsCOMPtr.h"
 #include "nsString.h"
 #include "nsIStreamConverter.h"
 #include "nsIDirIndexListener.h"
 
 #define NS_NSINDEXEDTOHTMLCONVERTER_CID \
 { 0xcf0f71fd, 0xfafd, 0x4e2b, {0x9f, 0xdc, 0x13, 0x4d, 0x97, 0x2e, 0x16, 0xe2} }
 
-class nsIDateTimeFormat;
 class nsIStringBundle;
 class nsITextToSubURI;
 
 class nsIndexedToHTML : public nsIStreamConverter,
                         public nsIDirIndexListener
 {
 public:
     NS_DECL_ISUPPORTS
@@ -42,17 +41,16 @@ protected:
     // Helper to properly implement OnStartRequest
     nsresult DoOnStartRequest(nsIRequest* request, nsISupports *aContext,
                               nsCString& aBuffer);
 
 protected:
     nsCOMPtr<nsIDirIndexParser>     mParser;
     nsCOMPtr<nsIStreamListener>     mListener; // final listener (consumer)
 
-    nsCOMPtr<nsIDateTimeFormat> mDateTime;
     nsCOMPtr<nsIStringBundle> mBundle;
 
     nsCOMPtr<nsITextToSubURI> mTextToSubURI;
 
 private:
     // Expecting absolute locations, given by 201 lines.
     bool mExpectAbsLoc;
 
--- a/security/manager/ssl/TransportSecurityInfo.cpp
+++ b/security/manager/ssl/TransportSecurityInfo.cpp
@@ -1,22 +1,22 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  *
  * 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 "TransportSecurityInfo.h"
 
+#include "DateTimeFormat.h"
 #include "PSMRunnable.h"
 #include "mozilla/Casting.h"
 #include "nsComponentManagerUtils.h"
 #include "nsIArray.h"
 #include "nsICertOverrideService.h"
-#include "nsIDateTimeFormat.h"
 #include "nsIObjectInputStream.h"
 #include "nsIObjectOutputStream.h"
 #include "nsIWebProgressListener.h"
 #include "nsIX509CertValidity.h"
 #include "nsNSSCertHelper.h"
 #include "nsNSSCertificate.h"
 #include "nsNSSComponent.h"
 #include "nsReadableUtils.h"
@@ -793,24 +793,19 @@ GetDateBoundary(nsIX509Cert* ix509,
   PRTime now = PR_Now();
   if (now > notAfter) {
     timeToUse = notAfter;
   } else {
     timeToUse = notBefore;
     trueExpired_falseNotYetValid = false;
   }
 
-  nsCOMPtr<nsIDateTimeFormat> dateTimeFormat = nsIDateTimeFormat::Create();
-  if (!dateTimeFormat) {
-    return;
-  }
-
-  dateTimeFormat->FormatPRTime(nullptr, kDateFormatLong, kTimeFormatNoSeconds,
+  DateTimeFormat::FormatPRTime(kDateFormatLong, kTimeFormatNoSeconds,
                                timeToUse, formattedDate);
-  dateTimeFormat->FormatPRTime(nullptr, kDateFormatLong, kTimeFormatNoSeconds,
+  DateTimeFormat::FormatPRTime(kDateFormatLong, kTimeFormatNoSeconds,
                                now, nowDate);
 }
 
 static void
 AppendErrorTextTime(nsIX509Cert* ix509,
                     nsINSSComponent *component,
                     nsString &returnedMessage)
 {
--- a/security/manager/ssl/nsNSSCertHelper.cpp
+++ b/security/manager/ssl/nsNSSCertHelper.cpp
@@ -1,25 +1,24 @@
 /* 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 "nsNSSCertHelper.h"
 
 #include <algorithm>
 
+#include "DateTimeFormat.h"
 #include "ScopedNSSTypes.h"
 #include "mozilla/Casting.h"
 #include "mozilla/NotNull.h"
 #include "mozilla/Sprintf.h"
 #include "mozilla/UniquePtr.h"
 #include "nsCOMPtr.h"
 #include "nsComponentManagerUtils.h"
-#include "nsDateTimeFormatCID.h"
-#include "nsIDateTimeFormat.h"
 #include "nsNSSASN1Object.h"
 #include "nsNSSCertTrust.h"
 #include "nsNSSCertValidity.h"
 #include "nsNSSCertificate.h"
 #include "nsNSSComponent.h"
 #include "nsServiceManagerUtils.h"
 #include "prerror.h"
 #include "secder.h"
@@ -1609,40 +1608,35 @@ ProcessSECAlgorithmID(SECAlgorithmID *al
   sequence.forget(retSequence);
   return NS_OK;
 }
 
 static nsresult
 ProcessTime(PRTime dispTime, const char16_t* displayName,
             nsIASN1Sequence* parentSequence)
 {
-  nsCOMPtr<nsIDateTimeFormat> dateFormatter = nsIDateTimeFormat::Create();
-  if (!dateFormatter) {
-    return NS_ERROR_FAILURE;
-  }
-
   nsString text;
   nsString tempString;
 
   PRExplodedTime explodedTime;
   PR_ExplodeTime(dispTime, PR_LocalTimeParameters, &explodedTime);
 
-  dateFormatter->FormatPRExplodedTime(nullptr, kDateFormatLong,
-                                      kTimeFormatSeconds, &explodedTime,
-                                      tempString);
+  DateTimeFormat::FormatPRExplodedTime(kDateFormatLong,
+                                       kTimeFormatSeconds, &explodedTime,
+                                       tempString);
 
   text.Append(tempString);
   text.AppendLiteral("\n(");
 
   PRExplodedTime explodedTimeGMT;
   PR_ExplodeTime(dispTime, PR_GMTParameters, &explodedTimeGMT);
 
-  dateFormatter->FormatPRExplodedTime(nullptr, kDateFormatLong,
-                                      kTimeFormatSeconds, &explodedTimeGMT,
-                                      tempString);
+  DateTimeFormat::FormatPRExplodedTime(kDateFormatLong,
+                                       kTimeFormatSeconds, &explodedTimeGMT,
+                                       tempString);
 
   text.Append(tempString);
   text.AppendLiteral(" GMT)");
 
   nsCOMPtr<nsIASN1PrintableItem> printableItem = new nsNSSASN1PrintableItem();
 
   printableItem->SetDisplayValue(text);
   printableItem->SetDisplayName(nsDependentString(displayName));
--- a/security/manager/ssl/nsNSSCertValidity.cpp
+++ b/security/manager/ssl/nsNSSCertValidity.cpp
@@ -57,26 +57,21 @@ nsresult
 nsX509CertValidity::FormatTime(const PRTime& aTimeDate,
                                PRTimeParamFn aParamFn,
                                const nsTimeFormatSelector aTimeFormatSelector,
                                nsAString& aFormattedTimeDate)
 {
   if (!mTimesInitialized)
     return NS_ERROR_FAILURE;
 
-  nsCOMPtr<nsIDateTimeFormat> dateFormatter = nsIDateTimeFormat::Create();
-  if (!dateFormatter) {
-    return NS_ERROR_FAILURE;
-  }
-
   PRExplodedTime explodedTime;
   PR_ExplodeTime(const_cast<PRTime&>(aTimeDate), aParamFn, &explodedTime);
-  return dateFormatter->FormatPRExplodedTime(nullptr, kDateFormatLong,
-					     aTimeFormatSelector,
-					     &explodedTime, aFormattedTimeDate);
+  return mozilla::DateTimeFormat::FormatPRExplodedTime(kDateFormatLong,
+					                                             aTimeFormatSelector,
+					                                             &explodedTime, aFormattedTimeDate);
 }
 
 NS_IMETHODIMP
 nsX509CertValidity::GetNotBeforeLocalTime(nsAString& aNotBeforeLocalTime)
 {
   return FormatTime(mNotBefore, PR_LocalTimeParameters,
                     kTimeFormatSeconds, aNotBeforeLocalTime);
 }
--- a/security/manager/ssl/nsNSSCertValidity.h
+++ b/security/manager/ssl/nsNSSCertValidity.h
@@ -1,17 +1,17 @@
 /* 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/. */
 
 #ifndef nsNSSCertValidity_h
 #define nsNSSCertValidity_h
 
+#include "DateTimeFormat.h"
 #include "ScopedNSSTypes.h"
-#include "nsIDateTimeFormat.h"
 #include "nsIX509CertValidity.h"
 #include "nsNSSShutDown.h"
 
 class nsX509CertValidity : public nsIX509CertValidity
                          , public nsNSSShutDownObject
 {
 public:
   NS_DECL_THREADSAFE_ISUPPORTS
--- a/toolkit/components/filepicker/nsFileView.cpp
+++ b/toolkit/components/filepicker/nsFileView.cpp
@@ -1,25 +1,25 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* 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 "nsIFileView.h"
 #include "nsITreeView.h"
 #include "mozilla/ModuleUtils.h"
 #include "nsITreeSelection.h"
 #include "nsITreeColumns.h"
 #include "nsITreeBoxObject.h"
 #include "nsIFile.h"
 #include "nsString.h"
 #include "nsReadableUtils.h"
 #include "nsCRT.h"
 #include "nsPrintfCString.h"
-#include "nsIDateTimeFormat.h"
 #include "nsQuickSort.h"
 #include "nsIAtom.h"
 #include "nsIAutoCompleteResult.h"
 #include "nsIAutoCompleteSearch.h"
 #include "nsISimpleEnumerator.h"
 #include "nsAutoPtr.h"
 #include "nsIMutableArray.h"
 #include "nsTArray.h"
@@ -229,17 +229,16 @@ protected:
 
   nsTArray<nsCOMPtr<nsIFile> > mFileList;
   nsTArray<nsCOMPtr<nsIFile> > mDirList;
   nsTArray<nsCOMPtr<nsIFile> > mFilteredFiles;
 
   nsCOMPtr<nsIFile> mDirectoryPath;
   nsCOMPtr<nsITreeBoxObject> mTree;
   nsCOMPtr<nsITreeSelection> mSelection;
-  nsCOMPtr<nsIDateTimeFormat> mDateFormatter;
 
   int16_t mSortType;
   int32_t mTotalRows;
 
   nsTArray<char16_t*> mCurrentFilters;
 
   bool mShowHiddenFiles;
   bool mDirectoryFilter;
@@ -286,20 +285,16 @@ nsFileView::~nsFileView()
   uint32_t count = mCurrentFilters.Length();
   for (uint32_t i = 0; i < count; ++i)
     free(mCurrentFilters[i]);
 }
 
 nsresult
 nsFileView::Init()
 {
-  mDateFormatter = nsIDateTimeFormat::Create();
-  if (!mDateFormatter)
-    return NS_ERROR_OUT_OF_MEMORY;
-
   return NS_OK;
 }
 
 // nsISupports implementation
 
 NS_IMPL_ISUPPORTS(nsFileView, nsITreeView, nsIFileView)
 
 // nsIFileView implementation
@@ -725,18 +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;
-    mDateFormatter->FormatPRTime(nullptr, kDateFormatShort, kTimeFormatSeconds,
-                                 lastModTime * 1000, temp);
+    mozilla::DateTimeFormat::FormatPRTime(kDateFormatShort, kTimeFormatSeconds,
+                                          lastModTime * 1000, temp);
     aCellText = temp;
   } else {
     // file size
     if (isDirectory)
       aCellText.SetCapacity(0);
     else {
       int64_t fileSize;
       curFile->GetFileSize(&fileSize);