fix(bkgpslog):timeNanosec:Make internal variables local
[BK-2020-03.git] / unitproc / bktemp-timeNanosec
CommitLineData
e9c166c0
SBS
1#!/bin/bash
2# Desc: Get timestamp in nanoseconds
3
4timeNanosec() {
5 # Desc: Get epoch nanoseconds
d0dc71da 6 # Version 0.1.2
e9c166c0
SBS
7 # Input: (none)
8 # Output: Nanoseconds since 1970-01-01
9 # Depends: date 8
d0dc71da 10 local currentTime epochSeconds fracNanosec epochNanosec
e9c166c0
SBS
11 currentTime="$(date +%s.%N)";
12 epochSeconds="$(echo "$currentTime" | cut -d. -f1)";
13 fracNanosec="$(echo "$currentTime" | cut -d. -f2)";
14 epochNanosec="$(( ("$epochSeconds" * 1000000000) + ("$fracNanosec") ))";
15 echo "$epochNanosec";
aec895f5 16} # Nanoseconds since 1970-01-01
e9c166c0
SBS
17
18#==BEGIN sample code==
19echo "It's been $(timeNanosec) nanoseconds since 1970-01-01.";
20#==END sample code==
5b497be8
SBS
21
22# Author: Steven Baltakatei Sandoval
23# License: GPLv3+