scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | README | LICENSE

_daysyear.c (401B)


      1 #include <time.h>
      2 #include "../libc.h"
      3 
      4 int _daysmon[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
      5 
      6 int
      7 _daysyear(int year)
      8 {
      9 	if (year%4 != 0)
     10 		return 365;
     11 	if (year%100 == 0 && year%400 != 0)
     12 		return 365;
     13 	return 366;
     14 }
     15 
     16 /*
     17  * Happy New Year!!!!
     18  */
     19 int
     20 _newyear(int year)
     21 {
     22 	int day;
     23 
     24 	year += 1900 - 1;
     25 	day = 1 + year + year/4;
     26 	day -= year/100;
     27 	day += year/400;
     28 
     29 	return day % 7;
     30 }