Click here to Skip to main content
15,886,085 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralVK_TAB in an edit control in a dialog Pin
Dave_16-Oct-03 5:03
Dave_16-Oct-03 5:03 
GeneralRe: VK_TAB in an edit control in a dialog Pin
igor196016-Oct-03 7:50
igor196016-Oct-03 7:50 
GeneralRe: VK_TAB in an edit control in a dialog Pin
Dave_16-Oct-03 8:02
Dave_16-Oct-03 8:02 
GeneralSocket Programming : connecting to server Pin
Cyberizen16-Oct-03 5:02
Cyberizen16-Oct-03 5:02 
GeneralRe: Socket Programming : connecting to server Pin
script_smiths16-Oct-03 22:23
script_smiths16-Oct-03 22:23 
GeneralPrinting Landscape on Windows 2000 Pin
Jonathan Craig16-Oct-03 5:00
Jonathan Craig16-Oct-03 5:00 
GeneralRe: Printing Landscape on Windows 2000 Pin
Steve S16-Oct-03 5:26
Steve S16-Oct-03 5:26 
GeneralDaylight saving problems when using winapi's timezone functions. Pin
Patric_J16-Oct-03 4:56
Patric_J16-Oct-03 4:56 
Hi, I get times from a server given in UTC (Coordinated Universal Time or Universal Time Coordinated),
that is similar to GMT (Greenwich Mean Time) but not adjusted to daylight saving time. That is, during
summer, UTC differs one hour from London time, since UK uses daylight saving during summer.

The application I develop is used worldwide so I can not assume or hardcode anything. This should not
be a problem since winapi have functions to handle this. I do the following.

The function I use to convert UTC time to local time (New York time for me) looks like this:

COleDateTime ConvertToLocalTime(const COleDateTime& timeUTC)<br />
{<br />
	// Set time environment variables.<br />
<br />
	_tzset();<br />
<br />
	// Output environment variables<br />
<br />
	CString str;<br />
	str.Format("offset = %d, daylight = %d, %s, %s\n", _timezone, _daylight, _tzname[0], _tzname[1]);<br />
	cout << (LPCTSTR)str<< endl;<br />
<br />
	// Adjust given time to local time.<br />
<br />
	COleDateTimeSpan timeSpanOffset(0, 0, 0, _timezone);<br />
<br />
	COleDateTime timeLocal = timeUTC - timeSpanOffset;<br />
<br />
	// Output local time<br />
<br />
	str.Format("time UTC = %s, time local = %s", timeUTC.Format("%H:%M:%S"), timeLocal.Format("%H:%M:%S"));<br />
	cout << (LPCTSTR)str<< endl;<br />
<br />
	return timeLocal;<br />
}


and produces the following output:

offset = 18000, daylight = 1, Eastern Standard Time, Eastern Daylight Time
time UTC = 11:23:45, time local = 06:23:45


Five hour difference which is fine during winter time, but when daylight saving is in effect, it only differs
four hours. Windows apperently handles this fine, the clock in the notification area adjusts properly, but is
there some way from the API to find out if daylight saving is in effect or not? Are there other ways than using
the functions I been using? _daylight only tells you if Windows should adjust for daylight saving or not.
Disabling automatic adjust of daylight saving in the Windows clock only affects the output as follows:

offset = 18000, daylight = 0, Eastern Standard Time, Eastern Standard Time
time UTC = 11:23:45, time local = 06:23:45


Thanks, Mellowman
GeneralRe: Daylight saving problems when using winapi's timezone functions. Pin
Patric_J20-Oct-03 7:40
Patric_J20-Oct-03 7:40 
GeneralCShellFileOp Pin
Kevin Marren16-Oct-03 3:53
Kevin Marren16-Oct-03 3:53 
GeneralRe: CShellFileOp Pin
David Crow16-Oct-03 6:54
David Crow16-Oct-03 6:54 
GeneralFILE Pin
hph16-Oct-03 3:51
hph16-Oct-03 3:51 
GeneralRe: FILE Pin
David Crow16-Oct-03 6:57
David Crow16-Oct-03 6:57 
GeneralSoftware analysis tools Pin
Shay Harel16-Oct-03 3:42
Shay Harel16-Oct-03 3:42 
GeneralClistBox problem here........help!!!!! :-( Pin
Steve Obbayi16-Oct-03 3:31
professionalSteve Obbayi16-Oct-03 3:31 
GeneralRe: ClistBox problem here........help!!!!! :-( Pin
Rafael Fernández López16-Oct-03 9:39
Rafael Fernández López16-Oct-03 9:39 
GeneralRe: ClistBox problem here........help!!!!! :-( Pin
Mike Danberg16-Oct-03 10:01
Mike Danberg16-Oct-03 10:01 
GeneralRe: ClistBox problem here........help!!!!! :-( Pin
Steve Obbayi16-Oct-03 19:07
professionalSteve Obbayi16-Oct-03 19:07 
GeneralCComboBox Pin
De Nardis Andrea16-Oct-03 3:29
De Nardis Andrea16-Oct-03 3:29 
GeneralRe: CComboBox Pin
David Crow16-Oct-03 7:07
David Crow16-Oct-03 7:07 
GeneralRe: CComboBox Pin
De Nardis Andrea16-Oct-03 8:04
De Nardis Andrea16-Oct-03 8:04 
Generalbluetooth Pin
da_adel16-Oct-03 3:28
da_adel16-Oct-03 3:28 
Questionhow do i make a bitmap appear on a button when i click on the button Pin
swerajan16-Oct-03 2:51
swerajan16-Oct-03 2:51 
GeneralOwner Drawn CHeaderCtrl Items Pin
Uller16-Oct-03 1:58
Uller16-Oct-03 1:58 
GeneralRe: Owner Drawn CHeaderCtrl Items Pin
Roger Allen16-Oct-03 2:19
Roger Allen16-Oct-03 2:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.