You are not logged in.
Hello,
I am using Delphi 12.3 and looking for an advise on a way to convert all TDateTime variables values from GMT+0 to a different GMT in a packed record which has lots of other variables and different data types.
What I am looking for is something like an utility function that I do not need to use record variable names in code.
Is that possible? Or I still need to change all of them one by one in classical way.
Thanks & Regards,
Ertan
Offline
Thank you for the help.
I need it for record
Offline
For completeness, here is a example changing all TDateTime in a record using TRttiContext in Delphi:
Offline
another demo, tested with FPC:
https://gist.github.com/zen010101/4af9a … ebe62f19a9
Usage:
var
Rec: TMyRecord;
begin
// ... populate Rec ...
// Convert from UTC to GMT+8
ConvertRecordDateTimesToTimezone(Rec, TypeInfo(TMyRecord), 8);
// Convert from UTC to EST (GMT-5)
ConvertRecordDateTimesToTimezone(Rec, TypeInfo(TMyRecord), -5);
end;
Offline