Skip to content
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

Fix wrong sign with negative zero hour timediff. Fixes #63 #64

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

tyzhnenko
Copy link
Contributor

Checking timediff sign by dash in first character of hour variable instead of comparison with zero.

if h[0] == '-':
isNegative = True
else:
isNegative = False
h, m, s, ms = int(h), int(m), int(s), int(ms)
td = timedelta(hours=abs(h), minutes=m, seconds=s,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel following is better.

h, m, s, ms = abs(int(h)), int(m), int(s), int(ms)
td = timedelta(hours=h, minutes=m, seconds=s microseconds=ms)

Because to know "sign of h is meaningless", I should look abs(h) and h is never used after that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Fix it.

@methane
Copy link
Collaborator

methane commented Jun 6, 2014

For your and my information, I've merged this to mysqlclient-python.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants