scc

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

_systime.c (381B)


      1 #include <time.h>
      2 
      3 #include "../../libc.h"
      4 
      5 time_t
      6 _systime(struct tm *tm)
      7 {
      8 	time_t t = 0;
      9 	int year = tm->tm_year + MINYEAR;
     10 
     11 	for (int i = EPOCH; i < year; ++i)
     12 		t += _daysyear(i) * SECDAY;
     13 	for (int i = 0; i < tm->tm_mon; ++i)
     14 		t += _daysmon[i] * SECDAY;
     15 
     16 	t += tm->tm_sec;
     17 	t += tm->tm_min * SECMIN;
     18 	t += tm->tm_hour * SECHOUR;
     19 	t += (tm->tm_mday-1) * SECDAY;
     20 	return t;
     21 }