#! /usr/bin/env python | |
import sys,os | |
from stat import * | |
#!/bin/bash | |
# if no args | |
if [[ -z "$*" ]] ; then # get the date as "hours(12) minutes" in a single call # make a bash array with it d=( $(date "+%I %M") ) # separate hours and minutes hour=${d[0]#0} # remove leading 0 or values <10 will be interpreted as octal min=${d[1]#0} else # get the arguments passed to the script hour=${1#0} min=${2#0} fi | |
# if no args | |
if (('" ".join(sys.argv[1:])' not in globals()) ): # get the date as "hours(12) minutes" in a single call | |
# make a bash array with it | |
d=(os.popen("date \\\"+%I %M\\\"").read()+) # separate hours and minutes | |
hour=str(d[0]#0) # remove leading 0 or values <10 will be interpreted as octal | |
min=str(d[1]#0) else: # get the arguments passed to the script | |
hour=str(sys.argv[1]) min=str(sys.argv[2]) | |
plain=(🕐 🕑 🕒 🕓 🕔 🕕 🕖 🕗 🕘 🕙 🕚 🕛 ) | |
plain=(🕐 🕑 🕒 🕓 🕔 🕕 🕖 🕗 🕘 🕙 🕚 🕛) | |
half=(🕜 🕝 🕞 🕟 🕠 🕡 🕢 🕣 🕤 🕥 🕦 🕧 ) | |
half=(🕜 🕝 🕞 🕟 🕠 🕡 🕢 🕣 🕤 🕥 🕦 🕧) | |
# array index starts at 0 | |
hi=$((hour-1)) | |
# array index starts at 0 | |
hi=(hour-1) | |
if [[ $min -lt 15 ]] ; then echo -n ${plain[$hi]} elif [[ $min -lt 45 ]] ; then echo -n ${half[$hi]} else echo -n ${plain[$((hi+1))]} fi | |
if (min < 15 ): print(str(plain[$hi])) elif (min < 45 ): print(str(half[$hi])) else: print(str(plain[$((hi+1))])) | |