diff src/core/ngx_times.c @ 394:05981f639d21 NGINX_0_7_9

nginx 0.7.9 *) Change: now ngx_http_charset_module works by default with following MIME types: text/html, text/css, text/xml, text/plain, text/vnd.wap.wml, application/x-javascript, and application/rss+xml. *) Feature: the "charset_types" and "addition_types" directives. *) Feature: now the "gzip_types", "ssi_types", and "sub_filter_types" directives use hash. *) Feature: the ngx_cpp_test_module. *) Feature: the "expires" directive supports daily time. *) Feature: the ngx_http_xslt_module improvements and bug fixing. Thanks to Denis F. Latypoff and Maxim Dounin. *) Bugfix: the "log_not_found" directive did not work for index files tests. *) Bugfix: HTTPS connections might hang, if kqueue, epoll, rtsig, or eventport methods were used; the bug had appeared in 0.7.7. *) Bugfix: if the "server_name", "valid_referers", and "map" directives used an "*.domain.tld" wildcard and exact name "domain.tld" was not set, then the exact name was matched by the wildcard; the bugs had appeared in 0.3.18.
author Igor Sysoev <http://sysoev.ru>
date Tue, 12 Aug 2008 00:00:00 +0400
parents 6639b93e81b2
children a094317ba307
line wrap: on
line diff
--- a/src/core/ngx_times.c
+++ b/src/core/ngx_times.c
@@ -291,3 +291,42 @@ ngx_gmtime(time_t t, ngx_tm_t *tp)
     tp->ngx_tm_year = (ngx_tm_year_t) year;
     tp->ngx_tm_wday = (ngx_tm_wday_t) wday;
 }
+
+
+time_t
+ngx_next_time(time_t when)
+{
+    time_t     now, next;
+    struct tm  tm;
+
+    now = ngx_time();
+
+    ngx_libc_localtime(now, &tm);
+
+    tm.tm_hour = (int) (when / 3600);
+    when %= 3600;
+    tm.tm_min = (int) (when / 60);
+    tm.tm_sec = (int) (when % 60);
+
+    next = mktime(&tm);
+
+    if (next == -1) {
+        return -1;
+    }
+
+    if (next - now > 0) {
+        return next;
+    }
+
+    tm.tm_mday++;
+
+    /* mktime() should normalize a date (Jan 32, etc) */
+
+    next = mktime(&tm);
+
+    if (next != -1) {
+        return next;
+    }
+
+    return -1;
+}