aboutsummaryrefslogtreecommitdiff
path: root/lib/date.c
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2022-05-05 19:37:22 -0400
committerTom Rini <trini@konsulko.com>2022-05-05 19:37:22 -0400
commit03b873b4f41010e4f85a72dd59016bb0b123dde1 (patch)
tree3ea6ba397b9ce3db7286537be078944c6daa23b8 /lib/date.c
parent5d834bfa5fa61dc9dff94a92672c0a1185cb3a83 (diff)
parentaa5ea20c71921e062aa91d5c7f924cef5d742ec2 (diff)
Merge branch '2022-05-05-assorted-cleanups-and-fixes'
- Assorted minor code cleanups. - Clean-up the reset uclass code slightly and fix some issues with a lack of handlers for a case in the driver. - Y2038 RTC fix
Diffstat (limited to 'lib/date.c')
-rw-r--r--lib/date.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/lib/date.c b/lib/date.c
index c589d9ed3a..e3d22459cd 100644
--- a/lib/date.c
+++ b/lib/date.c
@@ -71,19 +71,16 @@ int rtc_calc_weekday(struct rtc_time *tm)
* -year / 100 + year / 400 terms, and add 10.]
*
* This algorithm was first published by Gauss (I think).
- *
- * WARNING: this function will overflow on 2106-02-07 06:28:16 on
- * machines where long is 32-bit! (However, as time_t is signed, we
- * will already get problems at other places on 2038-01-19 03:14:08)
*/
-unsigned long rtc_mktime(const struct rtc_time *tm)
+time64_t rtc_mktime(const struct rtc_time *tm)
{
int mon = tm->tm_mon;
int year = tm->tm_year;
- int days, hours;
+ unsigned long days;
+ time64_t hours;
mon -= 2;
- if (0 >= (int)mon) { /* 1..12 -> 11, 12, 1..10 */
+ if (0 >= mon) { /* 1..12 -> 11, 12, 1..10 */
mon += 12; /* Puts Feb last since it has leap day */
year -= 1;
}
@@ -109,5 +106,5 @@ time64_t mktime64(const unsigned int year, const unsigned int mon,
time.tm_min = min;
time.tm_sec = sec;
- return (time64_t)rtc_mktime((const struct rtc_time *)&time);
+ return rtc_mktime((const struct rtc_time *)&time);
}