Lazarus

Programming => General => Topic started by: OC DelGuy on January 24, 2023, 10:07:52 pm

Title: Want to see something funny?
Post by: OC DelGuy on January 24, 2023, 10:07:52 pm
Yes, I say funny, though it's not funny at all!  It's really Bull$#!t!!

Just look at the line where the problem is!   WHAT??

I ask the system for the time, turn it into a string, and write it back as a TDate.
Simple, right?   No!!
I should see the 4.4!@#$%^&* e+004 Crap, Right?   Sys don't think so!!


How does the darn system give me the Wrong Format??

PS:  I included the Assembler window in case that means anything to Y'all.  To me it's just gibberish.
Title: Re: Want to see something funny?
Post by: KodeZwerg on January 24, 2023, 10:12:57 pm
How does the darn system give me the Wrong Format??
How about you show your used code instead of what the debugger show. That might be funnier than asking the glass sphere  8-)
Title: Re: Want to see something funny?
Post by: OC DelGuy on January 24, 2023, 10:14:39 pm
I don't get it Zwerg??  Isn't that the whole right side of the pic?
Title: Re: Want to see something funny?
Post by: OC DelGuy on January 24, 2023, 10:19:34 pm
Oh, there's no hidden code that does anything with the date formats.  It's all there.  All the other stuff isn't used.
Title: Re: Want to see something funny?
Post by: KodeZwerg on January 24, 2023, 10:22:24 pm
This is what your picture shows me. Only parts...
Title: Re: Want to see something funny?
Post by: OC DelGuy on January 24, 2023, 10:25:03 pm
This what you're looking for?:

