Package Exports
- set-now
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (set-now) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
set-now
Adds Date.setNow() to JavaScript's global Date object.
This is useful for making tests deterministic. Wind back the clock to a time in the past (or in the future).
Install
npm install set-nowUsage
require('set-now')
Date.setNow('2016-03-17T12:00:00')
new Date() // Thu Mar 17 2016 08:00:00 GMT-0400 (EDT)
Date.now() // 1458216000000
// wait 1 second
setTimeout(function () {
new Date() // Thu Mar 17 2016 08:00:01 GMT-0400 (EDT)
Date.setNow() // reset the time back to normal
new Date() // today's actual date
}, 1000)Date.setNow( [time] )
Set the clock to the specified time.
time{String} (optional) The time you want it to be. Iftimeis not specified, the clock will be reset to the actual time.