|
|
|
|
|
by calpaterson
3596 days ago
|
|
datetime.timedelta internally uses a triple of (days,seconds,microseconds) to represent it's data and exposes that to users of the class. That a timedelta can be represented in multiple ways is alone quite surprising but some of the representations that happen can be very confusing. I think the example I gave which represents "-1 day and a few microseconds" as "-2 days + 86399 milliseconds + 999969 microseconds" is very surprising and it commonly happens in practice. For comparison, here's what postgres does: postgres=> select now() - (now() + '12 milliseconds'::interval + '1 day'::interval);
?column?
-----------------------
-1 days -00:00:00.012
(1 row)
|
|