Ver código fonte

* If a variant contains a datetime value and is converted to a string, it should return a string in a date/time format. (+test)

git-svn-id: trunk@7643 -
joost 18 anos atrás
pai
commit
4d9c3244fe
3 arquivos alterados com 18 adições e 2 exclusões
  1. 1 0
      .gitattributes
  2. 2 2
      rtl/objpas/cvarutil.inc
  3. 15 0
      tests/tbs/tb0536.pp

+ 1 - 0
.gitattributes

@@ -6325,6 +6325,7 @@ tests/tbs/tb0532.pp svneol=native#text/x-pascal
 tests/tbs/tb0533.pp svneol=native#text/plain
 tests/tbs/tb0534.pp svneol=native#text/plain
 tests/tbs/tb0535.pp svneol=native#text/plain
+tests/tbs/tb0536.pp svneol=native#text/plain
 tests/tbs/ub0060.pp svneol=native#text/plain
 tests/tbs/ub0069.pp svneol=native#text/plain
 tests/tbs/ub0119.pp svneol=native#text/plain

+ 2 - 2
rtl/objpas/cvarutil.inc

@@ -1180,7 +1180,7 @@ begin
         varSingle   : Result := FloatToStr(vSingle);
         varDouble   : Result := FloatToStr(vDouble);
         varCurrency : Result := FloatToStr(vCurrency);
-        varDate     : Result := FloatToStr(vDate);
+        varDate     : Result := DateToStr(vDate);
         varBoolean  : Result := BoolToStr(vBoolean, True);
         varVariant  : Result := VariantToAnsiString(PVarData(vPointer)^);
         varByte     : Result := IntToStr(vByte);
@@ -1200,7 +1200,7 @@ begin
         varSingle   : Result := FloatToStr(PSingle(vPointer)^);
         varDouble   : Result := FloatToStr(PDouble(vPointer)^);
         varCurrency : Result := FloatToStr(PCurrency(vPointer)^);
-        varDate     : Result := FloatToStr(PDate(vPointer)^);
+        varDate     : Result := DateToStr(PDate(vPointer)^);
         varBoolean  : Result := BoolToStr(PWordBool(vPointer)^, True);
         varVariant  : Result := VariantToAnsiString(PVarData(vPointer)^);
         varByte     : Result := IntToStr(PByte(vPointer)^);

+ 15 - 0
tests/tbs/tb0536.pp

@@ -0,0 +1,15 @@
+program TestDateVariantConversion;
+
+uses variants;
+
+var dt : TDateTime;
+    v : variant;
+    s : String;
+
+begin
+  dt := 40000;
+  v := dt;
+  s := v;
+  // It should return the date, depending on the localisation settings
+  if s = '40000' then halt(1); 
+end.