Thread (1 message) 1 message, 1 author, 2016-06-15

Re: git pull on ia64 linux tree

From: Sanjoy Mahajan <hidden>
Date: 2016-06-15 22:41:54

I think it would be nice to use the TZ data to show the thing in the
timezone of the committer, though. Dunno how to do that, maybe
something like
TZ=$tz date -d "1970-01-01 + $sec sec"
Sadly, it looks like "date" doesn't understand timezone syntax like
that
Try:

negzone=`echo $tz | tr '[-]+' '+-'`
date -u -R -d "1970-01-01 $negzone + $sec sec" | sed "s/+0000/$tz/"

Or as a script:

#!/bin/bash
# usage: show-date.sh <utcseconds> <zone>
negzone=`echo $2 | tr '[-]+' '+-'`
date -u -R -d "1970-01-01 $negzone + $1 sec" | sed "s/+0000/$2/"

A simple test:

$ show-date.sh 10 +0200
Thu, 01 Jan 1970 02:00:10 +0200

Negating the timezone is an ugly workaround for date not understanding
a sensible TZ format.  I almost always use -u with date, otherwise I
get confused about what timezone it is using to interpret and to print
the date.

-Sanjoy
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help