-1

In the example below - I'm getting a value for seconds that do not match the microseconds. It is baffling me. Can anyone shed a light?

>>> a
datetime.datetime(2019, 9, 13, 21, 47, 46, 837435, tzinfo=<UTC>)
>>> b
datetime.datetime(2019, 9, 13, 21, 47, 54, 724570, tzinfo=<UTC>)
>>> (b-a).microseconds
887135
>>> (b-a).seconds
7
>>> (b-a)
datetime.timedelta(seconds=7, microseconds=887135)
martineau
  • 119,623
  • 25
  • 170
  • 301
David
  • 47
  • 9

2 Answers2

1

Microseconds is not the delta in microseconds, it is the non-integer reminder in microseconds. The time difference is 7 seconds and 887135 microseconds

Lior Cohen
  • 5,570
  • 2
  • 14
  • 30
0

I just realized that (b-a).seconds is not supposed to the equivalent of (b-a).microseconds. The exact time difference here is (b-a).seconds + (b-a).microseconds.

David
  • 47
  • 9