apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Reid" <dr...@jetnet.co.uk>
Subject Timezones logic...
Date Wed, 04 Jul 2001 00:31:30 GMT
In the recent discussions about implode/explode time it became obvious that
the documentation (such as it is) isn't very clear on why we do things the
way we do...  This I will attempt to solve by this email.

We wrote the apr_implode_time routine to take an exploded time structure
(that is an APR only structure) and create a time_t from it.  There is no
reason why this time_t needs to be in any particular time zone, in fact it's
often desirable to be able to choose the time zone.  That's what we provide
through the apr_explode_time and apr_implode_time functions.

Simple example.

This is something else on my todo list...  Basically allow each vhost on the
server (apache) to have a timezone setting given to it.  This is then used
when generating access log entries from that vhost, though not error_log
messages.  The process becomes very simple with the functions we have...

during the request we get the time by calling (pseudo code)
t = apr_time_now();

then when we write out to the access log instead of one line we have...
apr_explode_time(&xt, t, vhost->offset);
apr_strftime(str, str_size, max_str_size, "fmt", xt);

This is quick and easy and makes sense (I hope) to everyone reading it.  Yes
it is server oriented but then it also works for client apps.  Brane's
addition of apr_implode_gmt helps with those apps that demand a GMT/UTC

Now if anyone wants to do something fancy with the time (don't know what
that would be) we can always get a time_t from that exploded time using just
apr_implode_time, which will give us the correct time, i.e. the time that
we've just written into the log.  If the time returned by apr_implode_time
was different I'd say we had a bug!

That's why we have done things the way we have, and hopefully that makes
people happier about why.  I've written this as I probably won't get time to
change the docs anytime soon, so if anyone else wants to then please feel


View raw message