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 }