- Posted on
Sat Mar 28, 2020 1:43 pm
-
kw123
offline
-
- Posts: 8382
- Joined: May 12, 2013
- Location: Dallas, TX
-
1. what format is the date string in the variable?
2. the variable is a date STRING, not a datetime object
3. import datetime from datetime
then use datetime.now()
but thats just the start.
you should read on the datetime arithmetics .. and that is actually complicated
in principle:
import time
import datetime
1. get date time string from your variable
timeString = indigo.variables[27640136] .value
2. convert that string to "time since epoch" (the "%Y has to match the datetime string format in your variable)
timeWhenButtonPressed = time.mktime(time.strptime(timeString, "%Y-%m-%d-%H:%M:%S"))
deltaTime = time.time()- timeWhenButtonPressed
if deltaTime >1:
xx
else:
yy