From 586639907bbcf568089c04aced6669116888cdbf Mon Sep 17 00:00:00 2001 From: kaotisk Date: Sun, 16 Mar 2025 01:29:32 +0200 Subject: All date functions accumulated in _ak_utils --- lib/_ak_network_yggdrasil | 3 ++- lib/_ak_utils | 12 ++++++++++++ lib/_ak_zblock | 15 ++++++++------- lib/_ak_zchain | 5 +++-- 4 files changed, 25 insertions(+), 10 deletions(-) (limited to 'lib') diff --git a/lib/_ak_network_yggdrasil b/lib/_ak_network_yggdrasil index a551cd6..27fc0c8 100755 --- a/lib/_ak_network_yggdrasil +++ b/lib/_ak_network_yggdrasil @@ -18,6 +18,7 @@ ### along with this program. If not, see . ### source $AK_LIBDIR/_ak_log +source $AK_LIBDIR/_ak_utils function _ak_network_yggdrasil_scan_full(){ # This scan is using HIA resources to scan the whole cjdns network for peers @@ -65,7 +66,7 @@ function _ak_network_yggdrasil_scan_full(){ count="$(( $count + 1 ))" _ak_log_debug "Scanning [${count}/${max}] $ip..." node_fs_path="$AK_ZPEERSDIR/ygg/$(echo -n $ip| sed 's/://g')" - scan_ts="$(date -u +%s)" + scan_ts="$(_ak_datetime_unix)" if [ ! -d ${node_fs_path} ] then mkdir -p ${node_fs_path} diff --git a/lib/_ak_utils b/lib/_ak_utils index d437cb9..d9204e9 100755 --- a/lib/_ak_utils +++ b/lib/_ak_utils @@ -21,6 +21,18 @@ function _ak_datetime_unix(){ date -u +%s | tr -d '\n' } +function _ak_datetime_unix_nanosecs(){ + date -u +%s.%N | tr -d '\n' +} + +function _ak_datetime_human(){ + date -u +%Y%m%d_%H%M%S +} + +function _ak_datetime_human_date_only(){ + date -u +%Y%m%d +} + function _ak_datetime_unix_to_human(){ if [ ! -z $1 ] && [ -n "$1" ] && [ "$(echo $1 | sed -e 's/[0-9]\{10\}//g')" == "" ] then diff --git a/lib/_ak_zblock b/lib/_ak_zblock index b4a546b..1313127 100755 --- a/lib/_ak_zblock +++ b/lib/_ak_zblock @@ -20,6 +20,7 @@ #set -x source $AK_LIBDIR/_ak_log source $AK_LIBDIR/_ak_script +source $AK_LIBDIR/_ak_utils source $AK_LIBDIR/_ak_gpg source $AK_LIBDIR/_ak_html source $AK_LIBDIR/_ak_ipfs @@ -452,7 +453,7 @@ function _ak_zblock_show(){ # } function _ak_zblock_gen_html(){ - time_started=$(date -u +%s.%N) + time_started=$(_ak_datetime_unix_nanosecs) ss=$(echo $time_started | cut -d '.' -f 1) nss=$(echo $time_started | cut -d '.' -f 2) # Check if there are enough arguments @@ -475,11 +476,11 @@ function _ak_zblock_gen_html(){ _ak_zblock_show "$1" | jq > $arg _ak_generate_html_header > zblock-$1.html _ak_generate_html_zblock $arg >> zblock-$1.html - time_ended=$(date -u +%s.%N) + time_ended=$(_ak_datetime_unix_nanosecs) se=$(echo $time_ended | cut -d '.' -f 1) nse=$(echo $time_ended | cut -d '.' -f 2) printf '
\n' >> zblock-$1.html - printf '