mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 19:53:36 +00:00
LInt mockdate helper
This commit is contained in:
parent
3659b5b5c9
commit
4e4d3418b3
@ -6,10 +6,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
(function(name, definition) {
|
(function(name, definition) {
|
||||||
if (typeof module !== 'undefined') module.exports = definition();
|
if (typeof module !== "undefined") {module.exports = definition();}
|
||||||
else if (typeof define === 'function' && typeof define.amd === 'object') define(definition);
|
else if (typeof define === "function" && typeof define.amd === "object") {define(definition);}
|
||||||
else this[name] = definition();
|
else {this[name] = definition();}
|
||||||
}('MockDate', function() {
|
}("MockDate", function() {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var _Date = Date
|
var _Date = Date
|
||||||
@ -35,7 +35,7 @@
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
d = typeof d === 'undefined' ? 1 : d;
|
d = typeof d === "undefined" ? 1 : d;
|
||||||
h = h || 0;
|
h = h || 0;
|
||||||
M = M || 0;
|
M = M || 0;
|
||||||
s = s || 0;
|
s = s || 0;
|
||||||
@ -64,15 +64,15 @@
|
|||||||
MockDate.prototype = _Date.prototype;
|
MockDate.prototype = _Date.prototype;
|
||||||
|
|
||||||
function set(date, timezoneOffset) {
|
function set(date, timezoneOffset) {
|
||||||
var dateObj = new Date(date)
|
var dateObj = new Date(date);
|
||||||
if (isNaN(dateObj.getTime())) {
|
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() {
|
MockDate.prototype.getTimezoneOffset = function() {
|
||||||
return timezoneOffset;
|
return timezoneOffset;
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
Date = MockDate;
|
Date = MockDate;
|
||||||
@ -82,7 +82,7 @@
|
|||||||
|
|
||||||
function reset() {
|
function reset() {
|
||||||
Date = _Date;
|
Date = _Date;
|
||||||
Date.prototype.getTimezoneOffset = _getTimezoneOffset
|
Date.prototype.getTimezoneOffset = _getTimezoneOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user