secondjs
A simple second conversion utility. It takes an Number
(seconds) and allows you to convert that to minutes, hours, days, weeks and milliseconds.
Install
installation is simple using npm.
npm i secondjs --save
Usage
Basic example
If you would like to get started quickly, use the following as an example:
const secondjs = // get the individual minutes since some other timeconst seconds = 12345console // Outputs: Minutes: 205
Advanced example
A simple API is provided by example:
const secondjs = const seconds = 10000000const test = consoleconsoleconsoleconsoleconsoleconsoleconsoleconsole /* Outputs:seconds: 10000000minutes: 166666hours: 2777days: 115weeks: 16round: 16 weeks*/
Round
The round feature will use the largest time-value available by default.
const secondjs = console// Outputs: 2 hours
You can also pass in an override and make sure the value conforms to a specific measurement:
const secondjs = console// Outputs: 166 minutes
The following arguments are allowed:
- milliseconds
- seconds
- minutes
- hours
- days
- weeks
Milliseconds
We also support converting milliseconds:
const millisecondjs = console// Output (will vary): 1510677893 seconds since 1 January 1970 00:00:00 UTC
To do
Since this is still in "early-access" I wanted to make clear some goals:
- Add support for months
- Currently do not support this as it is non static (28-31 days)
- Add support for years
- Same as month support
- Optimize speed and memory
- Mainly supporting the caching of values.
License
MIT