TsDateEdit.OnChange may not have a correct date

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #37012
    HeDiBo
    Participant

    Implemented an OnChange event on a TsDateEdit, in order to set a CalendarDate for a TsMonthCalendar.

    It is possible to exit the TsDateEdit with the TsDateEdit.Date property still set to 0.

    In this project: [attachment=7743:acCalendarMouseUp.zip]

    try to delete the 0 from the 06 month. You will see the TsMonthCalendar jump to 30 december 1899, because the TsDateEdit.Date is still at 0, although the date is valid. Even when you leave the TsDateEdit control, the date remains 0.

    I think this is caused by some typical coding in the GetDate function:

    Code:
    function TsCustomDateEdit.GetDate: TDateTime;
    begin
    if (Pos(s_Space, Text) > 0) or (NullDate = FIntDate) then
    if DefaultToday and not (csDesigning in ComponentState) then
    Result := SysUtils.Date
    else
    Result := NullDate
    else
    Result := FIntDate;
    end;

    The test whether a space is in the date is not correct, a space in the date text may still yield a valid date.

    #55058
    Support
    Keymaster

    Thank you for the demo, I will fix it soon.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.