To print the time in Swatch .beats from the terminal, issue the following:
printf @;TZ=UTC-1 date '+scale=2;((%H*60+%M)*60+%S)/86.4'|bc
You can save this as a shell alias so that you can check the time in .beats whenever you like alias beat="printf @;TZ=UTC-1 date '+scale=2;((%H*60+%M)*60+%S)/86.4'|bc"
.
Notes:
- POSIX time offsets are specificed in reverse. So this is actually "UTC+1", the same as "Biel Mean Time".
- "centibeats" (.beats to two decimal places) are not official but commonly displayed on third party implementations.
There is some rounding going on above so the exact centibeat might be a fraction off. On Linux you could add .%N
after %S
to get better precision. On macOS and BSD this shell script that calls python could be better
#!/bin/sh
a=`TZ=UTC-1 python3 -c "from datetime import datetime; print(datetime.now().strftime('%H:%M:%S.%f'))"`;b=${a#*:}
printf @;echo "scale=2;((${a%%:*}*60+${b%:*})*60+${b#*:})/86.4"|bc
And yes… you could just do the entire thing in python. That be an exercise for the reader. 😉