From 892ba4f26afff2498f9f35b986d232d20e2e2541 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 19 Nov 2015 15:12:40 -0600 Subject: [PATCH] DS1307: Change year bias to 1968 which is a leap year juse like 2000 --- drivers/timers/ds3231.c | 10 ++++++---- sched/clock/clock_initialize.c | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/timers/ds3231.c b/drivers/timers/ds3231.c index 9704a7a2c7..c00b5e11a6 100644 --- a/drivers/timers/ds3231.c +++ b/drivers/timers/ds3231.c @@ -392,9 +392,11 @@ int up_rtc_getdatetime(FAR struct tm *tp) tp->tm_year = tmp + 100; } #else - /* No century indicator. The RTC will hold years since 1970 */ + /* No century indicator. The RTC will hold years since 1968 (a leap year like + * 2000) + */ - tp->tm_year = tmp + 70; + tp->tm_year = tmp + 68; #endif rtc_dumptime(tp, "Returning"); @@ -512,10 +514,10 @@ int up_rtc_settime(FAR const struct timespec *tp) } #else - /* Use years since 1970 */ + /* Use years since 1968 (a leap year like 2000) */ century = 0; - year = newtm.tm_year - 70; + year = newtm.tm_year - 68; #endif /* Save the month (1-12) with century */ diff --git a/sched/clock/clock_initialize.c b/sched/clock/clock_initialize.c index de855e3bc6..11d889f6d0 100644 --- a/sched/clock/clock_initialize.c +++ b/sched/clock/clock_initialize.c @@ -201,11 +201,11 @@ static void clock_inittime(void) void clock_initialize(void) { +#if defined(CONFIG_RTC) && !defined(CONFIG_RTC_EXTERNAL) /* Initialize the internal RTC hardware. Initialization of external RTC * must be deferred until the system has booted. */ -#if defined(CONFIG_RTC) && !defined(CONFIG_RTC_EXTERNAL) up_rtcinitialize(); #endif