Created
August 3, 2019 21:01
-
-
Save malicious/73b75e165d5d1abb42ffd0b07c52c57a to your computer and use it in GitHub Desktop.
Say current time on macOS (in Chinese)
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/sh | |
set -x | |
# Current time as HH MM | |
# - force leading space, because hours under 10 have a leading space anyway | |
# | |
WHOLE_DATE_STRING=${1:-"$(date "+ %l %M %p" | sed 's/^[[:space:]]*//')"} | |
HOUR_STRING="$( echo "$WHOLE_DATE_STRING" | cut -d' ' -f1)" | |
MINUTE_STRING="$(echo "$WHOLE_DATE_STRING" | cut -d' ' -f2)" | |
AMPM_STRING="$( echo "$WHOLE_DATE_STRING" | cut -d' ' -f3)" | |
case "$MINUTE_STRING" in | |
00) | |
case $AMPM_STRING in | |
AM) | |
say --voice=Mei-Jia "現在是. 上午 $HOUR_STRING 點鐘" | |
;; | |
*) | |
say --voice=Mei-Jia "現在是. $HOUR_STRING 點鐘" | |
;; | |
esac | |
;; | |
30) | |
say --voice=Mei-Jia "現在是. $HOUR_STRING 點半" | |
;; | |
*) | |
say --voice=Mei-Jia "現在是. $HOUR_STRING 點 $MINUTE_STRING 分" | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment