Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RelativeTime ".past" and ".future" keys does not support function #1196

Closed
drgx opened this issue Nov 9, 2020 · 1 comment · Fixed by #1197
Closed

RelativeTime ".past" and ".future" keys does not support function #1196

drgx opened this issue Nov 9, 2020 · 1 comment · Fixed by #1197
Labels

Comments

@drgx
Copy link
Contributor

drgx commented Nov 9, 2020

Describe the bug
As per this documentation, dayjs support additional token processing with the same API as moment js. It will throw an error if I pass past and future a function for additional processing.
For the rest of the relativeTime keys, it works perfectly.

Example of error:

dayjs.updateLocale("en", {
  relativeTime: {
    future: "in %s",
     past: (input) => {
       return "additional processing";
     },
    s: "just now",
    m: " 1 min",
    mm: "%d min",
    h: "1 hr",
    hh: "%d hrs",
    d: "a day",
    dd: "%d days",
    M: "a month",
    MM: "%d months",
    y: "a year",
    yy: "%d years"
  }
});

Can be tested here: https://codesandbox.io/s/dayjs-relativestime-bug-1k2m9?file=/src/index.js

Expected behavior
relativeTime.future and relativeTime.past should support function for additional processing

Information

  • Day.js Version 1.9.4, 1.9.5
  • OS: macOS
  • Browser Version 86.0.4240.183
  • Time zone: GMT+7
@drgx drgx changed the title RelativeTimes "past" and "future" does not support function RelativeTimes "past" and "future" keys does not support function Nov 9, 2020
@drgx drgx changed the title RelativeTimes "past" and "future" keys does not support function RelativeTime ".past" and ".future" keys does not support function Nov 9, 2020
@iamkun
Copy link
Owner

iamkun commented Dec 5, 2020

🎉 This issue has been resolved in version 1.9.7 🎉

The release is available on:

Your semantic-release bot 📦🚀

@iamkun iamkun added the released label Dec 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants