January 28th, 2004, 05:49 PM
figuring out all this timezone stuff
I'm trying to write a sample app. to find out the time on a computer and convert it to mountain time.
I'm new to this stuff, and I found out some stuff on _ftime which gives you the timezone that is the "Difference in minutes, moving westward, between UTC and local time. The value of timezone is set from the value of the global variable _timezone (see _tzset)."
I'm not sure what UTC is and if this is the write method I should be using for what I'm doing.
Can someone please suggest to me what I can do or is there some tutorial or sample code out there which has something similar to what i'm doing here?
January 28th, 2004, 08:45 PM
try this maybe this is what u r looking for if not tell
The above code will give u ur timezone is this wat u wanted r did I misread
nm = tmzninf.StandardName;
For getting the time try this
is this wat u want if not tell me
CTime t( 1999, 3, 19, 22, 15, 0 );
time_t osBinaryTime = t.GetTime();
printf( "time_t = %ld\n", osBinaryTime );
January 28th, 2004, 11:49 PM
Great, thank you Cyber Bandit I'll try this out!
Would it be proper programming to have a big switch statement where the cases are all the possible timezones each having a predefined off-set in hours to the mountain time?
i just want to make sure that there isn't some sdk method that will take the current time and can adjust it to a specified timezone (in my case, mountain time).
January 29th, 2004, 12:37 AM
well I think what u r looking for is SetTimeZoneInformation(). Hope this solves ur problem u can get more info bout that in MSDN just look for it
January 30th, 2004, 12:38 AM
Is mountain time the time zone for you and is your system set to that timezone? Will all systems using this software have their timezones set to mountain time?
Yes, UTC is very appropriate for use in this manner. You can use a function that gets the current UTC and then use a function that converts UTC to the time appropriate for your system. The C runtime functions can do that. In that way, the software will be flexible enough that it is likely to work in any timezone.
However if you need to convert to mountan time but mountain time is not the local time, then things are more complicated.
January 30th, 2004, 10:07 AM
Hi Sam, actually I have an app. that basically reads from a file that contains times in mountain time. Potentially this app may sit somewhere on a machine in a different timezone. The reason why I would like to figure out how to convert to mountain time, (not change it) is because I want to take the time on the person's machine (whatever timezone it is) and then see what it is in mountain time so that the time in the file makes sense.
I guess the thing i would be using is GetTimeZoneInformation and use the bias and also bring in the bias from the mountain time into the equation.
January 30th, 2004, 10:26 AM
Then I will assume you have it solved.
I did spend some time figuring out timezone information but it has been a while so it is good that your solution is easy enough that I don't need to attempt remembering or searching.
January 30th, 2004, 06:36 PM
Hi, I just have another question here.
Under the "date/time properties", I guess there is the potential for the user to check/uncheck the option "Automatically adjust clock for daylight savings changes"
Is there an api to determine if this option is checked or not?
Click Here to Expand Forum to Full Width
This is a Codeguru.com survey!