campo-sirio/gfm/dbdnly.c
alex ba237a9d91 Patch level : no patch
Files correlati     :
Ricompilazione Demo : [ ]
Commento            :
Aggiunti i sorgenti per Greenleaf Math Library (gfm.dll)


git-svn-id: svn://10.65.10.50/trunk@10079 c028cbd2-c16b-5b4b-a496-9718f37d4682
2002-02-26 12:19:02 +00:00

75 lines
1.3 KiB
C
Executable File

/* int DaysBetweenDates365NoLeapYear(m1,d1,y1, m2,d2,y2)
*
* ARGUMENT
* int m1,d1,y1; - Base Date
* int m2,d2,y2; - Date to compare with base
*
* DESCRIPTION
* Compares two dates in date args format, forming the difference in
* whole days. The result is a signed number:
*
* 0 if dates are same,
* +n if date1 > date2
* -n if date1 < date2
*
* A 365 day calendar without leap years is used.
*
* SIDE EFFECTS
* None.
*
* RETURNS
* +,-, or 0 days. 0 can indicate an error.
*
* POSSIBLE ERROR CODES
* GM_ARGVAL
* GM_OVERFLOW
*
* AUTHOR
* 05-Aug-1987 12:43:39
* Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved.
*
* MODIFICATIONS
*/
#include <stdio.h>
#include "gmsystem.h"
int DaysBetweenDates365NoLeapYear(m1,d1,y1,m2,d2,y2)
int m1,d1,y1,m2,d2,y2;
{
long n1, n2, n;
int x;
_MacStart(GM_DBDNLY);
if (m1<1||m1>12||d1<1||d1>31||y1<0||y1>9999||
m2<1||m2>12||d2<1||d2>31||y2<0||y2>9999) {
_MacErr(GM_ARGVAL);
_MacRet(GM_ARGVAL);
}
if (m1<=2) {
x=0;
}
else {
x=(4*m1 + 23) / 10;
}
n1 = (long) y1 * 365L + (long) (31*(m1-1) + d1 - x);
if (m2<=2) {
x=0;
}
else {
x=(4*m2 + 23) / 10;
}
n2 = (long) y2 * 365L + (long) (31*(m2-1) + d2 - x);
n = n1 - n2;
if (n<-32768L||n>32767L) {
_MacErr(GM_OVERFLOW);
_MacRet(GM_OVERFLOW);
}
_MacRet((int) n);
}