Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: ModPerl: Dev

APR::Date and microseconds in man page, seconds in reality

 

 

ModPerl dev RSS feed   Index | Next | Previous | View Threaded


jpz-mlmp at adelton

Aug 12, 2009, 12:34 PM

Post #1 of 1 (432 views)
Permalink
APR::Date and microseconds in man page, seconds in reality

Hello,

I have tried the example from the APR::Date man page and the result
surprised me. The man page says

ret: $date_parsed ( number )
the number of microseconds since 1 Jan 1970 GMT, or 0 if
out of range or if the date is invalid.

but it looks like the output is number of seconds, not microseconds:

$ perl
use APR::Date ();
$date_string = 'Sun, 06 Nov 1994 08:49:37 GMT';
$date_parsed = APR::Date::parse_http($date_string);
print $date_parsed, "\n";
__END__
784111777
$ TZ=GMT date -d '@784111777'
Sun Nov 6 08:49:37 GMT 1994

This is on mod_perl 2.0.4:

$ rpm -q mod_perl
mod_perl-2.0.4-8.i586

It also seems to be confirmed by the fact that mod_perl's xs/typemap
says

T_APR_TIME
sv_setnv($arg, (NV)(apr_time_sec($var)));

and apr-1.3.8's include/apr_time.h has

#define apr_time_sec(time) ((time) / APR_USEC_PER_SEC)

The net effect is that anything defined in mod_perl as returning
apr_time_t returns seconds to Perl, not microseconds. I came across
this issue when I tried to get the request duration in sub-second
resolution in mod_perl's log handler, and I failed.

I assume it does not make sense to change the semantics of apr_time_t
in mod_perl now that it's been used by lots of code around, so the
best approach would be to modify the documentation to change
'microseconds' to 'seconds'.

Is there some other way of handling the issue?

Thanks,

--
Jan Pazdziora

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe[at]perl.apache.org
For additional commands, e-mail: dev-help[at]perl.apache.org

ModPerl dev RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.