comparison src/core/ngx_times.c @ 324:0ab66f4b6c4d

nginx-0.0.3-2004-04-22-00:13:48 import
author Igor Sysoev <igor@sysoev.ru>
date Wed, 21 Apr 2004 20:13:48 +0000
parents ba876b26b76d
children 8733703a37f3
comparison
equal deleted inserted replaced
323:ba876b26b76d 324:0ab66f4b6c4d
84 #endif 84 #endif
85 85
86 86
87 void ngx_time_update(time_t s) 87 void ngx_time_update(time_t s)
88 { 88 {
89 char *p; 89 u_char *p;
90 ngx_tm_t tm; 90 ngx_tm_t tm;
91 #if (WIN32)
92 TIME_ZONE_INFORMATION tz;
93 #endif
94 91
95 if (ngx_cached_time == s) { 92 if (ngx_cached_time == s) {
96 return; 93 return;
97 } 94 }
98 95
111 p = cached_http_time1; 108 p = cached_http_time1;
112 } else { 109 } else {
113 p = cached_http_time0; 110 p = cached_http_time0;
114 } 111 }
115 112
116 ngx_snprintf(p, sizeof("Mon, 28 Sep 1970 06:00:00 GMT"), 113 ngx_snprintf((char *) p, sizeof("Mon, 28 Sep 1970 06:00:00 GMT"),
117 "%s, %02d %s %4d %02d:%02d:%02d GMT", 114 "%s, %02d %s %4d %02d:%02d:%02d GMT",
118 week[ngx_cached_gmtime.ngx_tm_wday], 115 week[ngx_cached_gmtime.ngx_tm_wday],
119 ngx_cached_gmtime.ngx_tm_mday, 116 ngx_cached_gmtime.ngx_tm_mday,
120 months[ngx_cached_gmtime.ngx_tm_mon - 1], 117 months[ngx_cached_gmtime.ngx_tm_mon - 1],
121 ngx_cached_gmtime.ngx_tm_year, 118 ngx_cached_gmtime.ngx_tm_year,
124 ngx_cached_gmtime.ngx_tm_sec); 121 ngx_cached_gmtime.ngx_tm_sec);
125 122
126 ngx_cached_http_time.data = p; 123 ngx_cached_http_time.data = p;
127 124
128 125
129 #if (WIN32) 126 #if (HAVE_TIMEZONE)
130 127
131 /* 128 ngx_gmtoff = ngx_timezone();
132 * we do not use GetLocalTime() because it does not return GMT offset,
133 * and our ngx_gmtime() is fast enough
134 */
135
136 if (GetTimeZoneInformation(&tz) != TIME_ZONE_ID_INVALID) {
137 ngx_gmtoff = - tz.Bias;
138 }
139
140 ngx_gmtime(ngx_cached_time + ngx_gmtoff * 60, &tm);
141
142 #elif (SOLARIS)
143
144 ngx_gmtoff = (daylight) ? - altzone / 60: - timezone / 60;
145 ngx_gmtime(ngx_cached_time + ngx_gmtoff * 60, &tm);
146
147 #elif defined __linux__
148
149 ngx_gmtoff = - timezone / 60 + daylight * 60;
150 ngx_gmtime(ngx_cached_time + ngx_gmtoff * 60, &tm); 129 ngx_gmtime(ngx_cached_time + ngx_gmtoff * 60, &tm);
151 130
152 #else 131 #else
153 132
154 ngx_localtime(&tm); 133 ngx_localtime(&tm);
161 p = cached_err_log_time1; 140 p = cached_err_log_time1;
162 } else { 141 } else {
163 p = cached_err_log_time0; 142 p = cached_err_log_time0;
164 } 143 }
165 144
166 ngx_snprintf(p, sizeof("1970/09/28 12:00:00"), 145 ngx_snprintf((char *) p, sizeof("1970/09/28 12:00:00"),
167 "%4d/%02d/%02d %02d:%02d:%02d", 146 "%4d/%02d/%02d %02d:%02d:%02d",
168 tm.ngx_tm_year, tm.ngx_tm_mon, 147 tm.ngx_tm_year, tm.ngx_tm_mon,
169 tm.ngx_tm_mday, tm.ngx_tm_hour, 148 tm.ngx_tm_mday, tm.ngx_tm_hour,
170 tm.ngx_tm_min, tm.ngx_tm_sec); 149 tm.ngx_tm_min, tm.ngx_tm_sec);
171 150
176 p = cached_http_log_time1; 155 p = cached_http_log_time1;
177 } else { 156 } else {
178 p = cached_http_log_time0; 157 p = cached_http_log_time0;
179 } 158 }
180 159
181 ngx_snprintf(p, sizeof("28/Sep/1970:12:00:00 +0600"), 160 ngx_snprintf((char *) p, sizeof("28/Sep/1970:12:00:00 +0600"),
182 "%02d/%s/%d:%02d:%02d:%02d %c%02d%02d", 161 "%02d/%s/%d:%02d:%02d:%02d %c%02d%02d",
183 tm.ngx_tm_mday, months[tm.ngx_tm_mon - 1], 162 tm.ngx_tm_mday, months[tm.ngx_tm_mon - 1],
184 tm.ngx_tm_year, tm.ngx_tm_hour, 163 tm.ngx_tm_year, tm.ngx_tm_hour,
185 tm.ngx_tm_min, tm.ngx_tm_sec, 164 tm.ngx_tm_min, tm.ngx_tm_sec,
186 ngx_gmtoff < 0 ? '-' : '+', 165 ngx_gmtoff < 0 ? '-' : '+',
241 220
242 mon += 2; 221 mon += 2;
243 222
244 if (yday >= 306) { 223 if (yday >= 306) {
245 /* 224 /*
246 * yday is not used in Win32 SYSTEMTIME 225 * there is no "yday" in Win32 SYSTEMTIME
247 * 226 *
248 * yday -= 306; 227 * yday -= 306;
249 */ 228 */
250 229
251 year++; 230 year++;
269 mday -= 28; 248 mday -= 28;
270 } 249 }
271 } 250 }
272 251
273 /* 252 /*
274 * yday is not used in Win32 SYSTEMTIME 253 * there is no "yday" in Win32 SYSTEMTIME
275 * 254 *
276 * } else { 255 * } else {
277 * yday += 31 + 28; 256 * yday += 31 + 28;
278 * 257 *
279 * if ((year % 4 == 0) && (year % 100 || (year % 400 == 0))) { 258 * if ((year % 4 == 0) && (year % 100 || (year % 400 == 0))) {