Hi
I have to deal with TimeZones and I'd like to use Time::ParseDate.
As I've got wrong results I herewith paste my little program that tries
to deal with an ebay-site that has two times: PST and MEZ and it
show a difference of only 3600 seconds (1 hour)?

Am I doing s.th wrong? Or is it a bug?

Thanks for your effort, I appreciate your 'service' allway when I came here! Best wishes to all for 2005 Carl
PS:I think you can copy, paste, and run it (hopefully)
#! /usr/bin/perl use LWP::Simple; use LWP::UserAgent; use Time::ParseDate; use Time::Zone; my $GETTIMELIMIT = 30; # official eBay-Time: PST and MEZ my $url = 'http://cgi3.ebay.de/aw-cgi/eBayISAPI.dll?TimeShow'; my @L = ladeEbay( $url ); # print "loaded:\t",scalar @L,"\n"; %time = ( myTime => tz_local_offset() ); print "\n"; while ( @L) { my $l = shift(@L); if ( $l =~ s/(\(eBay\-Zeit\))//) { $l =~ s/^(.+?>)//g; $l =~ s/(<.+?>)/ /g; #print "\nzeit1:\t$l\n"; my @i = split /[\s,\.]+/, $l; #print join '; ', @i, "\n\n"; #$i[0] = "$2 $1 $3" if ($i[0] =~ /(\w+)[\s-](\d+)[\s-](\d+)/); my @i = split /[\s,\.]+/, $l; $time{usaDay} = "$i[4] $i[5] $i[6]"; $i[7] =~ s/://g; #hhmmss[[AP]M] $i[7] .= ($i[7] lt '120000' ) ? ' AM':' PM'; $time{usaTime} = $i[7]; $time{usaTiZo} = $i[8]; $time{usaOFF} = tz_offset($i[8]); next; } if ( $l =~ s/(<B>eBay\s*Deutschland)//) { $l =~ s/^(.+?>)//g; $l =~ s/(<.+?>)/ /g; #print "zeit2:\t$l\n"; my @i = split /[\s,\.]+/, $l; #print join '; ', @i, "\n\n"; my @i = split /[\s,\.]+/, $l; $time{brdDay} = "$i[2] $i[3] $i[4]"; $i[5] =~ s/://g; #hhmmss[[AP]M] $i[5] .= ($i[5] lt '120000' ) ? ' AM':' PM'; $time{brdTime} = $i[5]; $time{brdTiZo} = $i[6]; $time{brdOFF} = tz_offset($i[6]); last; } } $time{difOFF} = $time{brdOFF} - $time{usaOFF}; $time{usaSec} = parsedate($time{usaDay}.' '.$time{usaTime}, ZONE => $t +ime{usaTiZo}); $time{brdSec} = parsedate($time{brdDay}.' '.$time{brdTime}, ZONE => $t +ime{brdTiZo}); $time{diTime} = $time{brdSec} - $time{usaSec}; foreach (sort keys %time) { print "\t$_ => \t$time{$_}\n"; } print "\n"; sub ladeEbay { my $s; eval { local $SIG{ALRM} = sub { die "Zeit_Limit $!"}; alarm($GETTIMELIMIT); # 30 Sekunden = 0.5 min für ein get my $ua = LWP::UserAgent->new; my $req = HTTP::Request->new(GET => $url); $s = $ua->request($req)->as_string; alarm(0); }; if ($@ and ($@ =~ /Zeit_Limit/) ) {# da steht u.a. "Zeit_Limit" dr +in $ERRORMAIL .="TIMEOUT, NIX GELADEN (30 sec): $@\n"; alarm(0); return; } $s =~ s/\x0A|\x0D//g; return split /<table|<td|<tr/i, $s; }

In reply to TimeZone Error? by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.