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
Last touches #1874
Last touches #1874
Conversation
Ready for review: @ElDeveloper and @josenavas |
@@ -1359,10 +1359,27 @@ def validate(self, restriction_dict): | |||
if datatype == datetime: | |||
val = str(val) | |||
try: | |||
datetime.strptime(val, '%m/%d/%y %H:%M:%S') | |||
datetime.strptime(val, '%m/%d/%Y %H:%M:%S') |
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.
Argh! That hurts! So sad that datetime doesn't support the "or" operator. What about something like this?
formats = ['%m/%d/%Y %H:%M:%S', '%m/%d/%Y %H:%M', '%m/%d/%Y %H', '%m/%d/%Y', '%m/%Y', '%Y']
dt = None
for fmt in formats:
try:
dt = datetime.strptime(val, fmt)
except ValueError:
pass
if dt is None:
warning_msg.append(....)
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.
😱
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.
Like it, will change.
Thanks @antgonza few comments |
👍 |
👍 given tests pass |
@antgonza there are a couple of real errors in here. Should be easy to fix though. |
Thanks, just pushed the fixes. |
Changes Unknown when pulling b47e486 on antgonza:last-touches into * on biocore:str-ing_info_fles*. |
Still missing the timestamp fix but want to see how the tests go ...