https://github.com/schickling/timemachine
Test your time-dependent app by monkey patching the Date function and overriding your system time.
https://github.com/schickling/timemachine
Last synced: 10 months ago
JSON representation
Test your time-dependent app by monkey patching the Date function and overriding your system time.
- Host: GitHub
- URL: https://github.com/schickling/timemachine
- Owner: schickling
- Created: 2013-09-26T14:43:43.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2021-01-18T14:07:39.000Z (over 5 years ago)
- Last Synced: 2025-03-29T14:06:36.470Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 85.9 KB
- Stars: 138
- Watchers: 6
- Forks: 35
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
timemachine [](https://travis-ci.org/schickling/timemachine)
===========
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
```sh
$ bower install timemachine
```
### NPM
```sh
$ npm install timemachine
```
## Usage
### Config
```js
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
```js
timemachine.reset();
console.log(new Date()); // Your real system time
```