Created
July 5, 2013 07:52
-
-
Save mindjiver/5932771 to your computer and use it in GitHub Desktop.
Is it really Friday?
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 | |
date=$(unset LC_TIME && date +%u) | |
if [ $date -eq 5 ]; then | |
echo "YES!" | |
else | |
echo "NO! :(" | |
fi |
Unicode version (try it in iTerm)
[ unset LC_TIME && date +%u
-eq 5 ] && echo -e "YES! \xF0\x9F\x8D\xBA" || echo "NO! :("
Even better one:
[ unset LC_TIME && date +%u
-eq 5 ] && echo -e "YES! \xF0\x9F\x8D\xBB" || echo "NO! :("
!/bin/python
from datetime import date
if date.today().isoweekday() == 5: print('Yes!')
else: print('No :(')
Locale-independent version:
[ LANG=C unset LC_TIME && date +%u
-eq 5 ] && echo -e "YES! \xF0\x9F\x8D\xBB" || echo "NO! :("
Actually, as @matwey pointed out, there is no need to set/uset locale and LC_TIME. So this should be simplified down to:
[ date +%u
-eq 5 ] && echo -e "YES! \xF0\x9F\x8D\xBB" || echo "NO! :("
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
One-liner:
[
unset LC_TIME && date +%u
-eq 5 ] && echo "YES!" || echo "NO! :("