Y
Yohan N. Leder
Hi,
I would like to produce a formatted GMT date & time string which will
depend of a user choice in a web form (in a CGI framework) about human
language he prefers (e.g. a french native may prefer to choose
'english'). I wish that it works under both Unix and Windows.
Here is a test script on which I'm trying to go through POSIX::setlocale
() as described in 'perldoc perllocale' about LC_TIME :
#!/usr/bin/perl -w
use strict;
use POSIX qw(locale_h strftime);
print "Content-type: text/html\n\n";
my $datetime;
# english
setlocale(LC_TIME, "en_US.ISO8859-1");
$datetime = strftime "%d %b %Y @ %H:%M:%S GMT", gmtime;
print "<p>ENGLISH =>".$datetime."</p>";
# french
setlocale(LC_TIME, "fr_FR.ISO8859-1");
$datetime = strftime "%d %b %Y @ %H:%M:%S GMT", gmtime;
print "<p>FRENCH => ".$datetime."</p>";
exit 0;
But it doesn't seems to work because it just displays (in client
browser) the same french string in both cases (tested with ActivePerl
5.8.8 under Windows 2K FR) :
ENGLISH => 07 juil. 2006 @ 21:18:35 GMT
FRENCH => 07 juil. 2006 @ 21:18:35 GMT
When I would like to obtain something like :
ENGLISH => 07 Jul 2006 @ 21:18:35 GMT
FRENCH => 07 juil. 2006 @ 21:18:35 GMT
I've also tried with Perl 5.00503 under FreeBSD US, and, this time, it
gives english strings only (the only difference is the minus 'j' in
French string, but still with English word):
ENGLISH =>07 Jul 2006 @ 21:41:14 GMT
FRENCH => 07 jul 2006 @ 21:41:14 GMT
How to proceed to get this string in English or French (i.e. month here)
for sure (ie. depending of a language value extracted from STDIN about
web form POST in the real script) ?
I would like to produce a formatted GMT date & time string which will
depend of a user choice in a web form (in a CGI framework) about human
language he prefers (e.g. a french native may prefer to choose
'english'). I wish that it works under both Unix and Windows.
Here is a test script on which I'm trying to go through POSIX::setlocale
() as described in 'perldoc perllocale' about LC_TIME :
#!/usr/bin/perl -w
use strict;
use POSIX qw(locale_h strftime);
print "Content-type: text/html\n\n";
my $datetime;
# english
setlocale(LC_TIME, "en_US.ISO8859-1");
$datetime = strftime "%d %b %Y @ %H:%M:%S GMT", gmtime;
print "<p>ENGLISH =>".$datetime."</p>";
# french
setlocale(LC_TIME, "fr_FR.ISO8859-1");
$datetime = strftime "%d %b %Y @ %H:%M:%S GMT", gmtime;
print "<p>FRENCH => ".$datetime."</p>";
exit 0;
But it doesn't seems to work because it just displays (in client
browser) the same french string in both cases (tested with ActivePerl
5.8.8 under Windows 2K FR) :
ENGLISH => 07 juil. 2006 @ 21:18:35 GMT
FRENCH => 07 juil. 2006 @ 21:18:35 GMT
When I would like to obtain something like :
ENGLISH => 07 Jul 2006 @ 21:18:35 GMT
FRENCH => 07 juil. 2006 @ 21:18:35 GMT
I've also tried with Perl 5.00503 under FreeBSD US, and, this time, it
gives english strings only (the only difference is the minus 'j' in
French string, but still with English word):
ENGLISH =>07 Jul 2006 @ 21:41:14 GMT
FRENCH => 07 jul 2006 @ 21:41:14 GMT
How to proceed to get this string in English or French (i.e. month here)
for sure (ie. depending of a language value extracted from STDIN about
web form POST in the real script) ?