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

Feature Request - Control the accuracy of RelativeTime #523

Closed
Newbie012 opened this issue Mar 7, 2019 · 4 comments
Closed

Feature Request - Control the accuracy of RelativeTime #523

Newbie012 opened this issue Mar 7, 2019 · 4 comments

Comments

@Newbie012
Copy link

The RelativeTime plugin is pretty useful. But it has its cons.

The current output of RelativeTime would be as specific as the amount of the current time units (e.g 44 seconds, 14 minutes, 3 hours) but not such as "1 hour and 2 minutes".

My suggestion is to control the accuracy of the relative time. For example:

Time from now .fromNow(RelativeTimeOpts)

type TimeUnit = 'seconds' | 'minutes' | 'hours' | 'days' | 'months' | 'years';

interface RelativeTimeOpts {
  withoutSuffix?: boolean;
  untilUntil?: TimeUnit;
}

This way, when we type .fromNow({untilUntil: 'seconds'}) it will print:


2 hours, 25 minutes and 3 seconds ago.


I guess that there's a better name than untilUnit out there, but you got the point :)

PS - I was sort-of already suggested it here - #414 but in a different way.

@iamkun
Copy link
Owner

iamkun commented Mar 8, 2019

Thanks. Maybe we should add a dayjs.duration plugin to better fits this situation.

@waseemahmad31
Copy link
Contributor

I can try to implement this feature.

@iamkun
Copy link
Owner

iamkun commented Apr 7, 2019

@waseemahmad31 Maybe adding a duration plugin is better?

@iamkun
Copy link
Owner

iamkun commented Apr 9, 2019

#564 todo: Duration plugin

@iamkun iamkun closed this as completed Apr 9, 2019
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

3 participants