Skip to content

Instantly share code, notes, and snippets.

@adnahmed
Created August 9, 2021 11:32
Show Gist options
  • Save adnahmed/ed4728bfad373833f044d49bf1b5db37 to your computer and use it in GitHub Desktop.
Save adnahmed/ed4728bfad373833f044d49bf1b5db37 to your computer and use it in GitHub Desktop.
#!/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