Test your time-dependent app by monkey patching the Date function and overriding your system time.
JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src fix: 1) new Date('<explicit date string'>) no longer fails if tick = … Mar 20, 2017
test fix: Update unit tests to better handle different time zones. Mar 20, 2017
.gitignore fix: 1) new Date('<explicit date string'>) no longer fails if tick = … Mar 20, 2017
.jshintrc Keep prototype Sep 26, 2013
.travis.yml
Gruntfile.js bump version Nov 23, 2016
README.md
bower.json
karma.conf.js
package.json bump Mar 23, 2017
timemachine.js Build release files Mar 20, 2017
timemachine.min.js

README.md

timemachine Build Status

Test your time-dependent app by monkey patching the Date function and overriding your system time. Timemachine is compatible with global namespaces, RequireJS, CommonJS and NodeJS.

Installation

Bower

$ bower install timemachine

NPM

$ npm install timemachine

Usage

Config

timemachine.config({
  dateString: 'December 25, 1991 13:12:59'
});

console.log(new Date()); // December 25, 1991 13:12:59
Parameter Description Default
dateString Date you want set as a string Thu, 01 Jan 1970 00:00:00 GMT
timestamp Date you want set as a timestamp 0
difference Time offset in milliseconds 0
tick Whether the system clock should continue ticking false
keepTime Whether the system time should be kept false

Reset

timemachine.reset();
console.log(new Date()); // Your real system time