open-index/open-npm huggingface dataset:
npm package: @shanecaf/duration-js
Description: Fork of duration-js
Author: Shane C.
Latest version: 0.1.10

# Duration.js

<div style="display: flex; gap: 5px;">
    <a href="https://jsr.io/@shanecaf/duration-js">
      <img src="https://jsr.io/badges/@shanecaf/duration-js" alt="" />
    </a>
    <a href="https://www.npmjs.com/package/@shanecaf/duration-js">
        <img alt="NPM Version" src="https://img.shields.io/npm/v/%40shanecaf%2Fduration-js">
    </a>
    <a href="https://jsr.io/@shanecaf/duration-js">
      <img src="https://jsr.io/badges/@shanecaf/duration-js/score" alt="" />
    </a>
    <a href="https://codeberg.org/shanecaf/Duration.js">
        <img alt="Codeberg Stars" src="https://img.shields.io/gitea/stars/shanecaf/Duration.js?gitea_url=https%3A%2F%2Fcodeberg.org%2F&logo=codeberg">
    </a>
</div>

---

A library for handling durations that uses the Temporal proposal polyfill.

This is a fork of [Duration.js](https://github.com/icholy/Duration.js) by [icholy](https://github.com/icholy) based on the `golang_compatible` branch.

## Example

```typescript
import { Duration, DiscordTimestamp } from '@shanecaf/duration-js';

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.
```

## Tests

Since this is a work in progress, there are no tests yet.