// by mustaqeem Ali Ali's Soft Corpo... // contact @ mustaqeem_2002@indiastudychannel.com
#define TRUE 1 #define FALSE 0
int months_of_year[] = {31,28,31,30,31,30,31,31,30,31,30,31};
int is_leap_year(int year) { int result;
if ( (year%4) != 0 ) // or- if ( year%4 ) result = FALSE; // or- if year is not divisible by 4 else if ( (year%400) == 0 ) // or- if ( !(year%400) ) result = TRUE; // or- if year is divisible by 400 else if ( (year%100) == 0 ) // or- if ( !(year%100) ) result = FALSE; // or- if year is divisible by 100 else // (but not by 400, since that case result = TRUE; // considered already) return ( result ); }
int number_of_days_in_the_year(int year) { return(is_leap_year(year))? 366 : 365; }
int number_of_days_till_now((int day,int mon,int year) { int i,sum=0; for (i=0;i { sum+= months_of_year[i]; } sum+= day; if(is_leap_year(year) && mon>2) sum++; return sum; }
**Reference: http://www.IndiaStudyChannel.com?ref=mustaqeem_2002**
Ali_date.c.txt |