Gets the format of the time is a function of the month of the week

YYYYMMDD format Date dbValueTime value

double $_GetWeekOfMonth(double dbValueTime)
{
int nYear = dbValueTime/10000;
int nMonth = (dbValueTime - nYear*10000)/100;
int nDay = (dbValueTime - nYear*10000 - nMonth * 100);
CTime4 time(nYear,nMonth,nDay,0,0,0);
CTime4 time1(nYear,nMonth,1,0,0,0);
int nDays1 = time1.GetDayOfWeek() - 1;
if (nDays1 == 0)
{
nDays1 = 7;
}
int nOffSet = nDays1 - 7;
double fRet = 0.0f;
if (nDay - 1 + nOffSet <= 0)
{
fRet = 1;
}
else
{
fRet = 1 + ceil(float(nDay - 1 + nOffSet) / 7.0f);
}
return fRet;
}

Guess you like

Origin www.cnblogs.com/zhangbing888823/p/11056679.html