kennethreitz / maya

Datetimes for Humans™
MIT License
3.41k stars 199 forks source link

Equality Comparison (and Others) Disregard Microseconds #156

Open DavidMuller opened 6 years ago

DavidMuller commented 6 years ago

The equality operators (e.g. __eq__) and other properties (e.g. .epoch) seem to ignore + truncate microseconds:

In [2]: m1, m2 = maya.now(), maya.now()

In [3]: m1
Out[3]: <MayaDT epoch=1527031930.399905>

In [4]: m2
Out[4]: <MayaDT epoch=1527031930.399909>

In [5]: m1 == m2
Out[5]: True

In [6]: m1.datetime() == m2.datetime()
Out[6]: False

In [7]: m1.epoch
Out[7]: 1527031930

Is this microsecond truncation behavior intentional? It seems to disagree with datetime's microsecond treatment, with the __repr__ of MayaDT itself, and with other MayaDT methods (e.g. .datetime(), . iso8601(), and of course .microsecond)

Thanks for this package!

timofurrer commented 6 years ago

Is this microsecond truncation behavior intentional?

I'm not entirely sure about this. The only reference in the commit history I could find was about simplifying the test suite - which is kinda strange ;)

I've committed #157 to be at least compatible with Python's datetime comparison methods. However, I'm not entirely sure how to deal with MayaDT.epoch. The POSIX timestamp / UNIX epoch is usually specified in seconds and not microseconds.

DavidMuller commented 6 years ago

Thanks for the update @timofurrer -- I'll follow along with the discussion in PR #157

github-actions[bot] commented 4 years ago

This Issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days

github-actions[bot] commented 4 years ago

This Issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days

github-actions[bot] commented 4 years ago

This Issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days