time_t is a black box, the right way to use it is through the inferface of functions that work with it. It could represent the time in increments of skittles strewn across the compiler developer's desk and still work perfectly when used the right way. ;)
What are you trying to do that requires intimate knowledge of how time_t is represented?
>What I am trying to do is to get the UTC epoch time from the local time
The epoch is usually based on UTC, so your question is kind of confusing. :( If you're lucky, this will work to find out both the UTC and local epoch, but it's not portable because time_t is a black box and setting it to 0 isn't guaranteed to be meaningful:
using namespace std;
time_t zero = 0;
cout << asctime(gmtime(&zero));
cout << asctime(localtime(&zero));
On most unix compilers, time(NULL) returns the number of seconds since January 1, 1970. If I do time(NULL) right now, it gives me 1218651371 (in EST). What I want it to give me is 1218665771, the UTC time of the local time. Does that make sense?
Woohoo! Edward now understands. :) This still isn't portable because it assumes that a time_t value of 0 is the epoch, but it should give you the result you need. difftime() gives you the number of seconds between two time_t values:
using namespace std;
time_t now = time(0);
// Local seconds since the epoch
cout << fixed << difftime(now, 0) << '\n';
// UTC seconds since the epoch
cout << fixed << difftime(mktime(gmtime(&now)), 0) << '\n';
Thanks, I think we almost have it. I just ran it and got:
The difference between the two is five hours, but this is being run from a pc set to EST, so I would expect a difference of four hours. Is there something wrong with the c++ code or the way the pc is setup? Doing the date command in the terminal window brings up:
Wed Aug 13 16:37:13 EDT 2008
So it looks like it is set to the correct timezone.
For Each ctrl As Control In Me.Controls("pnlMainPanel").Controls
If ctrl.GetType Is GetType(System.Windows.Forms.Panel) Then
For Each subCtrl As Control In ctrl.Controls
If subCtrl.GetType Is GetType(System.Windows.Forms.TextBox) Then
If subCtrl.GetType Is ...