Prechádzať zdrojové kódy

[yamlSerializer] TDateTime 0.0 as null

Exilon 5 rokov pred
rodič
commit
312349f089
1 zmenil súbory, kde vykonal 11 pridanie a 11 odobranie
  1. 11 11
      Quick.YAML.Serializer.pas

+ 11 - 11
Quick.YAML.Serializer.pas

@@ -7,7 +7,7 @@
   Author      : Kike Pérez
   Version     : 1.0
   Created     : 12/04/2019
-  Modified    : 31/03/20120
+  Modified    : 05/04/20120
 
   This file is part of QuickLib: https://github.com/exilon/QuickLib
 
@@ -696,11 +696,11 @@ begin
         begin
           if aTypeInfo = TypeInfo(TDateTime) then
           begin
-            if value <> 'null' then Result := JsonDateToDateTime(value);
+            if CompareText(value,'null') <> 0 then Result := JsonDateToDateTime(value);
           end
           else if aTypeInfo = TypeInfo(TDate) then
           begin
-            Result := StrToDate(value);
+            if CompareText(value,'null') <> 0 then Result := StrToDate(value);
           end
           else if aTypeInfo = TypeInfo(TTime) then
           begin
@@ -782,11 +782,11 @@ begin
         begin
           if propinfo.PropType = TypeInfo(TDateTime) then
           begin
-            Result := JsonDateToDateTime(value);
+            if CompareText(value,'null') <> 0  then Result := JsonDateToDateTime(value);
           end
           else if propinfo.PropType = TypeInfo(TDate) then
           begin
-            Result := StrToDate(value);
+            if CompareText(value,'null') <> 0 then Result := StrToDate(value);
           end
           else if propinfo.PropType = TypeInfo(TTime) then
           begin
@@ -1180,11 +1180,11 @@ begin
         begin
           if aValue.TypeInfo = TypeInfo(TDateTime) then
           begin
-            Result.Value := TYamlString.Create(DateTimeToJsonDate(aValue.AsExtended));
+            if aValue.AsExtended <> 0.0 then Result.Value := TYamlString.Create(DateTimeToJsonDate(aValue.AsExtended));
           end
           else if aValue.TypeInfo = TypeInfo(TDate) then
           begin
-            Result.Value := TYamlString.Create(DateToStr(aValue.AsExtended));
+            if aValue.AsExtended <> 0.0 then Result.Value := TYamlString.Create(DateToStr(aValue.AsExtended));
           end
           else if aValue.TypeInfo = TypeInfo(TTime) then
           begin
@@ -1293,11 +1293,11 @@ begin
         begin
           if aValue.TypeInfo = TypeInfo(TDateTime) then
           begin
-            Result.Value := TYamlString.Create(DateTimeToJsonDate(aValue.AsExtended));
+            if aValue.AsExtended <> 0.0 then Result.Value := TYamlString.Create(DateTimeToJsonDate(aValue.AsExtended));
           end
           else if aValue.TypeInfo = TypeInfo(TDate) then
           begin
-            Result.Value := TYamlString.Create(DateToStr(aValue.AsExtended));
+            if aValue.AsExtended <> 0.0 then Result.Value := TYamlString.Create(DateToStr(aValue.AsExtended));
           end
           else if aValue.TypeInfo = TypeInfo(TTime) then
           begin
@@ -1409,11 +1409,11 @@ begin
         begin
           if propinfo.PropType = TypeInfo(TDateTime) then
           begin
-            Result.Value := TYamlString.Create(DateTimeToJsonDate(GetFloatProp(aObject,aPropertyName)));
+            if aValue.AsExtended <> 0.0 then Result.Value := TYamlString.Create(DateTimeToJsonDate(GetFloatProp(aObject,aPropertyName)));
           end
           else if propinfo.PropType = TypeInfo(TDate) then
           begin
-            Result.Value := TYamlString.Create(DateToStr(GetFloatProp(aObject,aPropertyName)));
+            if aValue.AsExtended <> 0.0 then Result.Value := TYamlString.Create(DateToStr(GetFloatProp(aObject,aPropertyName)));
           end
           else if propinfo.PropType = TypeInfo(TTime) then
           begin