1.1.13 • Published 2 years ago

@thatbadname/time-string-converter v1.1.13

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

Time-String-to-Seconds

A very simple light-weight package that can do a few simple functions on time strings\ Discord Banner 4

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 PhraseValid Variations
Secondss, sec, secs, second, seconds
Minutesm, min, mins, minute, minutes
Hoursh, hour, hours
Daysd, day, days
Weeksw, wk, week, weeks
Monthsmo, month, months
Yearsy, yr, year, years

Installation

In your terminal run:

npm i @thatbadname/time-string-converter

and your done!

Code Examples

Converting to seconds

const convert = require('time-string-converter')
console.log(convert.convertStringToSeconds('1m'))
// Output: 60

Convert 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 1second
1.1.12

2 years ago

1.1.13

2 years ago

1.1.11

2 years ago

1.1.10

2 years ago

1.1.9

2 years ago

1.1.8

2 years ago

1.1.7

2 years ago

1.1.6

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago