From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: text/plain; format=flowed; charset=us-ascii From: Jonathan Sergent To: 9fans@cse.psu.edu Mime-Version: 1.0 (Apple Message framework v388) In-Reply-To: Subject: Re: [9fans] tiny bug in Acme News Content-Transfer-Encoding: 7bit Message-Id: <20010729033044.0EF8E199F4@mail.cse.psu.edu> Date: Sat, 28 Jul 2001 20:31:05 -0700 Topicbox-Message-UUID: d7726c04-eac9-11e9-9e20-41e7f4b1d025 On Saturday, July 28, 2001, at 08:07 PM, crdevilb@mtu.edu wrote: > /acme/news/src/news.c:119 > if(1 <= j && j <= 31) > should be > if(1 <= j && j <= 31 && !d) > > or it will report the date as the current hour. There are actually more problems than that if you look at the different formats in use in an average (?) newsgroup. There are things with timezone specifiers and such. A few months ago, I hacked my fixdate() to: char* fixdate(char *s) { char *f[10], *m, *t, *wd, tmp[40]; int d, i, j, nf, hh, mm, mn, yr; nf = tokenize(s, f, nelem(f)); wd = nil; d = 0; m = nil; t = nil; yr = 0; mn = 0; for(i=0; i 0)) { if (j < 70) yr = j + 2000; else if (j < 100) yr = j + 1900; else if (j > 1970) yr = j; } } if(d==0 || m==nil || t==nil) return nil; hh = strtol(t, 0, 10); mm = strtol(strchr(t, ':')+1, 0, 10); if (wd == nil) { Tm tm = { 0, mm, hh, d, mn, yr - 1900, 0, 0, "", 0 }; if (yr == 0 || mn == 0) return nil; wd = day[localtime(tm2sec(&tm))->wday]; } sprint(tmp, "%s %d %s %d:%.2d", wd, d, m, hh, mm); return estrdup(tmp); } I might have changed more than this function, but I can't remember. The whole thing is a little ugly.