Thanks for the reminder, Ivor.
You don't have a .npa with a little script that gives "message.string_set(this_is_now)", do you?
As a non-Python person, I'm having a bit of difficulty getting it going.
I got this to work (emulated) with a 1sec Blinker on the input, but can't figure out how to force leading zeros and 2 digits (%02d seems like it should work....).
import time
if inputs[0].changed_get():
this_is_now = time.localtime()
hrs = str(this_is_now[3])
min = str(this_is_now[4])
sec = str(this_is_now[5])
message.string_set(hrs + ":" + min +":" + sec)
Then I got to this:
import time
if inputs[0].changed_get():
this_is_now = time.localtime()
nice_time = "%02d:%02d:%02d" % (this_is_now[3],this_is_now[4],this_is_now[5])
message.string_set(nice_time)
Later in the night, I played with strftime, but will have to wait until Monday to play with real hardware:
import time
if inputs[0].changed_get():
this_is_now = time.localtime()
the_time = time.strftime("%H:%M:%S", this_is_now)
date = time.strftime("%d %B %Y", this_is_now)
message.string_set(this_is_now)
outputs[0].string_set(the_time)
outputs[1].string_set(date)
if this_is_now[8] ==1:
outputs[2].string_set("Daylight Saving: YES")
else:
outputs[2].string_set("Daylight Saving: NO")
Worked with hardware!!
Any other suggestions? Or cautions??
Last edited by phils (2009-04-06 00:55:19)
"The single biggest problem in communication is the illusion that it has taken place."
- George Bernard Shaw