summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2018-03-21 11:52:14 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2018-03-21 11:52:14 +0000
commit91eba4b27017c3b7bf0d0bb548a12a694ed51a3b (patch)
treed4abb4bb2cdfd779a94d78040529812ffc89f0fe
parent01c12e7ac7bd0c95099dbe299f049c59081e35bc (diff)
downloads6-91eba4b27017c3b7bf0d0bb548a12a694ed51a3b.tar.xz
Add -g option to s6-tai64nlocal
-rw-r--r--doc/s6-svdt.html7
-rw-r--r--doc/s6-tai64nlocal.html8
-rw-r--r--src/daemontools-extras/s6-tai64nlocal.c23
3 files changed, 35 insertions, 3 deletions
diff --git a/doc/s6-svdt.html b/doc/s6-svdt.html
index bb78061..a908d8c 100644
--- 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
index 0c7e597..2df3f86 100644
--- 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>&nbsp;: 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
index 7084abd..097102b 100644
--- 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) ;