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

[PATCH v3 2/3] gitweb: introduce localtime feature

From
Jakub Narebski <jnareb@gmail.com>
Date
Mar 18, 2011, 14:40 UTC
Message-ID
<201103181540.03431.jnareb@gmail.com>
In-Reply-To
<e160457138c1166ffa6faf1c58ea170e@localhost>
From: Kevin Cernekee <cernekee@gmail.com>

With this feature enabled, all timestamps are shown in the local timezone instead of GMT. The timezone is taken from the appropriate timezone string stored in the commit object.

This is useful if most of contributors (to a project) are based in a single office, all within the same timezone. In such case local time is more useful than GMT / UTC time that gitweb uses by default, and which is better choice for geographically scattered contributors.

This change does not affect relative timestamps (e.g. "5 hours ago"), and neither does it affect 'patch' and 'patches' views which already use localtime because they are generated by "git format-patch".

Affected views include:
* 'summary' view, "last change" field (commit time from latest change)
* 'log' view, author time
* 'commit' and 'commitdiff' views, author/committer time
* 'tag' view, tagger time

In the case of 'commit', 'commitdiff' and 'tag' views gitweb used to print both GMT time and time in timezone of author/tagger/comitter, marking localtime with "atnight" as appropriate; after this commit gitweb shows only local time. Marking localtime with "atnight" when needed is left for subsequent commit.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
Changes from original v2 version by Kevin Cernekee:
* Expanded commit message, explaining "whys" behind introducing this new
  feature (why and when can it be useful), as per
    http://thread.gmane.org/gmane.comp.version-control.git/169096/focus=169284
* Minor whitespace changes
 gitweb/gitweb.perl |   21 ++++++++++++++++++++-
 1 files changed, 20 insertions(+), 1 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 3960d34..1df3652 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -504,6 +504,19 @@ our %feature = (
 		'sub' => sub { feature_bool('remote_heads', @_) },
 		'override' => 0,
 		'default' => [0]},
+
+	# Use the author/commit localtime rather than GMT for all timestamps.
+	# Disabled by default.
+
+	# To enable system wide have in $GITWEB_CONFIG
+	# $feature{'localtime'}{'default'} = [1];
+	# To have project specific config enable override in $GITWEB_CONFIG
+	# $feature{'localtime'}{'override'} = 1;
+	# and in project config gitweb.localtime = 0|1;
+	'localtime' => {
+		'sub' => sub { feature_bool('localtime', @_) },
+		'override' => 0,
+		'default' => [0]},
 );
 
 sub gitweb_get_feature {
@@ -2930,6 +2943,12 @@ sub parse_date {
 	$date{'iso-tz'} = sprintf("%04d-%02d-%02d %02d:%02d:%02d %s",
 	                          1900+$year, $mon+1, $mday,
 	                          $hour, $min, $sec, $tz);
+
+	if (gitweb_check_feature('localtime')) {
+		$date{'rfc2822'} = sprintf "%s, %d %s %4d %02d:%02d:%02d $tz",
+		                   $days[$wday], $mday, $months[$mon],
+		                   1900+$year, $hour ,$min, $sec;
+	}
 	return %date;
 }
 
@@ -3992,7 +4011,7 @@ sub git_print_authorship_rows {
 		      "</td></tr>\n" .
 		      "<tr>" .
 		      "<td></td><td> $wd{'rfc2822'}";
-		print_local_time(%wd);
+		print_local_time(%wd) if !gitweb_check_feature('localtime');
 		print "</td>" .
 		      "</tr>\n";
 	}
-- 
1.7.3
Previous: Kevin CernekeeNext: Junio C Hamano
Message 3 of 17 in “gitweb: fix #patchNN anchors when path_info is enabled”
  1. 1/3 gitweb: fix #patchNN anchors when path_info is enabledKevin Cernekee, Mar 17, 2011
  2. 2/3 gitweb: introduce localtime featureKevin Cernekee, Mar 17, 2011
  3. 2/3 gitweb: introduce localtime featureJakub Narebski, Mar 18, 2011
  4. Junio C HamanoMar 18, 2011
  5. Jakub NarebskiMar 18, 2011
  6. Junio C HamanoMar 18, 2011
  7. 3/3 gitweb: show alternate author/committer timesKevin Cernekee, Mar 17, 2011
  8. 3/3 gitweb: Mark "atnight" author/committer times also for 'localtime'Jakub Narebski, Mar 18, 2011
  9. Kevin CernekeeMar 18, 2011
  10. Junio C HamanoMar 18, 2011
  11. Jakub NarebskiMar 18, 2011
  12. Junio C HamanoMar 19, 2011
  13. 1/3 gitweb: fix #patchNN anchors when path_info is enabledJakub Narebski, Mar 18, 2011
  14. Kevin CernekeeMar 18, 2011
  15. 1/3 gitweb: fix #patchNN anchors when path_info is enabledJakub Narebski, Mar 18, 2011
  16. Junio C HamanoMar 18, 2011
  17. Jakub NarebskiMar 18, 2011

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.