From 373d90593667369f768a8fc22b516a49429a91d0 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Thu, 12 Apr 2007 14:54:36 +0000 Subject: [PATCH] Store publication dates in RSS feed in reader-happy way. Fixes Sage, etc showing a last update of "N/A". --- IcculusNews_daemon.pl | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/IcculusNews_daemon.pl b/IcculusNews_daemon.pl index 1bad740..3fdc836 100755 --- a/IcculusNews_daemon.pl +++ b/IcculusNews_daemon.pl @@ -33,7 +33,7 @@ use HTML::Entities; # Version of IcculusNews. Change this if you are forking the code. -my $version = "2.0.2"; +my $version = "2.0.3"; # Global rights constants. @@ -459,6 +459,27 @@ sub update_queue_rights { } } +sub pubdate { + my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = @_; +print("year: $year\n"); + return POSIX::strftime("%a, %e %b %Y %H:%M:%S %z", $sec, $min, $hour, + $mday, $mon, $year, $wday, $yday, $isdst); +} + +sub sqlpubdate { + my $d = shift; + if ($d =~ /\A(\d+)\-(\d+)\-(\d+)\s+(\d+)\:(\d+)\:(\d+)\Z/) { + my $year = $1 - 1900; + my $mon = $2 - 1; + my $mday = $3 - 0; + my $hour = $4 - 0; + my $min = $5 - 0; + my $sec = $6 - 0; +print("sql year: $year\n"); + return pubdate($sec, $min, $hour, $mday, $mon, $year, 0, 0, 0); + } + return '???'; +} sub generate_rdf { my $qid = shift; @@ -520,6 +541,7 @@ sub generate_rdf { my $itemid = $row[1]; # my $itemtitle = encode_entities($row[2]); my $itemtitle = $row[2]; + my $itempubdate = encode_entities(sqlpubdate($row[3])); my $itempostdate = encode_entities($row[3]); my $authorname = encode_entities(((not defined $row[4]) ? $anon : $row[4])); my $ipaddr = long2ip($row[5]); @@ -540,6 +562,7 @@ sub generate_rdf { $rdfitems .= " $authorid\n"; $rdfitems .= " $itemid\n"; $rdfitems .= " $itempostdate\n"; + $rdfitems .= " $itempubdate\n"; $rdfitems .= " $ipaddr\n"; $rdfitems .= " $approved\n"; $rdfitems .= " $deleted\n"; @@ -548,6 +571,7 @@ sub generate_rdf { } $sth->finish(); + my $pubdate = pubdate(localtime()); my $rdf = <<__EOF__; @@ -559,6 +583,7 @@ sub generate_rdf { $siteurl $itemarcurl $queuedesc + $pubdate $channelimg