Message244151
Here's what mxDateTime uses:
>>> import mx.DateTime
>>>
>>> t1 = mx.DateTime.DateTime(2012,6,30,23,59,60)
>>> t2 = mx.DateTime.DateTime(2012,7,1,0,0,0)
>>>
>>> t1
<mx.DateTime.DateTime object for '2012-06-30 23:59:60.00' at 7fbb36008d68>
>>> t2
<mx.DateTime.DateTime object for '2012-07-01 00:00:00.00' at 7fbb36008d20>
>>>
>>> t2-t1
<mx.DateTime.DateTimeDelta object for '00:00:00.00' at 7fbb35ff0540>
>>> (t2-t1).seconds
0.0
>>>
>>> t1 + mx.DateTime.oneSecond
<mx.DateTime.DateTime object for '2012-07-01 00:00:01.00' at 7fbb360083d8>
It preserves the broken down values, but uses POSIX days of 86400 seconds per day to calculate time deltas.
It's a compromise, not a perfect solution, but it prevents applications from failing for that one second every now and then.
I don't believe there is a perfect solution, since what your application or users expect may well be different. All I can say is that raising exceptions in these rare cases is not what your users typically want :-) |
|
Date |
User |
Action |
Args |
2015-05-27 09:12:20 | lemburg | set | recipients:
+ lemburg, belopolsky, vstinner, doughellmann, akira |
2015-05-27 09:12:20 | lemburg | set | messageid: <1432717940.06.0.148867122247.issue23574@psf.upfronthosting.co.za> |
2015-05-27 09:12:19 | lemburg | link | issue23574 messages |
2015-05-27 09:12:19 | lemburg | create | |
|