OpenSprinkler Forums Hardware Questions OpenSprinkler Pi (OSPi) OpenSprinkler Interval Program now available for OSPi! Re: Re: OpenSprinkler Interval Program now available for OSPi!

#24447

Andrew
Participant

Hi Dan,

I’ve updated to the 10/July/2013 code and the program preview is wrong for our timezone (GMT+10). It believes that the today is tomorrow for the red line and the header at the top says “Program Preview of Tue Jul 16 2013” which is correct but using the url for /gp?d=17 (ie tomorrow) gives “Program Preview of Today” and shows the red line on it. There was the same issue some time ago on the regular OpenSprinkler that Ray corrected in the javascript. Not a big problem to live with though.

But I do still have a concern with trying to deal with timezones and time calculations in the code. The OS already knows the timezone and calculates the localtime accordingly. It handles daylight savings where appropriate and changes when local governments change these. Trying to duplicate all of that in the python code is fraught with problems as we’ve seen. And if you happen to miss the configuration setting in the options screen, as I did between one of the updates recently, you get very weird results of some things running generally as you would expect but then somethings run on the wrong days if the timezone settings line up badly, etc.

Can you see any problems with changing all references to time.time() to time.localtime() and remove all the timezone calculations?

I notice code like this:

dse = int((time.time()-time.timezone)/86400) # days since epoch

which doesn’t take DST into account which should become more accurate too.

There may be some places where time.time() needs to be outputted to the web to maintain compatibility with the standard OpenSprinkler javascript but I haven’t looked at how it handles the times to be sure.

Andrew
P.S. I hope I haven’t sounded to rude here. I am extremely impressed with the work you have done.