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

Add comparison of DateTime() #20

Open
jeanconn opened this issue Jun 16, 2015 · 3 comments
Open

Add comparison of DateTime() #20

jeanconn opened this issue Jun 16, 2015 · 3 comments

Comments

@jeanconn
Copy link
Contributor

It would perhaps be safer if full comparison operators were supported without explicitly casting to a type.

In [55]: d.date
Out[55]: '2015:167:17:53:01.588'

In [56]: m.date
Out[56]: '2015:168:17:53:10.701'

In [57]: d > m
Out[57]: True

In [58]: d.secs > m.secs
Out[58]: False
@taldcroft
Copy link
Member

👍

It is scary that this meaningless comparison gives a result.

@jeanconn
Copy link
Contributor Author

Yes, support or an error would be great

@taldcroft
Copy link
Member

Some variation on:

def __ge__(self, other):
    if not isinstance(other, DateTime):
        other = DateTime(other)
    return self - other >= 0

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

No branches or pull requests

2 participants