Fixes for TZAbstractTimestampFormatSettings

Code patches written by our users to solve certain "problems" that were not solved, yet.

Moderators: gto, cipto_kh, EgonHugeist, mdaems

Post Reply
MJFShark
Expert Boarder
Expert Boarder
Posts: 218
Joined: 04.06.2020, 13:59

Fixes for TZAbstractTimestampFormatSettings

Post by MJFShark »

The SetDateFormat and SetTimeFormat procedures use FFormat instead of either FDateFormat or FTimeFormat. Here are the fixed versions:

Code: Select all

procedure TZAbstractTimestampFormatSettings.SetDateFormat(const Value: String);
begin
  if ((FDateFormat = nil) and (Value <> '')) or ((FDateFormat <> nil) and (Value = '')) or ((FDateFormat <> nil) and (FDateFormat^ <> Value)) then begin
    if Value <> '' then begin
      FDateFormat := @FFormatSettings.ShortDateFormat;
      FDateFormat^ := Value;
    end else FDateFormat := nil;
    if Assigned(FOnFormatChanged) then
      FOnFormatChanged;
  end;
end;

procedure TZAbstractTimestampFormatSettings.SetTimeFormat(const Value: String);
begin
  if ((FTimeFormat = nil) and (Value <> '')) or ((FTimeFormat <> nil) and (Value = '')) or ((FTimeFormat <> nil) and (FTimeFormat^ <> Value)) then begin
    if Value <> '' then begin
      FTimeFormat := @FFormatSettings.ShortTimeFormat;
      FTimeFormat^ := Value;
    end else FTimeFormat := nil;
    if Assigned(FOnFormatChanged) then
      FOnFormatChanged;
  end;
end;
Thanks!

-Mark
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1956
Joined: 17.01.2011, 14:17

Re: Fixes for TZAbstractTimestampFormatSettings

Post by marsupilami »

Hello Mark,

I applied your patch. Having a patch file or a pull request really helps ;)

Bets regards,

Jan
MJFShark
Expert Boarder
Expert Boarder
Posts: 218
Joined: 04.06.2020, 13:59

Re: Fixes for TZAbstractTimestampFormatSettings

Post by MJFShark »

Hi Jan,

Sorry for that! I'll use one of those methods for future stuff.

-Mark
Post Reply