YETUS-583. switch to printf "%(..)T" on bash 4.2

Signed-off-by: Allen Wittenauer <aw@apache.org>
diff --git a/precommit/src/main/shell/core.d/00-yetuslib.sh b/precommit/src/main/shell/core.d/00-yetuslib.sh
index a759c41..5673004 100755
--- a/precommit/src/main/shell/core.d/00-yetuslib.sh
+++ b/precommit/src/main/shell/core.d/00-yetuslib.sh
@@ -442,3 +442,18 @@
     set +f
   fi
 }
+
+## @description  Get the date in ctime format
+## @audience     public
+## @stability    stable
+## @return       ctime
+function yetus_get_ctime
+{
+  if [[ "${BASH_VERSINFO[0]}" -gt 4 ]] \
+     || [[ "${BASH_VERSINFO[0]}" -eq 4 && "${BASH_VERSINFO[1]}" -gt 1 ]]; then
+    # shellcheck disable=SC2183
+    printf "%(%s)T"
+  else
+    date +"%s"
+  fi
+}
diff --git a/precommit/src/main/shell/core.d/docker.sh b/precommit/src/main/shell/core.d/docker.sh
index f7b968d..49d9e60 100755
--- a/precommit/src/main/shell/core.d/docker.sh
+++ b/precommit/src/main/shell/core.d/docker.sh
@@ -357,7 +357,7 @@
     tmptime=$(echo "${line}" | cut -f5 -d, | cut -f1 -d. )
     stoptime=$(dockerdate_to_ctime "${tmptime}")
     name=$(echo "${line}" | cut -f6 -d, )
-    curtime=$("${AWK}" 'BEGIN {srand(); print srand()}')
+    curtime=$(yetus_get_ctime)
     remove=false
 
     case ${status} in
@@ -454,7 +454,7 @@
   for id in "$@"; do
     tmptime=$(dockercmd image inspect --format '{{.Created}}' "${id}" | cut -f1 -d. )
     createtime=$(dockerdate_to_ctime "${tmptime}")
-    curtime=$(date "+%s")
+    curtime=$(yetus_get_ctime)
 
     ((difftime = curtime - createtime))
     if [[ ${difftime} -gt ${DOCKER_IMAGE_PURGE} ]]; then
diff --git a/precommit/src/main/shell/test-patch.sh b/precommit/src/main/shell/test-patch.sh
index be1364e..3578023 100755
--- a/precommit/src/main/shell/test-patch.sh
+++ b/precommit/src/main/shell/test-patch.sh
@@ -128,8 +128,7 @@
 ## @replaceable  no
 function start_clock
 {
-  yetus_debug "Start clock"
-  TIMER=$(date +"%s")
+  TIMER=$(yetus_get_ctime)
 }
 
 ## @description  Print the elapsed time in seconds since the start of the local timer
@@ -138,9 +137,8 @@
 ## @replaceable  no
 function stop_clock
 {
-  local -r stoptime=$(date +"%s")
+  local -r stoptime=$(yetus_get_ctime)
   local -r elapsed=$((stoptime-TIMER))
-  yetus_debug "Stop clock"
 
   echo ${elapsed}
 }
@@ -151,10 +149,8 @@
 ## @replaceable  no
 function stop_global_clock
 {
-  local -r stoptime=$(date +"%s")
+  local -r stoptime=$(yetus_get_ctime)
   local -r elapsed=$((stoptime-GLOBALTIMER))
-  yetus_debug "Stop global clock"
-
   echo ${elapsed}
 }