From: "John W. Krahn" <[EMAIL PROTECTED]> > Jenda Krynicky wrote: > > > > From: "John W. Krahn" <[EMAIL PROTECTED]> > > > Or, you could do it the "correct" way. :-) > > > > > > use POSIX 'strftime'; > > > > > > my $date = strftime '%a, %d %b %Y %H:%M:%S %z', localtime; > > > $smtp->datasend( "Date: $date\n" ); > > > > I'm not sure this is the correct way. > > This prints > > Sun, 05 Jan 2003 18:42:54 Central Europe Standard Time > > on my computer (Win2k, ActivePerl 5.5.1 build 631 as well as > > ActivePerl 5.8.0 build 804). > > Which is NOT understood properly by my mailer (Pegasus Mail 4.02a). > > On my system the manpage for strftime says: > > man 3 strftime > [snip] > %z The time-zone as hour offset from GMT. Required to > emit RFC822-conformant dates (using "%a, %d %b %Y > %H:%M:%S %z"). (GNU) > > As I don't have a Windows system to test this on I'm not sure why this > is happening.
I guess Windows treat %z as %Z. > However the POSIX manpage states: > > man 3pm POSIX > [snip] > If > you want your code to be portable, your format > (`fmt') argument should use only the conversion > specifiers defined by the ANSI C standard. These > are `aAbBcdHIjmMpSUwWxXyYZ%'. > > So it looks like the %z format is not portable. > If it doesn't work on your machine you can calculate it like this: > > $ 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. Jenda ===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz ===== When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]