ba237a9d91
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
77 lines
1.5 KiB
C
Executable File
77 lines
1.5 KiB
C
Executable File
/* void AddDaysToDate360( m2, d2, y2, m1, d1, y1, ndays )
|
|
*
|
|
* ARGUMENTS
|
|
* int m1, d1, y1 - Specify a base date.
|
|
* int *m2, *d2, *y2 - Specify a date to be calculated
|
|
* int ndays - Number of days (+ or -) to be added to base
|
|
*
|
|
* DESCRIPTION
|
|
* A signed number of days (ndays) is added to the base date to form a
|
|
* second date which is transferred to the variables m2,d2,y2. If any of
|
|
* the arguments are NULL on input, an error results.
|
|
*
|
|
* Years < 100 are taken to be in 20th century.
|
|
*
|
|
* All years are considered to have 12 equal months of 30 days each for
|
|
* a total of 360 days.
|
|
*
|
|
* SIDE EFFECTS
|
|
* Changes d2, m2, y2.
|
|
*
|
|
* RETURNS
|
|
* None.
|
|
*
|
|
* POSSIBLE ERROR CODES
|
|
*
|
|
* GM_ARGVAL
|
|
* GM_NULLPOINTER
|
|
*
|
|
* AUTHOR
|
|
* Don Killen 03-Feb-1988 16:27:32
|
|
* Copyright (C) 1988-1990 Greenleaf Software Inc. All rights reserved.
|
|
*
|
|
* MODIFICATIONS
|
|
*
|
|
*
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
#include "gm.h"
|
|
#include "gmsystem.h"
|
|
|
|
void AddDaysToDate360(m2,d2,y2,m1,d1,y1,ndays)
|
|
int m1,*m2,d1,*d2,y1,*y2,ndays;
|
|
{
|
|
|
|
long day;
|
|
|
|
_MacStart(GM_ADATE360);
|
|
|
|
if (d2==NULL||m2==NULL||y2==NULL) {
|
|
_MacErr(GM_NULLPOINTER);
|
|
_MacRetV;
|
|
}
|
|
|
|
if ( m1<1 || m1>12 || d1<1 || d1>31 || y1<1 || y1>9999 ) {
|
|
_MacErr(GM_ARGVAL);
|
|
_MacRetV;
|
|
}
|
|
day = (long) y1 * 360L + (long) ( (m1-1)*30 + (d1-1) + ndays);
|
|
/* computes days from Jan 1, Year 0 */
|
|
|
|
if (day<0L) { /* no negative years */
|
|
_MacErr(GM_ARGVAL);
|
|
_MacRetV;
|
|
}
|
|
|
|
/* changes to m2/d2/y2 */
|
|
*y2 = (int) (day / 360L);
|
|
day = day % 360L;
|
|
|
|
*m2 = (int) (day) / 30 + 1;
|
|
|
|
*d2 = (int) (day) % 30 + 1;
|
|
|
|
_MacRetV;
|
|
}
|