diff options
author | Patrick 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) |
commit | 7d5bb275dbe5c80bcb743150b1ae4463bc708333 (patch) | |
tree | 0684899e35a7cc7749668205ca6303de67c1310b | |
parent | cc8ae3314f06138823ebdef6890b23da0f17cbc6 (diff) |
ob_touch_t_gmtime(): New function
-rw-r--r-- | NEWS | 4 | ||||
-rw-r--r-- | lib/time.sh | 21 | ||||
-rw-r--r-- | man/local.mk | 3 |
3 files changed, 27 insertions, 1 deletions
@@ -3,6 +3,10 @@ opkbuild version 4.1.1 Released: ????-??-?? +libopkbuild: + + * A new function ob_touch_t_gmtime() has been added. + opkbuild version 4.1.0 ---------------------- 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 +} diff --git a/man/local.mk b/man/local.mk index c04b83a..6e6d3a2 100644 --- a/man/local.mk +++ b/man/local.mk @@ -59,7 +59,8 @@ man3_MANS = \ %reldir%/ob_parse_dep.3 \ %reldir%/ob_reduce_deps.3 \ %reldir%/ob_rfc822_mktime.3 \ - %reldir%/ob_iso8601_gmtime.3 + %reldir%/ob_iso8601_gmtime.3 \ + %reldir%/ob_touch_t_gmtime.3 man7_sources = \ %reldir%/opkbuild.7in man7_MANS = $(man7_sources:.7in=.7) |