You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
593 B

  1. var oldDate = global.Date;
  2. /*
  3. * fix new Date() to a fixed unix timestamp.
  4. */
  5. global.Date.fix = function (timestamp) {
  6. var time = timestamp * 1000;
  7. if (global.Date.unfake) {
  8. global.Date.unfake();
  9. }
  10. global.Date = function (ts) {
  11. return new oldDate(ts || time);
  12. };
  13. global.Date.prototype = Object.create(oldDate.prototype);
  14. global.Date.prototype.constructor = global.Date;
  15. global.Date.prototype.now = function () {
  16. return time;
  17. };
  18. global.Date.now = function () {
  19. return time;
  20. };
  21. global.Date.unfix = function () {
  22. global.Date = oldDate;
  23. };
  24. };