From: Kyle J. McKay Date: Sat, 13 Jul 2013 11:33:58 +0000 (-0700) Subject: Rename Girocco::Util::parse_date to parse_rfc2822_date X-Git-Url: https://repo.or.cz/w/girocco.git/commitdiff_plain/34cb083cc5061f6a6ba0036f68368d98acdfb906 Rename Girocco::Util::parse_date to parse_rfc2822_date Since gitweb.perl contains a parse_date subroutine the naming conflict can cause problems. The Util.pm version of the routine only handles RFC 2822 dates so the name is now more descriptive. --- diff --git a/Girocco/Util.pm b/Girocco/Util.pm index 960f0b6..994494c 100644 --- a/Girocco/Util.pm +++ b/Girocco/Util.pm @@ -13,7 +13,7 @@ BEGIN { filedb_atomic_append filedb_atomic_edit filedb_grep filedb_atomic_grep valid_email valid_email_multi valid_repo_url valid_web_url url_path - projects_html_list parse_date); + projects_html_list parse_rfc2822_date); } @@ -272,7 +272,7 @@ EOT my $changetime = $proj->{lastchange}; if ($changetime) { $rel = "" . - _rel_age(time - parse_date($changetime)) . + _rel_age(time - parse_rfc2822_date($changetime)) . "$changetime"; } else { $rel = "no commits"; @@ -304,8 +304,9 @@ BEGIN { } # Should be in "date '+%a, %d %b %Y %T %z'" format as saved to lastgc, lastrefresh and lastchange -# The leading "%a, " is optional, returns undef if unrecognized date -sub parse_date { +# The leading "%a, " is optional, returns undef if unrecognized date. This is also known as +# RFC 2822 date format and git's '%cD', '%aD' and --date=rfc2822 format. +sub parse_rfc2822_date { my $dstr = shift || ''; $dstr = $1 if $dstr =~/^[^\s]+,\s*(.*)$/; return undef unless $dstr =~ diff --git a/jobd/jobd.pl b/jobd/jobd.pl index fa7a9c8..7bfc45c 100755 --- a/jobd/jobd.pl +++ b/jobd/jobd.pl @@ -103,7 +103,7 @@ sub is_operation_uptodate { my ($project, $which, $threshold) = @_; my $path = get_project_path($project); my $timestamp = `GIT_DIR="$path" $Girocco::Config::git_bin config "gitweb.$which"`; - my $unix_ts = parse_date($timestamp) || 0; + my $unix_ts = parse_rfc2822_date($timestamp) || 0; (time - $unix_ts) <= $threshold ? $timestamp : undef; } diff --git a/shlib.sh b/shlib.sh index 873c8e5..f503269 100644 --- a/shlib.sh +++ b/shlib.sh @@ -93,7 +93,7 @@ config_set_raw() { check_interval() { od="$(config_get "$1")" [ -n "$od" ] || return 1 - os="$(perl -I@basedir@ -MGirocco::Util -e "print parse_date('$od')")" + os="$(perl -I@basedir@ -MGirocco::Util -e "print parse_rfc2822_date('$od')")" [ -n "$os" ] || return 1 ns="$(date +%s)" [ $ns -lt $(($os+$2)) ]