| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | datediff |
Hi guys,
/*
** The world began in 1900...according to time.h
** This i converted from a visual basic KB example, it returns the elapsed
** number of days between any two dates from 0 to infinity year.
** It seems to work ok.
*/
#include
#include
#define TEST
#ifdef TEST
#include
#endif
struct dosDate
{
unsigned int year;
unsigned char day;
unsigned char month;
unsigned char dow;
/* dow = 0 = Sunday */
};
long Date_Diff(struct dosDate *d1,struct dosDate *d2)
{
double y1 = d1->year + (d1->month - 2.85) / 12;
double y2 = d2->year + (d2->month - 2.85) / 12;
long a =
(long)
((long)
((long)(367 * y1)-1.75 * y1 + d1->day)-0.75 * (0.01 * y1)) + 1721119L;
long b =
(long)
((long)
((long)(367 * y2)-1.75 * y2 + d2->day)-0.75 * (0.01 * y2)) + 1721119L;
return (a-b);
};
void Get_Date(struct dosDate* dd)
{
union REGS regs;
regs.h.ah = 0x2a;
int86(0x21,®s,®s);
dd->year = regs.x.cx;
dd->month = regs.h.dh;
dd->day = regs.h.dl;
dd->dow = regs.h.al;
};
#ifdef TEST
main()
{
struct dosDate e,f;
long diff;
Get_Date(&e);
f.year = 2996;
f.month = 12;
f.day = 24;
diff = Date_Diff(&e,&f);
printf("\nOnly %d days left till that one.",abs((int)diff));
return 0;
}
#endif
L8r Frank(fadam{at}ozemail.com.au)
___ Blue Wave/DOS v2.21
--- Gash
* Origin: The Software Parlour (3:635/544)SEEN-BY: 50/99 620/243 623/630 632/349 635/503 544 727 711/401 409 410 413 SEEN-BY: 711/430 808 809 932 934 712/515 713/888 714/906 800/1 @PATH: 635/544 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™.