Mercurial > hg > nginx
comparison src/core/ngx_times.c @ 178:a8ff48d26cca
nginx-0.0.1-2003-11-11-00:09:22 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Mon, 10 Nov 2003 21:09:22 +0000 |
parents | |
children | 2d143372a1ee |
comparison
equal
deleted
inserted
replaced
177:4db54fdbcbe7 | 178:a8ff48d26cca |
---|---|
1 | |
2 #include <ngx_config.h> | |
3 #include <ngx_core.h> | |
4 | |
5 | |
6 time_t ngx_cached_time; | |
7 | |
8 static char cached_http_time[] = "Mon, 28 Sep 1970 06:00:00 GMT"; | |
9 ngx_str_t ngx_cached_http_time; | |
10 | |
11 static char cached_http_log_time[] = "28/Sep/1970:12:00:00"; | |
12 ngx_str_t ngx_cached_http_log_time; | |
13 | |
14 | |
15 time_t ngx_time() | |
16 { | |
17 return ngx_cached_time; | |
18 } | |
19 | |
20 | |
21 /* TODO: remove strftime() */ | |
22 | |
23 void ngx_time_update() | |
24 { | |
25 ngx_tm_t *tp, tm; | |
26 static char *months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", | |
27 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; | |
28 | |
29 /* STUB: need to move to ngx_init_time() */ | |
30 ngx_cached_http_time.data = cached_http_time; | |
31 ngx_cached_http_log_time.data = cached_http_log_time; | |
32 | |
33 tp = gmtime(&ngx_cached_time); | |
34 | |
35 ngx_cached_http_time.len = strftime(ngx_cached_http_time.data, | |
36 sizeof("Mon, 28 Sep 1970 06:00:00 GMT"), | |
37 "%a, %d %b %Y %H:%M:%S GMT", tp); | |
38 | |
39 | |
40 ngx_localtime(&tm); | |
41 | |
42 ngx_cached_http_log_time.len = ngx_snprintf(ngx_cached_http_log_time.data, | |
43 sizeof("28/Sep/1970:12:00:00"), | |
44 "%02d/%s/%d:%02d:%02d:%02d", | |
45 tm.ngx_tm_mday, | |
46 months[tm.ngx_tm_mon - 1], | |
47 tm.ngx_tm_year, | |
48 tm.ngx_tm_hour, | |
49 tm.ngx_tm_min, | |
50 tm.ngx_tm_sec); | |
51 } |