@@ -229,31 +229,14 @@ def _to_ordinalf(dt):
229
229
rdt = datetime .datetime .combine (cdate , midnight_time )
230
230
231
231
# Append the seconds as a fraction of a day
232
- base += _total_seconds (dt - rdt ) / SEC_PER_DAY
232
+ base += (dt - rdt ). total_seconds ( ) / SEC_PER_DAY
233
233
234
234
return base
235
235
236
236
237
237
# a version of _to_ordinalf that can operate on numpy arrays
238
238
_to_ordinalf_np_vectorized = np .vectorize (_to_ordinalf )
239
239
240
- try :
241
- # Available as a native method in Python >= 2.7.
242
- _total_seconds = datetime .timedelta .total_seconds
243
- except AttributeError :
244
- def _total_seconds (tdelta ):
245
- """
246
- Alias providing support for datetime.timedelta.total_seconds() function
247
- calls even in Python < 2.7.
248
-
249
- The input `tdelta` is a datetime.timedelta object, and returns a float
250
- containing the total number of seconds representing the `tdelta`
251
- duration. For large durations (> 270 on most platforms), this loses
252
- microsecond accuracy.
253
- """
254
- return (tdelta .microseconds +
255
- (tdelta .seconds + tdelta .days * SEC_PER_DAY ) * 1e6 ) * 1e-6
256
-
257
240
258
241
def _from_ordinalf (x , tz = None ):
259
242
"""
@@ -433,7 +416,7 @@ def drange(dstart, dend, delta):
433
416
"""
434
417
f1 = _to_ordinalf (dstart )
435
418
f2 = _to_ordinalf (dend )
436
- step = _total_seconds ( delta ) / SEC_PER_DAY
419
+ step = delta . total_seconds ( ) / SEC_PER_DAY
437
420
438
421
# calculate the difference between dend and dstart in times of delta
439
422
num = int (np .ceil ((f2 - f1 ) / step ))
@@ -1062,8 +1045,8 @@ def get_locator(self, dmin, dmax):
1062
1045
numDays = tdelta .days # Avoids estimates of days/month, days/year
1063
1046
numHours = (numDays * HOURS_PER_DAY ) + delta .hours
1064
1047
numMinutes = (numHours * MIN_PER_HOUR ) + delta .minutes
1065
- numSeconds = np .floor (_total_seconds ( tdelta ))
1066
- numMicroseconds = np .floor (_total_seconds ( tdelta ) * 1e6 )
1048
+ numSeconds = np .floor (tdelta . total_seconds ( ))
1049
+ numMicroseconds = np .floor (tdelta . total_seconds ( ) * 1e6 )
1067
1050
1068
1051
nums = [numYears , numMonths , numDays , numHours , numMinutes ,
1069
1052
numSeconds , numMicroseconds ]
@@ -1403,7 +1386,7 @@ def _close_to_dt(d1, d2, epsilon=5):
1403
1386
Assert that datetimes *d1* and *d2* are within *epsilon* microseconds.
1404
1387
"""
1405
1388
delta = d2 - d1
1406
- mus = abs (_total_seconds ( delta ) * 1e6 )
1389
+ mus = abs (delta . total_seconds ( ) * 1e6 )
1407
1390
assert mus < epsilon
1408
1391
1409
1392
0 commit comments