Selaa lähdekoodia

* Added jsoCheckEmptyDateTime option to check for 0 date/time

git-svn-id: trunk@21628 -
michael 13 vuotta sitten
vanhempi
commit
7718db9b5e
1 muutettua tiedostoa jossa 6 lisäystä ja 3 poistoa
  1. 6 3
      packages/fcl-json/src/fpjsonrtti.pp

+ 6 - 3
packages/fcl-json/src/fpjsonrtti.pp

@@ -20,8 +20,9 @@ Type
                        jsoComponentsInline,       // Always stream components inline. Default is to stream name, unless csSubcomponent in ComponentStyle
                        jsoTStringsAsArray,        // Stream TStrings as an array of strings. Associated objects are not streamed.
                        jsoTStringsAsObject,       // Stream TStrings as an object : string = { object }
-                       jsoDateTimeAsString,
-                       jsoUseFormatString);       // Use FormatString when creating JSON strings.
+                       jsoDateTimeAsString,       // Format a TDateTime value as a string
+                       jsoUseFormatString,        // Use FormatString when creating JSON strings.
+                       jsoCheckEmptyDateTime);    // If TDateTime value is empty and jsoDateTimeAsString is used, 0 date returns empty string
   TJSONStreamOptions = Set of TJSONStreamOption;
 
   TJSONFiler = Class(TComponent)
@@ -999,7 +1000,9 @@ Var
   S: String;
 
 begin
-  if (DateTimeFormat<>'') then
+  if (jsoCheckEmptyDateTime in Options) and (DateTime=0) then
+    S:=''
+  else if (DateTimeFormat<>'') then
     S:=FormatDateTime(DateTimeFormat,DateTime)
   else if Frac(DateTime)=0 then
     S:=DateToStr(DateTime)