You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by "Richard N. Fogle" <ri...@neosaint.org> on 2005/10/28 19:05:17 UTC
Time::localtime under mod_perl2 showing output in client-side time zones
We are experiencing strange behavior with the following code:
-----SNIP-----
#! /usr/bin/perl -w
$ENV{'MOD_PERL_API_VERSION'} = '2';
use strict;
use Time::localtime;
my $foot = time();
my $foo = localtime($foot);
my $year = $foo->year() + 1900;
my $headers = <<"EOF";
Content-type: text/html
Transfer-Encoded: chunked
\n
EOF
print $headers;
print "Timezone is ".$ENV{'TZ'}." <BR>";
print "Time::localtime: ";
printf "%d : %4d-%02d-%02d %02d:%02d:%02d \n",
$foot, $year, $foo->mon + 1, $foo->mday,
$foo->hour, $foo->min, $foo->sec;
print "<BR>System date: ".`date`;
-----SNIP-----
When we load this code as a CGI through a webserver and continually click 'refresh' the Time::localtime output will eventually change to reflect the time zone of the client! I'm CDT (system time) and another use is UTC, once this triggers workstation I will see Time::localtime output in UTC through my web client. Example:
Timezone is America/Chicago
Time::localtime: 1130518420 : 2005-10-28 11:53:40
System date: Fri Oct 28 11:53:41 CDT 2005
will change to:
Timezone is America/Chicago
Time::localtime: 1130518420 : 2005-10-28 18:53:40
System date: Fri Oct 28 11:53:41 CDT 2005
Once the user in the UTC time zone triggers this. We tested this with users in Hong Kong with the same results. Server information:
Red Hat Enterprise Linux ES release 3 (Taroon Update 5)
perl-5.8.0-89.10 - compiled with threads
mod_perl 1.99._09-10
Apache 2.0.46-54
We also tested this under the latest mod_perl and the latest perl (on the same server):
perl-5.8.7 (compiled with and without threads)
mod_perl 2.0.2
Apache 2.0.49
Server uname: Linux migration.klauser.com 2.4.21-32.0.1.ELsmp #1 SMP Tue May 17 17:52:23 EDT 2005 i686 i686 i386 GNU/Linux
We've tried the script with CGI(), I currently have it posted without. Same results. We've tried placing the time functions in a subroutine with private variables with the same results. Tried using Thread::Semaphore with the same results. If anyone would like the URL to see this for themselves write me off list. If there is need for additional information than I apologize in advance for not submitting it and will do so upon request.
Richard N. Fogle
<nosig>