소스 검색

[yamlSerializer] TDateTime 0.0 as null

Exilon 5 년 전
부모
커밋
312349f089
1개의 변경된 파일11개의 추가작업 그리고 11개의 파일을 삭제
  1. 11 11
      Quick.YAML.Serializer.pas

+ 11 - 11
Quick.YAML.Serializer.pas

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