diff options
author | Graeme Geldenhuys <graeme@mastermaths.co.za> | 2011-07-13 08:29:10 +0200 |
---|---|---|
committer | Graeme Geldenhuys <graeme@mastermaths.co.za> | 2011-07-13 08:29:10 +0200 |
commit | 96e659e2f1c26e629ac6c4de61d4eb8c4c15c323 (patch) | |
tree | c11726daac8628483926f1e81d88dba2daee9f3f /src | |
parent | 0a465fccd946b2632336af4f27adc1fe9437176a (diff) | |
download | fpGUI-96e659e2f1c26e629ac6c4de61d4eb8c4c15c323.tar.xz |
calendar bugfix: we excluded minyear and maxyear from valid range
This meant that sometimes we couldn't select the desired date.
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/fpg_popupcalendar.pas | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/src/gui/fpg_popupcalendar.pas b/src/gui/fpg_popupcalendar.pas index 2b248723..34f73f3d 100644 --- a/src/gui/fpg_popupcalendar.pas +++ b/src/gui/fpg_popupcalendar.pas @@ -303,7 +303,7 @@ procedure TYearSelectForm.SetYear(const AValue: Word); begin // always one year less on either side (min and max) so we don't go over // any possible month limits. - Result := (AYear > MinYear) and (AYear < MaxYear); + Result := (AYear >= MinYear) and (AYear <= MaxYear); end; begin @@ -791,27 +791,26 @@ begin end; end; +{ If AValue is out of range (min or max), then set it to the limit value } procedure TfpgPopupCalendar.SetDateValue(const AValue: TDateTime); +var + lDate: TDateTime; begin if FDate = AValue then Exit; //==> + lDate := AValue; if (trunc(AValue) >= trunc(FMinDate)) then - {$IFDEF DEBUG} - writeln('Passed min test') - {$ENDIF} + // do nothing - test passed else - exit; - + lDate := FMinDate; + if (trunc(AValue) <= trunc(FMaxDate)) then - {$IFDEF DEBUG} - writeln('Passed max test') - {$ENDIF} + // do nothing - test passed else - exit; + lDate := FMaxDate; - {$IFDEF DEBUG} writeln('SetDateValue: ', FormatDateTime('yyyy-mm-dd', AValue)); {$ENDIF} - FDate := AValue; + FDate := lDate; UpdateCalendar; end; |