The 0 in the seconds field doesn't show for the total time for the run. Not sure how to approach fixing this. I added a string representation to remedy this but im sure there's an easier more correct way.
I'm getting the following output:
Average Time: .0090997539
END: May 7, 2022 21:38:30.675997203
Total Time for the run = 0:.356970645
#Get Start Date Time
StartDate=$(date +"%B%e, %Y %T.%N")
StartDateTiming=`date --date="$StartDate" '+%s.%N'`
echo "START: $StartDate" | tee -a $function_FileName
echo "" | tee -a $function_FileName
#****SOME MORE CODE running*****
#Get End Date Time
EndDate=$(date +"%B%e, %Y %T.%N")
EndDateTiming=`date --date="$EndDate" '+%s.%N'`
echo "" | tee -a $function_FileName
echo "END: $EndDate" | tee -a $function_FileName
#Get START AND END TIME DURATIONS
#Get Minutes
StartDateMinutes=`date --date="$StartDate" '+%M'`
EndDateMinutes=`date --date="$EndDate" '+%M'`
DateDurationMinutes=`echo "scale = 10; $EndDateMinutes-$StartDateMinutes" | bc`
DateDurationSecsAndNano=`echo "scale = 10; $EndDateTiming-$StartDateTiming" | bc`
echo "" | tee -a $function_FileName
#IF any is 0 it doesnt show so make them string representations
if [[ $DateDurationMinutes -eq 0 ]]
then
DateDurationMinutes="0"
fi
#PUT ALL TIME VARIATIONS TOGETHER
TotalTime="$DateDurationMinutes:$DateDurationSecsAndNano"
echo "Total Time for the run = $TotalTime" | tee -a $function_FileName