IMSL C Math Library
date_to_days
Computes the number of days from January 1, 1900, to the given date.
Synopsis
#include <imsl.h>
int imsl_date_to_days (int day, int month, int year)
Required Arguments
int day (Input)
Day of the input date.
int month (Input)
Month of the input date.
int year (Input)
Year of the input date. The year 1950 would correspond to the year 1950 A.D., and the year 50 would correspond to year 50 A.D.
Return Value
Number of days from January 1, 1900, to the given date. If negative, it indicates the number of days prior to January 1, 1900.
Description
The function imsl_date_to_days returns the number of days from January 1, 1900, to the given date. The function imsl_date_to_days returns negative values for days prior to January 1, 1900. A negative year can be used to specify B.C. Input dates in year 0 and for October 5, 1582, through October 14, 1582, inclusive, do not exist; consequently, in these cases, imsl_date_to_days issues a terminal error.
The beginning of the Gregorian calendar was the first day after October 4, 1582, which became October 15, 1582. Prior to that, the Julian calendar was in use.
Example
The following example uses imsl_date_to_days to compute the number of days from January 15, 1986, to February 28, 1986.
 
#include <imsl.h>
#include <stdio.h>
 
int main()
{
int day0, day1;
 
day0 = imsl_date_to_days(15, 1, 1986);
day1 = imsl_date_to_days(28, 2, 1986);
printf("Number of days = %d\n", day1 - day0);
}
Output
 
Number of days = 44