Code: Pascal  [Select][+][-]
  1. program Consoleprog;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. uses
  6.   crt, sysutils
  7.   { you can add units after this };
  8.  
  9. Type
  10.   Tperson = Record
  11.     Fname, Lname    : String;
  12.     Age, Billet     : Integer;  //Billet is their room and bed.
  13.     Gender          : Char;
  14.     InDate, OutDate : TDate;    //Date they sign in and out.
  15.     InTime, OutTime : TTime;    //Time they sign in and out.
  16.   end;
  17.  
  18. var
  19.   GResident : array[1..300] of Tperson;
  20.   Recs, Recds : Integer;
  21.  
  22. procedure OutputFile;
  23.   var
  24.      Filename: Textfile;
  25.      Recds    : Integer;
  26.   Begin
  27.     assignfile(Filename, 'TextFile.txt');
  28.     try
  29.       rewrite(Filename);
  30.       for Recds:= 1 to Recs Do
  31.       Begin
  32.       WriteLn(Filename, GResident[recds].Fname);
  33.       WriteLn(Filename, GResident[recds].Lname);
  34.       WriteLn(Filename, GResident[recds].Age);
  35.       WriteLn(Filename, GResident[recds].Billet);
  36.       WriteLn(Filename, GResident[recds].Gender);
  37.       WriteLn(Filename, GResident[recds].InDate);
  38.       WriteLn(Filename, GResident[recds].InTime);
  39.       WriteLn(Filename, GResident[recds].OutDate);
  40.       WriteLn(Filename, GResident[recds].OutTime);
  41.       ReadLn(GResident[recds].Fname);
  42.       ReadLn(GResident[recds].Lname);
  43.       ReadLn(GResident[recds].Age);
  44.       ReadLn(GResident[recds].Billet);
  45.       ReadLn(GResident[recds].Gender);
  46.       ReadLn(GResident[recds].InDate);
  47.       ReadLn(GResident[recds].InTime);
  48.       ReadLn(GResident[recds].OutDate);
  49.       ReadLn(GResident[recds].OutTime);
  50.       end;
  51.       close(Filename);
  52.     except
  53.       WriteLn('File Error - Please Check Your File');
  54.     end;
  55.   end;
  56.  
  57. procedure InputFile;
  58.   Var
  59.     Filename: Textfile;
  60.     Recds    : Integer;
  61.  
  62.   Begin
  63.     assignfile(Filename, 'TextFile.txt');
  64.     Recds:=1;
  65.     try
  66.       reset(Filename);
  67.       while not eof(Filename) do
  68.         begin
  69.           ReadLn(Filename, GResident[recds].Fname);
  70.           ReadLn(Filename, GResident[recds].Lname);
  71.           ReadLn(Filename, GResident[recds].Age);
  72.           ReadLn(Filename, GResident[recds].Billet);
  73.           ReadLn(Filename, GResident[recds].Gender);
  74.           ReadLn(Filename, GResident[recds].InDate);
  75.           ReadLn(Filename, GResident[recds].InTime);
  76.           ReadLn(Filename, GResident[recds].OutDate);
  77.           ReadLn(Filename, GResident[recds].OutTime);
  78.           WriteLn(GResident[recds].Fname);
  79.           WriteLn(GResident[recds].Lname);
  80.           WriteLn(GResident[recds].Age);
  81.           WriteLn(GResident[recds].Billet);
  82.           WriteLn(GResident[recds].Gender);
  83.           WriteLn(GResident[recds].InDate);
  84.           WriteLn(GResident[recds].InTime);
  85.           WriteLn(GResident[recds].OutDate);
  86.           WriteLn(GResident[recds].OutTime);
  87.           Recds:=Recds+1;
  88.         end; {while}
  89.       Recs:=Recds;
  90.       close(Filename);
  91.     except
  92.       WriteLn('File Error - Please Check Your File');
  93.     end; {try}
  94.  
  95.  
  96.   end; {proc InputFile}
  97.  
  98. Procedure MakeNewfile;
  99.   Begin
  100.     GResident[1].Fname  :='Taylor';
  101.     GResident[1].Lname  :='Swift';
  102.     GResident[1].Age    :=33;
  103.     GResident[1].Billet :=1989;
  104.     GResident[1].Gender :='F';
  105.     GResident[1].InTime :=StrToDateTime('13:30:34'); // This is here to show that
  106.                                                      // there's no problem with time.
  107.     GResident[1].InDate :=Now;
  108.     WriteLn(now);              // This works.
  109.     WriteLn('This is Now:    ', datetostr(now)); // This does too.
  110.     WriteLn('This is Nothing');    // Nothing wrong here.
  111.     WriteLn('Now This is Now:', StrToDate(datetostr(now)));    // What??
  112.     WriteLn('This is also Nothing');      // This is here to show that the
  113.                                           // problem occured before this line.
  114.     GResident[1].InDate :=StrToDateTime('24-Jan-23');
  115.  
  116.     GResident[1].OutDate:=StrToDateTime('2/17/22');
  117.     GResident[1].OutTime:=StrToDateTime('15:50');
  118.  
  119.     GResident[2].Fname  :='Scarlett';
  120.     GResident[2].Lname  :='Johansson';
  121.     GResident[2].Age    :=38;
  122.     GResident[2].Billet :=1984;
  123.     GResident[2].Gender :='F';
  124.     GResident[2].InDate :=StrToDateTime('11/22/1984');
  125.     GResident[2].InTime :=StrToDateTime('13:30');
  126.     GResident[2].OutDate:=StrToDateTime('2/17/22');
  127.     GResident[2].OutTime:=StrToDateTime('15:50');
  128.  
  129.     GResident[3].Fname  :='Gal';
  130.     GResident[3].Lname  :='Gadot';
  131.     GResident[3].Age    :=37;
  132.     GResident[3].Billet :=1985;
  133.     GResident[3].Gender :='F';
  134.     GResident[3].InDate :=StrToDateTime('4/30/1985');
  135.     GResident[3].InTime :=StrToDateTime('13:30');
  136.     GResident[3].OutDate:=StrToDateTime('2/17/22');
  137.     GResident[3].OutTime:=StrToDateTime('15:50');
  138.  
  139.     {Recs :=3;
  140.     For recds:= 1 to Recs do
  141.     Begin
  142.       WriteLn(GResident[Recds].Fname,' ',GResident[Recds].Lname);
  143.       WriteLn(GResident[Recds].Age,'  ', GResident[Recds].Billet);
  144.       WriteLn(GResident[Recds].Gender);
  145.       WriteLn('This is InDate:  ',FormatDateTime('dd mmm yy',GResident[Recds].InDate));
  146.       WriteLn('This is InTime:  ',FormatDateTime('hh:nn',GResident[Recds].InTime));
  147.       WriteLn('This is OutDate: ',FormatDateTime('dd mmm yy',GResident[Recds].OutDate));
  148.       WriteLn('This is OutTime: ',FormatDateTime('hh:nn',GResident[Recds].OutTime));
  149.       WriteLn;
  150.     end;
  151.      }
  152.   end; {proc MakeNewfile}
  153.  
  154. begin
  155.  
  156.  
  157.  
  158.   MakeNewfile;
  159.   WriteLn('Press <Enter> To Quit');
  160.   ReadLn;
  161. end.
  162.  
  163.  
