1.1.13 • Published 3 years ago
@thatbadname/time-string-converter v1.1.13
Time-String-to-Seconds
A very simple light-weight package that can do a few simple functions on time strings\

Usage
Time strings should be formatted like <number><length>. being the time (eg: 7) and being the length (eg: years). If no valid input is provided (eg: 26lmao) it will ignore it and return 0. Something like 1m 17lmao would return 60
| Time Phrase | Valid Variations |
|---|---|
| Seconds | s, sec, secs, second, seconds |
| Minutes | m, min, mins, minute, minutes |
| Hours | h, hour, hours |
| Days | d, day, days |
| Weeks | w, wk, week, weeks |
| Months | mo, month, months |
| Years | y, yr, year, years |
Installation
In your terminal run:
npm i @thatbadname/time-string-converterand your done!
Code Examples
Converting to seconds
const convert = require('time-string-converter')
console.log(convert.convertStringToSeconds('1m'))
// Output: 60Convert seconds to time string
const convert = require('time-string-converter')
console.log(convert.convertSecondsToTimeObject(61))
/* Output: {
years: 0,
months: 0,
weeks: 0,
days: 0,
hours: 0,
minutes: 1,
seconds: 1
}
*/Convert seconds to formatted string
const convert = require('time-string-converter')
console.log(convert.reformatTimeString(61))
// Output: 1minute 1second1.1.12
3 years ago
1.1.13
3 years ago
1.1.11
3 years ago
1.1.10
3 years ago
1.1.9
3 years ago
1.1.8
3 years ago
1.1.7
3 years ago
1.1.6
3 years ago
1.1.5
3 years ago
1.1.4
3 years ago
1.1.3
3 years ago
1.1.2
3 years ago
1.1.1
3 years ago
1.1.0
3 years ago
1.0.5
3 years ago
1.0.4
3 years ago
1.0.3
3 years ago
1.0.2
3 years ago
1.0.1
3 years ago
1.0.0
3 years ago