COleDateTime,
Get first day of week, COleDateTimeSpan, VC++
Example
|
|
Using class COleDateTime,
you can obtain the first day of week easily, below is the
VC++ Example source code
for this: // This
method will use COleDateTime
class to obtain the first day of the week. COleDateTime CWeekNumber::FirstDayOfWeek(const
COleDateTime &date, int nWhich)
{
ASSERT((nWhich >= 1) && (nWhich <= 7));
ASSERT(date.GetStatus() == COleDateTime::valid);
COleDateTime dtVal(date);
int nCurDay = dtVal.GetDayOfWeek() - nWhich;
if (nCurDay < 0)
{
nCurDay += 7;
}
if (nCurDay)
{
COleDateTimeSpan ts(nCurDay);
dtVal -= ts;
}
return dtVal;
}
|