Skip to content

An utility module to convert metric units to their respective multiples or submultiples.

License

Notifications You must be signed in to change notification settings

ModCord/unit-converter

 
 

Repository files navigation

Unit Converter

An utility package for ModCord used to convert different metric units to their respectiv multiples and submultiples.

Usage

const { TimeUnits } = require("@modcord/unit-converter");
const { y, mon, w, d, h, m, s, ms } = TimeUnits;

function getDurationString(amountOfMs) {
  const [years, months, weeks, days, hours, minutes, seconds] = ms.to(y, mon, w, d, h, m, s)(amountOfMs);
  return `${years} years, ${months} months, ${weeks} weeks, ${days} days, ${hours} hours, ${minutes} minutes and ${seconds} seconds`;
}

getDurationString(40753197500);
// 1 years, 3 months, 2 weeks, 1 days, 3 hours, 4 minutes and 0 seconds

About

An utility module to convert metric units to their respective multiples or submultiples.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%