Merge "portability: use py script instead of 'date -d @1234'"
This commit is contained in:
commit
643fb2d763
|
@ -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))
|
||||
|
|
|
@ -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]))))
|
Loading…
Reference in New Issue