-
January 28th, 2004, 06:49 PM
#1
figuring out all this timezone stuff
Hi,
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?
Thank you
Shannon
-
January 28th, 2004, 09:45 PM
#2
try this maybe this is what u r looking for if not tell
Code:
CString nm;
TIME_ZONE_INFORMATION tmzninf;
GetTimeZoneInformation(&tmzninf);
nm = tmzninf.StandardName;
AfxMessageBox(nm);
The above code will give u ur timezone is this wat u wanted r did I misread
For getting the time try this
Code:
CTime t( 1999, 3, 19, 22, 15, 0 );
time_t osBinaryTime = t.GetTime();
printf( "time_t = %ld\n", osBinaryTime );
is this wat u want if not tell me
"I came"
"I saw"
"I conquered"
-
January 29th, 2004, 12:49 AM
#3
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).
thanks!
-
January 29th, 2004, 01:37 AM
#4
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
"I came"
"I saw"
"I conquered"
-
January 30th, 2004, 01:38 AM
#5
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, 11:07 AM
#6
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.
Thanks
-
January 30th, 2004, 11:26 AM
#7
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, 07:36 PM
#8
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?
Thanks!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|