-
Notifications
You must be signed in to change notification settings - Fork 464
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
apply PREFER_DAY_OF_MONTH in date.py #611
Conversation
Codecov Report
@@ Coverage Diff @@
## master #611 +/- ##
=========================================
+ Coverage 95.12% 95.2% +0.08%
=========================================
Files 302 302
Lines 2503 2505 +2
=========================================
+ Hits 2381 2385 +4
+ Misses 122 120 -2
Continue to review full report at Codecov.
|
(Explanation and example in a comment in the linked issue) |
@Gallaecio Currently, doing this: >>> dateparser.parse('02/2013', ['%m/%Y'])
datetime.datetime(2013, 2, 28, 0, 0) Is the same than doing this: >>> dateparser.parse('02/2013', '%m/%Y')
/home/marc/workprojects/dateparser/dateparser/date.py:142: FutureWarning: Date formats should be list, tuple or set of strings
warn(_DateLocaleParser.DATE_FORMATS_ERROR_MESSAGE, FutureWarning)
datetime.datetime(2013, 2, 28, 0, 0) (except for the deprecation warning). In the example in the issue, the second statement is
which is using the |
🤦♂️ |
dateparser/utils/__init__.py
Outdated
return calendar.monthrange(year, month)[1] | ||
|
||
|
||
def set_correct_day_from_settings(date_obj, settings, last_day=None, current_day=None): |
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.
💄 What about apply_day_of_the_month_from_settings
, to be consistent with apply_timezone_from_settings
?
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.
Hmmm... This was my first approach, but then I didn't like that naming. First of all "apply" seems to mean that you are "adding" something. It maybe has sense for the timezone, as sometimes you add it, but I'm not sure if this has sense for the day as what you are doing is to change it.
Secondly, apply_day_of_the_month_from_settings
seems to mean that it is getting the day from the settings; but what it is doing is using the rules in the settings to find the correct day.
For both reasons I prefer this naming: set_correct_day_from_settings
.
What do you think @Gallaecio ? Any better idea?
Note to self: I could also add a unit test for the function |
fixes #607