37 lines
964 B
Python
37 lines
964 B
Python
|
from CryptoBoxExceptions import CBPluginActionError
|
||
|
|
||
|
|
||
|
def prepareForm(hdf, cbox):
|
||
|
date = __getCurrentDate()
|
||
|
hdf["Data.Modules.date.year"] = date.year
|
||
|
hdf["Data.Modules.date.month"] = date.month
|
||
|
hdf["Data.Modules.date.day"] = date.day
|
||
|
hdf["Data.Modules.date.hour"] = date.hour
|
||
|
hdf["Data.Modules.date.minute"] = date.minute
|
||
|
|
||
|
|
||
|
def doAction(cbox, store=None, year=0, month=0, day=0, hour=0, minute=0):
|
||
|
import datetime
|
||
|
if store:
|
||
|
try:
|
||
|
year, month, day = int(year), int(month), int(day)
|
||
|
hour, minute = int(hour), int(minute)
|
||
|
new_date = datetime.datetime(year, month, day, hour, minute)
|
||
|
except ValueError:
|
||
|
raise CBPluginActionError, "InvalidDate"
|
||
|
# TODO: how to set the current time? (and how to become root?)
|
||
|
## we will continue with the system menue
|
||
|
return "form_system"
|
||
|
else:
|
||
|
return "form_date"
|
||
|
|
||
|
|
||
|
def getStatus(cbox):
|
||
|
return str(__getCurrentDate())
|
||
|
|
||
|
|
||
|
def __getCurrentDate():
|
||
|
import datetime
|
||
|
return datetime.datetime(2000,1,1).now()
|
||
|
|