diff options
author | David Brownell | 2008-02-04 00:34:35 +0100 |
---|---|---|
committer | Karel Zak | 2008-02-08 01:33:39 +0100 |
commit | 1b7c164c494090b069b92ffe9457ef2c09e63832 (patch) | |
tree | 5bd3aa559a8bda8cd94a9541ca6ce8b11bde7b34 /sys-utils/rtcwake.c | |
parent | losetup: add --associated option (diff) | |
download | kernel-qcow2-util-linux-1b7c164c494090b069b92ffe9457ef2c09e63832.tar.gz kernel-qcow2-util-linux-1b7c164c494090b069b92ffe9457ef2c09e63832.tar.xz kernel-qcow2-util-linux-1b7c164c494090b069b92ffe9457ef2c09e63832.zip |
rtcwake: fix UTC time usage
Timezone handling is broken in this version since it's always
passing UTC time into the kernel, even on systems where the
RTC uses the local timezone.
I think that bug must come from bugs in how the system used to
to originally develop this code handled the RTC timezone. Both
RTCs should have been kept in UTC ... but only one of them was.
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Diffstat (limited to 'sys-utils/rtcwake.c')
-rw-r--r-- | sys-utils/rtcwake.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/sys-utils/rtcwake.c b/sys-utils/rtcwake.c index 5fbd6da77..d9c9fbbf4 100644 --- a/sys-utils/rtcwake.c +++ b/sys-utils/rtcwake.c @@ -187,7 +187,17 @@ static int setup_alarm(int fd, time_t *wakeup) struct tm *tm; struct rtc_wkalrm wake; - tm = gmtime(wakeup); + /* The wakeup time is in POSIX time (more or less UTC). + * Ideally RTCs use that same time; but PCs can't do that + * if they need to boot MS-Windows. Messy... + * + * When clock_mode == CM_UTC this process's timezone is UTC, + * so we'll pass a UTC date to the RTC. + * + * Else clock_mode == CM_LOCAL so the time given to the RTC + * will instead use the local time zone. + */ + tm = localtime(wakeup); wake.time.tm_sec = tm->tm_sec; wake.time.tm_min = tm->tm_min; |