timezone-mock
Advanced tools
Comparing version 1.2.2 to 1.3.0
12
index.js
@@ -179,3 +179,3 @@ 'use strict'; | ||
MockDate.prototype.toString = MockDate.prototype.toLocaleString = function () { | ||
MockDate.prototype.toString = function () { | ||
if (this instanceof _Date) { | ||
@@ -219,2 +219,12 @@ // someone, like util.inspect, calling Date.prototype.toString.call(foo) | ||
MockDate.prototype.toLocaleString = function (locales, options) { | ||
options = options || {}; | ||
var time = this.d.getTime(); | ||
if (Number.isNaN(time)) { | ||
return new _Date('').toDateString(); | ||
} | ||
options.timeZone = timezone; | ||
return new _Date(time).toLocaleString(locales, options); | ||
}; | ||
MockDate.prototype.toLocaleDateString = function (locales, options) { | ||
@@ -221,0 +231,0 @@ options = options || {}; |
{ | ||
"name": "timezone-mock", | ||
"version": "1.2.2", | ||
"version": "1.3.0", | ||
"description": "A JavaScript library to mock the local timezone.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -79,4 +79,10 @@ timezone-mock | ||
The behavior of `toLocaleString()` has changed in v1.3.0 to more closely match Node's | ||
behavior, but only works on Node v14+. Use v1.2.2 for the old behavior. See note below. | ||
Most Date member functions are supported except for some conversions to | ||
locale-specific date strings. | ||
locale-specific date strings. These are mocked in a way that may only work | ||
reliably on Node v14+. Note that using locale-specific formatting is often | ||
device- and browser-dependant, so any use of these in tests may indicate a | ||
potential bug. | ||
@@ -83,0 +89,0 @@ With non-DST timezones, it should behave identically to the native Javascript |
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
28714
965
93