in reply to Re: Re: win32 date format
in thread win32 date format

Nothing to do with Perl. You need to set your locale

Start|Settings|Control Panel|Regional Options|Gerneral or Date

Just set the locale to English(United Kingdom) and then click on the Set as Default button and do the same. You need to do both because Microsoft don't believe in 1st normal databases. It is the same when you install windows - you have to set the locale 3 separate times to UK format - gotta love old M$. Alternatively click on the Date tab rather than General tab and set the desired format to whatever you want - yes you will need to set the long and short date formats or you will get some weird stuff happening.

cheers

tachyon

s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

Replies are listed 'Best First'.
Re: Re: Re: Re: win32 date format
by Anonymous Monk on Feb 08, 2003 at 14:02 UTC
    Hi Tachyon Thank you for your answer. I tried to set these regional settings via ctrl panel. Unfortunately despite several reboots the date format is still the same MM/DD/YY. It seems like the ctrl panel has stopped working. At one point it said the entries were corrupt and i would have to reinstall windows. Could localtime or gmtime functions override operating system date formats and keyboard layout or is it more likely caused by messing with excel and win32::ole::nls

      As noted M$ OS software uses very sub optimal databases ie they store the same info in several places and the utilities provided to update this info often perform badly ie don't do all the updates required leaving you with a corrupt OS.

      Locale info can come from either Win.ini or the locale database and you can set the locale DB for no over-ride (sounds like your problem). Read the win32::ole::nls docs, think about what you did to break it and try to undo that.

      You can often salvage the system and retain your tweaks by copying user.dat and system.dat (the 2 files associated with the registry (why 2 files - well might you ask!)) and your desktops (in Desktop or Documents and settings\%user%\Desktop depending on OS), reinstalling the OS and then replacing the files.

      If what you were originally trying to do was get Perl to give you particular format for dates use POSIX::strftime or (s)prinf() and the return from localtime() or gmtime() ie:

      # This gives you the web standard date format # Sat, 08 Feb 2003 15:13:54 GMT use POSIX; my $date = POSIX::strftime("%a, %d %b %Y %H:%M:%S GMT", gmtime(time()) + ); print $date, "\n"; # this will give you dd/mm/yyyy hh:mm:ss for GMT # note $mday is actual day, $mon 0 = jan, 1=feb, 11=dec # year is currently 103 ie you need to add 1900 for yyyy # or subtract 100 and pack with a left zero for yy my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime(time +); printf "%02d/%02d/%04d %02d:%02d:%02d\n", $mday, $mon+1, $year+1900, $ +hour, $min, $sec; # or for localtime my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(t +ime); printf "%02d/%02d/%04d %02d:%02d:%02d\n", $mday, $mon+1, $year+1900, $ +hour, $min, $sec; # this will give you dd/mm/yy for GMT my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime(time +); printf "%02d/%02d/%02d\n", $mday, $mon+1, $year-100; # etc # perl will preformat datestrings if you call localtime() or gmtime() +in # scalar as opposed to arrray context. you can see this here # time() is the default value as you can also see my @bits = localtime; my $str = localtime; print " array context: @bits scalar context: $str"; __DATA__ Sat, 08 Feb 2003 15:28:14 GMT 08/02/2003 15:28:14 08/02/2003 15:28:14 08/02/03 array context: 14 28 15 8 1 103 6 38 0 scalar context: Sat Feb 8 15:28:14 2003

      cheers

      tachyon

      s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print