diff --git a/configure.ac b/configure.ac index ae7cd238..58b78ac5 100644 --- a/configure.ac +++ b/configure.ac @@ -177,7 +177,7 @@ AC_ARG_WITH(plugin-path, [plugin_path=$withval], [plugin_path=yes]) AC_ARG_WITH(rtc-date, - AS_HELP_STRING([--with-rtc-date=DATE], [If RTC date/time is too old, restore to DATE, format "YYYY-MM-DD HH:MM", default "2000-01-01 00:00"]), + AS_HELP_STRING([--with-rtc-date=DATE], [If RTC date/time is too old, restore to DATE, format "YYYY-MM-DD HH:MM:SS", default "2000-01-01 00:00:00"]), [rtc_date=$withval], [rtc_date=no]) AC_ARG_WITH(rtc-file, @@ -282,7 +282,7 @@ AS_IF([test "x$with_random_seed" != "xno"], [ AC_DEFINE_UNQUOTED(RANDOMSEED, "$random_path", [Improve random at boot by seeding it with sth from before.])]) AS_IF([test "x$rtc_date" != "xno"], [ - AC_DEFINE(RTC_TIMESTAMP_CUSTOM, "$rtc_date", [Custom RTC restore date, default: 2000-01-01 00:00])], [ + AC_DEFINE_UNQUOTED(RTC_TIMESTAMP_CUSTOM, "$rtc_date", [Custom RTC restore date, default: 2000-01-01 00:00])], [ rtc_date=""]) AS_IF([test "x$rtc_file" != "xno"], [ diff --git a/plugins/rtc.c b/plugins/rtc.c index 9b4eeae5..a733f754 100644 --- a/plugins/rtc.c +++ b/plugins/rtc.c @@ -321,10 +321,12 @@ PLUGIN_INIT(plugin_init) { struct tm tm = { 0 }; - if (!strptime(rtc_timestamp, "%Y-%m-%d %H:%M", &tm)) - rtc_date_fallback = mktime(&tm); - else + if (!strptime(rtc_timestamp, RTC_FMT, &tm)) { + logit(LOG_ERR, "Invalid restore date '%s', reverting to '%s'", + rtc_timestamp, RTC_TIMESTAMP_BEGIN_2000); rtc_timestamp = RTC_TIMESTAMP_BEGIN_2000; + } else + rtc_date_fallback = mktime(&tm); uev_timer_init(ctx, &rtc_timer, update, NULL, RTC_PERIOD, RTC_PERIOD);