date: support -d @SECONDS_SINCE_1970
function old new delta parse_datestr 647 721 +74 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
238c83bd82
commit
5f94346f73
10
libbb/time.c
10
libbb/time.c
@ -68,6 +68,16 @@ void FAST_FUNC parse_datestr(const char *date_str, struct tm *ptm)
|
|||||||
end = '\0';
|
end = '\0';
|
||||||
/* else end != NUL and we error out */
|
/* else end != NUL and we error out */
|
||||||
}
|
}
|
||||||
|
} else if (date_str[0] == '@') {
|
||||||
|
time_t t = bb_strtol(date_str + 1, NULL, 10);
|
||||||
|
if (!errno) {
|
||||||
|
struct tm *lt = localtime(&t);
|
||||||
|
if (lt) {
|
||||||
|
*ptm = *lt;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
end = '1';
|
||||||
} else {
|
} else {
|
||||||
/* Googled the following on an old date manpage:
|
/* Googled the following on an old date manpage:
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user