Getting Started
@fleco/duration is loosely based on icholy’s Duration-js. I have updated the code and have added some functions that are helpful for Fleco.
$
npm install @fleco/duration
$
pnpm install @fleco/duration
$
yarn add @fleco/duration
$
bun add @fleco/duration
Example Program
import { Duration, DiscordTimestamp } from '@fleco/duration';
const duration = new Duration('1w 2d');
console.log(duration.endDate()); // Outputs a Date object.
//Discord Timestamps:
console.log(duration.toDiscordTimestamp(DiscordTimestamp.LongDateTime)); //Outputs <t:[date_in_epoch_sec]:F> for Discord.