mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-07-20 21:06:00 +02:00
Don't raise an exception when date in the edit is out of bounds. Issue #39825.
This commit is contained in:
parent
7ea1d8851c
commit
455dc87b83
@ -1587,6 +1587,9 @@ procedure TDateEdit.ButtonClick;//or onClick
|
|||||||
var
|
var
|
||||||
PopupOrigin: TPoint;
|
PopupOrigin: TPoint;
|
||||||
ADate: TDateTime;
|
ADate: TDateTime;
|
||||||
|
{$IFDEF WINDOWS}
|
||||||
|
CalendarMinDate,CalendarMaxDate: integer;
|
||||||
|
{$ENDIF}
|
||||||
begin
|
begin
|
||||||
inherited ButtonClick;
|
inherited ButtonClick;
|
||||||
|
|
||||||
@ -1594,6 +1597,24 @@ begin
|
|||||||
ADate := GetDate;
|
ADate := GetDate;
|
||||||
if ADate = NullDate then
|
if ADate = NullDate then
|
||||||
ADate := SysUtils.Date;
|
ADate := SysUtils.Date;
|
||||||
|
{$ifdef WINDOWS} // temporarily copied form TCustomCalendar, needs a proper fix
|
||||||
|
CalendarMinDate:=-53787;// 14 sep 1752, start of Gregorian calendar in England
|
||||||
|
CalendarMaxDate:=trunc(MaxDateTime);
|
||||||
|
if (ADate < CalendarMindate) then
|
||||||
|
begin
|
||||||
|
if FDefaultToday then
|
||||||
|
ADate := SysUtils.Date
|
||||||
|
else
|
||||||
|
ADate := CalendarMinDate
|
||||||
|
end
|
||||||
|
else if (ADate > CalendarMaxDate) then
|
||||||
|
begin
|
||||||
|
if FDefaultToday then
|
||||||
|
ADate := SysUtils.Date
|
||||||
|
else
|
||||||
|
ADate := CalendarMaxDate;
|
||||||
|
end;
|
||||||
|
{$endif}
|
||||||
ShowCalendarPopup(PopupOrigin, ADate, CalendarDisplaySettings,
|
ShowCalendarPopup(PopupOrigin, ADate, CalendarDisplaySettings,
|
||||||
@CalendarPopupReturnDate, @CalendarPopupShowHide, self);
|
@CalendarPopupReturnDate, @CalendarPopupShowHide, self);
|
||||||
//Do this after the dialog, otherwise it just looks silly
|
//Do this after the dialog, otherwise it just looks silly
|
||||||
|
Loading…
Reference in New Issue
Block a user