date: factor out date parsing (in preparation for touch -d)
[oweals/busybox.git] / util-linux / hwclock.c
index f226535fa4e89bc17317cfe0948e425cdcce5716..2cdb186c51ff226c8e8dce8a77e5d38b290dc30e 100644 (file)
@@ -8,7 +8,6 @@
 */
 
 #include <sys/utsname.h>
-#include <getopt.h>
 #include "libbb.h"
 #include "rtc_.h"
 
@@ -37,7 +36,10 @@ static void write_rtc(time_t t, int utc)
        struct tm tm;
        int rtc = rtc_xopen(&rtcname, O_WRONLY);
 
-       tm = *(utc ? gmtime(&t) : localtime(&t));
+       if (utc)
+               gmtime_r(&t, &tm);
+       else
+               localtime_r(&t, &tm);
        tm.tm_isdst = 0;
 
        xioctl(rtc, RTC_SET_TIME, &tm);
@@ -91,7 +93,7 @@ static void from_sys_clock(int utc)
 #define HWCLOCK_OPT_RTCFILE     0x20
 
 int hwclock_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
-int hwclock_main(int argc, char **argv)
+int hwclock_main(int argc UNUSED_PARAM, char **argv)
 {
        unsigned opt;
        int utc;