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

Custom range? #840

Closed
mackelito opened this issue Mar 17, 2020 · 5 comments
Closed

Custom range? #840

mackelito opened this issue Mar 17, 2020 · 5 comments

Comments

@mackelito
Copy link

I have been looking in the docs, googling and searched git issues but have not been able to find anything about setting a custom range?

I need to do something like this...

  • if more that 47h show x days
  • if more than 24h but less than 47h show x days and x hours
  • if less than 24h show x hours
  • if less than 3h show x hours and x mins
  • if less that 1h show x mins

Is that doable?

@iamkun
Copy link
Owner

iamkun commented Mar 18, 2020

This is a REALLY custom feature, I think. Better implement it in your own project or a custom plugin.

@mackelito
Copy link
Author

Yeah it sure is super custom :)
I was kind of hoping that we could tap in to the range config :)

@mackelito
Copy link
Author

mackelito commented Mar 18, 2020

we currently working on doing it like

dayjs.updateLocale('sv', {
      relativeTime: {
        ...dayjs.en.relativeTime,
hh: (number, withoutSuffix, key, isFuture) => {
          if (isFuture) {
            return `${number} timmar`
          }
        },

etc...

but then we need it for each locale.. just ends up in non dry code :)

@iamkun
Copy link
Owner

iamkun commented Mar 18, 2020

Or maybe #830 (comment) is a better way?

@iamkun
Copy link
Owner

iamkun commented Mar 27, 2020

Update: #851

We can set custom range thresholds now. 😬

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants