Comparing dates in a Python Script
Posted: Fri Mar 22, 2019 4:49 am
I am trying to compare two dates (as an Action, Execute Script, Python). In short, what I want to achieve is if the current date (taken from the Indigo Server) is less than a variable (which is entered as dd/mm/yyyy), then it sets another variable to Yes (and if not, it sets that variable to No). I wrote the following, but am getting errors (see below)
The first error I get is:
and if I take out the
Any ideas?
- Code: Select all
import datetime
SchoolHolidayExpiration = indigo.variables[1189488181].value
currentDate = indigo.server.getTime().date()
indigo.server.log(SchoolHolidayExpiration)
indigo.server.log(currentDate)
if currentDate <= SchoolHolidayExpiration:
indigo.variable.updateValue(815180286, value=Yes)
else:
indigo.variable.updateValue(815180286, value=No)
The first error I get is:
Script Error embedded script: Python argument types in
ServerInfo.log(datetime.date)
did not match C++ signature:
log(CCString message, CCString type='', bool isError=False)
Script Error Exception Traceback (most recent call shown last):
embedded script, line 7, at top level
ArgumentError: Python argument types in
ServerInfo.log(datetime.date)
did not match C++ signature:
log(CCString message, CCString type='', bool isError=False)
and if I take out the
, then I simply getindigo.server.log(currentDate)
TypeError: can't compare datetime.date to unicode
Any ideas?