0.4.0 • Published 1 year ago

@alexfr26/timemachine v0.4.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

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
ParameterDescriptionDefault
dateStringDate you want set as a stringThu, 01 Jan 1970 00:00:00 GMT
timestampDate you want set as a timestamp0
differenceTime offset in milliseconds0
tickWhether the system clock should continue tickingfalse
keepTimeWhether the system time should be keptfalse

Reset

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