Jenda Krynicky wrote: > > From: "John W. Krahn" <[EMAIL PROTECTED]> > > > > $ perl -MPOSIX -MTime::Local -e' > > $local = time; > > $gm = timelocal( gmtime $local ); > > $sign = qw( + + - )[ $local <=> $gm ]; > > $calc = sprintf "%s%02d%02d", $sign, (gmtime abs( $local - $gm > > ))[2,1]; > > > > print "Calculated: $calc\n", strftime( "strftime: %z\n", localtime ); > > ' Calculated: -0800 strftime: -0800 > > I like this code. It's a lot shorter than mine. It's a bit slower > though : > > Benchmark: timing 100000 iterations of John, Mine... > John: 7 wallclock secs ( 6.75 usr + 0.00 sys = 6.75 CPU) > @ 14814.81/s (n=100000) > Mine: 3 wallclock secs ( 2.90 usr + 0.00 sys = 2.90 CPU) > @ 34435.26/s (n=100000) > > Not that it matters though ... noone will compute this thousand times > :-) > > I guess I'll keep my code in Mail::Sender though.
In my test it didn't do as poorly. However if the %z format works then POSIX::strftime is much faster. Benchmark: timing 100000 iterations of Jenda, John, POSIX... Jenda: 62 wallclock secs (57.66 usr + 1.38 sys = 59.04 CPU) @ 1693.77/s (n=100000) John: 85 wallclock secs (78.25 usr + 1.26 sys = 79.51 CPU) @ 1257.70/s (n=100000) POSIX: 16 wallclock secs (15.62 usr + 0.91 sys = 16.53 CPU) @ 6049.61/s (n=100000) John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]