-
Notifications
You must be signed in to change notification settings - Fork 148
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
naturaldate returns ambiguous values #26
Comments
Following the same logic I would like to suggest deprecating month name abbreviations that are the current default. This can be implemented with backward compatibility option that would be to include an argument that allows passing the desired format string when calling the function: humanize.naturaldate(format="%b %d %Y) The default should be replaced by "%B %d %Y". |
I don't think this has anything to do with this bug, does it? (btw, I spotted a little typo in my text above. fixed) |
@dingens @ludstuen90 @tbille Right now in humanize 1.0, assuming today is Feb 02 2020, the inputs on the left produce the outputs on the right: (dt.date(2019, 2, 2), "Feb 02 2019"),
(dt.date(2019, 3, 2), "Mar 02"),
(dt.date(2019, 4, 2), "Apr 02"),
(dt.date(2019, 5, 2), "May 02"),
(dt.date(2019, 6, 2), "Jun 02"),
(dt.date(2019, 7, 2), "Jul 02"),
(dt.date(2019, 8, 2), "Aug 02"),
(dt.date(2019, 9, 2), "Sep 02"),
(dt.date(2019, 10, 2), "Oct 02"),
(dt.date(2019, 11, 2), "Nov 02"),
(dt.date(2019, 12, 2), "Dec 02"),
(dt.date(2020, 1, 2), "Jan 02"),
(dt.date(2020, 2, 2), "today"),
(dt.date(2020, 3, 2), "Mar 02"),
(dt.date(2020, 4, 2), "Apr 02"),
(dt.date(2020, 5, 2), "May 02"),
(dt.date(2020, 6, 2), "Jun 02"),
(dt.date(2020, 7, 2), "Jul 02"),
(dt.date(2020, 8, 2), "Aug 02"),
(dt.date(2020, 9, 2), "Sep 02"),
(dt.date(2020, 10, 2), "Oct 02"),
(dt.date(2020, 11, 2), "Nov 02"),
(dt.date(2020, 12, 2), "Dec 02"),
(dt.date(2021, 1, 2), "Jan 02"),
(dt.date(2021, 2, 2), "Feb 02 2021"), Would something like PR #107 be better? (dt.date(2019, 2, 2), "Feb 02 2019"),
(dt.date(2019, 3, 2), "Mar 02 2019"),
(dt.date(2019, 4, 2), "Apr 02 2019"),
(dt.date(2019, 5, 2), "May 02 2019"),
(dt.date(2019, 6, 2), "Jun 02 2019"),
(dt.date(2019, 7, 2), "Jul 02 2019"),
(dt.date(2019, 8, 2), "Aug 02 2019"),
(dt.date(2019, 9, 2), "Sep 02 2019"),
(dt.date(2019, 10, 2), "Oct 02"),
(dt.date(2019, 11, 2), "Nov 02"),
(dt.date(2019, 12, 2), "Dec 02"),
(dt.date(2020, 1, 2), "Jan 02"),
(dt.date(2020, 2, 2), "today"),
(dt.date(2020, 3, 2), "Mar 02"),
(dt.date(2020, 4, 2), "Apr 02"),
(dt.date(2020, 5, 2), "May 02"),
(dt.date(2020, 6, 2), "Jun 02"),
(dt.date(2020, 7, 2), "Jul 02"),
(dt.date(2020, 8, 2), "Aug 02 2020"),
(dt.date(2020, 9, 2), "Sep 02 2020"),
(dt.date(2020, 10, 2), "Oct 02 2020"),
(dt.date(2020, 11, 2), "Nov 02 2020"),
(dt.date(2020, 12, 2), "Dec 02 2020"),
(dt.date(2021, 1, 2), "Jan 02 2021"),
(dt.date(2021, 2, 2), "Feb 02 2021"), It uses So in this case, gives 4 months before without a year (Oct, Nov, Dev, Jan), and 5 months after without a year (Mar, Apr, May, Jun, Jul). Would that good enough or should it be more accurate? |
I'd suggest to add the year for all dates that are more than about five months away. This would lead to the following output:
(Even when only used for dates that are necessarily in the past, like "comment posted on ...", the current behaviour is not perfect: If I read "Jan 19" on Jan 18, 2015, I won't not assume it means Jan 19, 2014.)
The text was updated successfully, but these errors were encountered: