simplified julian date in finger

This commit is contained in:
James Tomasino 2022-03-16 00:32:30 +00:00
parent 658ba7c295
commit 99a408c66a
1 changed files with 1 additions and 25 deletions

View File

@ -7,34 +7,10 @@ if [ "$3" = "latest" ]; then
fi
if [ "$3" = "time" ]; then
GetJulianDay () {
year=$1
month=$2
day=$3
jd=$((day - 32075 + 1461 * (year + 4800 - (14 - month) / 12) / 4 + 367 * (month - 2 + ((14 - month) / 12) * 12) / 12 - 3 * ((year + 4900 - (14 - month) / 12) / 100) / 4))
printf "%s" "$jd"
}
GetJulianTime () {
mil="$(echo "x = ($(date +%s) - 43200 ) % 86400; scale=5; x / 86400" | bc)"
printf "%s" "$mil"
}
julian () {
year=$(date +"%Y")
month=$(date +"%m")
day=$(date +"%d")
todayJd=$(GetJulianDay "$year" "$month" "$day")
timeJd=$(GetJulianTime)
printf "%s%s\n" "$todayJd" "$timeJd"
}
echo The time is...
d="$(date -u)"
beatTAI=$(echo "x = ($(date +%s)) % 86400; scale=3; x / 86.4" | bc)
j=$(julian)
j=$(echo "x = $(date +%s); scale=5; x / 86400 + 2440587.5" | bc)
printf "Gregorian Date : %s\n" "$d"
printf "beatTAI : %s\n" "$beatTAI"
printf "Julian Date : %s\n" "$j"