Created
June 16, 2015 08:13
-
-
Save KristianLyng/66901ce11a0450107724 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| NOW=$(date +%s) | |
| WEEKEND=$(date -d 'friday 16:00:00' +%s) | |
| FRIDAY=$(date -d 'friday 00:00:00' +%s) | |
| DIFF=$(( ${FRIDAY} - ${NOW} )) | |
| DIFFD=$(( ${DIFF} / 86400 )) | |
| DIFFH=$(( (${DIFF} - ${DIFFD}*86400) / 3600 )) | |
| DIFFM=$(( (${DIFF} - ${DIFFD}*86400 - ${DIFFH}*3600) / 60 )) | |
| DIFFW=$(( ${WEEKEND} - ${NOW} )) | |
| DIFFWD=$(( ${DIFFW} / 86400 )) | |
| DIFFWH=$(( (${DIFFW} - ${DIFFWD}*86400) / 3600 )) | |
| DIFFWM=$(( (${DIFFW} - ${DIFFWD}*86400 - ${DIFFWH}*3600) / 60 )) | |
| mode=$(basename $0 | sed s/\.sh//) | |
| if [ "x$1" != "x" ]; then | |
| mode=$1 | |
| fi | |
| if [ $mode = "friday" ]; then | |
| echo "$DIFFD days, $DIFFH hours, $DIFFM minutes until Friday!" | |
| elif [ $mode = "fredag" ]; then | |
| echo "$DIFFD dager, $DIFFH timer, $DIFFM minutter til fredag!" | |
| elif [ $mode = "weekend" ]; then | |
| echo "$DIFFWD days, $DIFFWH hours, $DIFFWM minutes until the weekend!" | |
| elif [ $mode = "helg" ]; then | |
| echo "$DIFFWD dager $DIFFWH timer $DIFFWM minutter til helgen er her!" | |
| else | |
| echo "Jokkmokk! Try $0 friday, or $0 weekend, or $0 helg or $0 fredag" | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment