fix(unitproc):timeNanosec:minor comment with version and author
[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
aec895f5 6 # Version 0.1.1
e9c166c0
SBS
7 # Input: (none)
8 # Output: Nanoseconds since 1970-01-01
9 # Depends: date 8
10 currentTime="$(date +%s.%N)";
11 epochSeconds="$(echo "$currentTime" | cut -d. -f1)";
12 fracNanosec="$(echo "$currentTime" | cut -d. -f2)";
13 epochNanosec="$(( ("$epochSeconds" * 1000000000) + ("$fracNanosec") ))";
14 echo "$epochNanosec";
aec895f5 15} # Nanoseconds since 1970-01-01
e9c166c0
SBS
16
17#==BEGIN sample code==
18echo "It's been $(timeNanosec) nanoseconds since 1970-01-01.";
19#==END sample code==
5b497be8
SBS
20
21# Author: Steven Baltakatei Sandoval
22# License: GPLv3+