-
Notifications
You must be signed in to change notification settings - Fork 253
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
Round-up/down time units #117
Comments
Hmmm, I tend to agree with that. I'm not exactly sure what the right approach would be to correct this behavior, but it's worth a look. |
Right now, I'm wrapping the PrettyTime usage in a method that rounds the time difference to full days if the difference is more than 24h. This solves the 7 days vs. one week issue, which in my case is the only one I care about, but it's not nice obviously. In pseudo code I could imagine something like: var maxTimeUnit = findMaxTimeUnit(timeDiff) |
Actually, I think the simplest fix is to configure the Day timeUnit in the initTimeUnits method here:
I think this should have the desired effect, but it's possible there is a more precise solution. |
(Also, you can try updating the unit yourself locally (they are configurable via the PrettyTime API) if you want to get this working before I can "fix" it here and make a release.) |
Did you have any luck configuring the unit? |
Actually, I already fixed this by aligning the duration to full days, which worked in my case. But your suggestion makes a lot more sense of course. |
Would it be better with |
I'm not really sure what that would do? What's your line of reasoning for that change? |
If I understand correctly, that line computes the default value for Is there anything that I got wrong? |
I think this is related to an issue I had: A time a little less than 24 full hours was listed as "24 hours ago" rather than "1 day ago". But when I changed the Hours unit to have a maxQuantity of 23, I got a null error, presumably from the duration estimator not knowing how to fill in the time? The null was specifically on this line of PrettyTime:
|
Issue cleanup Thanks for filing this issue. We are cleaning old issues from the repository. If the issue is still reproducible, please re-open with a test case to reproduce the behavior. |
I believe that my script from #124 still reproduces the issue. |
I find it weird, that a difference of "almost 7 full days" is formatted as "7 days ago", whereas a difference of "a little more than 7 full days" if formatted as "a week ago".
Seeing items beside each other makes a user wonder what's going on.
I hope the example describes the issue. Probably this issue exists for any time units, where the quantity is just below 0, the next lower time unit is used, and when it reaches 1, the higher time unit is used.
I would suggest to round the quantity to the next aligned value of the lower time unit (days) before sending it to the higher time unit (week) for a check. Not sure how this can be done in the code.
The text was updated successfully, but these errors were encountered: