🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: news.software.nntp
1 messages
1 total messages Started by Iulius Sun, 01 Apr 2007 13:18
Innreport and change of year (problem)
#75995
Author: Iulius
Date: Sun, 01 Apr 2007 13:18
66 lines
3348 bytes
Hi,

There is a problem in the name of the last report of each year.
Instead of being named « news-notice.2006.12.31-04.15.02.html »,
it is named « news-notice.2006.01.01-00.00.00.html » and thus,
breaks everything in the html page (it is put at the bottom...).

And the line is « Jan 1 00:00:00 -- Dec 31 23:59:59 » instead of
« Dec 31 04:15:02 -- Jan 1 04:15:03 ».


The faulty code is:

if ($HTML) {
  # Create a new filename (unique and _sortable_)
  if ($ARCHIVE) {
    # The filename will contain the first date of the log or the current time.
    my ($ts, $tm, $th, $dd, $dm, $dy) = localtime;
    my ($m, $d, $h, $mn, $s) =
      $first_date =~ /^(\S+)\s+(\d+)\s+(\d+):(\d+):(\d+)$/;
    if ($m) {
      my $ddm = (index "JanFebMarAprMayJunJulAugSepOctNovDec", $m) / 3;
      # Adjust the year because syslog doesn't record it. We assume that
      # it's the current year unless the last date is in the future.
      my $ld = &ConvDate($last_date);
      $dy-- if $ld > $ts + 60 * ($tm + 60 * ($th + 24 * ($dd - 1 +
        substr("000031059090120151181212243273304334", $dm * 3, 3)))) ||
        $ld < &ConvDate($first_date);
      ($dm, $dd, $th, $tm, $ts) = ($ddm, $d, $h, $mn, $s);
    }
    $dm++; # because January = 0 and we prefer 1
    $dy += 100 if $dy < 90; # Try to pacify the year 2000 !
    $dy += 1900;
    $suffix = sprintf ".%02d.%02d.%02d-%02d$SEPARATOR%02d$SEPARATOR%02d",
		       $dy, $dm, $dd, $th, $tm, $ts;
  }
  else {
    $suffix = '';
  }
  $HTML_output = "$HTML_dir" . "/news-notice" . "$suffix" . ".html";

[...]


I do not know why ($d, $h, $mn, $s) is (0, 0, 0, 0) in the assignment.
It shouldn't...
And I cannot reproduce the problem if I manually give localtime!


Examples of the problem:

http://news.netcologne.de/innreport/stats/ (where there is Jan 1 - Dec 31)
http://talisker.lacave.net/news/innstats/ (where there is no Dec 31 - Jan 1)
(...)


By the way, is the « 000031059090120151181212243273304334 » right for
bissextile years?

Regards,

-- 
Julien

« -- Mais puisque je vous dis que je ne suis pas entré dans cette piscine de mon plein gré !
  -- Ce n'est pas une raison, espèce de dégoûtant pour ne pas enlever vos sandales !!! » (Astérix)
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads