Skip to content

Instantly share code, notes, and snippets.

@dhhdev
Last active October 17, 2016 19:36
Show Gist options
  • Save dhhdev/cb06fe6f85dab8cee1bf49fcd2e22894 to your computer and use it in GitHub Desktop.
Save dhhdev/cb06fe6f85dab8cee1bf49fcd2e22894 to your computer and use it in GitHub Desktop.
BSD date version of how many days until Christmas :-)
#!/bin/sh
# Today, as day-of-year (1-366)
TODAY=$(date -j +"%j")
# Christmas day, in d-B-y format converted to days
CHRISTMAS=$(date -jf "%d-%B-%y" "25-DEC-16" +"%j")
echo "There are $(($CHRISTMAS - $TODAY)) days until Christmas."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment