iamkun / iamkun/dayjs

Humanize doesn't work with ISO 8601 strings

Open
#1,691 0 comments 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

Great library, thanks for the work!

I'm having trouble understanding how I can get the same output from `.fromNow()` and `.humanize()`.

This works great:

```js
dayjs("2021-09-05T00:14:43.702Z").fromNow(); // outputs '2 months ago'
```

This doesn't:

```js
dayjs.duration("2021-09-05T00:14:43.702Z", "months").humanize(); // outputs 'NaN years'
```

The documentation isn't clear on what the first argument of `duration()` needs to be, but it looks like it doesn't like the date being in ISO 8601 format and perhaps wants a number instead?

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.