Version 1 of now

Updated 2017-08-23 19:46:18 by dbohdan

dbohdan 2017-08-23: now is a tiny little date and time calculator utility for the command line. It leverages Tcl's clock add for date arithmetic.

Download with wiki-reaper: wiki-reaper -x 48963 0 | tee now.tcl

Code

#! /usr/bin/env tclsh
# now v0.1.0 copyright (c) 2017 dbohdan. License: MIT.
package require Tcl 8.5

set formatOpts {}
while {[lindex $argv 0] in {-format -gmt -locale -timezone}} {
    set argv [lassign $argv k v]
    lappend formatOpts $k $v
} 

puts [clock format [clock add [clock seconds] {*}$argv] {*}$formatOpts]

Use examples

$ now
Wed Aug 23 19:46:15 DST 2017
$ now -3491 days
Fri Feb 01 19:46:37 STD 2008
$ now -timezone :UTC -9 years -6 months -22 days +5 hours 5 minutes
Fri Feb 01 22:54:59 UTC 2008