mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Properly handle timestamp conversion
This commit is contained in:
parent
f959113694
commit
f6da23e1aa
1 changed files with 9 additions and 1 deletions
|
@ -18,6 +18,8 @@ Module to provide redis functionality to Salt
|
|||
# Import Python libs
|
||||
from __future__ import absolute_import
|
||||
from salt.ext.six.moves import zip
|
||||
from salt.ext import six
|
||||
from datetime import datetime
|
||||
|
||||
# Import third party libs
|
||||
try:
|
||||
|
@ -513,8 +515,14 @@ def lastsave(host=None, port=None, db=None, password=None):
|
|||
|
||||
salt '*' redis.lastsave
|
||||
'''
|
||||
# Use of %s to get the timestamp is not supported by Python. The reason it
|
||||
# works is because it's passed to the system strftime which may not support
|
||||
# it. See: https://stackoverflow.com/a/11743262
|
||||
server = _connect(host, port, db, password)
|
||||
return int(server.lastsave().strftime("%s"))
|
||||
if six.PY2:
|
||||
return int((server.lastsave() - datetime(1970, 1, 1)).total_seconds())
|
||||
else:
|
||||
return int(server.lastsave().timestamp())
|
||||
|
||||
|
||||
def llen(key, host=None, port=None, db=None, password=None):
|
||||
|
|
Loading…
Add table
Reference in a new issue