Article View: borland.public.cppbuilder.nativeapi
Article #2282Re: NetRemoteTOD to Get Server Time
From: D Ray
Date: Tue, 20 Mar 2007 05:23
Date: Tue, 20 Mar 2007 05:23
50 lines
2697 bytes
2697 bytes
Not sure, but it looks like this works (still have some testing to do)
-- RetVal is a struct containing the result of the call to NetRemoteTOD
-- thanks for your replies...
DR
=====================================================================
TIME_ZONE_INFORMATION tzi;
DWORD TZStatus = GetTimeZoneInformation (&tzi);
//
// figure out whether there is a DST bias or not
//
long DSTBias = 0;
if (TZStatus == TIME_ZONE_ID_DAYLIGHT)
DSTBias = tzi.DaylightBias;
else
DSTBias = 0L;
//
// compute local hours
//
long LocalHours = RetVal.CurrentHour - (tzi.Bias/60) -
(DSTBias/60);
//
// if LocalHours is negative, we will have to add 23 to it --
and if we
// do that, we'll have to reduce the day by one. But this
is easier
// done after the date has been encoded as a TDateTime
//
bool DecrementDay = false;
if (LocalHours < 0)
{
LocalHours += 23;
DecrementDay = true;
}
//
// compute the combined regular time and DST bias
//
Bias = LocalHours - RetVal.CurrentHour;
T = EncodeDateTime (RetVal.CurrentYear, RetVal.CurrentMonth,
RetVal.CurrentDay,
LocalHours, RetVal.CurrentMins,
RetVal.CurrentSecs, 0);
if (DecrementDay)
T = IncDay (T, -1);
return;
Technical Details
Message-ID:
<45ff6f48$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<45fc2a82@newsgroups.borland.com> <esiov2t822j0k56pg1ke5ekulrcl3tiqfv@4ax.com> <45feb217@newsgroups.borland.com> <98gtv2p5l749u2k4vd19ta7k0snnlu2ub3@4ax.com> <45fee40d@newsgroups.borland.com> <d9juv2l837qjqg5h6hlqouhocronuqj4ju@4ax.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,9a57de6d3de75d9f X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit Date: Tue, 20 Mar 2007 00:23:17 -0500 From: D Ray <david@timecalc.com> User-Agent: Thunderbird 1.5.0.10 (Windows/20070221) MIME-Version: 1.0 Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: NetRemoteTOD to Get Server Time References: <45fc2a82@newsgroups.borland.com> <esiov2t822j0k56pg1ke5ekulrcl3tiqfv@4ax.com> <45feb217@newsgroups.borland.com> <98gtv2p5l749u2k4vd19ta7k0snnlu2ub3@4ax.com> <45fee40d@newsgroups.borland.com> <d9juv2l837qjqg5h6hlqouhocronuqj4ju@4ax.com> In-Reply-To: <d9juv2l837qjqg5h6hlqouhocronuqj4ju@4ax.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 206.255.70.144 Message-ID: <45ff6f48$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1174368072 206.255.70.144 (19 Mar 2007 22:21:12 -0800) Lines: 50 Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail