wxWidgets中wxDateTime与wxString的互操作

void datetest()
 {
 wxDateTime now=wxDateTime::Now();
 wxString date1=now.Format();
 wxString date2=now.Format(wxT("%X"));
 wxString date3=now.Format(wxT("%x"));
 
 //下面代码只显示日期部分
 cout<<"wxDateTime now=wxDateTime::Now():"<<wxDateTime::Now().FormatDate()<<endl;
 cout<<"now.Format():"<<date1<<endl;//日期时间
 cout<<"now.Format(wxT(\"%X\")):"<<date2<<endl;//时间
 cout<<"now.Format(wxT(\"%x\")):"<<date3<<endl;//日期
 
 //有趣的ParseDateTime()
 cout<<"\n\nwxDateTime::ParseDateTime():"<<endl;
 
 //tomorrow 是什么日子?
 cout<<"tomorrow:"<<endl;
 wxDateTime tomorrow;
 tomorrow.ParseDateTime(wxT("tomorrow 11:00am"));
 cout<<"Tomorrow is "<<tomorrow.Format()<<endl;
 
 //五一又是什么日子?
 cout<<"The Labor Day test:"<<endl;
 wxDateTime laborday;
 laborday.ParseDate(wxT("May 1st"));
 cout<<"The Labor Day is "<<laborday.Format()<<endl;
 
 //至于wxDateSpan,用法非常直白,仅举一例,顺便一提Format的另一种格式:
 wxDateSpan span(0,1);
 wxDateTime then=now.Add(span);
 cout<<then.Format(wxT("%B %d %Y"))<<endl;
 
 }


你可能感兴趣的:(wxWidgets中wxDateTime与wxString的互操作)