From: Barijaona Ramaholimihaso Date: Mon, 17 Sep 2007 03:52:30 +0000 (+0000) Subject: Introduces a $utc_offset variable which stores the offset between local time and... X-Git-Tag: v2_1_0~79 X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;ds=inline;h=bf867cbe9f9ab1a6e9473cf61f1c54f3da621359;hp=58d20d1c6ce8ac38ac33df3d4a29cea00197f39d;p=matthijs%2Fupstream%2Fblosxom.git Introduces a $utc_offset variable which stores the offset between local time and universal time, in a convenient format for building rfc822 and iso8601 compliant dates. --- diff --git a/blosxom.cgi b/blosxom.cgi index fbed8d5..13cf0f9 100755 --- a/blosxom.cgi +++ b/blosxom.cgi @@ -77,6 +77,7 @@ use FileHandle; use File::Find; use File::stat; use Time::localtime; +use Time::Local; use CGI qw/:standard :netscape/; $version = "2.0.2"; @@ -419,8 +420,8 @@ sub generate { $path &&= "/$path"; # Date fiddling for by-{year,month,day} archive views - use vars qw/ $dw $mo $mo_num $da $ti $yr $hr $min $hr12 $ampm /; - ($dw,$mo,$mo_num,$da,$ti,$yr) = nice_date($files{"$path_file"}); + use vars qw/ $dw $mo $mo_num $da $ti $yr $hr $min $hr12 $ampm $utc_offset/; + ($dw,$mo,$mo_num,$da,$ti,$yr,$utc_offset) = nice_date($files{"$path_file"}); ($hr,$min) = split /:/, $ti; ($hr12, $ampm) = $hr >= 12 ? ($hr - 12,'pm') : ($hr, 'am'); $hr12 =~ s/^0//; $hr12 == 0 and $hr12 = 12; @@ -494,11 +495,15 @@ sub nice_date { my($unixtime) = @_; my $c_time = ctime($unixtime); - my($dw,$mo,$da,$ti,$yr) = ( $c_time =~ /(\w{3}) +(\w{3}) +(\d{1,2}) +(\d{2}:\d{2}):\d{2} +(\d{4})$/ ); + my($dw,$mo,$da,$hr,$min,$yr) = ( $c_time =~ /(\w{3}) +(\w{3}) +(\d{1,2}) +(\d{2}):(\d{2}):\d{2} +(\d{4})$/ ); + $ti="$hr:$min"; $da = sprintf("%02d", $da); my $mo_num = $month2num{$mo}; - - return ($dw,$mo,$mo_num,$da,$ti,$yr); + + my $offset = timegm(00, $min, $hr, $da, $mo_num-1, $yr-1900)-$unixtime; + my $utc_offset = sprintf("%+03d", int($offset / 3600)).sprintf("%02d", ($offset % 3600)/60) ; + + return ($dw,$mo,$mo_num,$da,$ti,$yr,$utc_offset); }