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 --- modules/articles/main.sh | 3 ++- modules/categories/main.sh | 3 ++- modules/comments/main.sh | 3 ++- modules/files/main.sh | 3 ++- modules/folders/main.sh | 3 ++- modules/mixtapes/lib.sh | 16 ++++++++-------- modules/news/lib.sh | 3 ++- modules/reference/main.sh | 7 ++++--- modules/repositories/main.sh | 1 + modules/smfiles/lib.sh | 3 ++- modules/todos/main.sh | 3 ++- 11 files changed, 29 insertions(+), 19 deletions(-) (limited to 'modules') diff --git a/modules/articles/main.sh b/modules/articles/main.sh index c142725..9fa0304 100755 --- a/modules/articles/main.sh +++ b/modules/articles/main.sh @@ -31,6 +31,7 @@ descriptionString="Articles module for Arching Kaos" source $AK_LIBDIR/_ak_log source $AK_LIBDIR/_ak_script +source $AK_LIBDIR/_ak_utils source $AK_LIBDIR/_ak_ipfs source $AK_LIBDIR/_ak_gpg source $AK_LIBDIR/_ak_zblock @@ -48,7 +49,7 @@ fi _ak_modules_articles_create(){ TEMP="$(_ak_make_temp_directory)" cd $TEMP - export ARTICLES_FILE="$(date +%Y%m%d_%H%M%S)" + export ARTICLES_FILE="$(_ak_datetime_human)" if [ -z $EDITOR ] then _ak_log_error "No $EDITOR found. Exiting..." diff --git a/modules/categories/main.sh b/modules/categories/main.sh index 68d3c12..ebb9e9e 100755 --- a/modules/categories/main.sh +++ b/modules/categories/main.sh @@ -34,6 +34,7 @@ source $AK_LIBDIR/_ak_script source $AK_LIBDIR/_ak_ipfs source $AK_LIBDIR/_ak_gpg source $AK_LIBDIR/_ak_zblock +source $AK_LIBDIR/_ak_utils if [ ! -d $AK_CATEGORIES ]; then mkdir $AK_CATEGORIES @@ -46,7 +47,7 @@ fi _ak_modules_categories_create(){ TEMP="$(_ak_make_temp_directory)" cd $TEMP - export NEWS_FILE="$(date +%Y%m%d_%H%M%S)" + export NEWS_FILE="$(_ak_datetime_human)" vi $NEWS_FILE _ak_log_info "Renaming..." TITLE="$(head -n 1 $NEWS_FILE)" diff --git a/modules/comments/main.sh b/modules/comments/main.sh index 1e88a52..c469ba6 100755 --- a/modules/comments/main.sh +++ b/modules/comments/main.sh @@ -33,6 +33,7 @@ source $AK_LIBDIR/_ak_script source $AK_LIBDIR/_ak_ipfs source $AK_LIBDIR/_ak_gpg source $AK_LIBDIR/_ak_zblock +source $AK_LIBDIR/_ak_utils ZCOMMENTSDIR="$AK_WORKDIR/comments" TEMP="/tmp/aktmp" @@ -55,7 +56,7 @@ _ak_modules_comments_create(){ fi TEMP="$(_ak_make_temp_directory)" cd $TEMP - export COMMENTS_FILE="$(date -u +%s)" + export COMMENTS_FILE="$(_ak_datetime_unix)" vi $COMMENTS_FILE echo "Renaming..." TO_FILE=$COMMENTS_FILE diff --git a/modules/files/main.sh b/modules/files/main.sh index 72fb752..14cda6a 100755 --- a/modules/files/main.sh +++ b/modules/files/main.sh @@ -32,6 +32,7 @@ source $AK_LIBDIR/_ak_log source $AK_LIBDIR/_ak_ipfs source $AK_LIBDIR/_ak_gpg source $AK_LIBDIR/_ak_zblock +source $AK_LIBDIR/_ak_utils if [ ! -d $ZFILESDIR ]; then mkdir $ZFILESDIR @@ -103,7 +104,7 @@ main(){ cat > $TEMPASSIN/data < $mixtapes_playlists/1 - seek=$(( ($(date -u +%s) - $TS) % $DUR )) + seek=$(( ($(_ak_datetime_unix) - $TS) % $DUR )) index=$counter echo "$counter $index $seek" exit 0 @@ -70,8 +70,8 @@ _ak_modules_mixtapes_find_now(){ # watch -n 1 ' # TS=$(cat mixtapes_index | cut -d\ -f 1,6 | head -n 1 | cut -d\ -f 1) # DUR=$(cat mixtapes_index | cut -d\ -f 1,6 | head -n 1 | cut -d\ -f 2) - # echo $(( ($(date -u +%s) - $TS) / $DUR )) # Times played - # echo $(( ($(date -u +%s) - $TS) % $DUR )) # Seek time + # echo $(( ($(_ak_datetime_unix) - $TS) / $DUR )) # Times played + # echo $(( ($(_ak_datetime_unix) - $TS) % $DUR )) # Seek time # ' mixtapes_counter=1 @@ -79,7 +79,7 @@ _ak_modules_mixtapes_find_now(){ while [ $mixtapes_counter -le $total_number_of_mixtapes ] do _ak_log_debug "Counter: $mixtapes_counter" - # current_timestamp="$(date -u +%s)" + # current_timestamp="$(_ak_datetime_unix)" current_timestamp="$(cat $mixtapes_ord/$mixtapes_counter | cut -d ' ' -f 1)" current_duration="$(cat $mixtapes_ord/$mixtapes_counter | cut -d ' ' -f 6)" # diff_ts="$(( $current_timestamp - $timestamp ))" @@ -90,7 +90,7 @@ _ak_modules_mixtapes_find_now(){ then cat $mixtapes_ord/$mixtapes_counter > $mixtapes_playlists/$playlists_counter # Return playlist number, mixtape number and seek time - time_difference=$(( $(date -u +%s) - $current_timestamp)) + time_difference=$(( $(_ak_datetime_unix) - $current_timestamp)) seek_time=$(( $time_difference % $current_duration )) echo $playlists_counter $mixtapes_counter $seek_time # For this particular instance we would loop for ever in the @@ -151,7 +151,7 @@ _ak_modules_mixtapes_find_now(){ elif [ $mixtapes_counter -eq $total_number_of_mixtapes ] then - echo $(( ($(date -u +%s) - $current_timestamp) % $current_duration )) # Seek time + echo $(( ($(_ak_datetime_unix) - $current_timestamp) % $current_duration )) # Seek time fi mixtapes_counter=$(($mixtapes_counter + 1)) done @@ -197,7 +197,7 @@ _ak_modules_mixtapes_main(){ cat > data < $REFERENCEFILE << EOF $1 $2 @@ -125,7 +126,7 @@ _ak_modules_reference_add(){ FILE_SIGNATURE=$(_ak_ipfs_add $FILE_SIGN_FILE) cat > data <. ### source $AK_LIBDIR/_ak_zblock +source $AK_LIBDIR/_ak_utils PROGRAM="ak-module-$(realpath $0 | rev |cut -d '/' -f 2 | rev)" REPODIR="$HOME/projects" BAREDIR="$HOME/bare" diff --git a/modules/smfiles/lib.sh b/modules/smfiles/lib.sh index 6e90964..f3418ff 100755 --- a/modules/smfiles/lib.sh +++ b/modules/smfiles/lib.sh @@ -23,6 +23,7 @@ source $AK_LIBDIR/_ak_ipfs source $AK_LIBDIR/_ak_gpg source $AK_LIBDIR/_ak_zblock source $AK_LIBDIR/_ak_smfiles +source $AK_LIBDIR/_ak_utils _ak_sm_files_add(){ FILENAME="$1" @@ -103,7 +104,7 @@ _ak_sm_files_main(){ cat > data <