perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jan Pazdziora <>
Subject APR::Date and microseconds in man page, seconds in reality
Date Wed, 12 Aug 2009 19:34:14 GMT


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";
	$ 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

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

		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?


Jan Pazdziora

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message