Sujet : Re: "A diagram of C23 basic types"
De : rjh (at) *nospam* cpax.org.uk (Richard Heathfield)
Groupes : comp.lang.cDate : 17. Apr 2025, 01:05:07
Autres entêtes
Organisation : Fix this later
Message-ID : <vtpgjj$36b40$3@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
User-Agent : Mozilla Thunderbird
On 17/04/2025 00:31, Keith Thompson wrote:
<lots of good stuff snipped>
Like the Julian day number, it's
useful for computing the number of days between dates.
Indeed. <time.h> can do it, of course, but I find it a trifle clumsy for the purpose.
Date-heavy loops are the other win:
for(day = today(); day < enddate; day++)
{
fromjul(&y, &m, &d, day);
if(day % 7 < SATURDAY) /* skip weekends */
{
fprintf(fp, "%02d/%02d/%04d,%d,%s\n", d, m, y, foo, bar);
}
} and so on.
I suppose <time.h> can do that too, but I can't help thinking that it would be far less elegant... not that I've ever bothered to find out.
-- Richard HeathfieldEmail: rjh at cpax dot org dot uk"Usenet is a strange place" - dmr 29 July 1999Sig line 4 vacant - apply within