https://github.com/gregl83/systime
NodeJS Event Based System Time Keeper
https://github.com/gregl83/systime
clock nodejs systime timer
Last synced: about 1 month ago
JSON representation
NodeJS Event Based System Time Keeper
- Host: GitHub
- URL: https://github.com/gregl83/systime
- Owner: gregl83
- Created: 2015-05-04T06:07:47.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2016-11-28T16:25:30.000Z (over 9 years ago)
- Last Synced: 2026-03-03T12:32:37.507Z (3 months ago)
- Topics: clock, nodejs, systime, timer
- Language: JavaScript
- Homepage:
- Size: 12.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[](https://travis-ci.org/gregl83/systime)
[](https://coveralls.io/r/gregl83/systime?branch=master)
# systime
NodeJS Event Based System Time Keeper
Systime syncs with system time and emits time events. It accounts for fluctuations in time accuracy by continuously re-syncing with local system time.
Use this package for any software that needs to accurately track time (assuming system time is accurate).
For more information on computer clocks and time see [NTP.org](http://www.ntp.org/ntpfaq/NTP-s-sw-clocks.htm).
## Requirements
- NodeJS v5.11.x or higher
- NPM
See `./package.json`
## Installation
Source available on [GitHub](https://github.com/gregl83/systime) or install module via NPM:
$ npm install systime
## Usage
After requiring systime create a new instance. Bind event listeners to systime then call the start method.
```js
var Systime = require('systime')
var systime = new Systime()
// bind listeners to zero or more of the following events
// (each callback has a date object argument)
systime.on('second', date => console.log(date))
systime.on('minute', () => console.log('new minute'))
systime.on('hour', () => console.log('new hour'))
systime.on('day', () => console.log('new day'))
systime.on('week', () => console.log('new week'))
systime.on('month', () => console.log('new month'))
systime.on('year', () => console.log('new year'))
systime.start() // start systime
// runs until process has exited or systime.stop() method called
```
The above starts systime and console logs as event listeners are triggered.
See `./example/events.js` for working example.
That's it!
## License
MIT