#1 2023-06-14 07:04:38

VojkoCendak
Member
From: Celje Slovenia
Registered: 2012-09-02
Posts: 88

TSynSystemTime millisecond question

Hi,  (latest mormot from github, D11.2ent)

if I  do:
var isotime: TSynSystemTime;
  if isotime.FromText('1962-11-12T21:59:48') then
  or
  if isotime.FromText('1962-11-12T21:59:48.000') then
result is false, because milliseconds are always 2333.
intialization of values are random numbers (milliseconds are 2333). Also year, ...

Maybe I'm missing soemthing.

thank you,
Vojko

Last edited by VojkoCendak (2023-06-14 07:13:29)

Offline

#2 2023-06-14 07:10:56

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,132
Website

Re: TSynSystemTime millisecond question

It does not support milliseconds as input.

A TTimeLogBits is used for the conversion, which has a per-second resolution.

Offline

#3 2023-06-14 07:15:24

VojkoCendak
Member
From: Celje Slovenia
Registered: 2012-09-02
Posts: 88

Re: TSynSystemTime millisecond question

Yes, but the milliseconds are always 2333 (in my case) and the fuction ToDateTime fails,
because TryEncodeTime fails because milliseconds are greater then 1000.
maybe they should be always 0 then.

Last edited by VojkoCendak (2023-06-14 07:16:15)

Offline

#4 2023-06-14 07:28:49

VojkoCendak
Member
From: Celje Slovenia
Registered: 2012-09-02
Posts: 88

Re: TSynSystemTime millisecond question

Even if I use date only, milliseconds part is fixed in some random number:

  isotime.FromText('1962-11-13');
  dt := isotime.ToDateTime; // fails, because of millisecond part

function TSynSystemTime.ToDateTime: TDateTime;
var time: TDateTime;
begin 
  if TryEncodeDate(Year,Month,Day,result) then
    if TryEncodeTime(Hour,Minute,Second,MilliSecond,time) then  // fails !
      result := result+time else
      result := 0 else
    result := 0;
end;

thank you

Offline

#5 2023-06-14 07:37:22

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,132
Website

Re: TSynSystemTime millisecond question

Offline

#6 2023-06-14 07:48:53

VojkoCendak
Member
From: Celje Slovenia
Registered: 2012-09-02
Posts: 88

Re: TSynSystemTime millisecond question

yes it works. thank you

Offline

Board footer

Powered by FluxBB