Browse Source

--- Merging r23334 into '.':
U rtl/objpas/sysutils/dati.inc
--- Merging r23336 into '.':
U packages/fcl-net/src/netdb.pp
--- Merging r23372 into '.':
U packages/winunits-base/src/winutils.pp

# revisions: 23334,23336,23372
r23334 | michael | 2013-01-07 11:28:47 +0100 (Mon, 07 Jan 2013) | 1 line
Changed paths:
M /trunk/rtl/objpas/sysutils/dati.inc

* Fixed rounding errors in DateTimeToTimeStamp, causing errors in conversions
r23336 | michael | 2013-01-07 12:23:55 +0100 (Mon, 07 Jan 2013) | 1 line
Changed paths:
M /trunk/packages/fcl-net/src/netdb.pp

* Fixed bug ID #20484
r23372 | marco | 2013-01-13 13:55:31 +0100 (Sun, 13 Jan 2013) | 2 lines
Changed paths:
M /trunk/packages/winunits-base/src/winutils.pp

* Unblockfile to programmatically unblock MSIE downloads

git-svn-id: branches/fixes_2_6@23891 -

marco 12 years ago
parent
commit
b8a571fbb5

+ 6 - 2
packages/fcl-net/src/netdb.pp

@@ -536,13 +536,17 @@ Procedure CheckResolveFile;
 
 Var
   F : Integer;
+  N : String;
 
 begin
   If CheckResolveFileAge then
     begin
-    F:=FileAge(ResolveFileName);
+    N:=ResolveFileName;
+    if (N='') then
+      N:=EtcPath + SResolveFile;
+    F:=FileAge(N);
     If ResolveFileAge<F then
-      GetDnsServers(ResolveFileName);
+      GetDnsServers(N);
     end;  
 end;
 

+ 13 - 1
packages/winunits-base/src/winutils.pp

@@ -13,7 +13,7 @@
 
  **********************************************************************}
 
-{$mode objfpc}
+{$mode objfpc}{$H+}
 unit winutils;
 
 Interface
@@ -24,6 +24,9 @@ Uses Windows;
 // From Delphi.about.com with permission, http://delphi.about.com/od/delphitips2007/qt/is_win_admin.htm
 function IsWindowsAdmin: Boolean;
 
+// Removes Browsers "downloaded" attribute from a file.
+procedure UnBlockFile(const name:String);
+
 implementation
 
 const
@@ -79,4 +82,13 @@ begin
   end;
 end;
 
+procedure UnBlockFile(const name:String);
+var f : file;
+begin
+ assignfile(f,name+':Zone.Identifier');
+ rewrite(f,1);
+ truncate(f);
+ closefile(f);
+end;
+
 end.

+ 10 - 5
rtl/objpas/sysutils/dati.inc

@@ -52,10 +52,15 @@ end;
 {   DateTimeToTimeStamp converts DateTime to a TTimeStamp   }
 
 function DateTimeToTimeStamp(DateTime: TDateTime): TTimeStamp;
+
+Var
+  D : Double;
+
 begin
-  result.Time := Round(abs(Frac(DateTime)) * MSecsPerDay);
-  result.Date := DateDelta + trunc(DateTime);
-end ;
+  D:=DateTime * Single(MSecsPerDay);
+  result.Time := Abs(Round(D)) Mod MSecsPerDay;
+  result.Date := DateDelta + Round(D) div MSecsPerDay;
+end;
 
 {   TimeStampToDateTime converts TimeStamp to a TDateTime value   }
 
@@ -190,7 +195,7 @@ procedure DecodeTime(Time: TDateTime; out Hour, Minute, Second, MilliSecond: wor
 Var
   l : cardinal;
 begin
- l := Round(abs(Frac(time)) * MSecsPerDay);
+ l := DateTimeToTimeStamp(Time).Time;
  Hour   := l div 3600000;
  l := l mod 3600000;
  Minute := l div 60000;
@@ -896,7 +901,7 @@ var
 
 var
   Year, Month, Day, DayOfWeek, Hour, Minute, Second, MilliSecond: word;
-
+  DT : TDateTime;
 
   procedure StoreFormat(const FormatStr: string; Nesting: Integer; TimeFlag: Boolean);
   var