mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-15 09:42:57 -07:00
Update timestamp helper functions
This commit is contained in:
parent
b54576f08f
commit
4285b55c15
3 changed files with 15 additions and 15 deletions
|
@ -269,9 +269,9 @@ def make_backup(cleanup=False, scheduler=False):
|
|||
""" Makes a backup of config file, removes all but the last 5 backups """
|
||||
|
||||
if scheduler:
|
||||
backup_file = 'config.backup-{}.sched.ini'.format(helpers.now(no_sep=True))
|
||||
backup_file = 'config.backup-{}.sched.ini'.format(helpers.now())
|
||||
else:
|
||||
backup_file = 'config.backup-{}.ini'.format(helpers.now(no_sep=True))
|
||||
backup_file = 'config.backup-{}.ini'.format(helpers.now())
|
||||
backup_folder = plexpy.CONFIG.BACKUP_DIR
|
||||
backup_file_fp = os.path.join(backup_folder, backup_file)
|
||||
|
||||
|
|
|
@ -292,9 +292,9 @@ def make_backup(cleanup=False, scheduler=False):
|
|||
plexpy.NOTIFY_QUEUE.put({'notify_action': 'on_plexpydbcorrupt'})
|
||||
|
||||
if scheduler:
|
||||
backup_file = 'tautulli.backup-{}{}.sched.db'.format(helpers.now(no_sep=True), corrupt)
|
||||
backup_file = 'tautulli.backup-{}{}.sched.db'.format(helpers.now(), corrupt)
|
||||
else:
|
||||
backup_file = 'tautulli.backup-{}{}.db'.format(helpers.now(no_sep=True), corrupt)
|
||||
backup_file = 'tautulli.backup-{}{}.db'.format(helpers.now(), corrupt)
|
||||
backup_folder = plexpy.CONFIG.BACKUP_DIR
|
||||
backup_file_fp = os.path.join(backup_folder, backup_file)
|
||||
|
||||
|
|
|
@ -213,25 +213,25 @@ def today():
|
|||
return yyyymmdd
|
||||
|
||||
|
||||
def now(no_sep=False):
|
||||
now = datetime.datetime.now()
|
||||
if no_sep:
|
||||
return now.strftime("%Y%m%d%H%M%S")
|
||||
return now.strftime("%Y-%m-%d %H:%M:%S")
|
||||
|
||||
|
||||
def utc_now_iso():
|
||||
utcnow = datetime.datetime.utcnow()
|
||||
|
||||
return utcnow.isoformat()
|
||||
|
||||
|
||||
def timestamp_to_YMD(timestamp):
|
||||
return timestamp_to_datetime(timestamp).strftime("%Y-%m-%d")
|
||||
def now(sep=False):
|
||||
return timestamp_to_YMDHMS(timestamp(), sep=sep)
|
||||
|
||||
|
||||
def timestamp_to_datetime(timestamp):
|
||||
return datetime.datetime.fromtimestamp(cast_to_int(str(timestamp)))
|
||||
def timestamp_to_YMDHMS(ts, sep=False):
|
||||
dt = timestamp_to_datetime(ts)
|
||||
if sep:
|
||||
return dt.strftime("%Y-%m-%d %H:%M:%S")
|
||||
return dt.strftime("%Y%m%d%H%M%S")
|
||||
|
||||
|
||||
def timestamp_to_datetime(ts):
|
||||
return datetime.datetime.fromtimestamp(ts)
|
||||
|
||||
|
||||
def iso_to_YMD(iso):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue