-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhf
executable file
·30 lines (23 loc) · 944 Bytes
/
hf
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
#!/bin/bash
# HF : Horloge Floue
# Written by Quentin RIBAC (2017)
# This is free software.
# See LICENSE file for legal information.
# Usage: -c for 5 minutes precision, 15 minutes precision otherwise
hNames=( "minuit" "une heure" "deux heures" "trois heures" "quatre heures" "cinq heures" "six heures" "sept heures" "huit heures" "neuf heures" "dix heures" "onze heures" "midi" )
qNames=( "" " et quart" " et demi" " moins le quart" )
cNames=( "" " cinq" " dix" " et quart" " vingt" " vingt-cinq" " et demi" " moins vingt-cinq" " moins vingt" " moins le quart" " moins dix" " moins cinq" )
srcH="$(date '+%_H')"
srcM="$(date '+%_M')"
h="${srcH}"
q="$(bc <<< "(${srcM} + 7.5) / 15")"
c="$(bc <<< "(${srcM} + 2.5) / 5")"
[ "${q}" -ge 3 ] || [ "${1}" = '-c' -a "${c}" -ge 7 ] && (( h++ ))
[ "${h}" -ne 12 ] && (( h %= 12 ))
if [ "${1}" = '-c' ]
then
echo "${hNames[$h]}${cNames[$c]}"
exit 0
fi
echo "${hNames[$h]}${qNames[$q]}"
exit 0