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

Change "just now" label to "now" #38

Closed
silkfire opened this issue Oct 10, 2020 · 14 comments
Closed

Change "just now" label to "now" #38

silkfire opened this issue Oct 10, 2020 · 14 comments

Comments

@silkfire
Copy link

In a recent version, the twitter style label "now" was changed to "just now". Is there any way I could customize my style to use the previous wording?

@catamphetamine
Copy link
Owner

catamphetamine commented Oct 10, 2020 via email

@catamphetamine
Copy link
Owner

Fixed in javascript-time-ago@2.2.5: now it outputs "now" for 0 seconds and "1s" for 1 second.

@catamphetamine
Copy link
Owner

catamphetamine commented Oct 12, 2020

@silkfire Update: Added "twitter-now" style that outputs "now" for 0 seconds. "twitter" style doesn't output "now" now.

javascript-time-ago@2.2.6

@silkfire
Copy link
Author

silkfire commented Oct 12, 2020

I think I probably was confused myself about what I was looking for when I opened this issue in the first place.
What I actually wanted was to get the old behavior that I had with my setup.

I want the steps (gradatation?) of the old twitter style, so basically everything <1 min shows as 'now' (and not 1-59s), after that it should show as 1m, 2h, 3d, 4m, 5y, etc. But I don't want the rounding to happen. 8 min should be 8 min and not 10. Is there any way to achieve this behavior?

My custom style which used to work a few versions ago:

import defaultStyle from 'javascript-time-ago/commonjs/style/default';

const { gradation, units } = defaultStyle;
const defaultStyleShort = {
  gradation,
  flavour: ['tiny'],
  units,
};

@catamphetamine
Copy link
Owner

catamphetamine commented Oct 12, 2020

How about 0-40s — "now", then "1m", "2m", etc.

And "8 min should be 8 min and not 10"

@silkfire
Copy link
Author

I'd be okay with that. Is this achievable in the current version?

@catamphetamine
Copy link
Owner

I'd be okay with that.

Not ideal or good?

@silkfire
Copy link
Author

I'd be okay with that.

Not ideal or good?

Well I wasn't expecting 40-59s to be rounded up to 1m but I could be okay with that if the rest works as it did before.

@catamphetamine
Copy link
Owner

Well I wasn't expecting 40-59s to be rounded up to 1m but I could be okay with that if the rest works as it did before.

That's the question: what's better.

0-30 — now
30-90 — 1m
90-150 — 2m
etc

or

0-60 — now
60-90 — 1m // <--- disproportionately small
90-150 — 2m
etc

I'd prefer the first one.
You?

@catamphetamine
Copy link
Owner

See "twitter-minute-now" style in javascript-time-ago@2.2.8.

@silkfire
Copy link
Author

silkfire commented Oct 12, 2020

Well I wasn't expecting 40-59s to be rounded up to 1m but I could be okay with that if the rest works as it did before.

That's the question: what's better.

0-30 — now
30-90 — 1m
90-150 — 2m
etc

or

0-60 — now
60-90 — 1m // <--- disproportionately small
90-150 — 2m
etc

I'd prefer the first one.
You?

What's wrong with 0-59 — now, 60-119 — 1m, etc?

These rounded steppings seem very illogical to me.

@catamphetamine
Copy link
Owner

What's wrong with 0-59 — now, 60-119 — 1m, etc?

Ah, I see.
The currently implemented rounding mechanism performs a Math.round() when calculating the amount of time units, so 90 seconds is rounded to 2 minutes.
Perhaps there could be a place for "custom rounding", like Math.floor() instead of Math.round().
We'll see if people complain. If they do, then maybe I could implement a round: 'round'/'floor' option

@silkfire
Copy link
Author

That'd be nice to give the developer more control over the rounding mechanics, as of right now it seems very arbitrary to me.

@catamphetamine
Copy link
Owner

catamphetamine commented Oct 19, 2020

Published javascript-time-ago@2.3.0.

It has round parameter on a style or on .format().
Can be: "round", "floor".

Also, has "mini-minute-now" style.

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