]> err.no Git - util-linux/commitdiff
rtcwake: fix UTC time usage
authorDavid Brownell <david-b@pacbell.net>
Sun, 3 Feb 2008 23:34:35 +0000 (15:34 -0800)
committerKarel Zak <kzak@redhat.com>
Fri, 8 Feb 2008 00:33:39 +0000 (01:33 +0100)
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>
sys-utils/rtcwake.c

index 5fbd6da77d62b3792998b36663f8d2c971f54660..d9c9fbbf40650795072735268df3fd88d13b9881 100644 (file)
@@ -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;