diff options
author | Igor Sysoev <igor@sysoev.ru> | 2008-01-31 18:14:31 +0300 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2008-01-31 18:14:31 +0300 |
commit | ac5deaa9061e33eeb06e3f4e1b2a89d3f025d6ac (patch) | |
tree | 0a3d1729ce2c753985fa175ce288572d3c9f0b39 /src/core/ngx_times.c | |
parent | c20d3769bc0e22a29bf00feba829d887b948dbd4 (diff) |
treat time_t as unsigned time
Diffstat (limited to 'src/core/ngx_times.c')
-rw-r--r-- | src/core/ngx_times.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/core/ngx_times.c b/src/core/ngx_times.c index 949e0c6f7..1ba1210f0 100644 --- a/src/core/ngx_times.c +++ b/src/core/ngx_times.c @@ -203,18 +203,21 @@ ngx_http_cookie_time(u_char *buf, time_t t) void ngx_gmtime(time_t t, ngx_tm_t *tp) { - ngx_int_t sec, min, hour, mday, mon, year, wday, yday, days; + ngx_uint_t n, sec, min, hour, mday, mon, year, wday, yday, days; - days = (ngx_int_t) (t / 86400); + /* the calculation is valid for positive time_t only */ + n = (ngx_uint_t) t; + + days = n / 86400; /* Jaunary 1, 1970 was Thursday */ wday = (4 + days) % 7; - t %= 86400; - hour = (ngx_int_t) (t / 3600); - t %= 3600; - min = (ngx_int_t) (t / 60); - sec = (ngx_int_t) (t % 60); + n %= 86400; + hour = n / 3600; + n %= 3600; + min = n / 60; + sec = n % 60; /* the algorithm based on Gauss's formula */ |