Shell clock
Amos Shapir
amos at instable.UUCP
Thu Jan 15 00:15:39 AEST 1987
This is a shell file (not an archive) that converts the output of
'date' into a clock. It has been tried on BSD4.3 and SysV.2, but should
have no trouble on anything with a decent Bourne shell. Enjoy!
------ cut here ------
set `date`
m1=. m2=. m3=. m4=. m5=. m6=. m7=. m8=. m9=. ma=. mb=. mc=.
h1=' ' h3=' ' h5=' ' h6=' ' h7=' ' h9=' ' hb=' ' hc=' '
case $4 in
??:02:[345]?|??:0[3-6]:??|??:07:[012]?) m1=/ ;;
??:07:[345]?|??:0[89]:??|??:1[01]:??|??:12:[012]?) m2=/ ;;
??:12:[345]?|??:1[3-6]:??|??:17:[012]?) m3=- ;;
??:17:[345]?|??:1[89]:??|??:2[01]:??|??:22:[012]?) m4=\\ ;;
??:22:[345]?|??:2[3-6]:??|??:27:[012]?) m5=\\ ;;
??:27:[345]?|??:2[89]:??|??:3[01]:??|??:32:[012]?) m6=\| ;;
??:32:[345]?|??:3[3-6]:??|??:37:[012]?) m7=/ ;;
??:37:[345]?|??:3[89]:??|??:4[01]:??|??:42:[012]?) m8=/ ;;
??:42:[345]?|??:4[3-6]:??|??:47:[012]?) m9=- ;;
??:47:[345]?|??:4[89]:??|??:5[01]:??|??:52:[012]?) ma=\\ ;;
??:52:[345]?|??:5[3-6]:??|??:57:[012]?) mb=\\ ;;
??:57:[345]?|??:5[89]:??|??:0[01]:??|??:02:[012]?) mc=\| ;;
*) echo $4: wrong min; exit 1;;
esac
case $4 in
00:32:[345]?|00:3[3-9]:??|00:[45]?:??|\
01:[012]?:??|01:3[01]:??|01:32:[012]?|\
12:32:[345]?|12:3[3-9]:??|12:[45]?:??|\
13:[012]?:??|13:3[01]:??|13:32:[012]?) h1=/ ;;
01:32:[345]?|01:3[3-9]:??|01:[45]?:??|\
02:[012]?:??|02:3[01]:??|02:32:[012]?|\
13:32:[345]?|13:3[3-9]:??|13:[45]?:??|\
14:[012]?:??|14:3[01]:??|14:32:[012]?) h3=/ ;;
02:32:[345]?|02:3[3-9]:??|02:[45]?:??|\
03:[012]?:??|03:3[01]:??|03:32:[012]?|\
14:32:[345]?|14:3[3-9]:??|14:[45]?:??|\
15:[012]?:??|15:3[01]:??|15:32:[012]?) h3=- ;;
03:32:[345]?|03:3[3-9]:??|03:[45]?:??|\
04:[012]?:??|04:3[01]:??|04:32:[012]?|\
15:32:[345]?|15:3[3-9]:??|15:[45]?:??|\
16:[012]?:??|16:3[01]:??|16:32:[012]?) h3=\\ ;;
04:32:[345]?|04:3[3-9]:??|04:[45]?:??|\
05:[012]?:??|05:3[01]:??|05:32:[012]?|\
16:32:[345]?|16:3[3-9]:??|16:[45]?:??|\
17:[012]?:??|17:3[01]:??|17:32:[012]?) h5=\\ ;;
05:32:[345]?|05:3[3-9]:??|05:[45]?:??|\
06:[012]?:??|06:3[01]:??|06:32:[012]?|\
17:32:[345]?|17:3[3-9]:??|17:[45]?:??|\
18:[012]?:??|18:3[01]:??|18:32:[012]?) h6=\| ;;
06:32:[345]?|06:3[3-9]:??|06:[45]?:??|\
07:[012]?:??|07:3[01]:??|07:32:[012]?|\
18:32:[345]?|18:3[3-9]:??|18:[45]?:??|\
19:[012]?:??|19:3[01]:??|19:32:[012]?) h7=/ ;;
07:32:[345]?|07:3[3-9]:??|07:[45]?:??|\
08:[012]?:??|08:3[01]:??|08:32:[012]?|\
19:32:[345]?|19:3[3-9]:??|19:[45]?:??|\
20:[012]?:??|20:3[01]:??|20:32:[012]?) h9=/ ;;
08:32:[345]?|08:3[3-9]:??|08:[45]?:??|\
09:[012]?:??|09:3[01]:??|09:32:[012]?|\
20:32:[345]?|20:3[3-9]:??|20:[45]?:??|\
21:[012]?:??|21:3[01]:??|21:32:[012]?) h9=- ;;
09:32:[345]?|09:3[3-9]:??|09:[45]?:??|\
10:[012]?:??|10:3[01]:??|10:32:[012]?|\
21:32:[345]?|21:3[3-9]:??|21:[45]?:??|\
22:[012]?:??|22:3[01]:??|22:32:[012]?) h9=\\ ;;
10:32:[345]?|10:3[3-9]:??|10:[45]?:??|\
11:[012]?:??|11:3[01]:??|11:32:[012]?|\
22:32:[345]?|22:3[3-9]:??|22:[45]?:??|\
23:[012]?:??|23:3[01]:??|23:32:[012]?) hb=\\ ;;
11:32:[345]?|11:3[3-9]:??|11:[45]?:??|\
12:[012]?:??|12:3[01]:??|12:32:[012]?|\
23:32:[345]?|23:3[3-9]:??|23:[45]?:??|\
00:[012]?:??|00:3[01]:??|00:32:[012]?) hc=\| ;;
*) echo $4: wrong hour; exit 1;;
esac
case $4 in
0?:??:??|1[01]:??:??) ap=\* ;;
1[2-9]:??:??|2?:??:??) ap=\# ;;
*) echo $4: wrong am/pm; exit 1;;
esac
echo " $mb $mc $m1
$ma $hb$hc$h1 $m2
$m9 $h9 $ap $h3 $m3
$m8 $h7$h6$h5 $m4
$m7 $m6 $m5"
exit 0
------ cut here ------
--
Amos Shapir
National Semiconductor (Israel)
6 Maskit st. P.O.B. 3007, Herzlia 46104, Israel
(011-972) 52-522261 amos%nsta at nsc 34.48'E 32.10'N
More information about the Comp.sources.unix
mailing list