Jump to content


Photo

NxDateInspectorNode6 - storing only current date

NxDateInspectorNode6

  • Please log in to reply
4 replies to this topic

#1 MatejSi

MatejSi
  • Members
  • 12 posts

Posted 27 March 2020 - 10:18 AM

Hello Boki,

I have two issues with Date Nodes of Inspector6

 

1) When i create a date node and pick a date i.e. 5.3.2020, it shows correctly 5.3.2020 in the node, but when I try to read the value node.AsDateTime it always shows current date not the date in the node. Probably there is some problem with reading the value asdatetime and it throws Now; as default

 

2) When I set HideEmpty to true and assign node.AsDateTime := field[0].AsDateTime where field[0] is MySQL field with date column and null value, it shows 30.12.1899 (ignoring the HideEmpty property)

 

Please see attached file.

 

Thank you for your help.

Matěj

Attached Files



#2 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,220 posts
  • Gender:Male

Posted 28 March 2020 - 02:16 PM

Hi,

 

1) I'm using StrToDateTimeDef internally. Can you please try to test this function with one string variable and see if it works. Maybe FormatSettings need to be set? I will try to see why popup is not synchronised. I will change that if date is invalid, it set to 0.0

 

2) I will check it now and try to fix it. I think I now what is the problem.


boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#3 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,220 posts
  • Gender:Male

Posted 28 March 2020 - 02:25 PM

For 2nd issue, try changing line 3054 in NxInspectorNode6.pas:

 

procedure TNxInspectorNode6.SetAsDateTime(const Value: TDateTime);
begin
  if Value = 0.0 then Self.Value := '' else Self.Value := DateTimeToStr(Value);
end;

boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#4 MatejSi

MatejSi
  • Members
  • 12 posts

Posted 30 March 2020 - 08:43 AM

Hi,
The 2nd issue is solved. Thank you.
 
For the 1st issue - I thought that when you use DateTimeToStr and StrToDateTime without changing FormatSettings, it should take the same formatsettings based on some system default.
 
I tried to set the formatsettings and this part of code works:

var  fs : TFormatSettings;
begin


  fs := TFormatSettings.Create;
  fs.ShortDateFormat:='d. m. yyy';
  fs.DateSeparator:='.';

  edit1.Text:=datetostr(date, fs);
  showmessage(datetostr(strtodate(edit1.Text,fs),fs)); 

but i would like to have something more universal (not always the date will be in this format). But when I try to use this, it throws invalid date format error:

var  fs : TFormatSettings;
begin

fs := TFormatSettings.Create;
GetLocaleFormatSettings(syslocale.DefaultLCID, fs);

  edit1.Text:=datetostr(date, fs);
  showmessage(datetostr(strtodate(edit1.Text,fs),fs));

Do you know how to set it in your code so that it works with the same FormatSettings (StrToDateTime and also DateTimeToStr)

 

Thanks for your help.

Matěj



#5 MatejSi

MatejSi
  • Members
  • 12 posts

Posted 30 March 2020 - 05:57 PM

OK, i have found out that when I call showmessage(formatsettings.dateseparator) it shows '/' instead of local '.' 

 

So I set FormatSettings.DateSeparator:='.' and now it works (also Popup is now synchronized). So it was not issue of your component.

 

Thanks, Matěj

 

 

P.S. I still don't get it why when you use DateToStr it uses correct local date separator '.' but when you try it backwards StrToDate it tries to use '/' as date separator.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users