monotonic-timestamp
Monotonically increasing timestamp.
Last updated 12 years ago by dominictarr .
MIT · Repository · Original npm · Tarball · package.json
$ npm install monotonic-timestamp 
SYNC missed versions from official npm registry.

monotonic-timestamp

Monotonically increasing timestamp.

<img src=https://secure.travis-ci.org/'Dominic Tarr'/monotonic-timestamp.png?branch=master>

This is NOT a accurate representation of the time. Since js only measures time as ms, if you call Date.now() twice quickly, it's possible to get two identical time stamps.

monotonic-timestamp fixes that problem! (crudely)

Example

var timestamp = require('monotonic-timestamp')

console.log(timestamp())
console.log(timestamp())
console.log(timestamp())
console.log(timestamp())
console.log(timestamp())

subsequent calls to timestamp() are ALWAYS strictly ordered.

byte optimizations

My precious bytes! wasted on your timestamp!

pack it into a string!

timestamp().toString(36) 

if you want a constant-length string, you can use monotonic-timestamp-base36

of course, if you are using a binary protocol, it will be cheaper to use the float...

##TODO

syncronize network time.

License

MIT

Current Tags

  • 0.0.9                                ...           latest (10 years ago)

9 Versions

  • 0.0.9                                ...           10 years ago
  • 0.0.8                                ...           12 years ago
  • 0.0.7                                ...           12 years ago
  • 0.0.6                                ...           12 years ago
  • 0.0.5                                ...           12 years ago
  • 0.0.4                                ...           12 years ago
  • 0.0.3                                ...           12 years ago
  • 0.0.2                                ...           12 years ago
  • 0.0.1                                ...           12 years ago
Maintainers (1)
Downloads
Total 7
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (0)
None
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE