🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #13975

Re: Set System Date/Time

#13975
From: Mike Shultz
Date: Mon, 01 Sep 2003 10:14
31 lines
1728 bytes
    Thank you. I have one problem. Is this code OK?

bool __fastcall SetSystemNTPTime()
{
  TDateTime dt = GetNTPDateTime();
  SYSTEMTIME st;

  st.wDay    = dt.FormatString("d").ToInt();
  st.wMonth  = dt.FormatString("m").ToInt();
  st.wYear   = dt.FormatString("yyyy").ToInt();
//This line below shows 12
ShowMessage(dt.FormatString("h"));
//This line below sets 14. Why??
  st.wHour   = dt.FormatString("h").ToInt();
  st.wMinute = dt.FormatString("n").ToInt();
  st.wSecond = dt.FormatString("s").ToInt();

  st.wMilliseconds = 0;

  if (!SetSystemTime(&st)) {
    //ShowMessage("BAD");
    return false;
  }

  //ShowMessage("OK");
  return true;
}

    It sets bad hour (see comments in the code). Am I converting int to WORD
incorrectly??
Technical Details
Message-ID: <3f531c07@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-09!supernews.com!newsfeed.news2me.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail
References: <3f530b12$1@newsgroups.borland.com> <3f53139b@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,c8dcc4ffbd3f4cee
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-09-01 03:16:42 PST
From: "Mike Shultz" <no@where.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <3f530b12$1@newsgroups.borland.com> <3f53139b@newsgroups.borland.com>
Subject: Re: Set System Date/Time
Date: Mon, 1 Sep 2003 12:14:22 +0200
Lines: 33
Organization: TNT
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
NNTP-Posting-Host: 193.138.1.66
Message-ID: <3f531c07@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1062411271 193.138.1.66 (1 Sep 2003 03:14:31 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-09!supernews.com!newsfeed.news2me.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail