1
0
mirror of https://github.com/moparisthebest/wget synced 2024-07-03 16:38:41 -04:00

[svn] Doc fix.

This commit is contained in:
hniksic 2005-07-06 09:06:01 -07:00
parent ac4f55a297
commit 985e4d63a0

View File

@ -1225,27 +1225,28 @@ fnmatch (const char *pattern, const char *string, int flags)
/* timegm is a GNU extension, but lately also available on *BSD and /* timegm is a GNU extension, but lately also available on *BSD and
possibly elsewhere. */ possibly elsewhere. */
/* Inverse of gmtime: converts struct tm to time_t, assuming the data /* True if YEAR is a leap year. */
in tm is UTC rather than local timezone. This implementation #define ISLEAP(year) \
returns the number of seconds since 1970-01-01, converted to
time_t. */
#define IS_LEAP(year) \
((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0)) ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0))
/* Number of leap years in the range [y1, y2). */ /* Number of leap years in the range [y1, y2). */
#define LEAPDAYS(y1, y2) \ #define LEAPYEARS(y1, y2) \
((y2-1)/4 - (y1-1)/4) - ((y2-1)/100 - (y1-1)/100) + ((y2-1)/400 - (y1-1)/400) ((y2-1)/4 - (y1-1)/4) - ((y2-1)/100 - (y1-1)/100) + ((y2-1)/400 - (y1-1)/400)
/* Inverse of gmtime: converts struct tm to time_t, assuming the data
in tm is UTC rather than local timezone. This implementation
returns the number of seconds elapsed since midnight 1970-01-01,
converted to time_t. */
time_t time_t
timegm (struct tm *t) timegm (struct tm *t)
{ {
static const unsigned short int month_to_days[][13] = { static const unsigned short int month_to_days[][13] = {
{ 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 }, { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 }, /* normal */
{ 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335 } { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335 } /* leap */
}; };
const int year = 1900 + t->tm_year; const int year = 1900 + t->tm_year;
unsigned long secs; unsigned long secs; /* until 2106-02-07 for 32-bit unsigned long */
int days; int days;
if (year < 1970) if (year < 1970)
@ -1254,10 +1255,10 @@ timegm (struct tm *t)
days = 365 * (year - 1970); days = 365 * (year - 1970);
/* Take into account leap years between 1970 and YEAR, not counting /* Take into account leap years between 1970 and YEAR, not counting
YEAR itself. */ YEAR itself. */
days += LEAPDAYS (1970, year); days += LEAPYEARS (1970, year);
if (t->tm_mon < 0 || t->tm_mon >= 12) if (t->tm_mon < 0 || t->tm_mon >= 12)
return (time_t) -1; return (time_t) -1;
days += month_to_days[IS_LEAP (year)][t->tm_mon]; days += month_to_days[ISLEAP (year)][t->tm_mon];
days += t->tm_mday - 1; days += t->tm_mday - 1;
secs = days * 86400 + t->tm_hour * 3600 + t->tm_min * 60 + t->tm_sec; secs = days * 86400 + t->tm_hour * 3600 + t->tm_min * 60 + t->tm_sec;