Click here to Skip to main content
15,925,444 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Fonts and MFC Pin
Rafael Fernández López17-Oct-03 9:59
Rafael Fernández López17-Oct-03 9:59 
GeneralMedia Streaming / QoS Pin
Anonymous16-Oct-03 8:59
Anonymous16-Oct-03 8:59 
GeneralNetworking/Databasing Prog Pin
code_girl16-Oct-03 7:09
susscode_girl16-Oct-03 7:09 
GeneralRe: Networking/Databasing Prog Pin
Michael P Butler16-Oct-03 7:23
Michael P Butler16-Oct-03 7:23 
GeneralRe: Networking/Databasing Prog Pin
script_smiths16-Oct-03 21:54
script_smiths16-Oct-03 21:54 
Generalresizing dialog box to parent client area Pin
b_girl16-Oct-03 5:47
b_girl16-Oct-03 5:47 
GeneralRe: resizing dialog box to parent client area Pin
Terry O'Nolley16-Oct-03 13:36
Terry O'Nolley16-Oct-03 13:36 
GeneralRe: resizing dialog box to parent client area Pin
b_girl17-Oct-03 3:16
b_girl17-Oct-03 3:16 
QuestionName of the '|' key ? Pin
Brian van der Beek16-Oct-03 5:27
Brian van der Beek16-Oct-03 5:27 
AnswerRe: Name of the '|' key ? Pin
antlers16-Oct-03 5:36
antlers16-Oct-03 5:36 
AnswerRe: Name of the '|' key ? Pin
Chris Meech16-Oct-03 5:45
Chris Meech16-Oct-03 5:45 
AnswerRe: Name of the '|' key ? Pin
David Crow16-Oct-03 6:52
David Crow16-Oct-03 6:52 
GeneralRe: Name of the '|' key ? Pin
Anonymous16-Oct-03 7:51
Anonymous16-Oct-03 7:51 
AnswerRe: Name of the '|' key ? Pin
RChin17-Oct-03 6:34
RChin17-Oct-03 6:34 
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 

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.