2024-11-14 01:11:30 +01:00
|
|
|
if [ "$1" = "--help" ]; then
|
|
|
|
echo " + '
|
|
|
|
\$span = span
|
|
|
|
\$day = day
|
|
|
|
\$year = year
|
|
|
|
time.sh + '%span %day/%year'"
|
|
|
|
fi
|
2024-10-05 02:19:04 +02:00
|
|
|
#date
|
|
|
|
month=$(date +"%m")
|
|
|
|
dayofmonth=$(date +"%d")
|
2024-11-14 01:11:30 +01:00
|
|
|
year_den=$(date +"%Y")
|
|
|
|
if [ $((($year_den % 4))) == 0 ]; then
|
2024-10-05 02:19:04 +02:00
|
|
|
leapyear=1
|
2024-11-14 01:11:30 +01:00
|
|
|
elif [ $((($year_den % 4))) > 0 ]; then
|
2024-10-05 02:19:04 +02:00
|
|
|
leapyear=0
|
|
|
|
fi
|
|
|
|
totalday=0
|
|
|
|
if (( $month > 1 )); then
|
|
|
|
totalday=$((($totalday+31)));
|
|
|
|
fi
|
|
|
|
|
|
|
|
if (( $month > 2 )); then
|
|
|
|
totalday=$((($totalday+28+$leapyear))); # add value for leap year in february
|
|
|
|
fi
|
|
|
|
|
|
|
|
if (( $month > 3 )); then
|
|
|
|
totalday=$((($totalday+31)));
|
|
|
|
fi
|
|
|
|
|
|
|
|
if (( $month > 4 )); then
|
|
|
|
totalday=$((($totalday+30)));
|
|
|
|
fi
|
|
|
|
|
|
|
|
if (( $month > 5 )); then
|
|
|
|
totalday=$((($totalday+31)));
|
|
|
|
fi
|
|
|
|
|
|
|
|
if (( $month > 6 )); then
|
|
|
|
totalday=$((($totalday+30)));
|
|
|
|
fi
|
|
|
|
|
|
|
|
if (( $month > 7 )); then
|
|
|
|
totalday=$((($totalday+31)));
|
|
|
|
fi
|
|
|
|
|
|
|
|
if (( $month > 8 )); then
|
|
|
|
totalday=$((($totalday+31)));
|
|
|
|
fi
|
|
|
|
|
|
|
|
if (( $month > 9 )); then
|
|
|
|
totalday=$((($totalday+30)));
|
|
|
|
fi
|
|
|
|
|
|
|
|
if (( $month > 10 )); then
|
|
|
|
totalday=$((($totalday+31)));
|
|
|
|
fi
|
|
|
|
|
|
|
|
if (( $month > 11 )); then
|
|
|
|
totalday=$((($totalday+30)));
|
|
|
|
fi
|
2024-11-14 01:11:30 +01:00
|
|
|
day_den=$(((10#$totalday+10#$dayofmonth)))
|
|
|
|
day_hex=$(printf "%x\n" $totalday)
|
2024-10-05 02:19:04 +02:00
|
|
|
# Time
|
|
|
|
second=$(date +"%S")
|
|
|
|
minute=$(date +"%M")
|
|
|
|
hour=$(date +"%H")
|
|
|
|
nanosecond=$(date +"%N")
|
|
|
|
second_of_the_day=$(bc -l <<< "($hour * 3600) + ($minute * 60) + $second")
|
2024-11-14 01:11:30 +01:00
|
|
|
span_den=$(bc -l <<< "$second_of_the_day / (86400/65536)")
|
|
|
|
span_den=$(echo $span_den | awk '{printf("%d\n",$1 + 0.5)}' )
|
|
|
|
span_hex=$(printf "%x\n" $span_den)
|
|
|
|
year_hex=$(printf "%x\n" $year_den)
|
2024-10-05 02:19:04 +02:00
|
|
|
|
2024-11-14 01:11:30 +01:00
|
|
|
if [ "$1" = "--den" ]; then
|
|
|
|
echo $span_den $day_den/$year_den
|
|
|
|
elif [ "$1" = "--hex" ]; then
|
|
|
|
echo $span_hex $day_hex/$year_hex
|
|
|
|
else
|
|
|
|
echo "specify hex or den with --hex or --den"
|
|
|
|
fi
|