summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2024-05-08 06:05:05 -0300
committerEuAndreh <eu@euandre.org>2024-05-08 06:23:52 -0300
commit64e1a0013d8f4a323c3b177a6a73f920a0a839ff (patch)
tree2c522befe1448d0161baab1ae129d7f90bd2c35a /src
parentsrc/timestamp: Add working utility (diff)
downloadeut-64e1a0013d8f4a323c3b177a6a73f920a0a839ff.tar.gz
eut-64e1a0013d8f4a323c3b177a6a73f920a0a839ff.tar.xz
src/now: Add working utility
Diffstat (limited to 'src')
-rwxr-xr-xsrc/now31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/now b/src/now
new file mode 100755
index 0000000..72ca984
--- /dev/null
+++ b/src/now
@@ -0,0 +1,31 @@
+#!/bin/sh
+set -eu
+
+usage() {
+ cat <<-'EOF'
+ Usage:
+ now [-E]
+ EOF
+}
+
+EXTENDED=false
+while getopts 'E' flag; do
+ case "$flag" in
+ (E)
+ EXTENDED=true
+ ;;
+ (*)
+ usage >&2
+ exit 2
+ ;;
+ esac
+done
+shift $((OPTIND - 1))
+
+
+# FIXME: neither %s or %N are POSIX
+if [ "$EXTENDED" = true ]; then
+ date '+%s.%N'
+else
+ date '+%s'
+fi