Exemplo n.º 1
0
/* increment the hours on the DS3231M Clock */
void inc_Days(void) {
    byte day, month, year, lim;
    year = get_Year();
    month = get_Month();
    day = bcd_To_Byte(get_Day());
    if (month % 2)
        lim = 31;
    else {
        if (month == 2) {
            if (year % 4) lim = 28;
            else lim = 29;
        } else {
            lim = 30;
        }
    }
    if (day < lim) day++;
    else day = 1;
    set_Days(byte_To_BCD(day));
}
Exemplo n.º 2
0
void Value_date_imp::Increment( void ) 
{
	// Used in tests only so make it just for our datetime parser be happy.

	if( mValue == 0 )
	{
		Init();
		return;
	}


	vuint16 day = get_Day();
	vuint16 month = get_Month();
	vint32 year = get_Year();

	if( day < 31 )
	{
		put_Day( ++day );
	}
	else if( month < 12 )
	{	
		put_Day( 1 );
		put_Month( ++month );
	}
	else if( year < 9999 )
	{		
		put_Day(1);
		put_Month(1);
		put_Year( ++year );
	}
	else
	{
		// no nore date which makes parser happy. Actually we rarelly get here.
		Init();
	}
}
Exemplo n.º 3
0
void Value_datetime_imp::Increment( void ) 
{
	// Used in tests only so make it just for our datetime parser be happy.
	if( mValue == 0 )
	{
		Init();
		return;
	}

	vuint16 day = get_Day();
	vuint16 month = get_Month();
	vint32 year = get_Year();
	vuint16 hours = get_Hours();
	vuint16 minutes = get_Minutes();
	vuint16 seconds = get_Seconds();
	vuint16 ms = get_Milliseconds();

	if( ms < 999 )
	{
		put_Milliseconds( ++ms );
	}
	else if( seconds < 59 )
	{
		put_Milliseconds(1);
		put_Seconds( ++seconds );
	}
	else if( minutes < 59 )
	{
		put_Milliseconds(1);
		put_Seconds(0);
		put_Minutes( ++minutes );
	}
	else if( hours < 24 )
	{
		put_Milliseconds(1);
		put_Seconds(0);
		put_Minutes(0);
		put_Hours( ++hours );
	}
	else
	{
		// no nore time which makes parser happy. Actually we rarelly get here.

		if( day < 31 )
		{
			put_Day( ++day );
		}
		else if( month < 12 )
		{	
			put_Day( 1 );
			put_Month( ++month );
		}
		else if( year < 9999 )
		{		
			put_Day(1);
			put_Month(1);
			put_Year( ++year );
		}
		else
		{
			// no nore date which makes parser happy. Actually we rarelly get here.
			Init();
		}
	}
}