Local short date settings causing me a problem...

  • 17 years ago

    I have modified a Perl calendar found on PSC  so that the user can add events to it. The inputs are written to a file in this fmt:

    Quote:
    08/16/2003|Johnny's birthday!!!
    But if the users Regional Settings are different, short date = mm/dd/yy then I will get a mix of 2 and 4 digit yearsQuote:
    12/08/2003|Don's Birthday!!!!
    12/16/03|Char B-Day
    03/18/2003|Brenda B-Day
    03/19/03|Calib B-Day
    This is where my code needs help... If the person calling the web page has a different setting they won't see the appts written in the opposite setting.  How can I get around the fact that everyones PC has different short date settings???


    Code:
    sub CheckForAppts {    


               my $strAppts = '';
           my $Mo = 0;
           my $Da = 0;
           my $Ye = 0;
           my @Apptsarray = ();
           my $Apptdate = 0;
           my $Description = '';


    open and read from file


       open(DAT,"Appts.cgi") || die("Cannot Open File");
           @Apptsarray = <DAT>;
       close(DAT);


    assigned the contents to an array.


    close the file.



    foreach $Apptdate (@Apptsarray)
    {
    chomp ($Apptdate);
    ($Apptdate,$Description)=split (/\|/,$Apptdate);
    ($Mo,$Da,$Ye)=split (/\//,$Apptdate);
        if ($mon == ($Mo - 1) && $day == $Da && $year == $Ye) {


                   $strAppts .= "\ $Description <br>\n";
                   }
           }    


           return $strAppts;
       }


    From calendar globals:   $mon, $day, $year = localtime(time);


    I am not very exerienced in Perl.  I took me awhile to write this sub.


    Thanks for your help

  • 17 years ago

    I found a way to fix it!!!


    I modified the JavaScript popup calendar that fills the textbox to always output the format I want no matter what the user's Local format is....

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“A computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are, in short, a perfect match” - Bill Bryson