Comment 33 for bug 1095187

Revision history for this message
newbuntu (dsglass) wrote :

After looking into the details of how Ubuntu maintains the hardware vs. system clock, I believe I have fixed this - you do need to check whether the hardware clock is kept in UTC or not, but time zone also comes into play. Basically, setalarm normally calculates the wake time in UTC (date +%s), and so if the hardware clock is in UTC, setting this time directly works no matter what time zone you are in. If the hardware clock is in local time, the /sys/class/rtc/rtc0/wakealarm file still requires UTC, so the wake time must be converted by the time zone offset. The new code checks whether the hardware clock is in UTC by comparing the hour and minute recorded in /sys/class/rtc/rtc0/time to that provided by `date +%H:%M`

I have tested the following changes to setalarm with my computer set to UTC and local time, in multiple time zones (including ones that are not whole hours, such as +530). It works across the board. Please comment if it does not work for you. I'm attaching a patch, which can be applied to the original setalarm file from wakeup-1.3 by running `sudo patch /usr/bin/setalarm setalarm031914.diff`