On Tue, Mar 14, 2023 at 1:30 PM Ruediger Pluem <rpl...@apache.org> wrote:
>
> On 3/14/23 12:11 PM, yla...@apache.org wrote:
> > Author: ylavic
> > Date: Tue Mar 14 11:11:24 2023
> > New Revision: 1908380
> >
> > URL: http://svn.apache.org/viewvc?rev=1908380&view=rev
> > Log:
> > core: Add formats %{z} and %{strftime-format} to ErrorLogFormat.  PR 62161.
> >
> > %{z} prints the timezone offset (i.e. "[+-]nnnn") and %{strftime-format} 
> > allows
> > any %-format handled by [apr_]strftime().
> >
> > * include/util_time.h():
> >   Define new AP_CTIME_OPTION_GMTOFF option for ap_recent_ctime_ex().
> >
> > * server/util_time.c(ap_recent_ctime_ex):
> >   Handle AP_CTIME_OPTION_GMTOFF to print "[+-]nnnn" timezone.
> >
> > * server/log.c(log_ctime):
> >   If the format contains a '%' it's for strftime(), otherwise it's builtin
> >   with new 'z' as AP_CTIME_OPTION_GMTOFF.
[]
> >
> > +++ httpd/httpd/trunk/server/util_time.c Tue Mar 14 11:11:24 2023
[]
> > @@ -251,7 +259,19 @@ AP_DECLARE(apr_status_t) ap_recent_ctime
> >          *date_str++ = real_year % 100 / 10 + '0';
> >          *date_str++ = real_year % 10 + '0';
> >      }
> > -    *date_str++ = 0;
> > +    if (option & AP_CTIME_OPTION_GMTOFF) {
> > +        int off = xt.tm_gmtoff;
> > +        char sign = '+';
> > +        if (off < 0) {
> > +            off = -off;
> > +            sign = '-';
> > +        }
> > +        apr_snprintf(date_str, AP_CTIME_GMTOFF_LEN + 1, " %c%.2d%.2d",
> > +                     sign, off / 3600, (off % 3600) / 60);
>
> The code above does not use apr_snprintf but converts the numbers to strings 
> explicitly (I guess for performance reasons).
> Should we use the same approach here?

Thanks, done in r1908389.


Regards;
Yann.

Reply via email to