-
Notifications
You must be signed in to change notification settings - Fork 4
/
funclock.sh
executable file
·65 lines (55 loc) · 1.17 KB
/
funclock.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env bash
# Created By: Jake@Linux
# Created On: Tue 19 Jul 2022 12:38:28 PM CDT
# Project: fuzzy clock
box() {
title=" $1 "
edge=$(echo "$title" | sed 's/./*/g')
echo "$edge"
echo -e "\e[1;31m$title\e[0m"
echo "$edge"
}
txttime=("zero" "one" "two" "three" "four" "five" "six" "seven" "eight" "nine" "ten" "eleven" "twelve")
hr=$(date +'%I')
min=$(date +'%M')
hr=$(( "10#$hr" ))
min=$(( "10#$min" ))
if (( min >= 33 ))
then
if (( "$hr" == 12 ));
then
hr=1
else
hr=$(( "$hr" + 1 ))
fi
min=$(( 60 - $min ));
adverb="til"
else
adverb="after"
fi
txthour=${txttime[$hr]}
if (( min < 3 ))
then
written_time="it is $txthour o'clock"
elif (( min < 8 ))
then
written_time="it is five min $adverb $txthour"
elif (( min < 13 ))
then
written_time="it is ten min $adverb $txthour"
elif (( min < 18 ))
then
written_time="it is fifteen $adverb $txthour"
elif (( min < 23 ))
then
written_time="it is twenty $adverb $txthour"
elif (( min < 28 ))
then
written_time="it is twenty-five $adverb $txthour"
elif (( min < 33 ))
then
written_time="it is half past $txthour"
else
exit 1
fi
box "$written_time"