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.
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
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]