If anybody's bored and wants something to play with, here's a bash script to estimate the number of days until the next halving
#!/bin/bash
date --iso-8601
bid=$(curl -s "https://www.bitstamp.net/api/ticker/" | jq -r ".bid")
ask=$(curl -s "https://www.bitstamp.net/api/ticker/" | jq -r ".ask")
#p0 is midmarket price to 2 decimals
P0=$(bc -l <<< "scale=2; ($bid+$ask)/2")
echo "mid-market BTCUSD: "$P0
#height=$(curl -s "https://blockchain.info/latestblock" | jq -r ".height")
height=$(wget -q -O - "https://blockchain.info/latestblock" | jq -r ".height")
time=$(wget -q -O - "https://blockchain.info/latestblock" | jq -r ".time")
#May 11, 2020 19:23 halving time 1589225023
#seconds since last halving (sslh) = $time-1589225023
sslh=$(($time-1589225023))
#days since last halving (dsince) = seconds/86400
dsince=$(bc -l <<< "scale=6; $sslh/86400")
#projected days of 2020-2024 halving (dproj) = (time-1589225023)/((height/210000-3)*86400)
dproj=$(bc -l <<< "scale=6; $dsince/(($height/210000)-3)")
echo "projected duration of the current halving:"
echo $dproj
#rounding procedure
#extract decimals, double, add 1
num=$(bc -l <<< "scale=6; 2*($dproj-${dproj%.*})+1")
#truncate, subtract 1, divide by 2
num=$(bc -l <<< "scale=6; (${num%.*}-1)/2")
#add to original variable
dproj=$(bc -l <<< "scale=6; $dproj+$num")
#truncate
dproj=${dproj%.*}
echo $dproj "days"