From: Jimbo on
Hi

I am trying to write a function that finds whats the time is in a
specific city.

I have written some code that simple alters the System Time to get the
local time by simple adding the cities bias time(+/- x hours) to the
universal system time. But this causes some problems & doesn't
compensate for daylight savings.

[b]Does anyone know of a Win32 function that can help me get the time
of a specific city?[/b] For example I need to find the time in New
York, London, Sydney etc.

Existing code:
[source lang="cpp"]
string controller::localTime()
{
// Post: Returns focus cities local time

SYSTEMTIME lt;

GetSystemTime(<);
// convert Universal time to focusCity time
int hour = lt.wHour+focusCity->hrBias;
int minute = lt.wMinute+focusCity->minBias;

// convert time from int to string
stringstream out;

// if hour is negative num
if (hour <= 0) {
out << (hour+12);
}
else if (hour < 12) { // && hour > 0
out << "0" << hour;
}
else if (hour > 12) {
out << (hour-12);
}
else out << hour; // hour = 12pm

if (lt.wMinute < 10) {
out << ":0" << lt.wMinute;
}
else out << ":" << lt.wMinute;

string localT = " Local Time = "+out.str();
out.str(""); // clear stringstream

return localT;
}

[/source]
From: Christian ASTOR on
On 17 jan, 04:11, Jimbo <nill...(a)yahoo.com> wrote:

> I am trying to write a function that finds whats the time is in a
> specific city.

SystemTimeToTzSpecificLocalTime()