X-Git-Url: https://zdv2.bktei.com/gitweb/BK-2020-03.git/blobdiff_plain/e9332c6447b2b6cd413e1d66d281786810e988f3..4caeddd71a0f06cdd6d1824e26e2703c9c91866f:/unitproc/bktemp-timeEpochNS diff --git a/unitproc/bktemp-timeEpochNS b/unitproc/bktemp-timeEpochNS new file mode 100644 index 0000000..8c0fb08 --- /dev/null +++ b/unitproc/bktemp-timeEpochNS @@ -0,0 +1,24 @@ +#!/bin/bash +# Desc: Get timestamp in nanoseconds + +timeEpochNS() { + # Desc: Get epoch nanoseconds + # Usage: timeEpochNS + # Version 0.1.2 + # Input: (none) + # Output: Nanoseconds since 1970-01-01 + # Depends: date 8 + local currentTime epochSeconds fracNanosec epochNanosec + currentTime="$(date +%s.%N)"; + epochSeconds="$(echo "$currentTime" | cut -d. -f1)"; + fracNanosec="$(echo "$currentTime" | cut -d. -f2)"; + epochNanosec="$(( ("$epochSeconds" * 1000000000) + ("$fracNanosec") ))"; + echo "$epochNanosec"; +} # Nanoseconds since 1970-01-01 + +#==BEGIN sample code== +echo "It's been $(timeEpochNS) nanoseconds since 1970-01-01."; +#==END sample code== + +# Author: Steven Baltakatei Sandoval +# License: GPLv3+