PDA

View Full Version : Comparing date/time of files



NewsArchive
03-03-2009, 01:58 AM
Hi all,

I need to compare a tps file in a folder under Program Files and a folder
under Virtual store on vista to determine which one is newer. I've tried to
get the file date/time into variables, but they seem to be not comparing
correctly. Any ideas?

TIA:)

Best regards,

--
Arnór Baldvinsson - Icetips Creative, Inc.
Port Angeles, Washington
www.icetips.com - www.buildautomator.com

Icetips product subscriptions at http://www.icetips.com/subscribe.php

NewsArchive
03-03-2009, 01:59 AM
Hi Friedrich,

> get the file date/time into variables, but they seem to be not comparing
> correctly. Any ideas?

I've tried to do the Julian Date conversion on the date, but it always
returns 0. When I use this:

Set Variable %IT_VS_MEMBERS_DATE_TEMP% to FUNCTION:Get File Information(File
Date) of file "%IT_OLD_DATAPATH%\Members.tps"
Set Variable %IT_VS_MEMBERS_DATE% to FUNCTION:Julian
Day("%IT_VS_MEMBERS_DATE_TEMP%")

Display Message Box "VS File date/time: %IT_VS_MEMBERS_DATE% - %IT_VS_M..."
-- "Date/Time"

Then the message displays 0 for the IT_VS_MEMBERS_DATE.
IT_VS_MEMBERS_DATE_TEMP displays the formatted date. The date from Get File
Information is returned in yyyy/mm/dd, but the docs on JulianDay string
handling function state "Returns the date String (yyyymmdd) that has been
converted to Julian Day" This doesn't make much sense to me and it's
unclear if it expects the date in yyyymmdd as compared to the yyyy/mm/dd
from the Get File Information - or something else.

i finally figured out that I had to do a search/replace on the
%IT_VS_MEMBERS_DATE_TEMP% and search for "/" and replace with "" to get the
julian date.

It would be helpful if the Julian day function accepted the date from the
file function.

Now it's a question how the time, hh:mm:ss, compares...

Best regards,

--
Arnór Baldvinsson - Icetips Creative, Inc.
Port Angeles, Washington
www.icetips.com - www.buildautomator.com

Icetips product subscriptions at http://www.icetips.com/subscribe.php

NewsArchive
03-03-2009, 02:00 AM
Hi Arnór,

> Then the message displays 0 for the IT_VS_MEMBERS_DATE.
> IT_VS_MEMBERS_DATE_TEMP displays the formatted date. The date from
> Get File Information is returned in yyyy/mm/dd, but the docs on
> JulianDay string handling function state "Returns the date String
> (yyyymmdd) that has been converted to Julian Day" This doesn't make
> much sense to me and it's unclear if it expects the date in yyyymmdd
> as compared to the yyyy/mm/dd from the Get File Information - or
> something else.

yyyymmdd makes sense if you remember that the subscription feature ("Valid
Until Date" option) in SetupBuilder uses the yyyymmdd date format. The
sPSDK also uses the yyyymmdd. And the "Get System Info (Installer Compile
Date)" and "Get Atomic Clock Time" functions. Julian Day is extensively
used in the above functions to power setupPROTECT.

I think an option to control the date/time return format in "Get File Info"
would be handy (similar to what we already have in "Get System Info").

--
Friedrich Linder
Lindersoft
www.lindersoft.com
+1.954.252.3910

SetupBuilder "point. click. ship"
Create Windows Vista ready installations in minutes

-- Official Comodo Code Signing and SSL Certificate Partner

NewsArchive
03-03-2009, 02:04 AM
Hi Arnór,

> Now it's a question how the time, hh:mm:ss, compares...

See attached source code snippet and .sb6 demo project. This code should
work fine for file date/file comparison.

HTH,

--
Friedrich Linder
Lindersoft
www.lindersoft.com
+1.954.252.3910

SetupBuilder "point. click. ship"
Create Windows Vista ready installations in minutes

-- Official Comodo Code Signing and SSL Certificate Partner

NewsArchive
03-04-2009, 01:21 AM
Hi Friedrich,

> See attached source code snippet and .sb6 demo project. This code should
> work fine for file date/file comparison.

How about an additional option to retrieve the universal date time for the
file into a single variable immediately ready to compare?

Set %File1DateTime% to Get File Universal Date Time of file %File1%
Set %File2DateTime% to Get File Universal Date Time of file %File2%

If %File1DateTime% is less than %File2DateTime%
! File1 is older than File2
ElsIf %File1DateTime% equals %File2DateTime%
! File1 is same age as File2
Else
! File1 is newer than File2
End

This would cut down a LOT on the coding:)

Best regards,

--
Arnór Baldvinsson - Icetips Creative, Inc.
Port Angeles, Washington
www.icetips.com - www.buildautomator.com

Icetips product subscriptions at http://www.icetips.com/subscribe.php

NewsArchive
03-04-2009, 01:23 AM
Hi Arnór,

Well, in fact, this information is already available in the installer
because it's internally used in the "Install File(s)..." function when doing
a Check File replacement (Date/Time).

I'll put it on the Wish List :)

Friedrich

NewsArchive
03-04-2009, 01:23 AM
Hi Friedrich,

> I'll put it on the Wish List :)

Excellent:)

Now let me share with you _why I needed this, since it may shed some light
on why I think the universal file date/time would be a good idea:)

I'm working on converting some Clarion 5.5 projects to Clarion 6 and make
them vista compatible. What we discovered was that some users have messed
with turning UAC on and off, which of course messes with the data file
location as they are effectively switching between Program Files to Virtual
Store as the datafiles in the old non-vista compatible install were just in
the program folder. So the simplest way I would think of was to compare the
date/time of one of the .tps files that is opened every time the program is
run so the date/time is always updated. Which ever folder has the most
recent file is the one that is designated as the Old Data Folder when doing
the data conversion.

So for anyone in this situation being able to retrieve the universal value
which would always compare correctly would save quite a bit of coding,
particularly in situations where it is not clear where the most recent files
are:)

Best regards,

--
Arnór Baldvinsson - Icetips Creative, Inc.
Port Angeles, Washington
www.icetips.com - www.buildautomator.com

Icetips product subscriptions at http://www.icetips.com/subscribe.php

NewsArchive
03-04-2009, 01:24 AM
Hi Arnór,

Now that makes complete sense :) It's a very good idea indeed!

Thanks for sharing.

Friedrich

NewsArchive
03-05-2009, 01:36 AM
Hi Arnór,

Functionality added to SB7 and back-ported to SB6. It's based on the
sortable date/time format (conforms to ISO 8601).

Thanks again for your suggestion.

--
Friedrich Linder
Lindersoft
www.lindersoft.com
+1.954.252.3910

SetupBuilder "point. click. ship"
Create Windows Vista ready installations in minutes

-- Official Comodo Code Signing and SSL Certificate Partner