 <p>If you want to test just the logic (and not that <code>date</code> is working correctly), then allow your script to accept <code>CUR_DAY</code> and <code>CUR_HOUR</code> as arguments or via the environment, instead of always running <code>date</code>.</p> <p>Via the environment (<code>CUR_DAY=9 CUR_HOUR=22 myscript</code>)</p> <pre><code>: ${CUR_DAY:=$(date +%a)} : ${CUR_HOUR:=$(date +%H)} </code></pre> <p>Via arguments (<code>myscript 9 22</code>)</p> <pre><code>CUR_DAY=${1:-$(date +%a)} CUR_HOUR=${2:-$(date +%H)} </code></pre> <p>Either approach will work in any POSIX-compliant shell.</p>