Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit 019e163

Browse files
anderskpaulusmack
authored andcommitted
gitk: Allow displaying time zones from author and commit dates timestamps
Now gitk can be configured to display author and commit dates in their original timezone, by putting %z into datetimeformat in ~/.gitk. Signed-off-by: Anders Kaseorg <[email protected]> Signed-off-by: Paul Mackerras <[email protected]>
1 parent 4135d36 commit 019e163

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

gitk

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11580,7 +11580,29 @@ proc prefsok {} {
1158011580
proc formatdate {d} {
1158111581
global datetimeformat
1158211582
if {$d ne {}} {
11583-
set d [clock format [lindex $d 0] -format $datetimeformat]
11583+
# If $datetimeformat includes a timezone, display in the
11584+
# timezone of the argument. Otherwise, display in local time.
11585+
if {[string match {*%[zZ]*} $datetimeformat]} {
11586+
if {[catch {set d [clock format [lindex $d 0] -timezone [lindex $d 1] -format $datetimeformat]}]} {
11587+
# Tcl < 8.5 does not support -timezone. Emulate it by
11588+
# setting TZ (e.g. TZ=<-0430>+04:30).
11589+
global env
11590+
if {[info exists env(TZ)]} {
11591+
set savedTZ $env(TZ)
11592+
}
11593+
set zone [lindex $d 1]
11594+
set sign [string map {+ - - +} [string index $zone 0]]
11595+
set env(TZ) <$zone>$sign[string range $zone 1 2]:[string range $zone 3 4]
11596+
set d [clock format [lindex $d 0] -format $datetimeformat]
11597+
if {[info exists savedTZ]} {
11598+
set env(TZ) $savedTZ
11599+
} else {
11600+
unset env(TZ)
11601+
}
11602+
}
11603+
} else {
11604+
set d [clock format [lindex $d 0] -format $datetimeformat]
11605+
}
1158411606
}
1158511607
return $d
1158611608
}

0 commit comments

Comments
 (0)