UNPKG

593 BJavaScriptView Raw
1var oldDate = global.Date;
2
3/*
4 * fix new Date() to a fixed unix timestamp.
5 */
6global.Date.fix = function (timestamp) {
7 var time = timestamp * 1000;
8
9 if (global.Date.unfake) {
10 global.Date.unfake();
11 }
12
13 global.Date = function (ts) {
14 return new oldDate(ts || time);
15 };
16
17 global.Date.prototype = Object.create(oldDate.prototype);
18 global.Date.prototype.constructor = global.Date;
19
20 global.Date.prototype.now = function () {
21 return time;
22 };
23
24 global.Date.now = function () {
25 return time;
26 };
27
28 global.Date.unfix = function () {
29 global.Date = oldDate;
30 };
31
32};
\No newline at end of file