@modcord/unit-converter

1.0.2 • Public • Published

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

Dependencies (0)

    Dev Dependencies (2)

    Package Sidebar

    Install

    npm i @modcord/unit-converter

    Weekly Downloads

    2

    Version

    1.0.2

    License

    MIT

    Unpacked Size

    5.52 kB

    Total Files

    8

    Last publish

    Collaborators

    • mraugu