timezone-mock
Advanced tools
Comparing version 1.0.11 to 1.0.12
@@ -35,6 +35,4 @@ var assert = require('assert'); | ||
} | ||
} else if (typeof param === 'number') { | ||
} else if (typeof param === 'number' || param === null || param === undefined) { | ||
this.d = new _Date(param); | ||
} else if (typeof param === 'undefined') { | ||
this.d = new _Date(); | ||
} else { | ||
@@ -79,2 +77,3 @@ assert.ok(false, 'Unhandled type passed to MockDate constructor: ' + typeof param); | ||
MockDate.prototype[fn] = function () { | ||
if (Number.isNaN(this.d.getTime())) return NaN; | ||
var d = new _Date(this.d.getTime() - this.calcTZO() * HOUR); | ||
@@ -157,2 +156,3 @@ return d['getUTC' + fn.slice(3)](); | ||
MockDate.prototype.getTimezoneOffset = function () { | ||
if (Number.isNaN(this.d.getTime())) return NaN; | ||
return this.calcTZO() * 60; | ||
@@ -166,2 +166,3 @@ }; | ||
} | ||
if (Number.isNaN(this.d.getTime())) return new _Date('').toString(); | ||
return 'Mockday ' + this.d.toISOString() + ' GMT-0' + this.calcTZO() + '00 (MockDate)'; | ||
@@ -175,2 +176,3 @@ }; | ||
MockDate.prototype.toDateString = function () { | ||
if (Number.isNaN(this.d.getTime())) return new _Date('').toDateString(); | ||
return `${ weekDays[this.getDay()] } ${ months[this.getMonth()] } ${ this.getDate().toString().padStart(2, '0') } ${ this.getFullYear() }`; | ||
@@ -180,3 +182,2 @@ }; | ||
// TODO: | ||
// 'toDateString', | ||
// 'toLocaleDateString', | ||
@@ -183,0 +184,0 @@ // 'toLocaleTimeString', |
{ | ||
"name": "timezone-mock", | ||
"version": "1.0.11", | ||
"version": "1.0.12", | ||
"description": "A JavaScript library to mock the local timezone.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
22389
725