X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=drivers%2Frtc%2Fdate.c;h=c57317d2c267824b4c4a7f39a62e6918da98bd90;hb=8c56ea5c1e033f16993e5427300399ef848234bb;hp=bfa2e1378e22467cbe9c9049a868f7567ef46eee;hpb=45031f1a1e575bf2e5ceb3e6e9f5b8b09f4945a1;p=oweals%2Fu-boot.git diff --git a/drivers/rtc/date.c b/drivers/rtc/date.c index bfa2e1378e..c57317d2c2 100644 --- a/drivers/rtc/date.c +++ b/drivers/rtc/date.c @@ -1,8 +1,7 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * (C) Copyright 2001 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. - * - * SPDX-License-Identifier: GPL-2.0+ */ #include @@ -10,7 +9,8 @@ #include #include -#if defined(CONFIG_CMD_DATE) || defined(CONFIG_TIMESTAMP) +#if defined(CONFIG_CMD_DATE) || defined(CONFIG_DM_RTC) || \ + defined(CONFIG_TIMESTAMP) #define FEBRUARY 2 #define STARTOFTIME 1970 @@ -20,10 +20,6 @@ #define days_in_year(a) (leapyear(a) ? 366 : 365) #define days_in_month(a) (month_days[(a) - 1]) -static int month_days[12] = { - 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 -}; - static int month_offset[] = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 }; @@ -66,45 +62,6 @@ int rtc_calc_weekday(struct rtc_time *tm) return 0; } -int rtc_to_tm(int tim, struct rtc_time *tm) -{ - register int i; - register long hms, day; - - day = tim / SECDAY; - hms = tim % SECDAY; - - /* Hours, minutes, seconds are easy */ - tm->tm_hour = hms / 3600; - tm->tm_min = (hms % 3600) / 60; - tm->tm_sec = (hms % 3600) % 60; - - /* Number of years in days */ - for (i = STARTOFTIME; day >= days_in_year(i); i++) - day -= days_in_year(i); - tm->tm_year = i; - - /* Number of months in days left */ - if (leapyear(tm->tm_year)) - days_in_month(FEBRUARY) = 29; - for (i = 1; day >= days_in_month(i); i++) - day -= days_in_month(i); - days_in_month(FEBRUARY) = 28; - tm->tm_mon = i; - - /* Days are what is left over (+1) from all that */ - tm->tm_mday = day + 1; - - /* Zero unused fields */ - tm->tm_yday = 0; - tm->tm_isdst = 0; - - /* - * Determine the day of week - */ - return rtc_calc_weekday(tm); -} - /* * Converts Gregorian date to seconds since 1970-01-01 00:00:00. * Assumes input in normal date format, i.e. 1980-12-31 23:59:59