现在的位置: 首页 > 综合 > 正文

指定月的第一天和最后一天

2018年02月12日 ⁄ 综合 ⁄ 共 367字 ⁄ 字号 评论关闭

int nYear,nMon,nDay,nMinute,nSec;
 CTime tm = CTime::GetCurrentTime();
 CTime tmStart(tm.GetYear(), tm.GetMonth(), 1, 0, 0, 0);
 nYear = tm.GetYear();
 nMon = tm.GetMonth();
 if(nMon == 12)
 {
  nYear = nYear+1;
  nMon = 1;
 }
 else
 {
  nMon = nMon+1;
 }
 CTime tmNext(nYear, nMon, 1, 11, 59, 59);
 CTimeSpan ts(1,0,0,0);
 CTime tmEnd = tmNext-ts;
 nYear = tmEnd.GetYear();
 nMon = tmEnd.GetMonth();
 nDay = tmEnd.GetDay();

抱歉!评论已关闭.