Created
June 12, 2018 06:04
-
-
Save KimiyukiYamauchi/750d5c7073bbd7bfb0a259e447923826 to your computer and use it in GitHub Desktop.
This file contains 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 | |
thisyear=$(date '+%Y') # 今年の年 | |
birthday=$(date -d "${thisyear}${1}" '+%s') # 今年の誕生日のエポック | |
today=$(date '+%s') # 本日のエポック | |
if [ "$birthday" -gt "$today" ]; then | |
echo $(((birthday - today) / (60*60*24) + 1)) | |
elif [ $(date '+%m%d') = "${1}" ]; then | |
echo 'Today is birthday.' | |
else | |
nextbirthday=$(date -d "${thisyear}${1} next year" '+%s') # 来年の誕生日のエポック | |
echo $(((nextbirthday - today) / (60*60*24) + 1)) | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
./bd.sh mmdd
ex)
./bd.sh 0313