commit 91eba4b27017c3b7bf0d0bb548a12a694ed51a3b
parent 01c12e7ac7bd0c95099dbe299f049c59081e35bc
Author: Laurent Bercot <ska-skaware@skarnet.org>
Date: Wed, 21 Mar 2018 11:52:14 +0000
Add -g option to s6-tai64nlocal
Diffstat:
3 files changed, 35 insertions(+), 3 deletions(-)
diff --git a/doc/s6-svdt.html b/doc/s6-svdt.html
@@ -66,5 +66,12 @@ the latest <em>maxlines</em> deaths. </li>
<li> 111: system call failed </li>
</ul>
+<h2> Notes </h2>
+
+<ul>
+ <li> To obtain human-readable local time or GMT time instead of TAI64N timestamps,
+simply pipe s6-svdt's output into <a href="s6-tai64nlocal.html">s6-tai64nlocal</a>. </li>
+</ul>
+
</body>
</html>
diff --git a/doc/s6-tai64nlocal.html b/doc/s6-tai64nlocal.html
@@ -29,7 +29,7 @@ time.
<h2> Interface </h2>
<pre>
- s6-tai64nlocal
+ s6-tai64nlocal [ -g ]
</pre>
<ul>
@@ -38,6 +38,12 @@ unfinished line, s6-tai64n processes it
and writes it before exiting. </li>
</ul>
+<h2> Options </h2>
+
+<ul>
+ <li> <tt>-g</tt> : print GMT time instead of local time. </li>
+</ul>
+
<h2> Notes </h2>
<ul>
diff --git a/src/daemontools-extras/s6-tai64nlocal.c b/src/daemontools-extras/s6-tai64nlocal.c
@@ -4,14 +4,33 @@
#include <errno.h>
#include <skalibs/buffer.h>
#include <skalibs/strerr2.h>
+#include <skalibs/sgetopt.h>
#include <skalibs/tai.h>
#include <skalibs/djbtime.h>
#include <skalibs/stralloc.h>
#include <skalibs/skamisc.h>
-int main (void)
+#define USAGE "s6-tai64nlocal [ -g ]"
+
+int main (int argc, char const *const *argv)
{
+ int islocal = 1 ;
PROG = "s6-tai64nlocal" ;
+ {
+ subgetopt_t l = SUBGETOPT_ZERO ;
+ for (;;)
+ {
+ int opt = subgetopt_r(argc, argv, "g", &l) ;
+ if (opt == -1) break ;
+ switch (opt)
+ {
+ case 'g' : islocal = 0 ; break ;
+ default : strerr_dieusage(100, USAGE) ;
+ }
+ }
+ argc -= l.ind ; argv += l.ind ;
+ }
+
for (;;)
{
unsigned int p = 0 ;
@@ -28,7 +47,7 @@ int main (void)
if (p)
{
localtmn_t local ;
- if (localtmn_from_tain(&local, &a, 1))
+ if (localtmn_from_tain(&local, &a, islocal))
{
char fmt[LOCALTMN_FMT+1] ;
size_t len = localtmn_fmt(fmt, &local) ;