Rounded date/time

Asked by Nate Walker

Suggest swapping
            self.stop_event.wait(3600)
to
            currentMin_int = int(strftime("%M"))
            currentSec_int = int(strftime("%S"))
            timeToWait = 3600 - (currentSec_int + (currentMin_int * 60))
            self.stop_event.wait(timeToWait)
to allow the wallpaper to update on the hour, no matter what time the app is started
(obviously
from time import strftime
will have to be included as well, but combine this with the nicer date format fix i suggested it would all work out nicely :D )

Question information

Language:
English Edit question
Status:
Answered
For:
Weather wallpaper Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Raúl González Duque (zootropo) said :
#1

The problem is that NOAA reports don't update at 10 o'clock exactly, they may be updated at 10:05, 10:12...
And I don't know if all of them update at the same time.

There should be a value at the NOAA data file telling you when to go back to check for the new values...

Revision history for this message
Nate Walker (kiwinewt) said :
#2

report.getTime().split(' ')[1] will get the time it was created (with the date and time zone subtracted). This may be practically any time zone, depending on how each report is done.
One way around this may be to update every 15min? This likely wouldn't have much effect on the servers, and would mean that the information is always up to date for the user (and its always good to see the time increasing on the output, even if it has nothing else new to show, as the background picture is more likely to change on time as well)
Can be done by:
            currentMin_int = int(strftime("%M"))
            while currentMin_int > 15:
                currentMin_int -= 15
            currentSec_int = int(strftime("%S"))
            timeToWait = 900 -(currentSec_int + (currentMin_int * 60) )
Probably not the fastest or tidiest way to do it but it works

Revision history for this message
Nate Walker (kiwinewt) said :
#3

that code has a bug. it should be:
              while currentMin_int >= 15:
as if the time is xx:15/30/45 the timeToWait becomes less than 0
this sets the currentMin_int on a xx:15/30/45 to 0, therefore giving a full 15min wait before the next update

Revision history for this message
Raúl González Duque (zootropo) said :
#4

I just changed it to 900 seconds. Thanks Nate.

Can you help with this problem?

Provide an answer of your own, or ask Nate Walker for more information if necessary.

To post a message you must log in.