date: Correctly check outcome of mktime().

X-MFC-With:	7b390cb636
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D44982
This commit is contained in:
Dag-Erling Smørgrav 2024-04-28 19:12:58 +02:00
parent b30a7e5418
commit dafb424b8d

View file

@ -334,7 +334,9 @@ setthetime(const char *fmt, const char *p, int jflag, struct timespec *ts)
}
/* convert broken-down time to GMT clock time */
if ((ts->tv_sec = mktime(lt)) == -1)
lt->tm_yday = -1;
ts->tv_sec = mktime(lt);
if (lt->tm_yday == -1)
errx(1, "nonexistent time");
ts->tv_nsec = 0;