FtpFindFirstFile Daylight Saving Time Bug 
Author Message
 FtpFindFirstFile Daylight Saving Time Bug

I found a bug today that I cannot workaround. I've run the following code
100 times, and at random it thinks we're still in local standard time.

Using the FtpFindFirstFile to perform an FTP server directory listing, the
pData structure contains the last writetime for each file in that listing.
The FTP server's modified times are in UTC, which is what I want. I've been
using this function for many many months without incident until now. Today,
everytime I run the function I either get the correct information in UTC or
all the files set one hour ahead in UTC time. When the latter occurs, it
ALSO stamps the year 2001 instead of 2002 because the
FileTimeToSystemTime(lTime, sTime) function realizes that date hasn't
occurred yet and is impossible.

Why is this happening? I'll get two different answers at random when running
this code.

-Evan

Dim sTime As SYSTEMTIME, lTime As FILETIME
Dim pData As WIN32_FIND_DATA
Dim hListing as Long

hListing = FtpFindFirstFile(hDirectory, "sn.*", pData, INTERNET_FLAG_RELOAD
Or _
                               INTERNET_FLAG_NO_CACHE_WRITE, 0&)
Do
   Result = InternetFindNextFile(hListing, pData)
DoEvents
   strFilename = Left(pData.cFileName, InStr(1, pData.cFileName, String(1,
0), vbBinaryCompare) - 1)

   lTime = pData.ftLastWriteTime
   L = FileTimeToSystemTime(lTime, sTime)

   file_time = Format(sTime.wYear, "0000")  & Format(sTime.wMonth, "00") & _
                       Format(sTime.wDay, "00") & _
                       Format(sTime.wHour, "00") & _
                       Format(sTime.wMinute, "00")
Loop Until (Result = 0)



Fri, 24 Sep 2004 05:42:19 GMT  
 FtpFindFirstFile Daylight Saving Time Bug

Well as luck would have it, one of the computers on their server cluster was set
to GMT (London, Dublin, etc..) instead of GMT (Casablanca, Monrovia, etc..)
causing the data to be stamped GMT +1 hour.

Disregard the previous bug.

-Evan

Quote:

> I found a bug today that I cannot workaround. I've run the following code
> 100 times, and at random it thinks we're still in local standard time.

> Using the FtpFindFirstFile to perform an FTP server directory listing, the
> pData structure contains the last writetime for each file in that listing.
> The FTP server's modified times are in UTC, which is what I want. I've been
> using this function for many many months without incident until now. Today,
> everytime I run the function I either get the correct information in UTC or
> all the files set one hour ahead in UTC time. When the latter occurs, it
> ALSO stamps the year 2001 instead of 2002 because the
> FileTimeToSystemTime(lTime, sTime) function realizes that date hasn't
> occurred yet and is impossible.

> Why is this happening? I'll get two different answers at random when running
> this code.

> -Evan

> Dim sTime As SYSTEMTIME, lTime As FILETIME
> Dim pData As WIN32_FIND_DATA
> Dim hListing as Long

> hListing = FtpFindFirstFile(hDirectory, "sn.*", pData, INTERNET_FLAG_RELOAD
> Or _
>                                INTERNET_FLAG_NO_CACHE_WRITE, 0&)
> Do
>    Result = InternetFindNextFile(hListing, pData)
> DoEvents
>    strFilename = Left(pData.cFileName, InStr(1, pData.cFileName, String(1,
> 0), vbBinaryCompare) - 1)

>    lTime = pData.ftLastWriteTime
>    L = FileTimeToSystemTime(lTime, sTime)

>    file_time = Format(sTime.wYear, "0000")  & Format(sTime.wMonth, "00") & _
>                        Format(sTime.wDay, "00") & _
>                        Format(sTime.wHour, "00") & _
>                        Format(sTime.wMinute, "00")
> Loop Until (Result = 0)

  Evan.Bookbinder.vcf
< 1K Download


Sun, 26 Sep 2004 05:52:20 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Daylight saving - winter time - summer time - time zone

2. Daylight saving - winter time - summer time - time zone

3. Daylight saving - winter time - summer time - time zone

4. time zones and daylight saving time

5. Standard Time or Daylight Savings Time

6. Standard v. Daylight Savings Time Function

7. Daylight Savings Time Error

8. Daylight Savings Time

9. Daylight Savings-Time bias

10. Daylight Savings Time dates

11. Daylight Savings Time

12. how to calculate daylight saving time ?

 

 
Powered by phpBB® Forum Software