further renamed ngx.utc_now to ngx.utc_time, and ngx.now to ngx.strnow per Piotr's suggestion.
This commit is contained in:
Родитель
fa9f606ce7
Коммит
cbc0ca96c7
|
@ -510,13 +510,13 @@ Returns today's date (in the format `yyyy-mm-dd`) from nginx cached time (no sys
|
|||
|
||||
This is the local time.
|
||||
|
||||
ngx.now()
|
||||
ngx.strtime()
|
||||
-------------
|
||||
Returns the current timestamp (in the format `yyyy-mm-dd hh:mm:ss`) of the nginx cached time (no syscall involved unlike Lua's date library).
|
||||
|
||||
This is the local time.
|
||||
|
||||
ngx.utc_now()
|
||||
ngx.utc_time()
|
||||
----------------
|
||||
|
||||
Returns the current timestamp (in seconds) of the nginx cached time (no syscall involved unlike Lua's date library).
|
||||
|
@ -525,7 +525,7 @@ This is the UTC time.
|
|||
|
||||
ngx.cookie_time(sec)
|
||||
--------------------
|
||||
Returns a formated string can be used as the cookie expiration time. The parameter `sec` is the timestamp in seconds (like those returned from `ngx.time`).
|
||||
Returns a formated string can be used as the cookie expiration time. The parameter `sec` is the timestamp in seconds (like those returned from `ngx.utc_time`).
|
||||
|
||||
ngx.say(ngx.cookie_time(1290079655))
|
||||
# yields "Thu, 18-Nov-10 11:27:35 GMT"
|
||||
|
|
|
@ -110,13 +110,13 @@ ngx_http_lua_set_by_lua_env(lua_State *L, ngx_http_request_t *r, size_t nargs,
|
|||
lua_setfield(L, -2, "get_now_ts"); /* deprecated */
|
||||
|
||||
lua_pushcfunction(L, ngx_http_lua_ngx_get_now_ts);
|
||||
lua_setfield(L, -2, "utc_now");
|
||||
lua_setfield(L, -2, "utc_time");
|
||||
|
||||
lua_pushcfunction(L, ngx_http_lua_ngx_get_now);
|
||||
lua_setfield(L, -2, "get_now"); /* deprecated */
|
||||
|
||||
lua_pushcfunction(L, ngx_http_lua_ngx_get_now);
|
||||
lua_setfield(L, -2, "now");
|
||||
lua_setfield(L, -2, "strtime");
|
||||
|
||||
lua_pushcfunction(L, ngx_http_lua_ngx_get_today);
|
||||
lua_setfield(L, -2, "get_today"); /* deprecated */
|
||||
|
|
|
@ -507,13 +507,13 @@ init_ngx_lua_globals(lua_State *L)
|
|||
lua_setfield(L, -2, "get_now_ts"); /* deprecated */
|
||||
|
||||
lua_pushcfunction(L, ngx_http_lua_ngx_get_now_ts);
|
||||
lua_setfield(L, -2, "utc_now");
|
||||
lua_setfield(L, -2, "utc_time");
|
||||
|
||||
lua_pushcfunction(L, ngx_http_lua_ngx_get_now);
|
||||
lua_setfield(L, -2, "get_now"); /* deprecated */
|
||||
|
||||
lua_pushcfunction(L, ngx_http_lua_ngx_get_now);
|
||||
lua_setfield(L, -2, "now");
|
||||
lua_setfield(L, -2, "strtime");
|
||||
|
||||
lua_pushcfunction(L, ngx_http_lua_ngx_get_today);
|
||||
lua_setfield(L, -2, "get_today"); /* deprecated */
|
||||
|
|
20
t/012-now.t
20
t/012-now.t
|
@ -19,7 +19,7 @@ __DATA__
|
|||
=== TEST 1: use ngx.now in content_by_lua
|
||||
--- config
|
||||
location = /now {
|
||||
content_by_lua 'ngx.say(ngx.now())';
|
||||
content_by_lua 'ngx.say(ngx.strtime())';
|
||||
}
|
||||
--- request
|
||||
GET /now
|
||||
|
@ -30,7 +30,7 @@ GET /now
|
|||
=== TEST 2: use ngx.now in set_by_lua
|
||||
--- config
|
||||
location = /now {
|
||||
set_by_lua $a 'return ngx.now()';
|
||||
set_by_lua $a 'return ngx.strtime()';
|
||||
echo $a;
|
||||
}
|
||||
--- request
|
||||
|
@ -39,24 +39,24 @@ GET /now
|
|||
|
||||
|
||||
|
||||
=== TEST 3: use ngx.utc_now in content_by_lua
|
||||
=== TEST 3: use ngx.utc_time in content_by_lua
|
||||
--- config
|
||||
location = /utc_now {
|
||||
content_by_lua 'ngx.say(ngx.utc_now())';
|
||||
location = /utc_time {
|
||||
content_by_lua 'ngx.say(ngx.utc_time())';
|
||||
}
|
||||
--- request
|
||||
GET /utc_now
|
||||
GET /utc_time
|
||||
--- response_body_like: ^\d{10}$
|
||||
|
||||
|
||||
|
||||
=== TEST 4: use ngx.utc_now in set_by_lua
|
||||
=== TEST 4: use ngx.utc_time in set_by_lua
|
||||
--- config
|
||||
location = /utc_now {
|
||||
set_by_lua $a 'return ngx.utc_now()';
|
||||
location = /utc_time {
|
||||
set_by_lua $a 'return ngx.utc_time()';
|
||||
echo $a;
|
||||
}
|
||||
--- request
|
||||
GET /utc_now
|
||||
GET /utc_time
|
||||
--- response_body_like: ^\d{10}$
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче