-
-
Notifications
You must be signed in to change notification settings - Fork 36
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 IsDate feature #20
Conversation
Codecov Report
@@ Coverage Diff @@
## main #20 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 9 9
Lines 559 584 +25
Branches 145 153 +8
=========================================
+ Hits 559 584 +25
Continue to review full report at Codecov.
|
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 so much!
The first meaningful external contribution to this library means a lot.
Mostly LGTM, just a few things to tweak.
We should also add IsToday
like IsNow
, feel free to do that in this PR or I can add it seprately.
dirty_equals/_datetime.py
Outdated
lt: Optional[date] = None, | ||
ge: Optional[date] = None, | ||
le: Optional[date] = None, | ||
unix_number: bool = False, |
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.
I think we should remove this option, it doesn't really make sense to use unix timestamps with dates.
dirty_equals/_datetime.py
Outdated
""" | ||
|
||
if isinstance(delta, timedelta): | ||
delta = timedelta(days=delta.days) |
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.
perhaps a comment here explaining why this is necessary.
dirty_equals/_datetime.py
Outdated
""" | ||
Args: | ||
approx: A value to approximately compare to. | ||
delta: The allowable different when comparing to the value to `approx`, if omitted 2 seconds is used, |
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.
not sure 2 seconds really makes much sense here, I guess should be zero.
dirty_equals/_datetime.py
Outdated
) | ||
|
||
def prepare(self, other: Any) -> date: | ||
if isinstance(other, date): |
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.
😆 potential mistake here! datetime
is a subclass of date
, so isinstance(datetime.now(), date)
is True
.
if isinstance(other, date): | |
if type(other) == date: |
Is probably simplest.
format_string: Optional[str] = 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.
you need to add IsDate
to the docs, probably add it after this line.
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.
only docs remained in todo. I'll do it in an available time.
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.
this still needs adding, should be two lines.
@samuelcolvin Thanks for your reviews and valuable recommendations. I'll prepare a fix for bugs you found and add IsToday similar to IsNow. |
format_string: Optional[str] = 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.
this still needs adding, should be two lines.
thanks so much. |
No description provided.