Title: Re: Want to see something funny?
Post by: Martin_fr on January 24, 2023, 10:25:47 pm
It is a bit inconvenient, that I cant copy and paste text from an image....

I guess you mean
Code: Pascal  [Select][+][-]
  1. writeln(now);
  2. writeln(DateToStr(now));
  3. writeln(StrToDate(DateToStr(now)));  // this does not work ???
  4.  

In what way does it not work? Does it give an error message, stop in the debugger?

---------
Btw on my PC it works, but I have diff locale settings from you it seems.

Code: Text  [Select][+][-]
  1.  4.4950931732893521E+004
  2. 24/01/2023
  3.  4.4950000000000000E+004

I don't know about the "-" as date separator. I would guess it is set somewhere in your OS locale settings.


Title: Re: Want to see something funny?
Post by: OC DelGuy on January 24, 2023, 10:28:07 pm
Zwerg, There's ALOT more to the pic than that!!  I took a screenshot of the entire screen!
Title: Re: Want to see something funny?
Post by: OC DelGuy on January 24, 2023, 10:31:24 pm
It is a bit inconvenient, that I cant copy and paste text from an image....

I guess you mean
Code: Pascal  [Select][+][-]
  1. writeln(now);
  2. writeln(DateToStr(now));
  3. writeln(StrToDate(DateToStr(now)));  // this does not work ???
  4.  

In what way does it not work? Does it give an error message, stop in the debugger?

---------
Btw on my PC it works, but I have diff locale settings from you it seems.

Code: Text  [Select][+][-]
  1.  4.4950931732893521E+004
  2. 24/01/2023
  3.  4.4950000000000000E+004

I don't know about the "-" as date separator. I would guess it is set somewhere in your OS locale settings.

Yes, The first pic is what I mean.
How can it work for you?
Title: Re: Want to see something funny?
Post by: KodeZwerg on January 24, 2023, 10:33:11 pm
I havent tried yet but the first thing I would do is to remove unit "crt" from "uses".
Since you use Windows, I suggest you also put this line somewhere at top of your code like
Code: Pascal  [Select][+][-]
  1. program Consoleprog;
  2. {$IFDEF MSWINDOWS}{$APPTYPE CONSOLE}{$ENDIF}

I investigate later what you do there  :D
Title: Re: Want to see something funny?
Post by: OC DelGuy on January 24, 2023, 10:41:09 pm
Really?  You can't see the screenshot in the OP?
I guess that doesn't work on my computer also!
I have a brand new MSI Katana GF76 11UD
I7 Intel processor
It's not like I'm on a piece of crap trying to play with the big boys!
But, even if the computer was a piece of crap, then the function should work on the same line of code, on the same computer!

I'm really not getting this!
Title: Re: Want to see something funny?
Post by: Martin_fr on January 24, 2023, 10:41:27 pm
Yes, The first pic is what I mean.
How can it work for you?

Different date separator. Your PC uses -  and mine use /

So I guess there is an issues parsing dates that have - as separator.
But I have not tested that.

Neither have I investigated, if that should work or not. (Though it seems that if it uses it for printing, one might expect it should).

Anyway for now: Good night.


---EDIT

It may also be because I get a 4 digit year, and you only get a 2 digit year
Title: Re: Want to see something funny?
Post by: OC DelGuy on January 24, 2023, 10:47:11 pm
I havent tried yet but the first thing I would do is to remove unit "crt" from "uses".
Since you use Windows, I suggest you also put this line somewhere at top of your code like
Code: Pascal  [Select][+][-]
  1. program Consoleprog;
  2. {$IFDEF MSWINDOWS}{$APPTYPE CONSOLE}{$ENDIF}

