awk mktime expected different date format. replace with date in seconds

This commit is contained in:
James Tomasino 2020-06-28 16:45:07 +00:00
parent ac94486c80
commit c78d6eb575
1 changed files with 2 additions and 1 deletions

3
bot.sh
View File

@ -182,7 +182,8 @@ do
json=$(curl -s "https://radio.tildeverse.org/api/station/1/schedule?rows=1" | jq ".[]")
nextdj=$(jq -r .name <<< "$json")
nexttime=$(LANG=C TZ=UTC date -d "$(jq -r .start <<< "$json")")
timediff=$(TZ=UTC awk -v d="$nexttime" 'BEGIN { then=mktime(d); now=systime(); print strftime("%Hh %Mm", then - now); }')
nexttimesecs=$(LANG=C TZ=UTC date -d "$nexttime" +%s)
timediff=$(TZ=UTC awk -v d="$nexttimesecs" 'BEGIN { then=d; now=systime(); print strftime("%Hh %Mm", then - now); }')
msg "$from" "$schedule - $nextdj will be on at $nexttime (in $timediff)"
;;