Daylight savings time problem

Hello friends,
I'm developing a win32 not MFC program which needs to display a date and time so made: current year, month and day, but hour retrieved by a CSV file.
This is the code I'm using:
1
2
3
4
5
6
7
8
9
10
SYSTEMTIME st;
time_t rawtime;
time ( &rawtime );
tm * timeinfo = localtime ( &rawtime );
timeinfo->tm_year = st.wYear-1900;
timeinfo->tm_mon = st.wMonth-1;
timeinfo->tm_mday = st.wDay; 
timeinfo->tm_hour=nHour;
timeinfo->tm_min=nMin;
mktime(timeinfo); 

where 'nHour' is the hour retrieved by CSV file.
I want to get the exact CSV file hour, but when Daylight savings time occur I get nHour plus or minus 1 depending on season.
How to avoid this program behavior?
Thanks
If you're working with time zones or DST, you need to work with GMT (UTC).

Also, you shouldn't write into the static tm* like that. Declare your own and use that.
Last edited on
Hello kbw,
thank you for the reply, but I don't handstand. Can you post an example about how my code should be?
Topic archived. No new replies allowed.