/***************************************************************************//*
* @par Description:
* This function is called by the readRecord function and is used to check the
* birth date field in the record. It calls the function converDate to convert
* the binary record entry to a usuable date. It first checks the month for 
* being between 1 and 12 inclusive. Then it calls the check day function that
* checks the number day based on what the month is. Finally it checks to see 
* if the year is between 1900 and 2013. An invalid month flags errors[7], an 
* invalid day flags errors[8], and an invalid year flags errors[9]. Returns 
* to checkRecord.
*
*
* @param[in] record - a structure that holds a record and its contents.
* @param[in] errors - a boolean array that holds what errors have been found.
*
*
******************************************************************************/
void checkBirthDate ( Record *record, bool errors[] )
{
    int temp1, temp2, temp3;
    convertDate ( temp1, temp2, temp3, record, 1 );
    if ( temp1 < 1 || temp1 > 12 )          //Month
        errors[7] = true;
    checkDay ( temp1, temp2, errors, 0 );   //Day
    if ( temp3 < 1900 || temp3 > 2013 )     //Year
        errors[9] = true;
}
Data::Data(int day,int month,int year)
{
    if (month>0 &&month<13) 
        this->month=month;
    else
        this->month=1;
    this->year=year;
    
    day=checkDay(day);
}
示例#3
0
int checkDate(int year, int month, int day) {
	// 1 ~ 12월 입력했는지 확인
	if (!checkMonth(month)) {
		printf("1 ~ 12월로 입력해주세요.\n");
		return 0;
	} else if (!checkDay(year, month, day)) {
		printf("%d년 %d월 %d일은 존재하지 않습니다.\n", year, month, day);
		return 0;
	}
	return 1;
}
/***************************************************************************//*
* @par Description:
* This function is called by the readRecord function and is used to check the
* License date field in the record. It calls the function converDate to convert
* the binary record entry to a usuable date. It first checks the month for
* being between 1 and 12 inclusive. Then it calls the check day function that
* checks the number day based on what the month is. Finally it checks to see if
* the year is between 1900 and 2013. An invalid month flags errors[10], an
* invalid day flags errors[11], and an invalid year flags errors[12]. Returns
* to checkRecord.
*
*
* @param[in] record - a structure that holds a record and its contents.
* @param[in] errors - a boolean array that holds what errors have been found.
*
*
******************************************************************************/
void checkLicenseDate ( Record *record, bool errors[] )
{
    int temp1, temp2, temp3;
    convertDate ( temp1, temp2, temp3, record, 2 );
    if ( temp1 < 1 || temp1 > 12 )          //Month
        errors[10] = true;
    checkDay ( temp1, temp2, errors, 1 );   //Day
    if ( temp3 < 1900 || temp3 > 2013 )     //Year
    {
        errors[12] = true;
    }
}
示例#5
0
// constructor confirms proper value for month
// utility function checks day to confirm proper
// value for a day
Date::Date(int year, int month, int day)
{
	m_year = {year}; // could validate year

	// validate month
	if (month > 0 && month <= months) {
		m_month = {month};
	}
	else {
		throw std::invalid_argument("month must be 1-12");
	}
	
	// validate day
	m_day = checkDay(day);

	std::cout << "Date object constructor for date ";
	print();
	std::cout << '\n';
}
示例#6
0
bool timedEvent::checkTime() {
	time_t rawTime;
	bool result;
	struct tm *currentTime,*sunTime;
	rawTime = time(NULL);
	int totalMins, totalCheck;
	currentTime = localtime(&rawTime);
	result = checkDay((currentTime->tm_wday + 1),day);
	totalMins = currentTime->tm_hour * 60 + currentTime->tm_min; 
	if(runOnSunset) {
		sunTime = theWeather->getSunSetTime();
		totalCheck = sunTime->tm_hour * 60 + sunTime->tm_min + min;
	} else if(runOnSunrise) {
		sunTime = theWeather->getSunRiseTime();
		totalCheck = sunTime->tm_hour * 60 + sunTime->tm_min + min;
	} else {
		totalCheck = hour * 60 + min;
	}
	result = result && (totalCheck == totalMins);
	return(result);
}
/***************************************************************************//*
* @par Description:
* This function is called by the readRecord function and is used to check the
* expiration date field in the record. It calls the function converDate to
* convert the binary record entry to a usuable date. It first checks the month
* for being between 1 and 12 inclusive. Then it calls the check day function
* that checks the number day based on what the month is. Finally it checks to
* see if the year is between 1900 and 2013. An invalid month flags errors[13],
* an invalid day flags errors[14], and an invalid year flags errors[15]. It
* also checks if the expiration date is after the license date and assigns
* errors[16] accordingly.
*
*
* @param[in] record - a structure that holds a record and its contents.
* @param[in] errors - a boolean array that holds what errors have been found.
*
*
******************************************************************************/
void checkExpirationDate ( Record *record, bool errors[] )
{
    int temp1, temp2, temp3;
    int tempLic1, tempLic2, tempLic3;       //Temp ints for license date
    convertDate ( temp1, temp2, temp3, record, 3 );
    if ( temp1 < 1 || temp1 > 12 )          //Month
        errors[13] = true;
    checkDay ( temp1, temp2, errors, 2 );   //Day
    if ( temp3 < 1900 || temp3 > 2013 )     //Year
    {
        errors[15] = true;
    }
    convertDate ( tempLic1, tempLic2, tempLic3, record, 2 );

    //Check that expiration is after license.
    if ( tempLic3 > temp3 )
        errors[16] = true;
    if ( tempLic3 == temp3 && tempLic1 > temp1 )
        errors[16] = true;
    if ( tempLic3 == temp3 && tempLic1 == temp1 && tempLic2 > temp2 )
        errors[16] = true;
}