This commit is contained in:
Roman Arutyunyan 2025-07-16 20:05:57 +02:00 committed by GitHub
commit 8741018d90
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 41 additions and 4 deletions

View File

@ -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

View File

@ -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

View File

@ -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;
}