* [PATCH 1/3] gitk: Remove unused $cdate array
@ 2011-01-19 19:46 Anders Kaseorg
2011-01-19 19:47 ` [PATCH 2/3] gitk: Remember time zones from author and commit timestamps Anders Kaseorg
2011-01-19 19:47 ` [PATCH 3/3] gitk: Allow displaying " Anders Kaseorg
0 siblings, 2 replies; 15+ messages in thread
From: Anders Kaseorg @ 2011-01-19 19:46 UTC (permalink / raw)
To: Paul Mackerras; +Cc: git
It was unused since commit 9f1afe05c3ab7228e21ba3666c6e35d693149b37.
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
---
gitk | 5 +----
1 files changed, 1 insertions(+), 4 deletions(-)
diff --git a/gitk b/gitk
index a0f7816..bf68959 100755
--- a/gitk
+++ b/gitk
@@ -1621,7 +1621,7 @@ proc readcommit {id} {
}
proc parsecommit {id contents listed} {
- global commitinfo cdate
+ global commitinfo
set inhdr 1
set comment {}
@@ -1671,9 +1671,6 @@ proc parsecommit {id contents listed} {
}
set comment $newcomment
}
- if {$comdate != {}} {
- set cdate($id) $comdate
- }
set commitinfo($id) [list $headline $auname $audate \
$comname $comdate $comment]
}
--
1.7.4.rc1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 2/3] gitk: Remember time zones from author and commit timestamps
2011-01-19 19:46 [PATCH 1/3] gitk: Remove unused $cdate array Anders Kaseorg
@ 2011-01-19 19:47 ` Anders Kaseorg
2011-01-19 19:47 ` [PATCH 3/3] gitk: Allow displaying " Anders Kaseorg
1 sibling, 0 replies; 15+ messages in thread
From: Anders Kaseorg @ 2011-01-19 19:47 UTC (permalink / raw)
To: Paul Mackerras; +Cc: git
When resolving a conflicted cherry-pick, this lets us pass
GIT_AUTHOR_DATE to git citool with the correct timezone.
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
---
gitk | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/gitk b/gitk
index bf68959..5c6058a 100755
--- a/gitk
+++ b/gitk
@@ -659,7 +659,7 @@ proc newvarc {view id} {
if {![info exists commitinfo($id)]} {
parsecommit $id $commitdata($id) 1
}
- set cdate [lindex $commitinfo($id) 4]
+ set cdate [lindex [lindex $commitinfo($id) 4] 0]
if {![string is integer -strict $cdate]} {
set cdate 0
}
@@ -1641,10 +1641,10 @@ proc parsecommit {id contents listed} {
set line [split $line " "]
set tag [lindex $line 0]
if {$tag == "author"} {
- set audate [lindex $line end-1]
+ set audate [lrange $line end-1 end]
set auname [join [lrange $line 1 end-2] " "]
} elseif {$tag == "committer"} {
- set comdate [lindex $line end-1]
+ set comdate [lrange $line end-1 end]
set comname [join [lrange $line 1 end-2] " "]
}
}
@@ -11018,7 +11018,7 @@ proc prefsok {} {
proc formatdate {d} {
global datetimeformat
if {$d ne {}} {
- set d [clock format $d -format $datetimeformat]
+ set d [clock format [lindex $d 0] -format $datetimeformat]
}
return $d
}
--
1.7.4.rc1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 3/3] gitk: Allow displaying time zones from author and commit timestamps
2011-01-19 19:46 [PATCH 1/3] gitk: Remove unused $cdate array Anders Kaseorg
2011-01-19 19:47 ` [PATCH 2/3] gitk: Remember time zones from author and commit timestamps Anders Kaseorg
@ 2011-01-19 19:47 ` Anders Kaseorg
2011-05-29 4:46 ` Paul Mackerras
1 sibling, 1 reply; 15+ messages in thread
From: Anders Kaseorg @ 2011-01-19 19:47 UTC (permalink / raw)
To: Paul Mackerras; +Cc: git
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 <andersk@mit.edu>
---
gitk | 13 ++++++++++++-
1 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/gitk b/gitk
index 5c6058a..a072593 100755
--- a/gitk
+++ b/gitk
@@ -11018,7 +11018,18 @@ proc prefsok {} {
proc formatdate {d} {
global datetimeformat
if {$d ne {}} {
- set d [clock format [lindex $d 0] -format $datetimeformat]
+ if {[string match {*%[zZ]*} $datetimeformat]} {
+ if {[catch {set d [clock format [lindex $d 0] -timezone [lindex $d 1] -format $datetimeformat]}]} {
+ # Tcl < 8.5 does not support -timezone.
+ global env
+ set zone [lindex $d 1]
+ set env(TZ) "IDK[string range $zone 0 2]:[string range $zone 3 end]"
+ set d [clock format [lindex $d 0] -format $datetimeformat]
+ unset env(TZ)
+ }
+ } else {
+ set d [clock format [lindex $d 0] -format $datetimeformat]
+ }
}
return $d
}
--
1.7.4.rc1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH 3/3] gitk: Allow displaying time zones from author and commit timestamps
2011-01-19 19:47 ` [PATCH 3/3] gitk: Allow displaying " Anders Kaseorg
@ 2011-05-29 4:46 ` Paul Mackerras
2011-05-30 3:05 ` Anders Kaseorg
0 siblings, 1 reply; 15+ messages in thread
From: Paul Mackerras @ 2011-05-29 4:46 UTC (permalink / raw)
To: Anders Kaseorg; +Cc: git
On Wed, Jan 19, 2011 at 02:47:52PM -0500, Anders Kaseorg wrote:
> 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 <andersk@mit.edu>
> ---
> gitk | 13 ++++++++++++-
> 1 files changed, 12 insertions(+), 1 deletions(-)
>
> diff --git a/gitk b/gitk
> index 5c6058a..a072593 100755
> --- a/gitk
> +++ b/gitk
> @@ -11018,7 +11018,18 @@ proc prefsok {} {
> proc formatdate {d} {
> global datetimeformat
> if {$d ne {}} {
> - set d [clock format [lindex $d 0] -format $datetimeformat]
> + if {[string match {*%[zZ]*} $datetimeformat]} {
> + if {[catch {set d [clock format [lindex $d 0] -timezone [lindex $d 1] -format $datetimeformat]}]} {
> + # Tcl < 8.5 does not support -timezone.
> + global env
> + set zone [lindex $d 1]
> + set env(TZ) "IDK[string range $zone 0 2]:[string range $zone 3 end]"
What is this about? Where is the IDK prefix for timezones defined or
described?
> + set d [clock format [lindex $d 0] -format $datetimeformat]
> + unset env(TZ)
Oops, we just lost any previous setting of TZ...
Paul.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 3/3] gitk: Allow displaying time zones from author and commit timestamps
2011-05-29 4:46 ` Paul Mackerras
@ 2011-05-30 3:05 ` Anders Kaseorg
2011-05-30 3:06 ` [PATCH v2 " Anders Kaseorg
2011-05-30 5:35 ` [PATCH " Jakub Narebski
0 siblings, 2 replies; 15+ messages in thread
From: Anders Kaseorg @ 2011-05-30 3:05 UTC (permalink / raw)
To: Paul Mackerras; +Cc: git
On Sun, 29 May 2011, Paul Mackerras wrote:
> > @@ -11018,7 +11018,18 @@ proc prefsok {} {
> > proc formatdate {d} {
> > global datetimeformat
> > if {$d ne {}} {
> > - set d [clock format [lindex $d 0] -format $datetimeformat]
> > + if {[string match {*%[zZ]*} $datetimeformat]} {
> > + if {[catch {set d [clock format [lindex $d 0] -timezone [lindex $d 1] -format $datetimeformat]}]} {
> > + # Tcl < 8.5 does not support -timezone.
> > + global env
> > + set zone [lindex $d 1]
> > + set env(TZ) "IDK[string range $zone 0 2]:[string range $zone 3 end]"
>
> What is this about? Where is the IDK prefix for timezones defined or
> described?
Yeah, sorry, that deserved a bit more explanation. This is a kludge to
get Tcl 8.4 to format dates in the right timezone. IDK is an arbitrary
made up 3-letter code (“I Don’t Know”), since a UTC offset can’t generally
be converted into a zone name. The format of TZ is described at:
http://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html
http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html
Actually, reading that again, I just realized that I need to invert the
sign. Also that it can be longer than 3 letters; I’ll use “Unknown”
instead.
> > + set d [clock format [lindex $d 0] -format $datetimeformat]
> > + unset env(TZ)
>
> Oops, we just lost any previous setting of TZ...
Good point.
Thanks for taking a look. I’ll follow up with a fixed version.
Anders
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v2 3/3] gitk: Allow displaying time zones from author and commit timestamps
2011-05-30 3:05 ` Anders Kaseorg
@ 2011-05-30 3:06 ` Anders Kaseorg
2011-05-30 19:35 ` Andreas Schwab
2011-05-30 5:35 ` [PATCH " Jakub Narebski
1 sibling, 1 reply; 15+ messages in thread
From: Anders Kaseorg @ 2011-05-30 3:06 UTC (permalink / raw)
To: Paul Mackerras; +Cc: git
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 <andersk@mit.edu>
---
gitk | 18 +++++++++++++++++-
1 files changed, 17 insertions(+), 1 deletions(-)
diff --git a/gitk b/gitk
index 8e15572..c77771e 100755
--- a/gitk
+++ b/gitk
@@ -11021,7 +11021,23 @@ proc prefsok {} {
proc formatdate {d} {
global datetimeformat
if {$d ne {}} {
- set d [clock format [lindex $d 0] -format $datetimeformat]
+ # If $datetimeformat includes a timezone, display in the
+ # timezone of the argument. Otherwise, display in local time.
+ if {[string match {*%[zZ]*} $datetimeformat]} {
+ if {[catch {set d [clock format [lindex $d 0] -timezone [lindex $d 1] -format $datetimeformat]}]} {
+ # Tcl < 8.5 does not support -timezone. Emulate it by
+ # setting TZ=Unknown±NNNN.
+ global env
+ catch {set savedTZ $env(TZ)}
+ set zone [lindex $d 1]
+ set sign [string map {+ - - +} [string index $zone 0]]
+ set env(TZ) Unknown$sign[string range $zone 1 2]:[string range $zone 3 4]
+ set d [clock format [lindex $d 0] -format $datetimeformat]
+ if {[catch {set env(TZ) $savedTZ}]} {unset env(TZ)}
+ }
+ } else {
+ set d [clock format [lindex $d 0] -format $datetimeformat]
+ }
}
return $d
}
--
1.7.5.3
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH 3/3] gitk: Allow displaying time zones from author and commit timestamps
2011-05-30 3:05 ` Anders Kaseorg
2011-05-30 3:06 ` [PATCH v2 " Anders Kaseorg
@ 2011-05-30 5:35 ` Jakub Narebski
2011-05-30 6:17 ` Tim Guirgies
1 sibling, 1 reply; 15+ messages in thread
From: Jakub Narebski @ 2011-05-30 5:35 UTC (permalink / raw)
To: Anders Kaseorg; +Cc: Paul Mackerras, git
Anders Kaseorg <andersk@MIT.EDU> writes:
> On Sun, 29 May 2011, Paul Mackerras wrote:
> > > @@ -11018,7 +11018,18 @@ proc prefsok {} {
> > > proc formatdate {d} {
> > > global datetimeformat
> > > if {$d ne {}} {
> > > - set d [clock format [lindex $d 0] -format $datetimeformat]
> > > + if {[string match {*%[zZ]*} $datetimeformat]} {
> > > + if {[catch {set d [clock format [lindex $d 0] -timezone [lindex $d 1] -format $datetimeformat]}]} {
> > > + # Tcl < 8.5 does not support -timezone.
> > > + global env
> > > + set zone [lindex $d 1]
> > > + set env(TZ) "IDK[string range $zone 0 2]:[string range $zone 3 end]"
> >
> > What is this about? Where is the IDK prefix for timezones defined or
> > described?
>
> Yeah, sorry, that deserved a bit more explanation. This is a kludge to
> get Tcl 8.4 to format dates in the right timezone. IDK is an arbitrary
> made up 3-letter code (“I Don’t Know”), since a UTC offset can’t generally
> be converted into a zone name. The format of TZ is described at:
> http://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html
> http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html
>
> Actually, reading that again, I just realized that I need to invert the
> sign. Also that it can be longer than 3 letters; I’ll use “Unknown”
> instead.
Why not use UTC+N timezone (note: please check of for +HHMM it is
UTC+HH or UTC-HH) for timezone with given numeric offset from
Coordinated Universal Time?
BTW. UTC because http://www.nist.gov/pml/div688/utcnist.cfm#cut
--
Jakub Narebski
Poland
ShadeHawk on #git
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 3/3] gitk: Allow displaying time zones from author and commit timestamps
2011-05-30 5:35 ` [PATCH " Jakub Narebski
@ 2011-05-30 6:17 ` Tim Guirgies
2011-05-30 6:29 ` Jakub Narebski
0 siblings, 1 reply; 15+ messages in thread
From: Tim Guirgies @ 2011-05-30 6:17 UTC (permalink / raw)
To: Jakub Narebski; +Cc: Anders Kaseorg, Paul Mackerras, git
[-- Attachment #1: Type: text/plain, Size: 2040 bytes --]
On Sun, May 29, 2011 at 10:35:08PM -0700, Jakub Narebski wrote:
> Anders Kaseorg <andersk@MIT.EDU> writes:
> > On Sun, 29 May 2011, Paul Mackerras wrote:
>
> > > > @@ -11018,7 +11018,18 @@ proc prefsok {} {
> > > > proc formatdate {d} {
> > > > global datetimeformat
> > > > if {$d ne {}} {
> > > > - set d [clock format [lindex $d 0] -format $datetimeformat]
> > > > + if {[string match {*%[zZ]*} $datetimeformat]} {
> > > > + if {[catch {set d [clock format [lindex $d 0] -timezone [lindex $d 1] -format $datetimeformat]}]} {
> > > > + # Tcl < 8.5 does not support -timezone.
> > > > + global env
> > > > + set zone [lindex $d 1]
> > > > + set env(TZ) "IDK[string range $zone 0 2]:[string range $zone 3 end]"
> > >
> > > What is this about? Where is the IDK prefix for timezones defined or
> > > described?
> >
> > Yeah, sorry, that deserved a bit more explanation. This is a kludge to
> > get Tcl 8.4 to format dates in the right timezone. IDK is an arbitrary
> > made up 3-letter code (“I Don’t Know”), since a UTC offset can’t generally
> > be converted into a zone name. The format of TZ is described at:
> > http://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html
> > http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html
> >
> > Actually, reading that again, I just realized that I need to invert the
> > sign. Also that it can be longer than 3 letters; I’ll use “Unknown”
> > instead.
>
> Why not use UTC+N timezone (note: please check of for +HHMM it is
> UTC+HH or UTC-HH) for timezone with given numeric offset from
> Coordinated Universal Time?
>
> BTW. UTC because http://www.nist.gov/pml/div688/utcnist.cfm#cut
But what of half-hour offsets, in that case? A better idea would be
UTC+HHMM or UTC-HHMM. As an example, SA (CST) has a timezone of
UTC+0930.
Tim
--
lt.infiltrator@gmail.com
() ascii ribbon campaign - against html e-mail
/\ www.asciiribbon.org - against proprietary attachments
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 3/3] gitk: Allow displaying time zones from author and commit timestamps
2011-05-30 6:17 ` Tim Guirgies
@ 2011-05-30 6:29 ` Jakub Narebski
2011-05-30 21:35 ` Anders Kaseorg
0 siblings, 1 reply; 15+ messages in thread
From: Jakub Narebski @ 2011-05-30 6:29 UTC (permalink / raw)
To: Tim Guirgies; +Cc: Anders Kaseorg, Paul Mackerras, git
Tim Guirgies wrote:
> On Sun, May 29, 2011 at 10:35:08PM -0700, Jakub Narebski wrote:
> > Anders Kaseorg <andersk@MIT.EDU> writes:
[...]
> > > Yeah, sorry, that deserved a bit more explanation. This is a kludge to
> > > get Tcl 8.4 to format dates in the right timezone. IDK is an arbitrary
> > > made up 3-letter code (“I Don’t Know”), since a UTC offset can’t generally
> > > be converted into a zone name. The format of TZ is described at:
> > > http://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html
> > > http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html
> > >
> > > Actually, reading that again, I just realized that I need to invert the
> > > sign. Also that it can be longer than 3 letters; I’ll use “Unknown”
> > > instead.
> >
> > Why not use UTC+N timezone (note: please check of for +HHMM it is
> > UTC+HH or UTC-HH) for timezone with given numeric offset from
> > Coordinated Universal Time?
> >
> > BTW. UTC because http://www.nist.gov/pml/div688/utcnist.cfm#cut
>
> But what of half-hour offsets, in that case? A better idea would be
> UTC+HHMM or UTC-HHMM. As an example, SA (CST) has a timezone of
> UTC+0930.
I think full specification is UTC+HH:MM or UTC-HH:MM. GNU date
understands 'TZ=UTC+09:30 date'.
P.S. I should have remembered about fractional timezones, as we have had
problems in gitweb with those... and I have checked then that git.git
repository includes some commits in fractional timezones.
--
Jakub Narebski
Poland
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2 3/3] gitk: Allow displaying time zones from author and commit timestamps
2011-05-30 3:06 ` [PATCH v2 " Anders Kaseorg
@ 2011-05-30 19:35 ` Andreas Schwab
2011-05-30 21:45 ` Anders Kaseorg
0 siblings, 1 reply; 15+ messages in thread
From: Andreas Schwab @ 2011-05-30 19:35 UTC (permalink / raw)
To: Anders Kaseorg; +Cc: Paul Mackerras, git
Anders Kaseorg <andersk@MIT.EDU> writes:
> + catch {set savedTZ $env(TZ)}
if {[info exits env(TZ)]} {set savedTZ $env(TZ)}
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 3/3] gitk: Allow displaying time zones from author and commit timestamps
2011-05-30 6:29 ` Jakub Narebski
@ 2011-05-30 21:35 ` Anders Kaseorg
2011-05-30 22:17 ` Andreas Schwab
0 siblings, 1 reply; 15+ messages in thread
From: Anders Kaseorg @ 2011-05-30 21:35 UTC (permalink / raw)
To: Jakub Narebski; +Cc: Tim Guirgies, Paul Mackerras, git
On Mon, 30 May 2011, Jakub Narebski wrote:
> > > Why not use UTC+N timezone […]?
>
> I think full specification is UTC+HH:MM or UTC-HH:MM. GNU date
> understands 'TZ=UTC+09:30 date'.
No, that’s not what the letter code in TZ means. TZ=EDT+04:00 means that
• The current time zone is called EDT.
• The current time zone is at offset -04:00 from UTC. (Note the sign
reversal.)
EDT is displayed as the name of the zone and is not used in any
calculations; it does not mean we’re taking an offset _from_ EDT.
So it doesn’t make sense to write TZ=UTC±NN:NN for any NN:NN other than
00:00. Otherwise libc will happily give you the nonsense that you asked
for:
$ TZ=UTC+00:00 date; TZ=UTC+09:30 date
Mon May 30 21:21:32 UTC 2011
Mon May 30 11:51:32 UTC 2011
This is why I used “Unknown” instead of “UTC”.
(Oh, my comment should have said “Unknown±NN:NN” instead of
“Unknown±NNNN”; the code gets it right.)
If I wanted to do better, I’d need a way to translate UTC offsets to zone
names, but I don’t know of a canonical way to do that (there’s not even a
unique answer in general).
In Tcl ≥ 8.5, none of this matters because ‘clock format -timezone’ just
uses the numerical UTC offset as the zone name. For the fallback code, I
can’t do that by manipulating TZ, because the zone name needs to be made
of letters.
Anders
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2 3/3] gitk: Allow displaying time zones from author and commit timestamps
2011-05-30 19:35 ` Andreas Schwab
@ 2011-05-30 21:45 ` Anders Kaseorg
2011-05-30 21:47 ` [PATCH v3 " Anders Kaseorg
0 siblings, 1 reply; 15+ messages in thread
From: Anders Kaseorg @ 2011-05-30 21:45 UTC (permalink / raw)
To: Andreas Schwab; +Cc: Paul Mackerras, git
On Mon, 30 May 2011, Andreas Schwab wrote:
> > + catch {set savedTZ $env(TZ)}
> if {[info exits env(TZ)]} {set savedTZ $env(TZ)}
That felt like a lot of noise just to save and restore an environment
variable, but since I more or less learned Tcl just to write this patch,
I’ll defer to your judgement of style here.
Thanks,
Anders
diff --git a/gitk b/gitk
index c77771e..6a4c8ed 100755
--- a/gitk
+++ b/gitk
@@ -11026,14 +11026,20 @@ proc formatdate {d} {
if {[string match {*%[zZ]*} $datetimeformat]} {
if {[catch {set d [clock format [lindex $d 0] -timezone [lindex $d 1] -format $datetimeformat]}]} {
# Tcl < 8.5 does not support -timezone. Emulate it by
- # setting TZ=Unknown±NNNN.
+ # setting TZ=Unknown±NN:NN.
global env
- catch {set savedTZ $env(TZ)}
+ if {[info exists env(TZ)]} {
+ set savedTZ $env(TZ)
+ }
set zone [lindex $d 1]
set sign [string map {+ - - +} [string index $zone 0]]
set env(TZ) Unknown$sign[string range $zone 1 2]:[string range $zone 3 4]
set d [clock format [lindex $d 0] -format $datetimeformat]
- if {[catch {set env(TZ) $savedTZ}]} {unset env(TZ)}
+ if {[info exists savedTZ]} {
+ set env(TZ) $savedTZ
+ } else {
+ unset env(TZ)
+ }
}
} else {
set d [clock format [lindex $d 0] -format $datetimeformat]
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v3 3/3] gitk: Allow displaying time zones from author and commit timestamps
2011-05-30 21:45 ` Anders Kaseorg
@ 2011-05-30 21:47 ` Anders Kaseorg
0 siblings, 0 replies; 15+ messages in thread
From: Anders Kaseorg @ 2011-05-30 21:47 UTC (permalink / raw)
To: Paul Mackerras; +Cc: git, Andreas Schwab, Jakub Narebski, Tim Guirgies
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 <andersk@mit.edu>
---
gitk | 24 +++++++++++++++++++++++-
1 files changed, 23 insertions(+), 1 deletions(-)
diff --git a/gitk b/gitk
index 8e15572..6a4c8ed 100755
--- a/gitk
+++ b/gitk
@@ -11021,7 +11021,29 @@ proc prefsok {} {
proc formatdate {d} {
global datetimeformat
if {$d ne {}} {
- set d [clock format [lindex $d 0] -format $datetimeformat]
+ # If $datetimeformat includes a timezone, display in the
+ # timezone of the argument. Otherwise, display in local time.
+ if {[string match {*%[zZ]*} $datetimeformat]} {
+ if {[catch {set d [clock format [lindex $d 0] -timezone [lindex $d 1] -format $datetimeformat]}]} {
+ # Tcl < 8.5 does not support -timezone. Emulate it by
+ # setting TZ=Unknown±NN:NN.
+ global env
+ if {[info exists env(TZ)]} {
+ set savedTZ $env(TZ)
+ }
+ set zone [lindex $d 1]
+ set sign [string map {+ - - +} [string index $zone 0]]
+ set env(TZ) Unknown$sign[string range $zone 1 2]:[string range $zone 3 4]
+ set d [clock format [lindex $d 0] -format $datetimeformat]
+ if {[info exists savedTZ]} {
+ set env(TZ) $savedTZ
+ } else {
+ unset env(TZ)
+ }
+ }
+ } else {
+ set d [clock format [lindex $d 0] -format $datetimeformat]
+ }
}
return $d
}
--
1.7.5.3
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH 3/3] gitk: Allow displaying time zones from author and commit timestamps
2011-05-30 21:35 ` Anders Kaseorg
@ 2011-05-30 22:17 ` Andreas Schwab
2011-05-30 22:41 ` [PATCH v4 " Anders Kaseorg
0 siblings, 1 reply; 15+ messages in thread
From: Andreas Schwab @ 2011-05-30 22:17 UTC (permalink / raw)
To: Anders Kaseorg; +Cc: Jakub Narebski, Tim Guirgies, Paul Mackerras, git
Anders Kaseorg <andersk@MIT.EDU> writes:
> In Tcl ≥ 8.5, none of this matters because ‘clock format -timezone’ just
> uses the numerical UTC offset as the zone name. For the fallback code, I
> can’t do that by manipulating TZ, because the zone name needs to be made
> of letters.
POSIX defines the form TZ="<-0430>+04:30" where <...> can contain any
character from [a-zA-Z0-9+-].
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v4 3/3] gitk: Allow displaying time zones from author and commit timestamps
2011-05-30 22:17 ` Andreas Schwab
@ 2011-05-30 22:41 ` Anders Kaseorg
0 siblings, 0 replies; 15+ messages in thread
From: Anders Kaseorg @ 2011-05-30 22:41 UTC (permalink / raw)
To: Andreas Schwab; +Cc: Jakub Narebski, Tim Guirgies, Paul Mackerras, git
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 <andersk@mit.edu>
---
On Tue, 31 May 2011, Andreas Schwab wrote:
> POSIX defines the form TZ="<-0430>+04:30" where <...> can contain any
> character from [a-zA-Z0-9+-].
Oh hey, it does! Let’s use that then.
Anders
gitk | 24 +++++++++++++++++++++++-
1 files changed, 23 insertions(+), 1 deletions(-)
diff --git a/gitk b/gitk
index 8e15572..ca3aa54 100755
--- a/gitk
+++ b/gitk
@@ -11021,7 +11021,29 @@ proc prefsok {} {
proc formatdate {d} {
global datetimeformat
if {$d ne {}} {
- set d [clock format [lindex $d 0] -format $datetimeformat]
+ # If $datetimeformat includes a timezone, display in the
+ # timezone of the argument. Otherwise, display in local time.
+ if {[string match {*%[zZ]*} $datetimeformat]} {
+ if {[catch {set d [clock format [lindex $d 0] -timezone [lindex $d 1] -format $datetimeformat]}]} {
+ # Tcl < 8.5 does not support -timezone. Emulate it by
+ # setting TZ (e.g. TZ=<-0430>+04:30).
+ global env
+ if {[info exists env(TZ)]} {
+ set savedTZ $env(TZ)
+ }
+ set zone [lindex $d 1]
+ set sign [string map {+ - - +} [string index $zone 0]]
+ set env(TZ) <$zone>$sign[string range $zone 1 2]:[string range $zone 3 4]
+ set d [clock format [lindex $d 0] -format $datetimeformat]
+ if {[info exists savedTZ]} {
+ set env(TZ) $savedTZ
+ } else {
+ unset env(TZ)
+ }
+ }
+ } else {
+ set d [clock format [lindex $d 0] -format $datetimeformat]
+ }
}
return $d
}
--
1.7.5.3
^ permalink raw reply related [flat|nested] 15+ messages in thread
end of thread, other threads:[~2011-05-30 22:42 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-19 19:46 [PATCH 1/3] gitk: Remove unused $cdate array Anders Kaseorg
2011-01-19 19:47 ` [PATCH 2/3] gitk: Remember time zones from author and commit timestamps Anders Kaseorg
2011-01-19 19:47 ` [PATCH 3/3] gitk: Allow displaying " Anders Kaseorg
2011-05-29 4:46 ` Paul Mackerras
2011-05-30 3:05 ` Anders Kaseorg
2011-05-30 3:06 ` [PATCH v2 " Anders Kaseorg
2011-05-30 19:35 ` Andreas Schwab
2011-05-30 21:45 ` Anders Kaseorg
2011-05-30 21:47 ` [PATCH v3 " Anders Kaseorg
2011-05-30 5:35 ` [PATCH " Jakub Narebski
2011-05-30 6:17 ` Tim Guirgies
2011-05-30 6:29 ` Jakub Narebski
2011-05-30 21:35 ` Anders Kaseorg
2011-05-30 22:17 ` Andreas Schwab
2011-05-30 22:41 ` [PATCH v4 " Anders Kaseorg
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.