I am using MariaDB on m Dev machine and Mysql on the server. I am using timestamp (ie, UTC) fields for datetime. On some screens the value is being shown on grids.
One way I might achieve this in VCL is to use GetText Event of TField and return the value converted to the local time zone. However, GetText doesn't appear to get called.
Is there a better way than using Calculated Field and its event to define and return another local datetime field?
What about on a form where the TDatetime is displayed (and edited) in the appropriate edit/select control?
Sorry, I didn't clarify it. This is on the webapp, using XDATA. As mentioned, this would work fine on VCL, where GetText/SetText works. But GetText is not getting called on the webapp. I haven't yet tested SetText.
Additionally, I was asking if there is a better way to convert UTC to Local DateTime for Display and Edit. Perhaps there is a property to achieve this. We are talking about webapps, not Windows, so Timezone is more of an issue.
Perhaps TMS have implemented something
Or maybe there is way to do it on TXdataWebDataSet, that I am not aware of.
Claude says that Firedac connection has params to do this. But converting it to the same timezone, on the server for every client, is not what's required.
For VCL, it would be easy for me to intercept in a number of places to achieve this.
Possible solutions in order of preference
Ideally I would want to fix this at the Entity level on the server (based on the clients timezone at that time).
Intercept it on the client and convert it back and forth.
I could intercept TDateFields in AfterOpen event (to convert to local time zone) and BeforePost event (to convert to UTC). But the latter is dangerous. If there is error, Now the data on the client is in UTC and not local.
QS: Am I able to define my own attribute for the Entities? This would be the most elegant solution.