🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: news.software.nntp
7 messages
7 total messages Started by John F. Morse Sun, 01 Jan 2006 07:08
Date bug at year end
#72956
Author: John F. Morse
Date: Sun, 01 Jan 2006 07:08
7 lines
1228 bytes
Apparent bug in the date routine for the Daily Report:

Daily Usenet report from Jan  1 00:00:03 to Dec 31 23:55:49


-- 
John
Re: Date bug at year end
#72940
Author: Bozweb
Date: Sun, 01 Jan 2006 10:59
12 lines
1525 bytes
On Sun, 01 Jan 2006 07:08:17 GMT, "John F. Morse"
<xanadu.bbs@invalid.net> wrote:

>Apparent bug in the date routine for the Daily Report:
>
>Daily Usenet report from Jan  1 00:00:03 to Dec 31 23:55:49

Yes, me to:
Daily Usenet report from Jan  1 00:00:13 to Dec 31 23:58:31
Inn 2.4.2
http://news.bozweb.net/
Key: 0x82DEE1A0
Re: Date bug at year end
#72942
Author: Russ Allbery
Date: Sun, 01 Jan 2006 17:27
14 lines
1614 bytes
John F Morse <xanadu.bbs@invalid.net> writes:

> Apparent bug in the date routine for the Daily Report:
> Daily Usenet report from Jan  1 00:00:03 to Dec 31 23:55:49

Yeah, I think I tried to fix that once and failed.  innreport doesn't deal
very well with changes of year, mostly because syslog doesn't put the year
into log dates.

-- 
Russ Allbery (rra@stanford.edu)             <http://www.eyrie.org/~eagle/>

          Please post questions rather than mailing me directly.
     <http://www.eyrie.org/~eagle/faqs/questions.html> explains why.
Re: Date bug at year end
#72950
Author: John F. Morse
Date: Mon, 02 Jan 2006 16:39
25 lines
1898 bytes
Russ Allbery wrote:

>John F Morse <xanadu.bbs@invalid.net> writes:
>
>  
>
>>Apparent bug in the date routine for the Daily Report:
>>Daily Usenet report from Jan  1 00:00:03 to Dec 31 23:55:49
>>    
>>
>
>Yeah, I think I tried to fix that once and failed.  innreport doesn't deal
>very well with changes of year, mostly because syslog doesn't put the year
>into log dates.
>


Interesting.... I wonder if Bell Labs (or Linus) thought the OS would 
last more than a year? ;-)

I guess you could have INN look at the clock for the date and time. I 
doubt if it is even worth the trouble.

-- 
John
Re: Date bug at year end
#72953
Author: Russ Allbery
Date: Mon, 02 Jan 2006 18:01
17 lines
1854 bytes
John F Morse <xanadu.bbs@invalid.net> writes:

> Interesting.... I wonder if Bell Labs (or Linus) thought the OS would 
> last more than a year? ;-)

> I guess you could have INN look at the clock for the date and time. I 
> doubt if it is even worth the trouble.

syslog has an utterly obnoxious date format, but unfortunately so many
things parse it that you really can't ever change it.  It doesn't sort,
it uses English month names, it doesn't have the year... bleh.

-- 
Russ Allbery (rra@stanford.edu)             <http://www.eyrie.org/~eagle/>

          Please post questions rather than mailing me directly.
     <http://www.eyrie.org/~eagle/faqs/questions.html> explains why.
Re: Date bug at year end
#72963
Author: Jeffrey M. Vinocur
Date: Mon, 02 Jan 2006 20:42
36 lines
2607 bytes
In article <87sls65x1n.fsf@windlord.stanford.edu>,
Russ Allbery  <rra@stanford.edu> wrote:
>John F Morse <xanadu.bbs@invalid.net> writes:
>
>> I guess you could have INN look at the clock for the date and time. I 
>> doubt if it is even worth the trouble.

It is kinda interesting, isn't it, deciding how much effort to
spend in fixing an essentially cosmetic bug that only occurs once
a year.


>syslog has an utterly obnoxious date format, but unfortunately so many
>things parse it that you really can't ever change it.  It doesn't sort,
>it uses English month names, it doesn't have the year... bleh.

Which makes the code in innreport so scary I almost ran away
screaming.  I -think- this:

      # 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);

might actually be code to detect this scenario (although I can't
tell for sure because it makes my head hurt), but it seems to
only affect parts of the HTML-ized results and not the news.daily
email.  On the other hand, if it actually does something useful,
I think it might be a big step towards a fix.


-- 
Jeffrey M. Vinocur
jeff@litech.org
Re: Date bug at year end
#72964
Author: Russ Allbery
Date: Mon, 02 Jan 2006 21:47
72 lines
4254 bytes
Jeffrey M Vinocur <jeff@litech.org> writes:
> Russ Allbery  <rra@stanford.edu> wrote:

>> syslog has an utterly obnoxious date format, but unfortunately so many
>> things parse it that you really can't ever change it.  It doesn't sort,
>> it uses English month names, it doesn't have the year... bleh.

> Which makes the code in innreport so scary I almost ran away
> screaming.  I -think- this:

>       # 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);

> might actually be code to detect this scenario (although I can't tell
> for sure because it makes my head hurt), but it seems to only affect
> parts of the HTML-ized results and not the news.daily email.  On the
> other hand, if it actually does something useful, I think it might be a
> big step towards a fix.

Yes, that substr thing is evil.  It's a string consisting of the
cumulative days of the year at the start of each month, each as three
digits, concatenated together.

There are better ways to do this, such as the below that makes mktime do
the heavy lifting and gets year transitions right, but I never wanted to
tackle the restructuring required to use them.  $fileyear and $filemonth
in this case should be taken from the mtime of the file.

use POSIX qw(mktime);
{
    my $i = 1;
    %MONTHS = map { $_ => $i++ }
        qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
}

# Given a single line of a log file, the year of the log file, and the month
# of the log file, strip off the leading timestamp and convert it into seconds
# since epoch and then return a list consisting of that timestamp and the rest
# of the line.
#
# A syslog date is in the form:
#
#     mmm DD HH:MM:SS
#
# with no year.  We therefore have to be able to guess at the year by taking
# into account year and month of the file and assuming that if the month of
# the date is greater than the month of the file, the date is actually from
# the previous year.
#
# Warns and returns undef on a failure to parse the date.
sub parse_time {
    my ($self, $line, $fileyear, $filemonth) = @_;
    $line =~ s/^(\w\w\w) ([ \d]\d) (\d\d):(\d\d):(\d\d) //
        or return;
    my ($month, $day, $hour, $min, $sec) = ($1, $2, $3, $4, $5);
    $month = $MONTHS{$month} or return;
    my $year = ($month <= $filemonth ) ? $fileyear : $fileyear - 1;
    $year -= 1900;
    $month -= 1;
    my $time = mktime ($sec, $min, $hour, $day, $month, $year);
    return ($time, $line);
}

-- 
Russ Allbery (rra@stanford.edu)             <http://www.eyrie.org/~eagle/>

          Please post questions rather than mailing me directly.
     <http://www.eyrie.org/~eagle/faqs/questions.html> explains why.
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