Opened 17 years ago
Closed 17 years ago
#554 closed defect (fixed)
TextToDate function does not convert properly
Reported by: | Alfredo Torre | Owned by: | Víctor de Buen Remiro |
---|---|---|---|
Priority: | highest | Milestone: | |
Component: | Text | Version: | 1.1.6 |
Severity: | major | Keywords: | |
Cc: | imendez, César Pérez Álvarez, msalvatori |
Description
Please, try to run this TOL code:
Text MyFormat = "%n%Y";
Text Txt01 = FormatDate(y2007m04d01, MyFormat);
Date Dte01 = TextToDate("Abr2007", MyFormat);
Date Dte02 = TextToDate(FormatDate(y2007m04d01, MyFormat), MyFormat);
Dte01 and Dte02 are both TheBegin date.
Change History (2)
comment:1 Changed 17 years ago by
Owner: | changed from danirus to Víctor de Buen Remiro |
---|
comment:2 Changed 17 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
Problem has been fixed in CVS (1.1.6 and 1.1.7).
If you try this non compact format, it's to say, a blanck separated format, you will get you are expecting:
Text MyFormat = "%n %Y";
Text Txt01 = FormatDate(y2007m04d01, MyFormat);
Date Dte01 = TextToDate("Abr 2007", MyFormat);
Date Dte02 = TextToDate(FormatDate(y2007m04d01, MyFormat), MyFormat);
Problem was that the date parser uses sscanf to be so fast as possible and this function don't stop reading after a blanck character is found or a specific number of characters has been readed. This limit was fixed to %64s to be valid both short (%n) and long (%N) month formats, but short month has fixed length 3 and so is parseable with sscanf using %3s. Then it has been easy to touch the internal code to make inversible the compact format. However, long months are of variable length and will not be inversible using a compact format.
I will see how difficult is to solve it
Thanks for reporting