aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2003-11-10 21:09:22 +0000
committerIgor Sysoev <igor@sysoev.ru>2003-11-10 21:09:22 +0000
commitd59a047a7070dc6af13b2e35c097efccc8ce38d0 (patch)
tree7efbd7a8fd2e4d871da3165dab7287c49fb0341e /src/core
parent7832933eed3cb0187eca4fba87076f10c897925e (diff)
downloadnginx-d59a047a7070dc6af13b2e35c097efccc8ce38d0.tar.gz
nginx-d59a047a7070dc6af13b2e35c097efccc8ce38d0.zip
nginx-0.0.1-2003-11-11-00:09:22 import
Diffstat (limited to 'src/core')
-rw-r--r--src/core/ngx_core.h1
-rw-r--r--src/core/ngx_times.c51
-rw-r--r--src/core/ngx_times.h18
3 files changed, 70 insertions, 0 deletions
diff --git a/src/core/ngx_core.h b/src/core/ngx_core.h
index 1db2e41df..7a19d1b71 100644
--- a/src/core/ngx_core.h
+++ b/src/core/ngx_core.h
@@ -27,6 +27,7 @@ typedef struct ngx_connection_s ngx_connection_t;
#include <ngx_table.h>
#include <ngx_file.h>
#include <ngx_files.h>
+#include <ngx_times.h>
#include <ngx_inet.h>
#include <ngx_conf_file.h>
#include <ngx_os_init.h>
diff --git a/src/core/ngx_times.c b/src/core/ngx_times.c
new file mode 100644
index 000000000..423e4cd35
--- /dev/null
+++ b/src/core/ngx_times.c
@@ -0,0 +1,51 @@
+
+#include <ngx_config.h>
+#include <ngx_core.h>
+
+
+time_t ngx_cached_time;
+
+static char cached_http_time[] = "Mon, 28 Sep 1970 06:00:00 GMT";
+ngx_str_t ngx_cached_http_time;
+
+static char cached_http_log_time[] = "28/Sep/1970:12:00:00";
+ngx_str_t ngx_cached_http_log_time;
+
+
+time_t ngx_time()
+{
+ return ngx_cached_time;
+}
+
+
+/* TODO: remove strftime() */
+
+void ngx_time_update()
+{
+ ngx_tm_t *tp, tm;
+ static char *months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
+ "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
+
+ /* STUB: need to move to ngx_init_time() */
+ ngx_cached_http_time.data = cached_http_time;
+ ngx_cached_http_log_time.data = cached_http_log_time;
+
+ tp = gmtime(&ngx_cached_time);
+
+ ngx_cached_http_time.len = strftime(ngx_cached_http_time.data,
+ sizeof("Mon, 28 Sep 1970 06:00:00 GMT"),
+ "%a, %d %b %Y %H:%M:%S GMT", tp);
+
+
+ ngx_localtime(&tm);
+
+ ngx_cached_http_log_time.len = ngx_snprintf(ngx_cached_http_log_time.data,
+ sizeof("28/Sep/1970:12:00:00"),
+ "%02d/%s/%d:%02d:%02d:%02d",
+ tm.ngx_tm_mday,
+ months[tm.ngx_tm_mon - 1],
+ tm.ngx_tm_year,
+ tm.ngx_tm_hour,
+ tm.ngx_tm_min,
+ tm.ngx_tm_sec);
+}
diff --git a/src/core/ngx_times.h b/src/core/ngx_times.h
new file mode 100644
index 000000000..2cbcc7249
--- /dev/null
+++ b/src/core/ngx_times.h
@@ -0,0 +1,18 @@
+#ifndef _NGX_TIMES_H_INCLUDED_
+#define _NGX_TIMES_H_INCLUDED_
+
+
+#include <ngx_config.h>
+#include <ngx_core.h>
+
+
+time_t ngx_time();
+void ngx_time_update();
+
+
+extern time_t ngx_cached_time;
+extern ngx_str_t ngx_cached_http_time;
+extern ngx_str_t ngx_cached_http_log_time;
+
+
+#endif /* _NGX_TIMES_H_INCLUDED_ */