Forum Discussion

jeeejay's avatar
jeeejay
Contributor
12 years ago

Account for Daylight Saving in aqFile.GetLastWriteTime

Hello,



We have a script where we check for the 'Last Modified' date of a given file and compare it with an expected value. If they do not match, then we perform some other actions.



Since yesterday, the function started reporting a difference for all files - the difference being exactly one hour which is obviously due to daylight saving.



So in Windows Explorer, Date Modified for a particuar file is displayed as 2:30 PM but aqFile.GetLastWriteTime returns 1:30 PM for the same file. I'd like to know the reason for this behavior.



I know I can simply change the expected values, or add a line of code by using aqDateTime.AddHours() to make the comparison pass however; I'm looking for a more robust solution within TestComplete.

1 Reply


  • Hi,


     


    That's strange. Let's check how Microsoft's FileSystemObject object works in this situation. Could you please execute the following code and let us know what result you get?




    function GetFileDateLastModified()


    {


      var fs, file;


      var FileName = "PathToTheFile";


      fs = Sys.OleObject("Scripting.FileSystemObject");


      if (fs.FileExists(FileName))


      {


        file = fs.GetFile(FileName);


        var dateLastModified = file.DateLastModified;


        Log.Message(dateLastModified);


      }