[PATCH] osmo-gsm-manuals[master]: portability: use py script instead of 'date -d @1234'

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Tue Oct 18 12:33:43 UTC 2016


Hello lynxis lazus, Jenkins Builder,

I'd like you to reexamine a change.  Please visit

    https://gerrit.osmocom.org/1081

to look at the new patch set (#2).

portability: use py script instead of 'date -d @1234'

On FreeBSD, the 'date' command's -d option has a completely different meaning.
Instead, use a small python script to do the date format conversion, which
should be more portable.

As a side effect, we now also use UTC instead of the build server's timezone,
which may be considered a more international choice.

Add build/unix-time-to-fmt.py, call in build/Makefile.asciidoc.inc.

Change-Id: I91a40656184f553ee375216d8ba5c7788fe9990d
---
M build/Makefile.asciidoc.inc
A build/unix-time-to-fmt.py
2 files changed, 19 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-manuals refs/changes/81/1081/2

diff --git a/build/Makefile.asciidoc.inc b/build/Makefile.asciidoc.inc
index 1a77419..7def592 100644
--- a/build/Makefile.asciidoc.inc
+++ b/build/Makefile.asciidoc.inc
@@ -1,7 +1,7 @@
 BUILDDIR = $(TOPDIR)/build
 
 GIT_VERSION := $(shell git describe --abbrev=4 --dirty --always --tags)
-GIT_DATE := $(shell date -d @`git log -n 1 "--pretty=%at" ../.` "+%Y-%b-%e")
+GIT_DATE := $(shell $(TOPDIR)/build/unix-time-to-fmt.py `git log -n 1 "--pretty=%at" ../.`)
 
 # prepend the document name with the version numbe suffix
 #DOCS_VER = $(foreach P, $(ASCIIDOCS), $(P)-v$(shell xmllint --recover --xpath "//revnumber[position()=last()]/text()" $(P)-docinfo.xml 2>/dev/null))
diff --git a/build/unix-time-to-fmt.py b/build/unix-time-to-fmt.py
new file mode 100755
index 0000000..d081797
--- /dev/null
+++ b/build/unix-time-to-fmt.py
@@ -0,0 +1,18 @@
+#!/usr/bin/env python3
+"""
+Usage:
+
+  unix-time-to-fmt.py 1234567 [%Y-%m-%d[...]]
+
+Convert unix timestamp to a string of the given format in UTC, according to
+  https://docs.python.org/2/library/time.html
+Default is '%Y-%b-%d' --> 2016-Jan-01
+"""
+
+import sys, time
+
+fmt = '%Y-%b-%d'
+if len(sys.argv) > 2:
+  fmt = sys.argv[2]
+
+print(time.strftime(fmt, time.gmtime(float(sys.argv[1]))))

-- 
To view, visit https://gerrit.osmocom.org/1081
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I91a40656184f553ee375216d8ba5c7788fe9990d
Gerrit-PatchSet: 2
Gerrit-Project: osmo-gsm-manuals
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: lynxis lazus <lynxis at fe80.eu>



More information about the gerrit-log mailing list