swatch beats internet time
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
608B

  1. #!/bin/bash
  2. ##
  3. # Displays the current Swatch Internet Time
  4. #
  5. # -shaun kerr.
  6. ##
  7. set -e
  8. function usage {
  9. cat <<EOF
  10. Usage: $0 [-s -h]
  11. Displays the current Swatch Internet Time
  12. -s | Do not display fractions
  13. -h | Show help
  14. EOF
  15. }
  16. while getopts "sh" o; do
  17. case $o in
  18. s) fmt="@%03d\n" ;;
  19. h) usage; exit 0 ;;
  20. *) usage; exit 1 ;;
  21. esac
  22. done
  23. seconds=$(date -u +"%-S")
  24. minutes=$(date -u +"%-M")
  25. hours=$((($(date -u +"%-H")+1)%24))
  26. if [ -z $fmt ]; then fmt="@%07.3f\n"; fi
  27. awk -v b="$((seconds + minutes*60 + hours*3600 ))" \
  28. -v fmt="$fmt" \
  29. 'BEGIN { printf(fmt,b/86.4); }'