than mktime(3) because the UNIX Epoch is defined in UTC rather than
in the local timezone.
Combining %s with other format specifiers is usually not useful.
But if a user does that, then parsing the whole input as UTC seems
better than parsing some of it as UTC and some of it in the local
time zone.
Bug found by Bryan Vyhmeister.
The final patch is joint work with and OK by gerhard@.
No objection when shown on tech@.
-/* $OpenBSD: date.c,v 1.56 2019/08/08 02:17:51 cheloha Exp $ */
+/* $OpenBSD: date.c,v 1.57 2021/08/11 13:41:48 schwarze Exp $ */
/* $NetBSD: date.c,v 1.11 1995/09/07 06:21:05 jtc Exp $ */
/*
}
/* convert broken-down time to UTC clock time */
- if ((tval = mktime(lt)) == -1)
+ if (pformat != NULL && strstr(pformat, "%s") != NULL)
+ tval = timegm(lt);
+ else
+ tval = mktime(lt);
+ if (tval == -1)
errx(1, "specified date is outside allowed range");
if (jflag)