Skip to content

Commit

Permalink
Tentative fix/improvement for issue #118
Browse files Browse the repository at this point in the history
DefaultMARSJSONSerializationOptions.DateIsUTC now gets initialized in the initialization section of MARS.Core.JSON unit.
  • Loading branch information
andrea-magni committed May 11, 2023
1 parent 2ea5098 commit 3c58b14
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions Source/MARS.Core.JSON.pas
Original file line number Diff line number Diff line change
Expand Up @@ -267,17 +267,16 @@ TJSONObjectHelper = class helper(TJSONValueHelper) for TJSONObject
{$ELSE}
var DefaultMARSJSONSerializationOptions: TMARSJSONSerializationOptions = (
SkipEmptyValues: True;
DateIsUTC: True;
DateIsUTC: True; // check the initialization section of this unit!
DateFormat: ISO8601;
);
{$ENDIF}

implementation

uses
DateUtils, Variants, StrUtils
, MARS.Core.Utils
, MARS.Rtti.Utils
System.DateUtils, System.TimeSpan, System.Variants, System.StrUtils
, MARS.Core.Utils, MARS.Rtti.Utils
;

class function TJSONObjectHelper.TValueToJSONValue(
Expand Down Expand Up @@ -1582,4 +1581,9 @@ constructor JSONNameAttribute.Create(const AName: string);
FName := AName;
end;

initialization
var LUTCOffsetInMinutes := Trunc(TTimeZone.Local.GetUTCOffset(Now).TotalMinutes);
DefaultMARSJSONSerializationOptions.DateIsUTC := LUTCOffsetInMinutes = 0;


end.

0 comments on commit 3c58b14

Please sign in to comment.