www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/01/11/19:06:30

From: Jason Green <news AT jgreen4 DOT fsnet DOT co DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: strftime: Need Help with Time Offsets
Date: Thu, 11 Jan 2001 21:56:52 +0000
Organization: Customer of Energis Squared
Lines: 33
Message-ID: <pm9s5t8j5d364g2u2lal5vpjkp8mcjo2gj@4ax.com>
References: <t21e5t4m6auc7k7vqlj78cv0c8qg1gngfh AT 4ax DOT com> <Pine DOT OSF DOT 4 DOT 30 DOT 0101090827480 DOT 1867-100000 AT sirppi DOT helsinki DOT fi>
NNTP-Posting-Host: modem-67.tellurium.dialup.pol.co.uk
Mime-Version: 1.0
X-Trace: newsg1.svr.pol.co.uk 979250211 29787 62.136.43.67 (11 Jan 2001 21:56:51 GMT)
NNTP-Posting-Date: 11 Jan 2001 21:56:51 GMT
X-Complaints-To: abuse AT theplanet DOT net
X-Newsreader: Forte Agent 1.7/32.534
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Esa A E Peuha <peuha AT cc DOT helsinki DOT fi> wrote:

> > Erm, sorry, this is not obvious to me.  Although that's probably more
> > to do with damage suffered staring at date maths code. ;-)
> 
> No wonder. :-)  It's all pretty simple once you really understand it,
> but it can be mind-boggling before that. 

For a student of mathematics perhaps. ;-)

> > I put your code into functions.  Unfortunately, it sometimes gets the
> > week number wrong where week 52/53 overlaps into the new year.
> 
> So it does.  That's because I made a silly mistake (see below).
> 
> >       /* day belongs to last week of previous year */
> >       return number_of_week (t->tm_wday,
> >                              t->tm_yday +
> >                              ((isleap(t->tm_year + TM_YEAR_BASE)) ?
> >                               366:365));
> 
> This, of course, needs to add the number of days in the previous year,
> so it should test for isleap(t->tm_year + TM_YEAR_BASE - 1). 

Yep that fixes it, thanks.  I'll put this together with what I have
already and post a patch to the djgpp-workers list.

> BTW, why
> is there an extra set of parentheses around isleap(...)?

Only because I generally prefer to place parentheses around the
condition just as if it were an `if' or `while' statement, I think
that makes the code easier to read.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019