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

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

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,718
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.

Online

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

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

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: 93

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,718
Website

Re: TSynSystemTime millisecond question

Online

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

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

Re: TSynSystemTime millisecond question

yes it works. thank you

Offline

#7 2024-08-27 09:21:07

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

Re: TSynSystemTime millisecond question

Hi,

we have another issue with TSynSystemTime.FromDate, where also minutes...milliseconds are not initialized to 0,
which lead to nasty things...

Offline

#8 2024-08-27 15:04:48

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

Re: TSynSystemTime millisecond question

I disagree, it does what it is documented for: it fills Year/Month/Day fields.
Since you are confused, I am adding some explicit notice about it:
https://github.com/synopse/mORMot2/commit/3bde1cea

If you need something else, you need to call Clear before.

Online

Board footer

Powered by FluxBB