You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to migrate from moment to dayjs, and I found something which IMHO is weird: it looks like humanize does not work without durationandrelativeTime plugin.
This script, which is a copy/paste from the humanize doc, result to an error:
constdayjs=require("dayjs")constduration=require("dayjs/plugin/duration")dayjs.extend(duration)constresult=dayjs.duration(1,"minutes").humanize()// a minuteconsole.log({ result })
TypeError: t(...).add(...).locale(...).fromNow is not a function
at s.u.humanize (/private/tmp/dayjstest/node_modules/dayjs/plugin/duration.js:1:2489)
constdayjs=require("dayjs")constduration=require("dayjs/plugin/duration")constrelativeTime=require('dayjs/plugin/relativeTime')dayjs.extend(duration)dayjs.extend(relativeTime)constresult=dayjs.duration(1,"minutes").humanize()// a minuteconsole.log({ result })// { result: 'a minute' }
Expected behavior
Well, I feel like plugin should work in isolation. If it is not possible, maybe it can be a good thing to update the documentation and wrote that humanize require both relativeTime and duration plugins.
But, I'm still a beginner with dayjs, so maybe I just missed something big. What do you think ?
Information
Day.js Version :v1.8.25
OS: MacOS Mojave
Node: 13.11.0
The text was updated successfully, but these errors were encountered:
Describe the bug
Hello guys, and thank you for this awesome lib.
I am trying to migrate from moment to dayjs, and I found something which IMHO is weird: it looks like humanize does not work without duration and relativeTime plugin.
This script, which is a copy/paste from the humanize doc, result to an error:
Error logs: https://pastebin.com/rGhgezBU
But, adding relativeTime plugin make it works:
Expected behavior
Well, I feel like plugin should work in isolation. If it is not possible, maybe it can be a good thing to update the documentation and wrote that humanize require both relativeTime and duration plugins.
But, I'm still a beginner with dayjs, so maybe I just missed something big. What do you think ?
Information
The text was updated successfully, but these errors were encountered: