summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorPatrick McDermott <patrick.mcdermott@libiquity.com>2019-06-18 10:45:59 (EDT)
committer Patrick McDermott <patrick.mcdermott@libiquity.com>2019-06-18 10:45:59 (EDT)
commit7d5bb275dbe5c80bcb743150b1ae4463bc708333 (patch)
tree0684899e35a7cc7749668205ca6303de67c1310b /lib
parentcc8ae3314f06138823ebdef6890b23da0f17cbc6 (diff)
ob_touch_t_gmtime(): New function
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
+}