← Commit list

32a8f70ac

Denys Vlasenko
Denys Vlasenko
2020-11-28
SUCCESS Duration: 151s

Subject

libbb: in @SECONDS date format, use 64-bit time if libc allows

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

coreutils/date.c+1 -0
@@ -111,6 +111,7 @@
//usage: )
//usage: "\n"
//usage: "\nRecognized TIME formats:"
+//usage: "\n @seconds_since_1970"
//usage: "\n hh:mm[:ss]"
//usage: "\n [YYYY.]MM.DD-hh:mm[:ss]"
//usage: "\n YYYY-MM-DD hh:mm[:ss]"
libbb/time.c+5 -1
@@ -90,7 +90,11 @@ void FAST_FUNC parse_datestr(const char *date_str, struct tm *ptm)
ptm->tm_mon -= 1; /* Adjust month from 1-12 to 0-11 */
} else
if (date_str[0] == '@') {
- time_t t = bb_strtol(date_str + 1, NULL, 10);
+ time_t t;
+ if (sizeof(t) <= sizeof(long))
+ t = bb_strtol(date_str + 1, NULL, 10);
+ else /* time_t is 64 bits but longs are smaller */
+ t = bb_strtoll(date_str + 1, NULL, 10);
if (!errno) {
struct tm *lt = localtime(&t);
if (lt) {