git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] fix git log time display for western timezones

From
Nicolas Pitre <nico@cam.org>
Date
Apr 23, 2005, 03:06 UTC
Message-ID
<Pine.LNX.4.62.0504222300010.26129@localhost.localdomain>

It appears that the date command doesn't know how to substract time and always adds it. The time zone fixup has to be done separately otherwise time displayed in a negative time zone is wrong.

Signed-off-by: Nicolas Pitre <nico@cam.org>
Index: gitlog.sh
===================================================================
--- 2a91836b5814ffacb1fde000dfb1e55457761c88/gitlog.sh  (mode:100755 sha1:53b55be31b38b2ab88434cf1ac0a868700e64525)
+++ uncommitted/gitlog.sh  (mode:100775)
@@ -56,8 +56,9 @@
 
 				date=(${rest#*> })
 				sec=${date[0]}; tz=${date[1]}
-				dtz=${tz/+/+ }; dtz=${dtz/-/- }
-				pdate="$(date -Rud "1970-01-01 UTC + $sec sec $dtz" 2>/dev/null)"
+				dtz=${tz/+/}
+				lsec=$(expr $dtz / 100 \* 3600 + $dtz % 100 \* 60 + $sec)
+				pdate="$(date -Rud "1970-01-01 UTC + $lsec sec" 2>/dev/null)"
 				if [ "$pdate" ]; then
 					echo -n $color$key $rest | sed "s/>.*/> ${pdate/+0000/$tz}/"
 					echo $coldefault
Message 1 of 1 in “fix git log time display for western timezones”
  1. fix git log time display for western timezonesNicolas Pitre, Apr 23, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.