本文整理汇总了C++中DateTime::AddDay方法的典型用法代码示例。如果您正苦于以下问题:C++ DateTime::AddDay方法的具体用法?C++ DateTime::AddDay怎么用?C++ DateTime::AddDay使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DateTime
的用法示例。
在下文中一共展示了DateTime::AddDay方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Format
// ============================
bool DateCommand::EvaluateCommand()
// ============================
{
bool bResult = false;
// Initialise the argument value as the argument's literal value.
m_strArgumentValue = m_strArgument;
// Interpret the date-command's parameter.
if ( m_bHasParameter )
{
InterpretParameter();
}
// Determine if the parameter is not empty.
if ( !m_strParameter.empty() )
{
// Determine the format, and check if this operation succeeds.
string strFormat;
if ( DetermineFormat( m_strParameter, strFormat ) )
{
// Initialise the years, months, and days to add to zero.
int nYearsAdd = 0;
int nMonthsAdd = 0;
int nDaysAdd = 0;
// Determine what the values for the years, months, and days to
// add are as specified in the parameter; check if this operation
// succeeds.
if ( DetermineTimeToAdd( m_strParameter, nYearsAdd, nMonthsAdd, nDaysAdd ) )
{
// Create a DateTime object for the current machine date.
DateTime dtNow;
// Add to this date the found years, months, and days.
dtNow.AddYear( nYearsAdd );
dtNow.AddMonth( nMonthsAdd );
dtNow.AddDay( nDaysAdd );
// Format the date-string, and take the result as the
// argument value.
m_strArgumentValue = Format( strFormat, &dtNow );
bResult = true;
}
}
else
{
// The format is missing; notify the parser of this error.
m_pTheParser->NotifyMissingDateFormat();
}
}
else
{
// The format is missing; notify the parser of this error.
m_pTheParser->NotifyMissingDateFormat();
}
return bResult;
}