-
Notifications
You must be signed in to change notification settings - Fork 128
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
fromNow
does not pluralize correctly: "1 minutes ago"
#273
Comments
Hey @lukehutch , I appreciate you bringing this to my attention. I was able to replicate the issue final j1 = Jiffy.parseFromList(
[2024, 1, 1, 2, 0, 0, 0, 0]
);
final j2 = Jiffy.parseFromList(
[2024, 1, 1, 1, 58, 30, 0, 0]
);
print(j1.from(j2)); // in 1 minutes It should be Upon investigation, I've identified the issue. A recent pull request #267 addressed the usage of the However, we overlooked updating the calculation of relative time in the The solution involves updating the code to utilize floating-point values. This adjustment can be achieved by testing the Lines 47 to 54 in a278808
Thank you for your attention to this matter and your contribution to Jiffy. I will open a PR to fix this. |
Correct, This is not the issue I am raising. The issue is that The Jiffy source for |
Yes, correct, I was just saying the Lines 47 to 54 in a278808
So the relative time calculation should use Also , in Jiffy, there is no |
But other locales have different ways of representing one minute, in english its |
But the real issue that should be fixed is that we need to set the |
In spanish, we have set it to
|
@lukehutch Here is the PR that should fix this big #274 |
Weird, I could have sworn I got |
@jama5262 OK, I took a look at the code, and I see what you were saying. But there is still a potential bug here, I think... if (seconds < 45) {
result = relativeDateTime.lessThanOneMinute(seconds.round());
} else if (seconds < 90) {
result = relativeDateTime.aboutAMinute(minutes.round());
} else if (minutes < 45) {
result = relativeDateTime.minutes(minutes.round()); Even with everything in floating point, it is dicey to assume that The |
Same for hours, days, months, and years too, for the "about a" versions... they should all check the appropriate rounded version for consistency. (In particular, months as a fractional number worries me -- what is a fractional month, when the length of a month changes from day to day?) |
Hmm, ok, I see what you are trying to say |
You you be able to setup a PR for this @lukehutch ? |
@jama5262 Unfortunately no, I'm working up to 20 hours a day right now trying to get my app launched... |
Describe the bug
Calling
jiffy.fromNow()
produces text that is not correctly pluralized in English (presumably also in other languages). For example:"1 minutes ago"
.How to reproduce the bug
Call
fromNow
on a Jiffy from a minute ago.What is the expected behavior
It should render the result differently if the number is 1, e.g.
"1 minute ago"
(same for minutes, hours, days, weeks, months, years).Not every language needs special pluralization handling for the number 1, but a lot do.
The text was updated successfully, but these errors were encountered: