8284539: Configure --with-source-date=version fails on MacOS

Reviewed-by: erikj, ihse
This commit is contained in:
Andrew Leonard 2022-04-19 14:25:33 +00:00
parent ac77b63018
commit da3d8b1d1e

View File

@ -239,12 +239,17 @@ AC_DEFUN([UTIL_GET_EPOCH_TIMESTAMP],
timestamp=$($DATE --utc --date=$2 +"%s" 2> /dev/null)
else
# BSD date
timestamp=$($DATE -u -j -f "%FZ %TZ" "$2" "+%s" 2> /dev/null)
# ISO-8601 date&time in Zulu 'date'T'time'Z
timestamp=$($DATE -u -j -f "%FT%TZ" "$2" "+%s" 2> /dev/null)
if test "x$timestamp" = x; then
# BSD date cannot handle trailing milliseconds.
# Try again ignoring characters at end
timestamp=$($DATE -u -j -f "%Y-%m-%dT%H:%M:%S" "$2" "+%s" 2> /dev/null)
fi
if test "x$timestamp" = x; then
# Perhaps the time was missing.
timestamp=$($DATE -u -j -f "%FT%TZ" "$2""T00:00:00Z" "+%s" 2> /dev/null)
fi
fi
$1=$timestamp
])