summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/time.sh21
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/time.sh b/lib/time.sh
index 95510e5..64843f5 100644
--- a/lib/time.sh
+++ b/lib/time.sh
@@ -190,3 +190,24 @@ ob_iso8601_gmtime()
printf '%04d-%02d-%02dT%02d:%02d:%02dZ' $(_ob_gmtime "${timep}")
return 0
}
+
+## @brief Convert seconds since the Epoch into a date and time
+## @details \fBob_touch_t_gmtime\fP() converts the number of non-leap seconds
+## elapsed since the Epoch into date and time in UTC formatted for the
+## \fB-t\fP option of the \fBtouch\fP utility according to POSIX. It
+## is similar to the C function \fBgmtime\fP except that it returns a
+## formatted string instead of a structure.
+## @operand timep req The number of non-leap seconds elapsed since the Epoch.
+## @return Returns 0.
+## @stdout Prints the date and time in UTC formatted for the \fBtouch\fP
+## utility's \fB-t\fP option.
+## @pure yes This function has no side effects.
+ob_touch_t_gmtime()
+{
+ local timep="${1}"
+ shift 1 || _ob_abort
+
+ # [[CC]YY]MMDDhhmm[.SS]
+ printf '%04d%02d%02d%02d%02d.%02d' $(_ob_gmtime "${timep}")
+ return 0
+}