CNLMath : Utilities : days_to_date
days_to_date
Gives the date corresponding to the number of days since January 1, 1900.
Synopsis
#include <imsl.h>
void imsl_days_to_date (int days, int *day, int *month, int *year)
Required Arguments
int days (Input)
Number of days since January 1, 1900.
int *day (Output)
Day of the output date.
int *month (Output)
Month of the output date.
int *year (Output)
Year of the output date. The year 1950 would correspond to the year 1950 A.D., and the year 50 would correspond to year 50 A.D.
Description
The function imsl_days_to_date computes the date corresponding to the number of days since January 1, 1900. For a negative input value of days, the date computed is prior to January 1, 1900. This function is the inverse of function imsl_date_to_days.
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_days_to_date to compute the date for the 100th day of 1986. This is accomplished by first using IMSL function imsl_date_to_days to get the “day number” for December 31, 1985.
 
#include <imsl.h>
#include <stdio.h>
 
int main()
{
int day0, day, month, year;
 
day0 = imsl_date_to_days(31, 12, 1985);
imsl_days_to_date(day0+100, &day, &month, &year);
printf("Day 100 of 1986 is (day-month-year) %d-%d-%d\n",
day, month, year);
}
Output
 
Day 100 of 1986 is (day-month-year) 10-4-1986