Yes, I have been trying to use the TimeStampFormat, I might be wrong but the
ISO8601 date has a somewhat conditional output, thus I cannot see how I can use a fixed format string.
The way I understand the ISO8601 date is that it will have a "Z" at the end of the date sting if time has zero offset to UTC, and "±hh:mm" will be added (replace the "Z") if time has an offset to UTC.
So I usually call System.DateUtils.DateToISO8601(Now, false); to get the format I need, but I not able to make this call with the TMSLogger I think.
Dates are in local time zone, so you can get the current time one offset of the machine and set TimeStampFormat accordingly, adding the suffix +hh:mm manually to it.
I hope the way I solved it is correct. I'll post it here in case someone else needs it aswell.
const
PLACEHOLDER = 'PLACEHOLDER';
Neg: array[Boolean] of string = ('+', '-');
begin
// Add a placeholder to be replaced with 'Z' or the UTC time offset.
var lTimeStampFormat := Format('{%%"[yyyy-mm-dd hh:nn:ss.zzz%s]"dt}', [PLACEHOLDER]);
// I.e: {%"[yyyy-mm-dd hh:nn:ss.zzzPLACEHOLDER]"dt}
// Slightly modified code from System.DateUtils.DateToISO8601()
var lTimeZone := TTimeZone.Local;
var lBias := Trunc(lTimeZone.GetUTCOffset(Now).Negate.TotalMinutes);
if lBias <> 0 then begin
var lOffsetTimeStr := Format('%s%.02d:%.02d', [Neg[lBias > 0], Abs(lBias) div MinsPerHour, Abs(lBias) mod MinsPerHour]);
lTimeStampFormat := lTimeStampFormat.Replace(PLACEHOLDER, lOffsetTimeStr);
// I.e: {%"[yyyy-mm-dd hh:nn:ss.zzz+02:00]"dt}
end else begin
lTimeStampFormat := lTimeStampFormat.Replace(PLACEHOLDER, '''Z''');
// I.e: {%"[yyyy-mm-dd hh:nn:ss.zzz''Z'']"dt
end;
// Assign the UTC ISO8601 format string to the logger
TMSLogger.OutputFormats.TimeStampFormat := lTimeStampFormat;
TMSLogger.UtcTimeStamp := true;
...
...
end;