// ============================ 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; }