Skip to content

Commit

Permalink
V2.67: fix incorrect schedule date at the beginning of month
Browse files Browse the repository at this point in the history
The date time conversion between UTC and local time may go wrong at the
beginning of month. The “+1 month” may point to March, if you run it on
31th January (because 31th February doesn’t exist).
  • Loading branch information
uugear committed Feb 13, 2020
1 parent acc9267 commit ca87e52
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion wittyPi/daemon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ cur_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# utilities
. "$cur_dir/utilities.sh"

log 'Witty Pi daemon (v2.66) is started.'
log 'Witty Pi daemon (v2.67) is started.'

# log Raspberry Pi model
pi_model=$(cat /proc/device-tree/model)
Expand Down
4 changes: 2 additions & 2 deletions wittyPi/utilities.sh
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ get_utc_date_time()
local datestr=$(date +%Y-)
local curDate=$(date +%d)
if [[ "$date" < "$curDate" ]] ; then
datestr+=$(date --date="$(date +%m) +1 month" +%m-)
datestr+=$(date --date="$(date +%Y-%m-15) +1 month" +%m-)
else
datestr+=$(date +%m-)
fi
Expand Down Expand Up @@ -208,7 +208,7 @@ get_local_date_time()
local datestr=$(date +%Y-)
local curDate=$(date +%d)
if [[ "$date" < "$curDate" ]] ; then
datestr+=$(date --date="$(date +%m) +1 month" +%m-)
datestr+=$(date --date="$(date +%Y-%m-15) +1 month" +%m-)
else
datestr+=$(date +%m-)
fi
Expand Down
2 changes: 1 addition & 1 deletion wittyPi/wittyPi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ echo '==========================================================================
echo '| |'
echo '| Witty Pi - Realtime Clock + Power Management for Raspberry Pi |'
echo '| |'
echo '| < Version 2.66 > by UUGear s.r.o. |'
echo '| < Version 2.67 > by UUGear s.r.o. |'
echo '| |'
echo '================================================================================'

Expand Down

0 comments on commit ca87e52

Please sign in to comment.