diff options
Diffstat (limited to 'include/functions')
-rw-r--r-- | include/functions | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/include/functions b/include/functions index 5b211707..38cc46b3 100644 --- a/include/functions +++ b/include/functions @@ -2562,14 +2562,18 @@ GetTimestamp() { ts=0 - case "${OS}" in - "Linux") + # Detect if the implementation of date supports nanoseconds, + if [ "${OS}" = "Linux" ]; then + current_nanoseconds=$(date "+%N") + # Verify if the result of the command is a number + if [ -n "$current_nanoseconds" ] && [ "$current_nanoseconds" -eq "$current_nanoseconds" ] 2>/dev/null; then ts=$(date "+%s%N") - ;; - *) + else ts=$(date "+%s") - ;; - esac + fi + else + ts=$(date "+%s") + fi echo $ts } |