1,317
社区成员
发帖
与我相关
我的任务
分享
void __fastcall TForm1::Button1Click(TObject *Sender)
{
TStringStream *stream= new TStringStream(NULL);
TIdHTTP *http=new TIdHTTP(NULL);
http->Get("http://www.beijing-time.org/time15.asp", stream);
String dtstr=stream->DataString,dt0,dt;
int p1,p2;
p1=dtstr.Pos(";");
dtstr=dtstr.SubString(p1+1,200);
for(int i=0;i<7;i++)
{
p1=dtstr.Pos("=");
p2=dtstr.Pos(";");
dt0=dtstr.SubString(p1+1,p2-p1-1);
dtstr=dtstr.SubString(p2+1,200);
if(i!=3)
dt+=dt0;
if(i<2)
dt=dt+"-";
if(i==2)
dt+=" ";
if(i>3 && i<6)
dt+=":";
}
TDateTime datetime=StrToDateTime(dt);
ShowMessage(datetime);
delete stream,http;
}
void __fastcall TForm6::Button1Click(TObject *Sender)
{
TStringStream *stream;
stream = new TStringStream();
this->IdHTTP1->Get("http://www.beijing-time.org/time15.asp", stream);
this->Caption = stream->Size;
Memo1->Text = stream->DataString;
delete stream;
}