TIP: Click on subject to list as thread! ANSI
echo: aust_c_here
to: Frank Adam
from: David Nugent
date: 1996-09-10 16:52:56
subject: datediff

FA> ** The world began in 1900...according to time.h

Not quite. The actual epoch date can be anything, according to the fancy of
the vendor. You can't rely on a specific epoch date. Most compilers -
certainly all under UNIX I've ever used - use 01-Jan-1970 as their epoch.
It may differ on other platforms. Microsoft 7.0 uses 1900, but earlier and
later versions of the same compiler use 1970. AFAIK, Borland and Watcom
have always used 1970.


 FA> long Date_Diff(struct dosDate *d1,struct dosDate *d2)
 FA> {
 FA>  double y1 = d1->year + (d1->month - 2.85) / 12;
 FA>  double y2 = d2->year + (d2->month - 2.85) / 12;
 FA>  long a =
 FA> (long)
 FA>  ((long)
 FA>   ((long)(367 * y1)-1.75 * y1 + d1->day)-0.75 * (0.01 * y1)) + 1721119L;

Won't you run into problems with rounding mixing float/doubles with long?

I honestly don't know since never tried myself. I tend to stick with
integer math wherever possible, and in this case you don't really need
floating point anyway.

--- MaltEd/2 1.0.b6
* Origin: Unique Computing Pty Limited (3:632/348)
SEEN-BY: 50/99 620/243 623/630 632/103 107 348 360 633/371 634/388 396
SEEN-BY: 635/301 502 503 544 639/252 711/401 409 410 413 430 808 809 932 934
SEEN-BY: 712/515 713/888 714/906 800/1
@PATH: 632/348 635/503 50/99 711/808 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.