Comment 18 for bug 1095187

Revision history for this message
Eric-lind-7 (eric-lind-7) wrote : Re: Wakeup makes my computer wake up around midnight and not at 6h45 as I asked

Upon further examination of the other proposed fix:

# Get Time zone offset. As of Ubuntu 12.10, the wakealarm file is time in UTC.
tz=$(date +%:z)
tzhr=${tz:0:3}
tzmin=${tz:4:2}

# Actually set alarm #
settime=$(date -d "$(date -d @$wake_time) +$tzhr hours +$tzmin mins - $offset mins" +%s)
echo $settime > /sys/class/rtc/rtc0/wakealarm

I think that this may also have a problem.

date +%:z returns a numerical value that can be either positive or negative, but the substring tzmin doesn't preserve the sign value of tz so, for users with tz < 0 and tzmin /= 0, $tzhr hours + $tzmin mins will give an incorrect value.

For example:
tz=-05:31
tzhr=-05
tzmin=31

So,
$(date -d "$(date -d @$wake_time) +(-05) hours +31 mins" +%s) /= $(date -d "$(date -d @$wake_time) +(-05) hours +(-31) mins" +%s)

I'm not certain of the best way to address this yet but I'll keep thinking.

There is also another small problem with the sign which is, if tz > 0 then tzhr will have a colon in it. I'm not sure if this is really a problem or not but I thought it was worth pointing out.

Eric