Jump to content

Editing Local Time, Storing in DB as UTC


Tim Mckay

Recommended Posts

Howdy everyone,

I am very new to uniGUI, and am absolutely loving it.  I am converting a 200,000 lines IntraWeb app to uniGUI.

Because our users are international, we are storing all dates in our SQL database in UTC.

My question is theoretical and practical:

1)  What I have tried which mostly works...

I have a TClientDataSet and have added all the Fields.  For each of the TDateTimeFields, I have implemented OnGetText and OnSetText events which works very nicely on the TUniDBGrid.  The OnGetText takes the database UTC Datestamp, converts to TTimezone.Local based on short date format.  My OnSetText takes the user input from Local and converts to UTC and saves to the dataset.

What I have found so far is that the TUniDBDateTimePicker control looks at the database values and for some reason the OnGetText/OnSetText event handlers of the TDateTimeFields don't fire... so my users would see UTC and edit UTC which would be totally confusing.

I suppose in theory I could take their inputs and handle the OnChange/OnChangeValue events of the TUniDBDateTimePicker, but that doesn't solve the issue of the control showing UTC values from the database and not Local timezone.

One option I had considered was to create a sub-class of just using the TUniDateTimePicker (not the DB one), and implement my own handling of the Load/Save events with the appropriate conversions.

2) What general advice would you advise in regards to making it possible to edit dates & times in local timezone and store in UTC.

Maybe I'm just going at this the wrong way, and if there are better ways of showing and editing in Local time/date but save to UTC, I would love to know.

 

Many thanks in advance!

 

Tim 

Link to comment
Share on other sites

Wow,

Thanks for the super quick reply.

This is only with the Free/trial edition at this time.  v 1.90.0 build 1500 is what it says on the startup page.

(Using RAD Studio XE7 with C++ and Delphi personalities, if that makes a difference).  Also have SDAC, EntityDAC, Castalia, IntraWeb, CodeSite and JEDI installed.

Thanks,

 

Tim 

Link to comment
Share on other sites

  • 3 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...