mirror of
https://github.com/beetbox/beets.git
synced 2025-12-24 09:33:46 +01:00
Python 2.6 compatibility for date queries.
The method datetime.timedelta.total_seconds() is only available since 2.7.
This commit is contained in:
parent
64fdd174b3
commit
cf0a10b652
1 changed files with 8 additions and 1 deletions
|
|
@ -331,7 +331,14 @@ class FalseQuery(Query):
|
|||
|
||||
def _to_epoch_time(date):
|
||||
epoch = datetime.fromtimestamp(0)
|
||||
return int((date - epoch).total_seconds())
|
||||
delta = date - epoch
|
||||
try:
|
||||
return int((delta).total_seconds())
|
||||
except AttributeError:
|
||||
# datetime.timedelta.total_seconds() is not available on Python 2.6
|
||||
return int((delta.microseconds
|
||||
+ (delta.seconds + delta.days * 24 * 3600) * 10 ** 6)
|
||||
/ 10.0 ** 6)
|
||||
|
||||
|
||||
def _parse_periods(pattern):
|
||||
|
|
|
|||
Loading…
Reference in a new issue