View Issue Details

IDProjectCategoryView StatusLast Update
0027454LazarusPackagespublic2015-02-24 14:35
ReporterMaarten van der Waal Assigned ToBart Broersma  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Platform-OSWindows 
Product Version1.2.6 
Target Version1.4 
Summary0027454: TDateEdit can't read own date when formatted to give eg 02-feb-2014
DescriptionHaving on my system the shortdateformat as dd-MMM-yyyy, the first click on the icon right-of the TDateEdit shows the (correct) date as (eg.) 12-feb-2015. Then clicking again on the icon brings an 'EConvertError' with message "12-feb-2015" is not a valid date format.
Steps To ReproduceMake the system shortdateformat dd-MMM-yyyy (dd-MMM-jjjj for Dutch)
Open a new project, add a TDateEdit to the form and run. Click to get a date and click again to get the error. Here, the calender should be shown again.
Additional InformationProbably the error is caused by:
function StrToDate(const S: AnsiString): TDateTime;
begin
    result := StrToDate(@S[1],Length(s),DefaultFormatSettings.ShortDateFormat,#0);
end;
which is found in dati.inc,
Where the DefaultFormatSettings (as defined in sysinth.inc) has a fixed definition.
TagsNo tags attached.
Fixed in Revisionr47782
LazTarget-
WidgetsetWin32/Win64
Attached Files

Activities

Bart Broersma

2015-02-12 23:20

developer   ~0081006

StrToDate cannot handle stings with literal month names.
AFAIK this is compatible with Delphi.

When you click the button a call to GetDate is made, which calls StrToDate with '12-feb-2015' and this fails.
As a result Getdate now returns either ToDay of 0 (dpending on the setting of DefaultToday.

The net result is that you choose a date and when you click again the date is reset to Today when the calendar pops up.
At least this is how it works for me with trunk, using the same setting for shortdateformat as you described.

Can you please test with trunk?

Maarten van der Waal

2015-02-12 23:49

reporter   ~0081008

Where can I get this trunc? (Sorry, can't find this)

Bart Broersma

2015-02-13 09:09

developer   ~0081013

Last edited: 2015-02-13 09:10

View 2 revisions

> Where can I get this trunc?
(It's trunk with a k ;-) )

http://wiki.lazarus.freepascal.org/Getting_Lazarus#Getting_Lazarus_SVN_development_version

If you cannot do that then I would ask you to create a backtrace for me and attach it to this report.
See: http://wiki.lazarus.freepascal.org/Creating_a_Backtrace_with_GDB

Q1: please upload an example application (sources only) demonstrating the issue.
While your description is easy to follow, the actual bug may depend on various properties of TDateEdit or other project options.

Q2: do you build for win32 or win64?

Q3: does the eeror occur only when running inside Lazarus or also when running the executable without Lazarus (double clicking on the executable in Explorer)?

Maarten van der Waal

2015-02-13 19:43

reporter  

TDateEdit.zip (2,715 bytes)

Maarten van der Waal

2015-02-13 19:53

reporter   ~0081035

Bart, thanks for your answer and questions.

Q1: the source is uploaded now.

Q2: I installed Lazarus for win32/win64 and use it as is. No settings have been changed by me. As a matter of fact I searched and did not find the target OS to compile to... (Only for build Lazarus)

Q3: The error occurs in debug mode, so started inside Lazarus. Today I tested the exe, which functions as you described in your first post (0081006)

Bart Broersma

2015-02-13 20:18

developer   ~0081037

The debugger catches the exception and then you get the error dialog.
Outside the IDE it will run just fine.

This leavses the fact that GetDate cannot handle '12-feb-2015' and opens the calendar on the current date.
May not be that easy to fix.

Bart Broersma

2015-02-14 16:07

developer   ~0081068

Please test (outside IDE) and close if OK.

Maarten van der Waal

2015-02-23 22:57

reporter   ~0081378

Tested the improvement, and OK!
It works in debug mode and outside IDE!
Choosen date is correctly shown as the startdate when clicked (again)

Great and fast work. Thanks Bart!

Issue History

Date Modified Username Field Change
2015-02-12 17:51 Maarten van der Waal New Issue
2015-02-12 23:20 Bart Broersma Note Added: 0081006
2015-02-12 23:20 Bart Broersma LazTarget => -
2015-02-12 23:20 Bart Broersma Status new => feedback
2015-02-12 23:49 Maarten van der Waal Note Added: 0081008
2015-02-12 23:49 Maarten van der Waal Status feedback => new
2015-02-13 09:09 Bart Broersma Note Added: 0081013
2015-02-13 09:10 Bart Broersma Assigned To => Bart Broersma
2015-02-13 09:10 Bart Broersma Status new => feedback
2015-02-13 09:10 Bart Broersma Note Edited: 0081013 View Revisions
2015-02-13 19:43 Maarten van der Waal File Added: TDateEdit.zip
2015-02-13 19:53 Maarten van der Waal Note Added: 0081035
2015-02-13 19:53 Maarten van der Waal Status feedback => assigned
2015-02-13 20:14 Bart Broersma Status assigned => resolved
2015-02-13 20:14 Bart Broersma Resolution open => fixed
2015-02-13 20:15 Bart Broersma Resolution fixed => no change required
2015-02-13 20:16 Bart Broersma Status resolved => assigned
2015-02-13 20:16 Bart Broersma Resolution no change required => reopened
2015-02-13 20:18 Bart Broersma Note Added: 0081037
2015-02-14 16:07 Bart Broersma Fixed in Revision => r47782
2015-02-14 16:07 Bart Broersma Note Added: 0081068
2015-02-14 16:07 Bart Broersma Status assigned => resolved
2015-02-14 16:07 Bart Broersma Resolution reopened => fixed
2015-02-14 16:07 Bart Broersma Target Version => 1.4
2015-02-23 22:57 Maarten van der Waal Note Added: 0081378
2015-02-24 14:35 Bart Broersma Status resolved => closed