0.0.3 • Published 6 months ago

text-time v0.0.3

Weekly downloads
-
License
MIT
Repository
-
Last release
6 months ago

text-time

text-time is a tool to help you to parse text that contain time data to seconds

:warning: Node.js >= 14 is required (Open an issue if you require a lower version of Node.js and explain why)

Motivations

I noticed in my experience that some config contains time in second and like it is an environment variable or a JSON file, I could not write time with this format: 60 * 60 * 24 (means 1 day). This format allows you to easily understand what time it represents, compared to 86400. I thought it will be very fun if in my configuration, I may write 1 day. This project is the purpose.

Usage

const TextTime = require('text-time');

const tt = new TextTime();
console.log(tt('4 months')); // 10368000

Features

  • :zap: International ! (Supports :fr: and :uk:)
  • change the output format

API

constructor - new TextTime({ output })

  • output: By default, the time is returned in second. You can change the unit like you want.
unitENFR
secondsecond, secondsseconde, secondes
minuteminute, minutesminute, minutes
hourhour, hoursheure, heures
dayday, daysjour, jours, journée, journées
monthmonth, monthsmois
yearyear, yearsan, ans, année, années

Todo