Showing 3 changed files with 43 additions and 7 deletions
+7
gitprep.conf
... ...
@@ -13,6 +13,13 @@
13 13
 ;;; Tags limit (default:1000)
14 14
 ;tags_limit=1000
15 15
 
16
+;;; Time Zone
17
+;;; GitPrep time zone is GMT by default
18
+;;; You can set your local time zone.
19
+;time_zone=+9:00
20
+;time_zone=+10:30
21
+;time_zone=-4:00
22
+
16 23
 [admin]
17 24
 ;;; If you forget admin password,
18 25
 ;;; set this value to 1 and access /reset-password page.
+16 -3
lib/Gitprep.pm
... ...
@@ -68,10 +68,23 @@ sub startup {
68 68
     mkdir $rep_home
69 69
       or croak "Can't create directory $rep_home: $!";
70 70
   }
71
-  $self->git($git);
72 71
   
73
-  # Added public path
74
-  # push @{$self->static->paths}, $rep_home;
72
+  # Time Zone
73
+  if (my $time_zone = $conf->{basic}{time_zone}) {
74
+    
75
+    if ($time_zone =~ /^([\+-])?([0-9]?[0-9]):([0-9][0-9])$/) {
76
+      my $sign = $1 || '';
77
+      my $hour = $2;
78
+      my $min = $3;
79
+      
80
+      my $time_zone_second = $sign . ($hour * 60 * 60) + ($min * 60);
81
+      $git->time_zone_second($time_zone_second);
82
+    }
83
+    else {
84
+      $self->log->warn("Bad time zone $time_zone. Time zone become GMT");
85
+    }
86
+  }
87
+  $self->git($git);
75 88
   
76 89
   # DBI
77 90
   my $db_file = $ENV{GITPREP_DB_FILE}
+20 -4
lib/Gitprep/Git.pm
... ...
@@ -15,6 +15,7 @@ has 'bin';
15 15
 has encoding => 'UTF-8';
16 16
 has 'rep_home';
17 17
 has text_exts => sub { ['txt'] };
18
+has 'time_zone_second';
18 19
 
19 20
 sub branch {
20 21
   my ($self, $user, $project, $branch_name) = @_;
... ...
@@ -1264,10 +1265,25 @@ sub parse_commit_text {
1264 1265
   my $age = time - $commit{committer_epoch};
1265 1266
   $commit{age} = $age;
1266 1267
   $commit{age_string} = $self->_age_string($age);
1267
-  my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($commit{committer_epoch});
1268
-  $commit{age_string_date} = sprintf '%4d-%02d-%02d', 1900 + $year, $mon + 1, $mday;
1269
-  $commit{age_string_datetime} = sprintf '%4d-%02d-%02d %02d:%02d:%02d',
1270
-    1900 + $year, $mon + 1, $mday, $hour, $min, $sec;
1268
+  
1269
+  # GMT
1270
+  {
1271
+    my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($commit{committer_epoch});
1272
+    $commit{age_string_date} = sprintf '%4d-%02d-%02d', 1900 + $year, $mon + 1, $mday;
1273
+    $commit{age_string_datetime} = sprintf '%4d-%02d-%02d %02d:%02d:%02d',
1274
+      1900 + $year, $mon + 1, $mday, $hour, $min, $sec;
1275
+  }
1276
+  
1277
+  # Local Time
1278
+  {
1279
+    my $time_zone_second = $self->time_zone_second || 0;
1280
+    
1281
+    my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($commit{committer_epoch} + $time_zone_second);
1282
+    $commit{age_string_date_local}
1283
+      = sprintf '%4d-%02d-%02d', 1900 + $year, $mon + 1, $mday;
1284
+    $commit{age_string_datetime_local} = sprintf '%4d-%02d-%02d %02d:%02d:%02d',
1285
+      1900 + $year, $mon + 1, $mday, $hour, $min, $sec;
1286
+  }
1271 1287
   
1272 1288
   return \%commit;
1273 1289
 }