]> git.kaiwu.me - nginx.git/commitdiff
nginx-0.0.1-2003-11-12-20:25:12 import
authorIgor Sysoev <igor@sysoev.ru>
Wed, 12 Nov 2003 17:25:12 +0000 (17:25 +0000)
committerIgor Sysoev <igor@sysoev.ru>
Wed, 12 Nov 2003 17:25:12 +0000 (17:25 +0000)
src/core/ngx_times.c
src/http/ngx_http_parse_time.c
src/os/win32/ngx_time.c

index af801d74615dfba930b55fc2c6c973338149ca42..fcc7152abd8f5f2cdd19dea1958a6a854fde79b9 100644 (file)
@@ -35,6 +35,24 @@ void ngx_time_update()
     ngx_cached_http_time.data = cached_http_time;
     ngx_cached_http_log_time.data = cached_http_log_time;
 
+#if 0
+
+    days = sec / 86400;
+    days = days - 31 - 28 + 719527;
+
+    year = days * 400 / (365 * 400 + 100 - 4 + 1);
+    yday = days - (365 * year + year / 4 - year / 100 + year / 400);
+
+    month = (yday + 30) * 12 / 367;
+    mday = yday - (month * 367 / 12 - 31);
+
+    if (++month > 11) {
+        month -= 12;
+        year++;
+    }
+
+#endif
+
     tp = gmtime(&ngx_cached_time);
 
     ngx_cached_http_time.len = strftime(ngx_cached_http_time.data,
index 26deb28411ec5a00fec87c3440601748411998e2..6b98bad43de1a5a1bc1736bc0154d3e179e01415 100644 (file)
@@ -232,19 +232,24 @@ time_t ngx_http_parse_time(char *value, size_t len)
         return NGX_ERROR;
     }
 
-    /* shift new year to March 1, needed for Gauss's formula */
+    /*
+     * shift new year to March 1 and start months from 1 (not 0),
+     * it's needed for Gauss's formula
+     */
 
     if (--month <= 0) {
        month += 12;
        year -= 1;
     }
 
-    /* Gauss's formula for Grigorian days from 1 March 1 BC */
+           /* Gauss's formula for Grigorian days from 1 March 1 BC */
 
     return (365 * year + year / 4 - year / 100 + year / 400
-                                               + 367 * month / 12 + day - 31
+            + 367 * month / 12 - 31
+            + day
+
            /*
-            * 719527 days are between March 1, 1 BC and March 1, 1970,
+            * 719527 days were between March 1, 1 BC and March 1, 1970,
             * 31 and 28 days in January and February 1970
             */
 
index 0aa2c5e749c37a6f34538fa9eaa70f42eef39931..435f430151dcd49b6bff34235c1dfc2bb93e8b6c 100644 (file)
@@ -15,7 +15,7 @@ void ngx_gettimeofday(struct timeval *tp)
      * of 100-nanosecond intervals that have elapsed since
      * 12:00 A.M. January 1, 1601 (UTC).
      *
-     * Between January 1, 1970 (Epoch) and January 1, 1601 there are
+     * Between January 1, 1970 (Epoch) and January 1, 1601 there were
      * 134744 days,
      * 11644473600 seconds or
      * 11644473600,000,000,0 100-nanosecond intervals.