mirror of
https://github.com/nginx/nginx.git
synced 2025-07-20 19:27:29 +08:00
Merge b857b3415f
into c52c5698cd
This commit is contained in:
commit
8741018d90
@ -360,7 +360,7 @@ ngx_gmtime(time_t t, ngx_tm_t *tp)
|
||||
*/
|
||||
|
||||
/* days since March 1, 1 BC */
|
||||
days = days - (31 + 28) + 719527;
|
||||
days = days + 719527 - (31 + 28);
|
||||
|
||||
/*
|
||||
* The "days" should be adjusted to 1 only, however, some March 1st's go
|
||||
|
@ -46,6 +46,9 @@ ngx_timezone_update(void)
|
||||
s = time(NULL);
|
||||
|
||||
t = localtime(&s);
|
||||
if (t == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
strftime(buf, 4, "%H", t);
|
||||
|
||||
@ -57,12 +60,20 @@ void
|
||||
ngx_localtime(time_t s, ngx_tm_t *tm)
|
||||
{
|
||||
#if (NGX_HAVE_LOCALTIME_R)
|
||||
(void) localtime_r(&s, tm);
|
||||
if (localtime_r(&s, tm) == NULL) {
|
||||
ngx_memzero(tm, sizeof(struct tm));
|
||||
return;
|
||||
}
|
||||
|
||||
#else
|
||||
ngx_tm_t *t;
|
||||
|
||||
t = localtime(&s);
|
||||
if (t == NULL) {
|
||||
ngx_memzero(tm, sizeof(struct tm));
|
||||
return;
|
||||
}
|
||||
|
||||
*tm = *t;
|
||||
|
||||
#endif
|
||||
@ -76,12 +87,20 @@ void
|
||||
ngx_libc_localtime(time_t s, struct tm *tm)
|
||||
{
|
||||
#if (NGX_HAVE_LOCALTIME_R)
|
||||
(void) localtime_r(&s, tm);
|
||||
if (localtime_r(&s, tm) == NULL) {
|
||||
ngx_memzero(tm, sizeof(struct tm));
|
||||
return;
|
||||
}
|
||||
|
||||
#else
|
||||
struct tm *t;
|
||||
|
||||
t = localtime(&s);
|
||||
if (t == NULL) {
|
||||
ngx_memzero(tm, sizeof(struct tm));
|
||||
return;
|
||||
}
|
||||
|
||||
*tm = *t;
|
||||
|
||||
#endif
|
||||
@ -92,12 +111,20 @@ void
|
||||
ngx_libc_gmtime(time_t s, struct tm *tm)
|
||||
{
|
||||
#if (NGX_HAVE_LOCALTIME_R)
|
||||
(void) gmtime_r(&s, tm);
|
||||
if (gmtime_r(&s, tm) == NULL) {
|
||||
ngx_memzero(tm, sizeof(struct tm));
|
||||
return;
|
||||
}
|
||||
|
||||
#else
|
||||
struct tm *t;
|
||||
|
||||
t = gmtime(&s);
|
||||
if (t == NULL) {
|
||||
ngx_memzero(tm, sizeof(struct tm));
|
||||
return;
|
||||
}
|
||||
|
||||
*tm = *t;
|
||||
|
||||
#endif
|
||||
|
@ -44,6 +44,11 @@ ngx_libc_localtime(time_t s, struct tm *tm)
|
||||
struct tm *t;
|
||||
|
||||
t = localtime(&s);
|
||||
if (t == NULL) {
|
||||
ngx_memzero(tm, sizeof(struct tm));
|
||||
return;
|
||||
}
|
||||
|
||||
*tm = *t;
|
||||
}
|
||||
|
||||
@ -54,6 +59,11 @@ ngx_libc_gmtime(time_t s, struct tm *tm)
|
||||
struct tm *t;
|
||||
|
||||
t = gmtime(&s);
|
||||
if (t == NULL) {
|
||||
ngx_memzero(tm, sizeof(struct tm));
|
||||
return;
|
||||
}
|
||||
|
||||
*tm = *t;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user