News:

Download Pelles C here: http://www.smorgasbordet.com/pellesc/

Main Menu

_ftime problem

Started by Greg, December 21, 2004, 08:38:12 AM

Previous topic - Next topic

Pelle

Thanks for the update, Robert! Seems to work in two time-zones at least...

Pelle
/Pelle

tiwag

Hi Pelle,

timetest also works correct here at my location using CET

WinXP SP2

Pelle

Hello tiwag,

Thanks for the info - good to know.

Pelle
/Pelle

Greg

The timezone issues with _ftime, localtime etc. are all corrected in the 3.00.0 Beta #1.

Thanks for all your efforts Pele. I'm liking Pelle's C more and more all the time.

Pelle

Thanks! That's what I needed - some good news... ;)

Pelle
/Pelle

Garvan

Hi Pelle:

_ftime() is still broken in version 3.00.0 beta 1. If fails in time-zones greater than +6 GMT. The timezone returns 0, and UTC time is returned instead of local time.

I tested your posted timetest.exe while in Holland, and it worked, but that was not much of a test, was it? I am in Bangkok (+7GMT) now and it does not work here.

Is the function _tzset(); needed? VC++ seams to work with or without it, and I could not find it in PellesC.

Garvan

Pelle

Hello Garvan,

Quote from: "Garvan"
I tested your posted timetest.exe while in Holland, and it worked, but that was not much of a test, was it? I am in Bangkok (+7GMT) now and it does not work here.
Test for me, in the sense that if localtime() is working, there is no fundamental flaw in calculating the timezone offset. If only _ftime() is wrong, I should look in one place for the problem. If also localtime() is wrong, I should look at the "bigger picture". This is why I wanted as many people as possible, from different timezones, to report the results.

Quote from: "Garvan"
Is the function _tzset(); needed? VC++ seams to work with or without it, and I could not find it in PellesC.
According to the docs, the _tzset function uses the current setting of the environment variable TZ to assign values to three global variables.
I have similar code, that checks the environment variable TZ, but it's called automatically - no need to call any _tzset function (if I can't find the TZ variable, I fall back and ask Windows about the "TZ" value, which is the parsed/analyzed).

I tried changing the Windows timezone setting, on my Swedish Windows XP, to various zones over the world (+/- many hours from GMT). It worked for most places, but not for some. I wasn't sure if this is because my Swedish version lacks some "setting files", or if there is a problem *sometimes*.

Pelle
/Pelle

Greg

Those functions are all working correctly for me with the 3.00.0 Beta #1.

My timezone is Pacific Standard Time ( GMT-8 )  or TZ=PST8PDT.

Greg

Pelle,

May I suggest you post the source code for timetest.exe so people can try it in their time zone and everyone would be using the same code.

Pelle

OK, here is the code - I have added a call to gmtime() for completeness.

Pelle
/Pelle

Greg

timetest.c returns all the correct values here ( GMT-8 ) using both crt.lib and pocrt.lib version 3.00.0 Beta #1.

Pelle

Thanks for the info, Greg. It works here too (GMT+1) - not sure why it fails on some machines.

Pelle
/Pelle

Greg

Pelle,

Quote(GMT+1)

You are either up very late or up very early.  :)

Pelle

Way too late... but I promise, I will go to bed now...  :shock:

Pelle
/Pelle

Garvan

Hi Pelle:

Sorry for not making my report clearer. localtime is also wrong.

This is a comparison result from running your code compiled with VC and then PellesC in a batch file. I am at GMT+7, using WinXP with the 3.0 beta 1 release.

Thanks

Garvan


VC++
_ftime() reports:
 seconds...........1105680571
 milliseconds......14
 UTC offset........-420 minutes
 daylight saving...No

localtime() reports:
 year..............2005
 month.............1
 day...............14
 hours.............12
 minutes...........29
 seconds...........31
 day of week.......Fri
 day of year.......13
 daylight saving...No

gmtime() reports:
 year.............2005
 month............1
 day..............14
 hours............5
 minutes..........29
 seconds..........31
 day of week......Fri
 day of year......13
 daylight saving..No


-----------
PellesC
_ftime() reports:
 seconds...........1105680571
 milliseconds......34
 UTC offset........0 minutes
 daylight saving...Unknown

localtime() reports:
 year..............2005
 month.............1
 day...............14
 hours.............5
 minutes...........29
 seconds...........31
 day of week.......Fri
 day of year.......13
 daylight saving...Unknown

gmtime() reports:
 year.............2005
 month............1
 day..............14
 hours............5
 minutes..........29
 seconds..........31
 day of week......Fri
 day of year......13
 daylight saving..No