diff --git a/resources/lib/backup.py b/resources/lib/backup.py index 5483396..93387b8 100644 --- a/resources/lib/backup.py +++ b/resources/lib/backup.py @@ -428,7 +428,7 @@ class XbmcBackup: date_time = datetime(int(dirName[0:4]),int(dirName[4:6]),int(dirName[6:8]),int(dirName[8:10]),int(dirName[10:12])) #format the string based on region settings - result = "%s %s" % (date_time.strftime(xbmc.getRegion('dateshort')),date_time.strftime(xbmc.getRegion('time'))) + result = utils.getRegionalTimestamp(date_time, ['dateshort','time']) return result diff --git a/resources/lib/utils.py b/resources/lib/utils.py index fc921ea..1f4aa0e 100644 --- a/resources/lib/utils.py +++ b/resources/lib/utils.py @@ -29,6 +29,14 @@ def setSetting(name,value): def getString(string_id): return __Addon.getLocalizedString(string_id) +def getRegionalTimestamp(date_time,dateformat=['dateshort']): + result = '' + + for aFormat in dateformat: + result = result + ("%s " % date_time.strftime(xbmc.getRegion(aFormat))) + + return result.strip() + def encode(string): result = '' diff --git a/scheduler.py b/scheduler.py index 431c9d7..cf9adb1 100644 --- a/scheduler.py +++ b/scheduler.py @@ -1,7 +1,7 @@ import xbmc import xbmcvfs import xbmcgui -import datetime +from datetime import datetime import time import resources.lib.utils as utils from resources.lib.croniter import croniter @@ -123,12 +123,12 @@ class BackupScheduler: #find the cron expression and get the next run time cron_exp = self.parseSchedule() - cron_ob = croniter(cron_exp,datetime.datetime.fromtimestamp(now)) + cron_ob = croniter(cron_exp,datetime.fromtimestamp(now)) new_run_time = cron_ob.get_next(float) if(new_run_time != self.next_run): self.next_run = new_run_time - utils.log("scheduler will run again on " + datetime.datetime.fromtimestamp(self.next_run).strftime('%m-%d-%Y %H:%M')) + utils.log("scheduler will run again on " + utils.getRegionalTimestamp(datetime.fromtimestamp(self.next_run),['dateshort','time'])) #write the next time to a file fh = xbmcvfs.File(self.next_run_path, 'w') @@ -137,7 +137,7 @@ class BackupScheduler: #only show when not in silent mode if(progress_mode != 2): - utils.showNotification(utils.getString(30081) + " " + datetime.datetime.fromtimestamp(self.next_run).strftime('%m-%d-%Y %H:%M')) + utils.showNotification(utils.getString(30081) + " " + utils.getRegionalTimestamp(datetime.fromtimestamp(self.next_run),['dateshort','time'])) def settingsChanged(self): current_enabled = utils.getSetting("enable_scheduler")