I investigate later what you do there  :D

Thanks Zwerg.
PS: I'm pissed at how something so simple doesn't work in my computer and it works on someone else's computer. Mind Blown!
Title: Re: Want to see something funny?
Post by: KodeZwerg on January 24, 2023, 10:58:52 pm
Test this please.
Code: Pascal  [Select][+][-]
  1. program Project1;
  2. {$IFDEF MSWINDOWS}{$APPTYPE CONSOLE}{$ENDIF}
  3.  
  4. uses
  5.   SysUtils;
  6.  
  7. var
  8.   dat: TDate;
  9.   LYear, LMonth, LDay: Word;
  10. begin
  11.   dat := Now; // this is current date and time
  12.   DecodeDate(dat, LYear, LMonth, LDay); // split it up
  13.   dat := EncodeDate(LYear, LMonth, LDay); // put it together again
  14.   writeln(dat); // now really just the date value is printed
  15.   writeln(DateToStr(dat)); // show it however your system is configured to show it
  16.   writeln(StrToDate(DateToStr(dat))); // compare that to the writeln(dat);, it must be same now
  17.   ReadLn; // let console open until you press return
  18. end.
Title: Re: Want to see something funny?
Post by: wp on January 24, 2023, 11:04:46 pm
OC DelGuy, please stop shouting at us by using these huge letters and the red color.

Your post is very confusing and it is not clear what the problem is. Why don't you simply write what you were expecting and what you got?

My guess is that you wonder why the line "WriteLn(StrToDate(DateToStr(Now))" does not print a date but a number.

First of all: dates and floating point numbers are the same in Pascal. The date is the number of days past Dec 30 1899. The conversion function DateToStr(some_date) converts this number to a string formatted like a date (depending on details in your FormatSettings record). And StrToDate does the opposite: it takes a date-formatted string and converts it back to the count of days since Dec 30 1899.

The instruction "WriteLn(StrToDate(DateToStr(Now))" consists of four parts which are executed from the inside to the outside:
/1/ Now: determines the current date (and time) - always rember: as number of days sincd Dec 30 1899. This, for today, the value 44951. (The fractional part, BTW, represents the time between 0:00 and 24:00 - I am ignoring it here).
/2/ DateToStr(...): converts that day count to a nicely formatted date string, in your case probably '01/24/2023'
/3/ StrToDate(...): takes that date string and converts it back to date - but remember: date is just a number! So, the result is 44951
/4/ WriteLn(...): Prints this number. OK, since it is a floating point value the standard WriteLn() prints it in exponential notation. Nothing mystic here!

The output of this sequence is absolutely correct.
Title: Re: Want to see something funny?
Post by: tetrastes on January 24, 2023, 11:15:09 pm

So I guess there is an issues parsing dates that have - as separator.

It may also be because I get a 4 digit year, and you only get a 2 digit year

No, at least at linux with fpc 3.2.2:
Code: Bash  [Select][+][-]
  1.  4.4951124173946759E+004
  2. This is Now:    25-1-23
  3. This is Nothing
  4. Now This is Now: 4.4951000000000000E+004

But this is strange date format. For my locale it should be 25.01.2023.

EDIT: I have to add uses clocale at unixes to get localized format.
Title: Re: Want to see something funny?
Post by: tetrastes on January 25, 2023, 09:51:40 am
How does the darn system give me the Wrong Format??

I can confirm this (windows 10, fpc 3.2.2):
Code: Bash  [Select][+][-]
  1.  4.4951563328148150E+004                                                                                              
  2. This is Now:    2023-янв-25                                                                                            
  3. This is Nothing                                                                                                        
  4. An unhandled exception occurred at $0000000100011C9F:                                                                  
  5. EConvertError: "2023-янв-25" is not a valid date format                                                                  
  6. $0000000100011C9F                                                                                                      
  7. $000000010000186F                                                                                                      
  8. $00000001000018D6                                                                                                      
  9. $000000010000D140                                                                                                      
  10. $00000001000016F0                                                                                                      
  11. $00007FF94BB47614                                            
  12. $00007FF94C3626A1
  13. Now This is Now:

It seems that StrToDate doesn't understand short date formats with months as strings, not numbers.

