https://github.com/js-sdk/js-sdk-timediff
Simple timediff utilities.
https://github.com/js-sdk/js-sdk-timediff
javascript library timediff
Last synced: about 1 year ago
JSON representation
Simple timediff utilities.
- Host: GitHub
- URL: https://github.com/js-sdk/js-sdk-timediff
- Owner: js-sdk
- License: unlicense
- Created: 2017-09-14T23:20:26.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-09-14T23:33:29.000Z (almost 9 years ago)
- Last Synced: 2025-02-25T23:05:12.252Z (over 1 year ago)
- Topics: javascript, library, timediff
- Language: JavaScript
- Size: 4.88 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license.md
Awesome Lists containing this project
README
# js-sdk-timediff
Simple timediff utilities. This library has no notion of time zone.
## library
```ts
$ TimeDiff(timestamp : Number) -> TimeDiff
// Holds the value and provide some utilities.
$ TimeDiff::of(milliseconds : Number) -> TimeDiff
// Smart contructor
$ TimeDiff.valueOf() -> Number
// Treat as a number so we can use the basic operation like '+'...
$ TimeDiff.concat(b : TimeDiff) -> TimeDiff
// Implements semigroup for TimeDiff.
$ TimeDiff.toDate() -> Date
// Returns a 'Date' from now.
$ timeDiff(t2 : Date, t1 : Date) -> TimeDiff
// Returns the diff of 2 'Date's.
$ timeDiffFromNow(t : Date) -> TimeDiff
// Returns the diff from now.
$ asSeconds(tdiff : TimeDiff) -> Number
// Returns the number of seconds of a 'TimeDiff'.
$ asMinutes(tdiff : TimeDiff) -> Number
// Returns the number of minutes of a 'TimeDiff'.
$ asHours(tdiff : TimeDiff) -> Number
// Returns the number of hours of a 'TimeDiff'.
$ asDays(tdiff : TimeDiff) -> Number
// Returns the number of days of a 'TimeDiff'.
$ asMonths(tdiff : TimeDiff) -> Number
// Returns the number of months (speculative) of a 'TimeDiff'.
$ asYears(tdiff : TimeDiff) -> Number
// Returns the number of years (no precise) of a 'TimeDiff'.
$ asComponents(tdiff : TimeDiff) -> { days: Number,
hours: Number,
minutes: Number,
seconds: Number }
// Returns an object with all components (does not include year and month).
```
## license
See `license.md` or visit [Unlicense](http://unlicense.org).