lib/replace/timegm.c

ソースコードを見る。

関数

static int is_leap (unsigned y)
time_t rep_timegm (struct tm *tm)


関数

static int is_leap ( unsigned  y  )  [static]

timegm.c41 行で定義されています。

参照元 rep_timegm().

00042 {
00043         y += 1900;
00044         return (y % 4) == 0 && ((y % 100) != 0 || (y % 400) == 0);
00045 }

time_t rep_timegm ( struct tm *  tm  ) 

timegm.c47 行で定義されています。

参照先 is_leap().

00048 {
00049         static const unsigned ndays[2][12] ={
00050                 {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
00051                 {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}};
00052         time_t res = 0;
00053         unsigned i;
00054 
00055         if (tm->tm_mon > 12 ||
00056             tm->tm_mon < 0 ||
00057             tm->tm_mday > 31 ||
00058             tm->tm_min > 60 ||
00059             tm->tm_sec > 60 ||
00060             tm->tm_hour > 24) {
00061                 /* invalid tm structure */
00062                 return 0;
00063         }
00064         
00065         for (i = 70; i < tm->tm_year; ++i)
00066                 res += is_leap(i) ? 366 : 365;
00067         
00068         for (i = 0; i < tm->tm_mon; ++i)
00069                 res += ndays[is_leap(tm->tm_year)][i];
00070         res += tm->tm_mday - 1;
00071         res *= 24;
00072         res += tm->tm_hour;
00073         res *= 60;
00074         res += tm->tm_min;
00075         res *= 60;
00076         res += tm->tm_sec;
00077         return res;
00078 }


Sambaに対してSat Aug 29 21:23:37 2009に生成されました。  doxygen 1.4.7