This works:
Code: Bash  [Select][+][-]
  1.  4.4951574145185186E+004
  2. This is Now:    2023-01-25
  3. This is Nothing
  4. Now This is Now: 4.4951000000000000E+004
Title: Re: Want to see something funny?
Post by: Martin_fr on January 25, 2023, 10:15:07 am
It seems that StrToDate doesn't understand short date formats with months as strings, not numbers.

https://gitlab.com/freepascal.org/fpc/source/-/issues/39757
Title: Re: Want to see something funny?
Post by: OC DelGuy on January 26, 2023, 08:51:42 am
OC DelGuy, please stop shouting at us by using these huge letters and the red color.

Wp, I thought AllCaps meant shouting.  I was just trying to soften the complaint.  In my own head, I was trying to sound like Kevin Hart in his Satellite Radio commercials.  Like when they come up to him and say "You don't have to listen to satellite radio in your car."  And they give him a phone and he says "What?"  Then they tell him he can hear it on his tablet.  So he throws the phone away and says: "What?"  Then a laptop and he tosses the tablet and says: "What?"  Amazon Alexa and he tosses the laptop and says: "What?"  In my mind, I sounded like him!  :D :D

The "No!" was actually like a sing-song sarcastic no.  I considered typing "Noooooooooooooo!!!", but that's like when you've fallen off a cliff.  You yell out "Noooooooooooo!!" as you're falling.

The "Sys don't think so.", was a play on Damon Wayans' (is the name spelled right?) "Homie, the clown".  His catch phrase was "Homie don't play that!"

So, don't sweat it, Wp.  I was just being sarcastic!  Trying to be funny.  Just keeping my head from overheating and throwing my computer out the window.  Wouldn't even go far...  My window is inch-thick plexi-glass.  It'd just bounce back and bonk me in the head! :o  :D :D

Why don't you simply write what you were expecting and what you got?

Because I thought you'd see the same thing I did.

