mirror of
https://github.com/robweber/xbmcbackup.git
synced 2024-11-14 20:35:48 +01:00
added utils function for regional date, use for scheduler notifications as well
This commit is contained in:
parent
f0d8e297a9
commit
6c33e7c9ba
@ -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]))
|
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
|
#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
|
return result
|
||||||
|
|
||||||
|
@ -29,6 +29,14 @@ def setSetting(name,value):
|
|||||||
def getString(string_id):
|
def getString(string_id):
|
||||||
return __Addon.getLocalizedString(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):
|
def encode(string):
|
||||||
result = ''
|
result = ''
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import xbmc
|
import xbmc
|
||||||
import xbmcvfs
|
import xbmcvfs
|
||||||
import xbmcgui
|
import xbmcgui
|
||||||
import datetime
|
from datetime import datetime
|
||||||
import time
|
import time
|
||||||
import resources.lib.utils as utils
|
import resources.lib.utils as utils
|
||||||
from resources.lib.croniter import croniter
|
from resources.lib.croniter import croniter
|
||||||
@ -123,12 +123,12 @@ class BackupScheduler:
|
|||||||
#find the cron expression and get the next run time
|
#find the cron expression and get the next run time
|
||||||
cron_exp = self.parseSchedule()
|
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)
|
new_run_time = cron_ob.get_next(float)
|
||||||
|
|
||||||
if(new_run_time != self.next_run):
|
if(new_run_time != self.next_run):
|
||||||
self.next_run = new_run_time
|
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
|
#write the next time to a file
|
||||||
fh = xbmcvfs.File(self.next_run_path, 'w')
|
fh = xbmcvfs.File(self.next_run_path, 'w')
|
||||||
@ -137,7 +137,7 @@ class BackupScheduler:
|
|||||||
|
|
||||||
#only show when not in silent mode
|
#only show when not in silent mode
|
||||||
if(progress_mode != 2):
|
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):
|
def settingsChanged(self):
|
||||||
current_enabled = utils.getSetting("enable_scheduler")
|
current_enabled = utils.getSetting("enable_scheduler")
|
||||||
|
Loading…
Reference in New Issue
Block a user