Topic: Bug fix with DateTime

At delphi,

Datetime process function has 'Invalid TTimestamp Value'.

I change that below.

If TTimeStamp field Date is 0, TimeStampToDateTime has raise exception with invalid TTimeStamp value message.

procedure TSqlitePassTranslator.IntegerToTimeText
         (Const Value: Integer;
          Const TimePattern: String;
          Const HourStart, HourLength, MinStart, MinLength, SecStart, SecLength, MSecStart, MSecLength: Word;
          out StrValue: String);
var
Hour, Min, Sec, MSec: Word;
TimePartStr: String;
PStrValue: PChar;
TimeStamp : TTimeStamp;
begin
 Timestamp.Time := Value;
 Timestamp.Date := 1;
 DecodeTime(TimeStampToDateTime(TimeStamp), Hour, Min, Sec, MSec);
 { Necessary conversion oterwise we would be pointing on FDatabase.DatatypeOptions.FTimeFormat }

or

procedure TSqlitePassTranslator.IntegerToTimeText
         (Const Value: Integer;
          Const TimePattern: String;
          Const HourStart, HourLength, MinStart, MinLength, SecStart, SecLength, MSecStart, MSecLength: Word;
          out StrValue: String);
var
Hour, Min, Sec, MSec: Word;
TimePartStr: String;
PStrValue: PChar;
TimeValue : TTime;
begin
 TimeValue := Value / 1000 / 60 / 60 / 24;
 DecodeTime(TimeValue, Hour, Min, Sec, MSec);
 { Necessary conversion oterwise we would be pointing on FDatabase.DatatypeOptions.FTimeFormat }
 StrValue := StrPas(PChar(TimePattern));
 ...

Re: Bug fix with DateTime

Parcel,

Thanks for this bug fix. I didn't test it yet but...

The procedure TSqlitePassTranslator.IntegerToTimeText will be modified in the next release with :

...
Const
TimeDiv = 86400000; { 1000 / 60 / 60 / 24 }

var
....
TimeValue : TTime;

begin
 TimeValue := Value / TimeDiv;
 DecodeTime(TimeValue, Hour, Min, Sec, MSec);
...

Re: Bug fix with DateTime

Thank you, luckylazarus smile