Created
August 9, 2021 11:32
-
-
Save adnahmed/ed4728bfad373833f044d49bf1b5db37 to your computer and use it in GitHub Desktop.
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/bash | |
# Name: Internet Time | |
# Version: 1 | |
# Author: Adnan Ahmed Khan | |
# Contact: mailtoadnan.ahmed@gmail.com | |
# Description: Swatch Internet Time (Swatch Clock) | |
# calculate the time of the future | |
GetInternetTime(){ | |
hours="$(date +'%H')" | |
minutes="$(date +'%M')" | |
seconds="$(date +'%S')" | |
# Time (Seconds) | |
TimeInSeconds=$(echo "((($hours * 60) + $minutes) * 60) + $seconds"| bc) | |
SecondsInBeat=86.4 | |
# Calculate beats to two decimal places | |
x=$(echo "scale=2;$TimeInSeconds / $SecondsInBeat"| bc ) | |
if [[ 1 -eq "$(echo "$x < 0"| bc)" ]]; then | |
beats="$(echo "$x * -1"|bc)" | |
else beats=$x | |
fi | |
echo $beats | |
} | |
GetInternetTime |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment