LInt mockdate helper

This commit is contained in:
rejas 2020-03-25 06:53:09 +01:00
parent 3659b5b5c9
commit 4e4d3418b3

View File

@ -6,10 +6,10 @@
*/
(function(name, definition) {
if (typeof module !== 'undefined') module.exports = definition();
else if (typeof define === 'function' && typeof define.amd === 'object') define(definition);
else this[name] = definition();
}('MockDate', function() {
if (typeof module !== "undefined") {module.exports = definition();}
else if (typeof define === "function" && typeof define.amd === "object") {define(definition);}
else {this[name] = definition();}
}("MockDate", function() {
"use strict";
var _Date = Date
@ -35,7 +35,7 @@
break;
default:
d = typeof d === 'undefined' ? 1 : d;
d = typeof d === "undefined" ? 1 : d;
h = h || 0;
M = M || 0;
s = s || 0;
@ -64,15 +64,15 @@
MockDate.prototype = _Date.prototype;
function set(date, timezoneOffset) {
var dateObj = new Date(date)
var dateObj = new Date(date);
if (isNaN(dateObj.getTime())) {
throw new TypeError('mockdate: The time set is an invalid date: ' + date)
throw new TypeError("mockdate: The time set is an invalid date: " + date);
}
if (typeof timezoneOffset === 'number') {
if (typeof timezoneOffset === "number") {
MockDate.prototype.getTimezoneOffset = function() {
return timezoneOffset;
}
};
}
Date = MockDate;
@ -82,7 +82,7 @@
function reset() {
Date = _Date;
Date.prototype.getTimezoneOffset = _getTimezoneOffset
Date.prototype.getTimezoneOffset = _getTimezoneOffset;
}
return {