in reply to Re: Local Date Format
in thread Local Date Format

Thanks for the help. I'm still a little confused on how I can dertermine the date format according to the OS settings. (is it mm/dd/yyyy or yyyy/mm/dd, etc.)

Replies are listed 'Best First'.
Re^3: Local Date Format
by Fletch (Bishop) on Feb 22, 2005 at 16:41 UTC

    The POSIX::strftime routine has several format specifiers (%B, %c, et al) which will behave correctly for whatever the current locale is. You don't need to worry about the components, just use one of these (%x for your particular question) and let it worry about it. See your platform's man strftime for more details on the specifiers.

Re^3: Local Date Format
by gellyfish (Monsignor) on Feb 22, 2005 at 16:38 UTC

    This really depends on the OS - on this here system I would probably start by grovelling around in the output from locale LC_TIME however this is not going to be portable and as you don't say what OS you are on you are unlikely to get a more useful response.

    /J\

Re^3: Local Date Format
by gaal (Parson) on Feb 22, 2005 at 17:06 UTC
    How portable do you need this to be? On unix, this oughta work, but is dirty:

    my $date_fmt = grep s/^date_fmt="(.*)"$/$1/, `locale -k LC_TIME`;

    You could do this in c (one hopes) on any POSIX system — possibly inlining it in Perl with Inline::C — with the setlocale() function; make the second paramater NULL to query the current locale.

      Thanks gaal, this is a good start and I'll definately be exploring it!