From 93f3ee1ac543a6afab07f1bfd27a8dfb616400d7 Mon Sep 17 00:00:00 2001 From: quackerd Date: Mon, 8 Mar 2021 06:12:30 -0500 Subject: [PATCH] fix freebsd --- libozsh.zsh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libozsh.zsh b/libozsh.zsh index 235a444..3165882 100644 --- a/libozsh.zsh +++ b/libozsh.zsh @@ -51,7 +51,7 @@ function ozsh_update { } function ozsh_autoupdate { - local timediff=$(( ($(date --date="$(date)" +%s) - $(date --date="$(cat $OZSH_LASTUPDATE_FILE)" +%s) ) / (60*60*24) )) + local timediff=$(( ( $(strftime -r %Y-%m-%d $(date +%Y-%m-%d)) - $(strftime -r %Y-%m-%d $(cat $OZSH_LASTUPDATE_FILE)) ) / 86400 )) if [ "$timediff" -ge "7" ]; then vared -p 'Would you like to update ozsh? [y/N]: ' -c answer if [ "$answer" = "y" ] || [ "$answer" = "Y" ]; then @@ -68,9 +68,12 @@ function ozsh_init { # create lastupdate file if not exist if [ ! -f $OZSH_LASTUPDATE_FILE ]; then - echo $(date) > $OZSH_LASTUPDATE_FILE + echo $(date +%Y-%m-%d) > $OZSH_LASTUPDATE_FILE fi + # load the datetime module + zmodload zsh/datetime + ozsh_autoupdate }