tomocafe / bash-boost

bash-boost is a set of library functions for bash, useful for both scripting and interactive use. It draws inspiration from the Boost C++ libraries.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

util/time

tomocafe opened this issue · comments

Date and time utilities leveraging builtin printf interface to strftime.

bb_now [{+,-}N{s,m,h,D,W,M,Y}] gives epoch timestamp relative to now. Multiple offsets can be given, e.g. +1d -2h.

bb_timefmt formats timestamp, defaults to now.

bb_parsetime YYYY/MM/DD[ hh:mm[:ss]] gives epoch timestamp for date string. Separator character does not matter, but all values must be exact length (4 digits for year, 2 digits for month, etc.). Hours, minutes, seconds are optional and default to 00:00:00.

Done, except bb_parsetime. Too complicated to do in pure bash, just use GNU coreutils date.