-
-
Notifications
You must be signed in to change notification settings - Fork 55
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
Add years and months to the human date formatter #425
Conversation
I'm not quite sure what the error in the CICD is about 🤔
|
Thanks for your contribution! Days, minutes, hours, and seconds have a more or less constant value, unlike months and years which can have different lengths (notwithstanding that we have them in Numbat as average values), so I think we might want to think twice about adding them to |
Also, please note that we have an open PR targeting |
This test makes sure that all modules can be used in a standalone way. You can reproduce the error in the following way: start numbat with the |
Yeah, I do think it makes sense considering those units already exist in numbat (and the documentation does have proper warnings about them being average value). To me As a side note on the subject, I was wondering if, for durations greater than a month, it would be more ergonomic to hide the hours, minutes and seconds, as
I added the management of the negative time to this pull request (I have used
Yep, thanks, I solved it ^^ |
I'm not completely sure about this. As @triallax mentioned, I'm with you (@ValentinLeTallec) that we're often just interested in a rough estimation. But in this case, I can already call We may want to have that same feature (split a time span into mixed units) for years/months/days as well, but then the imprecision bothers me. |
This comment was marked as duplicate.
This comment was marked as duplicate.
Yeah, it does make sens to keep precise measurements for the use case you are describing. I think the current version is more geared toward a My use case would be more something like :
Maybe we could separate it in two functionalities ? |
But in this exact use case, the imprecision actually bothers me. I don't want this to be off by 1 day. |
Then maybe more like that :
? |
Maybe we could keep the current format, but add something like "approx. 1 year, 6 months, 16 days" in parenthesis after the default output in case the time is larger than, say, 2 months? |
Yep, that does sounds good to me 🙂 |
For durations larger than 2 months, do you prefer :
or
? I personally prefer the second option as it is more concise and it avoids computing 2 times the days/hours/minutes/seconds which is more or less needed for the first option (at least in my implementation) |
I also prefer the second option, but I would only show months and years in parenthesis. For times smaller than 1 year (but larger than 2 months), I would only show months. For times smaller than 100 years, I would show years and months. For times larger than 100 years, I would only show years. Something like |
So to sum-up, we would have :
I feel like it would be in line with the desired accuracy to also display days for |
Why "only show months" here? I would think that we only show the latter part in this case.
Again, I'm skeptical. Imagine someone runs something like this:
If we do like you propose, we would not add "approx. 2 months", but "approx. 1 month + 29 days" instead. That is more correct if you know exactly what "1 month" represents in Numbat. But it's confusing if you interpret it in terms of calendar months. |
My bad, it's a typo from copy-pasting, I edited my message to strike through it.
But then what about cases where you are not so near one of the edges of the month ? Having :
rather than :
feels like a pretty big loss of accuracy in the approximation.
I think someone expecting calendar months will already be disturbed by the Especially, thanks to your previous suggestion, as we now have clear indication ( While
was indeed confusing, the new version is much clearer on what is an approximation
|
Sorry for dragging this out for so long.
Final alternative suggestion: how about decimal months? Rounded to one decimal, so we would see things like 1.4 months or 2.9 months) |
Yep, let do that |
78d94cc
to
b2410ca
Compare
time < 2 months show all 10 days + 2 hours + ... 2 months < time < 1 year only months (1 decimal) 65.12 days (approx. 2.2 months) 1 year < time < 100 years only years and months 710 days (approx. 1 year + 11 months) 100 year < time only years 71000 days (approx. 194 years)
New version with what we discussed ! |
@@ -20,19 +20,27 @@ assert_eq((1 day -> human), "1 day") | |||
assert_eq((1.37 day -> human), "1 day + 8 hours + 52 minutes + 48 seconds") | |||
|
|||
assert_eq((1 week -> human), "7 days") | |||
assert_eq((1.5 weeks -> human), "10 days + 12 hours") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this test missing now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because of #589 😅 , but with your answer there, I think I could improve the code here to have it work too 🙂 .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, fixed in 89a141b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the updates! Great change 👍
Hi, the current implementation of the
human
formatter uses days as its biggest unit, I added years and monthsBefore :
After :
P.S Love numbat ^^