FreeBASIC  0.91.0
time_dateserial.c
Go to the documentation of this file.
1 /* dateserial function */
2 
3 #include "fb.h"
4 
5 /*:::::*/
6 FBCALL int fb_DateSerial ( int year, int month, int day )
7 {
8  int result = 2;
9  int cur_year = 1900;
10  int cur_month = 1;
11  int cur_day = 1;
12 
13  fb_hNormalizeDate( &day, &month, &year );
14 
15  if( cur_year < year ) {
16  while( cur_year != year ) {
17  result += fb_hTimeDaysInYear( cur_year++ );
18  }
19  } else {
20  while( cur_year != year ) {
21  result -= fb_hTimeDaysInYear( --cur_year );
22  }
23  }
24 
25  while( cur_month != month ) {
26  result += fb_hTimeDaysInMonth( cur_month++, year );
27  }
28 
29  result += day - cur_day;
30 
31  return result;
32 }
33