diff src/core/ngx_times.c @ 409:8ac40cae79f0

nginx-0.0.10-2004-08-29-07:55:41 import
author Igor Sysoev <igor@sysoev.ru>
date Sun, 29 Aug 2004 03:55:41 +0000
parents 80e72c428b39
children 9a97dcdd2421
line wrap: on
line diff
--- a/src/core/ngx_times.c
+++ b/src/core/ngx_times.c
@@ -214,14 +214,51 @@ size_t ngx_http_time(u_char *buf, time_t
     ngx_gmtime(t, &tm);
 
     return ngx_snprintf((char *) buf, sizeof("Mon, 28 Sep 1970 06:00:00 GMT"),
-                                       "%s, %02d %s %4d %02d:%02d:%02d GMT",
-                                       week[tm.ngx_tm_wday],
-                                       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);
+                                      "%s, %02d %s %4d %02d:%02d:%02d GMT",
+                                      week[tm.ngx_tm_wday],
+                                      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);
+}
+
+
+size_t ngx_http_cookie_time(u_char *buf, time_t t)
+{
+    ngx_tm_t  tm;
+
+    ngx_gmtime(t, &tm);
+
+    /*
+     * Netscape 3.x does not understand 4-digit years at all and
+     * 2-digit years more than "37"
+     */
+
+    if (tm.ngx_tm_year > 2037) {
+        return ngx_snprintf((char *) buf,
+                                      sizeof("Mon, 28-Sep-1970 06:00:00 GMT"),
+                                      "%s, %02d-%s-%d %02d:%02d:%02d GMT",
+                                      week[tm.ngx_tm_wday],
+                                      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);
+    } else {
+        return ngx_snprintf((char *) buf,
+                                      sizeof("Mon, 28-Sep-70 06:00:00 GMT"),
+                                      "%s, %02d-%s-%02d %02d:%02d:%02d GMT",
+                                      week[tm.ngx_tm_wday],
+                                      tm.ngx_tm_mday,
+                                      months[tm.ngx_tm_mon - 1],
+                                      tm.ngx_tm_year % 100,
+                                      tm.ngx_tm_hour,
+                                      tm.ngx_tm_min,
+                                      tm.ngx_tm_sec);
+    }
 }