iamkun / iamkun/dayjs

[Feature request] `duration.asObject()`

Open
#2,971 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
48.7k
Forks
2.5k
PR merge metrics
No merged PRs in 30d

Description

Hi,

It would be nice to have an `asObject` method on durations, e.g. to convert a number of milliseconds into `{ years, months, weeks, days, hours, minutes, seconds }`.

That would be a shorthand for the following :

```js
const durationAsObject = duration => ({
years: duration.years(),
months: duration.months(),
days: duration.days(),
hours: duration.hours(),
minutes: duration.minutes(),
seconds: duration.seconds()
});
```

Thanks

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.