Artificial intelligent assistant

how to get quarter information like last,current,next quarter using shell script likewise -- 2017q4,2018q1,2018q2 how to get quarter information like last,current,next quarter using shell script likewise -- 2017q4,2018q1,2018q2

This will do it using bash:


declare -i m=$(date +%m)
declare -i cq=($m-1)/3+1
declare -i cy=$(date +%Y)
declare -i py=$cy; [ $m -lt 4 ] && py=$cy-1
declare -i pq=$cq-1; [ $pq -eq 0 ] && pq=4
declare -i ny=$cy; [ $m -gt 9 ] && ny=$cy+1
declare -i nq=$cq+1; [ $nq -gt 4 ] && nq=1
echo ${py}q${pq},${cy}q${cq},${ny}q${nq}


ex for now: 2018q1,2018q2,2018q3

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 1b8c958a769d7db4acfc004ee0082822