I am generating a clock for my MFC application that figures out what the current time is based on the selected timezone. What I need to do is calculate an offset using the system time. I get GMT time and figure out what the time is based on an offset, for instance I will calculate what MST is and update the clock to display the current time in the MST timezone.
Is there a function that will allow me to do this? For example in Java the "Calandar" object has a member function "add", Calendar.add that takes two values ( Calendar.HOURS, offset) and does the addition for you.
Example: Calendar cal;
cal.add(Calendar.HOURS, offset);
THIS IS WHAT I HAVE USED FOR MY C++ CODE SO FAR
Code:
time_t now;
struct tm *tm_now;
int hour;
int minutes;
int new_hour;
now = time ( NULL );
tm_now = gmtime ( &now );
hours = tm_now->tm_hour;