Comparing version 0.6.2 to 0.6.3
@@ -24,2 +24,26 @@ import createCachedFormatter, { numberFormats, dateTimeFormats } from "./format"; | ||
} | ||
const getDateTimeFormat = () => { | ||
const delegate = Intl.DateTimeFormat; | ||
function DateTimeFormat() { | ||
const args = Array.prototype.slice.apply(arguments); | ||
args[0] = args[0] || "en-US"; | ||
args[1] = args[1] || {}; | ||
args[1].timeZone = args[1].timeZone || "America/Toronto"; | ||
return delegate.apply(this, args); | ||
} | ||
DateTimeFormat.prototype = delegate.prototype; | ||
return DateTimeFormat; | ||
}; | ||
try { | ||
Intl.DateTimeFormat(); | ||
(new Date()).toLocaleString(); | ||
(new Date()).toLocaleDateString(); | ||
(new Date()).toLocaleTimeString(); | ||
} | ||
catch (err) { | ||
Date.prototype.toLocaleString = Date.prototype.toString; | ||
Date.prototype.toLocaleDateString = Date.prototype.toDateString; | ||
Date.prototype.toLocaleTimeString = Date.prototype.toTimeString; | ||
Intl.DateTimeFormat = getDateTimeFormat(); | ||
} | ||
const dateFormatter = createCachedFormatter(Intl.DateTimeFormat); | ||
@@ -26,0 +50,0 @@ const numberFormatter = createCachedFormatter(Intl.NumberFormat); |
@@ -26,2 +26,26 @@ "use strict"; | ||
} | ||
var getDateTimeFormat = function () { | ||
var delegate = Intl.DateTimeFormat; | ||
function DateTimeFormat() { | ||
var args = Array.prototype.slice.apply(arguments); | ||
args[0] = args[0] || "en-US"; | ||
args[1] = args[1] || {}; | ||
args[1].timeZone = args[1].timeZone || "America/Toronto"; | ||
return delegate.apply(this, args); | ||
} | ||
DateTimeFormat.prototype = delegate.prototype; | ||
return DateTimeFormat; | ||
}; | ||
try { | ||
Intl.DateTimeFormat(); | ||
(new Date()).toLocaleString(); | ||
(new Date()).toLocaleDateString(); | ||
(new Date()).toLocaleTimeString(); | ||
} | ||
catch (err) { | ||
Date.prototype.toLocaleString = Date.prototype.toString; | ||
Date.prototype.toLocaleDateString = Date.prototype.toDateString; | ||
Date.prototype.toLocaleTimeString = Date.prototype.toTimeString; | ||
Intl.DateTimeFormat = getDateTimeFormat(); | ||
} | ||
var dateFormatter = format_1.default(Intl.DateTimeFormat); | ||
@@ -28,0 +52,0 @@ var numberFormatter = format_1.default(Intl.NumberFormat); |
{ | ||
"name": "t-i18n", | ||
"version": "0.6.2", | ||
"version": "0.6.3", | ||
"description": "Simple, standards-based localization", | ||
@@ -5,0 +5,0 @@ "author": "Mitch Cohen <mitch.cohen@me.com>", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
38747
948