aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2008-04-10 09:37:12 +0000
committerIgor Sysoev <igor@sysoev.ru>2008-04-10 09:37:12 +0000
commitb8a71b6c1bf2a7883fa94f24155791ab2c3d3924 (patch)
tree17e3eddbdd5fb26c354c182a18c7533f99551dd2
parentd52c878692f4a0dde54cb4bf76be1d0a7689b14e (diff)
downloadnginx-b8a71b6c1bf2a7883fa94f24155791ab2c3d3924.tar.gz
nginx-b8a71b6c1bf2a7883fa94f24155791ab2c3d3924.zip
comment Gauss' formula
-rw-r--r--src/http/ngx_http_parse_time.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/http/ngx_http_parse_time.c b/src/http/ngx_http_parse_time.c
index 115508954..eac23f2f9 100644
--- a/src/http/ngx_http_parse_time.c
+++ b/src/http/ngx_http_parse_time.c
@@ -240,7 +240,7 @@ ngx_http_parse_time(u_char *value, size_t len)
/*
* shift new year to March 1 and start months from 1 (not 0),
- * it is needed for Gauss's formula
+ * it is needed for Gauss' formula
*/
if (--month <= 0) {
@@ -248,11 +248,20 @@ ngx_http_parse_time(u_char *value, size_t len)
year -= 1;
}
- /* Gauss's formula for Grigorian days from March 1, 1 BC */
+ /* Gauss' formula for Grigorian days since March 1, 1 BC */
- return (365 * year + year / 4 - year / 100 + year / 400
- + 367 * month / 12 - 31
- + day
+ return (
+ /* days in years including leap years since March 1, 1 BC */
+
+ 365 * year + year / 4 - year / 100 + year / 400
+
+ /* days before the month */
+
+ + 367 * month / 12 - 30
+
+ /* days before the day */
+
+ + day - 1
/*
* 719527 days were between March 1, 1 BC and March 1, 1970,