-
Notifications
You must be signed in to change notification settings - Fork 44
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
Refactor fmt_time
, fmt_date
and fmt_datetime
#290
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #290 +/- ##
==========================================
- Coverage 81.71% 81.68% -0.03%
==========================================
Files 41 41
Lines 4325 4287 -38
==========================================
- Hits 3534 3502 -32
+ Misses 791 785 -6 ☔ View full report in Codecov by Sentry. |
@rich-iannone can you verify that |
I mostly wanted to make sure that
So I think the code change is great here. Thanks, @jrycw ! |
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.
LGTM!
Please correct me if I'm mistaken, but it seems you're testing |
@jrycw you are right. I mistakenly thought that With that change, the following code works:
This seems like a good improvement because the first and last cases failed before, but they provide formatted output now (and they work as can be expected). To do this, I renamed def _iso_str_to_datetime(x: str) -> datetime:
"""
Converts a string in ISO format to a datetime object.
Args:
x (str): The string to be converted.
Returns:
datetime: The converted datetime object.
"""
return datetime.fromisoformat(x) The code in # If `x` is a string, assume it is an ISO datetime string and convert it to a datetime object
if isinstance(x, str):
# Convert the ISO datetime string to a datetime object
x = _iso_str_to_datetime(x) @jrycw @machow does this change make sense? I could push the changes to the branch (or you could modify). Also, some new test cases are needed here. |
LGTM! If @machow is also on board with this, could @rich-iannone push your changes to the branch? I'll then proceed to add the relevant tests based on your demonstration. |
This sounds good to me! |
Related to #299, it turns out we could make similar modifications to
I believe the modifications are correct, but please feel free to correct any mistakes I may have made. |
This might sound a bit wild, but I just discovered a similar function called
|
fmt_date
and fmt_datetime
fmt_time
, fmt_date
and fmt_datetime
I attempted to remove |
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.
LGTM!
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.
Thanks for this! I haven't followed too closely, but the tests seem to cover big cases!
Related to #222 , I'm thinking we could possibly delegate the validation of lifts to the built-in
datetime.datetime.fromisoformat
function.Fixes: #299