I ask the computer for the time (now), tell it to convert it into a string (DateToString), then tell it to convert it back into a datecode (StrToDate), which I know is a float (hence the 4.4!@#$%^&*E+004), and display it on the console (WriteLn).

And what I saw (the output) was basically like talking to my wife!  I ask her what she wants from the supermarket (now).  She writes it down on a piece of paper (DateToStr).  I then tell her to look at the paper and ask: "What's that say?".  And she turns around and tells me: "I can't read that.  It's not formatted right! (this is the (StrToDate)) part.  And then I'm like: "You wrote the darned note!!!  And you're telling me it's in the wrong format???  You wrote it!!"    >:(  Oh Wifey, Wifey.  If you could only hear what you say!  :D ;D


That's the "funny" part that's actually Bull$#!t.  ::)  ::)

My guess is that you wonder why the line "WriteLn(StrToDate(DateToStr(Now))" does not print a date but a number.

No sir, Wp.  I wonder why I got the error that the format was wrong.  That line was where I got the runtime error.  That line didn't print on the console.  You might have confused the output that Martin_fr showed.  It seems to have worked on his computer, but not mine.

First of all: dates and floating point numbers are the same in Pascal. The date is the number of days past Dec 30 1899. The conversion function DateToStr(some_date) converts this number to a string formatted like a date (depending on details in your FormatSettings record). And StrToDate does the opposite: it takes a date-formatted string and converts it back to the count of days since Dec 30 1899.

The instruction "WriteLn(StrToDate(DateToStr(Now))" consists of four parts which are executed from the inside to the outside:
/1/ Now: determines the current date (and time) - always rember: as number of days sincd Dec 30 1899. This, for today, the value 44951. (The fractional part, BTW, represents the time between 0:00 and 24:00 - I am ignoring it here).
/2/ DateToStr(...): converts that day count to a nicely formatted date string, in your case probably '01/24/2023'
/3/ StrToDate(...): takes that date string and converts it back to date - but remember: date is just a number! So, the result is 44951
/4/ WriteLn(...): Prints this number. OK, since it is a floating point value the standard WriteLn() prints it in exponential notation. Nothing mystic here!

Yes, I know I ask a lot of questions here, But this I know.

The output of this sequence is absolutely correct.

Nope.  It's not correct.  It's also not incorrect.  It's nothing, since it didn't even execute the line.

Your post is very confusing and it is not clear what the problem is.

And Here I will concede.  You are correct.  I included one thing that was irrelevant (the assembler dialog) when I should have taken the screenshot with the actual error message.  My mistake.  Had I included the error message, I believe it might not have been confusing.
Title: Re: Want to see something funny?
Post by: OC DelGuy on January 26, 2023, 08:57:11 am
I havent tried yet but the first thing I would do is to remove unit "crt" from "uses".
Since you use Windows, I suggest you also put this line somewhere at top of your code like
Code: Pascal  [Select][+][-]
  1. program Consoleprog;
  2. {$IFDEF MSWINDOWS}{$APPTYPE CONSOLE}{$ENDIF}

I investigate later what you do there  :D

Cool.  I'm answering this post on my Chromebook, so when i get back to my MSI Laptop  I'll type that in.  Probably like around 0900 California time.
Title: Re: Want to see something funny?
Post by: OC DelGuy on January 26, 2023, 09:19:44 am
Yes, The first pic is what I mean.
How can it work for you?

Different date separator. Your PC uses -  and mine use /

So I guess there is an issues parsing dates that have - as separator.
But I have not tested that.

Neither have I investigated, if that should work or not. (Though it seems that if it uses it for printing, one might expect it should).

Anyway for now: Good night.


---EDIT

It may also be because I get a 4 digit year, and you only get a 2 digit year

I don't get it Martin.  It's not like I'm asking two different computers.  It's the same machine!  It's like the two functions are looking (or not looking) at different places for the format.  It's like DateToStr is asking the system: "What's the format?" and converts it to that format, but the StrToDate function says:  "I don't care about the system format, I got my own format that I read and that's not it!  Kind of like a stubborn child.  Or maybe the DateToStr is being stubborn:  "I'm not asking the system what the format is.  I'm converting it my way".  I don't know.  I kind of got ticked off at the absurdity of this problem that I disappeared for a little while.  I'm over it now, so I'll start using all of y'allses suggestions and, hopefully, get to the bottom of this fiasco!
Title: Re: Want to see something funny?
Post by: OC DelGuy on January 26, 2023, 09:22:00 am
Test this please.
Code: Pascal  [Select][+][-]
  1. program Project1;
  2. {$IFDEF MSWINDOWS}{$APPTYPE CONSOLE}{$ENDIF}
  3.  
  4. uses
  5.   SysUtils;
  6.  
  7. var
  8.   dat: TDate;
  9.   LYear, LMonth, LDay: Word;
  10. begin
  11.   dat := Now; // this is current date and time
  12.   DecodeDate(dat, LYear, LMonth, LDay); // split it up
  13.   dat := EncodeDate(LYear, LMonth, LDay); // put it together again
  14.   writeln(dat); // now really just the date value is printed
  15.   writeln(DateToStr(dat)); // show it however your system is configured to show it
  16.   writeln(StrToDate(DateToStr(dat))); // compare that to the writeln(dat);, it must be same now
  17.   ReadLn; // let console open until you press return
  18. end.

I will test this at about 0900 Thursday, California time.
Title: Re: Want to see something funny?
Post by: OC DelGuy on January 26, 2023, 09:36:32 am
It seems that StrToDate doesn't understand short date formats with months as strings, not numbers.

I will stipulate that: "StrToDate doesn't understand short date formats with months as strings, not numbers."   But then my question is: "Why does DateToStr convert it to that format?  On the same machine?

I mean, do you understand what I'm saying?  Or am I so stupid that everyone is wondering what the heck I'm talking about?

 >:( >:(  Darn system!!  >:( >:(
Title: Re: Want to see something funny?
Post by: wp on January 26, 2023, 09:49:13 am
It seems that StrToDate doesn't understand short date formats with months as strings, not numbers.

I will stipulate that: "StrToDate doesn't understand short date formats with months as strings, not numbers."   But then my question is: "Why does DateToStr convert it to that format?  On the same machine?
My words in https://gitlab.com/freepascal.org/fpc/source/-/issues/39757... Reopen this bug report, and tell them that you do not understand their decision to not fix it... (I even had submitted a patch for it)
Title: Re: Want to see something funny?
Post by: OC DelGuy on January 26, 2023, 09:52:35 am
https://gitlab.com/freepascal.org/fpc/source/-/issues/39757

Code: Text  [Select][+][-]
  1.  
  2. Motivated by freepascal.org/lazarus/lazarus#39779 (closed) I thought about the issue that StrToDate and StrToDateTime allow only numeric values in their date/time parts. The format expected is taken from the ShortDateFormat of the FormatSettings record where the month is assumed to be in the one- or two-digit representation.
  3.  
  4. But why can there be only numbers in the month part? In the FormatSettings.ShortDateFormat the month can be specified as 'mmm' or even 'mmmm' - and this inserts the short or long month names in the strings created by DateToStr. However, these strings cannot be converted back to dates by calling the inverse StrToDate function? I know that Delphi does the same, it accepts only numeric month strings. But I don't see a real reason for this asymmetry.
  5.  

This is exactly what's happening to me!   He says that DateToStr outputs lettered months.  But that StrToDate won't convert it back!  This sounds like a Pascal issue and not a System issue.  They offer a patch that's supposed to solve the problem, but at the bottom of the page they say:
Code: Text  [Select][+][-]
  1.  
  2. Resolution:  Wont fix.
  3.  
  4.  
Title: Re: Want to see something funny?
Post by: OC DelGuy on January 26, 2023, 09:55:47 am
It seems that StrToDate doesn't understand short date formats with months as strings, not numbers.

I will stipulate that: "StrToDate doesn't understand short date formats with months as strings, not numbers."   But then my question is: "Why does DateToStr convert it to that format?  On the same machine?
My words in https://gitlab.com/freepascal.org/fpc/source/-/issues/39757... Reopen this bug report, and tell them that you do not understand their decision to not fix it... (I even had submitted a patch for it)

Wait, They decided not to fix it.  Or...   The solution (patch) didn't fix it?
Title: Re: Want to see something funny?
Post by: OC DelGuy on January 26, 2023, 10:02:38 am
Wp, Is this you?

Code: Text  [Select][+][-]
  1. I am enclosing a patch which extends the StrToDate function such that also the month text representations
  2. are accepted (both short and long forms). It requires only a few changes, and don't think that it will
  3. cause a noticeable speed drop. Since StrToDateTime internally calls StrToDate, it will be extended
  4. automatically.
  5.  
Title: Re: Want to see something funny?
Post by: wp on January 26, 2023, 10:03:40 am
They decided not to fix it, because there is another function, ScanDateTime, which does not have the issue.

Wp, Is this you?
Yes.
Title: Re: Want to see something funny?
Post by: OC DelGuy on January 26, 2023, 10:16:46 pm
They decided not to fix it, because there is another function, ScanDateTime, which does not have the issue.

Well, Golly Gee Willikers!  Why the heck am I not using ScanDateTime??!!

PS: Not shouting, just emphasizing...
Title: Re: Want to see something funny?
Post by: OC DelGuy on January 26, 2023, 10:33:29 pm
Test this please.

I did.  I got a runtime error on the same line.  See my screenshot.  It should be clearer as I shot the actual error message too, this time.

I'm going to try the ScanDateTime function...
Title: Re: Want to see something funny?
Post by: Curt Carpenter on January 27, 2023, 05:55:38 pm
In my experience OC DelGuy, when working with open source, community supported software, you sometimes just have to accept the state of the code, find your own work-arounds and make your own compromises and adjustments.  It can be frustrating but there are three ways, I think, to cope with that frustration: 1) anti up for a commercial program supported by a full-time staff (see "embarcadero" -- expensive, although even that solution can be frustrating!) 2) stay the course until your experience and self-education equip you to make your own constructive recommendations to "fix" problems (although remember that fixing your problem may create new problems for others -- something that community maintainers and developers guard vigorously against so we don't have to) or 3) scroll up to the top of the page here and click the applicable "Donate" button (you'll feel better about ranting about what you see as shortcomings :).

Not trying to be sanctimonious here.  Adobe recently "fixed" a user's problem in Photoshop, only to discover that the fix "broke" a feature of their software for a few thousand other users who were not real happy...  It's an effect that most of us don't worry much about as we work on our own problems.   
TinyPortal © 2005-2018