void Taskmanager::printMenu(Day &day, Day &dDay)
{
	IoHandler ioh;
	while (true)
	{
		try
		{
			printDay(day, dDay);

			string inputData = ioh.inputMenu("날짜 이동(년월일, (다음날)+, (전날)-), D-day 계산(+/- 날짜), 종료(Q) : ");

			if (inputData == "q" || inputData == "Q")
			{
				break;
			}

			int menu = checkInputData(inputData);

			switch (menu)
			{

				//하루이동
			case ONE_DAY_MOVE:
			{
				oneDayMove(day, dDay, inputData);
				break;
			}

			//DDay지정
			case SET_D_DAY:
			{
				setDDay(day, dDay);
				break;
			}

			//지정날짜이동
			case SET_DAY:
			{
				setDay(day, dDay, inputData);
				break;
			}

			default:
			{
				ioh.putMsg("잘못된 기능 입력");
				ioh.putNewLine();
				break;
			}
			}
		}
		catch (string error)
		{
			ioh.putMsg(error);
			ioh.putNewLine();
		}

		ioh.putNewLine();
	}
	ioh.putNewLine();
}
Exemplo n.º 2
0
void SabreController::setAndPrintDay( uint8_t value )
{
	cli();
	// get the maximal number of days in the month
	uint8_t maxValue = DateTime::daysInMonth(Month - 1);
	//// correct it when the year is a leap year
	if (Month == 2)
	{
		if (DateTime::isLeapYear(Year))
		{
			maxValue += 1;
		}
	}
	Helper::SetPointerValue(value, &Day, maxValue, 1);
	
	printDay();
	sei();
}
Exemplo n.º 3
0
void fullMoon()
{
	int Y = 2012;
	int M = 1;
	int D = 1;

	int L = 5;
	int AG;

	int day;

	for (; D <= 31; D++)
	{
		AG = D + M + L;
		if (AG > 30)
			AG -= 30;
		if (AG == 15)
		{
			if (M == 1 || M == 2)
				day = (1 + Month[M] + D - 1) % 7;
			else
				day = (1 + Month[M] + D) % 7;

			printDate(D, M, Y);
			printDay(day);
			printf("\n");
			break;
		}
	}

	int currentDays = D;

	for (int i = 2; i <= 13; i++)
	{
		
		if (i % 2 != 0)
			currentDays += 30;
		else
			currentDays += 29;

		month_day(currentDays);
	}
}
Exemplo n.º 4
0
void month_day(int yearday)
{
	int year = 2012;
	int month, day;
	static int daytab[13] = { 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
	int i;
	for (i = 1; yearday > daytab[i]; i++)
		yearday -= daytab[i];
	month = i;
	day = yearday;

	int dayWeek;
	if (month == 1 || month == 2)
		dayWeek = (1 + Month[month] + day - 1) % 7; //1 - смещение 2012 года, т.к. високосный
	else
		dayWeek = (1 + Month[month] + day) % 7;

	printDate(day, month, year);
	printDay(dayWeek);
	printf("\n");
}
Exemplo n.º 5
0
int main(int argc, char * argv[])
{
    Day d1=Day::Thu;
    Day d2=Day::Fri;
    Day d3=Day::Sun;
    Holiday d4=Holiday::Sat;
    Holiday d5=Holiday::Sun;

    /*    for (int i=5;i<28;i++)
        {
        printDay(d);std::cout << " + " << i <<  " days = ";
    	d2+=i;
    	printDay(d2);
        std::cout << "\n";
        }
    */
//    d=d+1;
    //d--;

    //d+=1;
    if(d1 > d2)
    {
        printDay(d1);
        std::cout << ">";
        printDay(d2);
        std::cout << "\n";
    }
    else
    {
        printDay(d1);
        std::cout << "<";
        printDay(d2);
        std::cout << "\n";
    }
    if(d3!=d4 && d3!=d5)
    {
        printDay(d3);
        std::cout << " is not a holiday\n";
    }
    else if(d3==d4 || d3==d5)
    {
        printDay(d3);
        std::cout << " is a holiday\n";
    }
    else;

    return 0;
}
Exemplo n.º 6
0
//----------------------------------------------------------------------------
// The main program function
//
void calcAndPrint(CalData& cd)
{
    // calc. start and end days
    //
    long jd_start = DateOps::dmyToDay( 1, cd.month, cd.year );
    long jd_end = ( cd.month < 12 ) ?
                  DateOps::dmyToDay( 1, cd.month + 1, cd.year ) :
                  DateOps::dmyToDay( 1, 1, cd.year + 1 );

    int end = int(jd_end - jd_start);

    // fill in data for month in question
    //
    TimePair sunRS[DAYS], moonRS[DAYS], astTwi[DAYS];
    double jd[DAYS];
    static const double hourFraction = 1./24.;

    double tzAdj = (double)cd.loc.timeZone() * hourFraction;
    long dstStart = DateOps::dstStart( cd.year );
    long dstEnd = DateOps::dstEnd( cd.year );

#if defined( PROGRESS_BAR )
    fprintf( stderr, "working" );
#endif

    for( int i=0; i<=end+1; i++ )
    {
        long day = jd_start + i;

        // automatically adjust for DST if enabled
        // This 'rough' method will be off by one on moon rise/set between
        //   midnight and 2:00 on "clock change" days. (sun & astTwi never
        //   occur at these times.)
        //
        double dstAdj =
            ( false == g_ignoreDst && day>=dstStart && day<dstEnd) ?
            hourFraction : 0.;

        jd[i] = (double)day - (tzAdj + dstAdj) - .5;

        // calculate rise/set times for the sun
        RiseSet::getTimes( sunRS[i], RiseSet::SUN, jd[i], cd.loc );

        // calculate rise/set times for Astronomical Twilight
        RiseSet::getTimes( astTwi[i], RiseSet::ASTRONOMICAL_TWI, jd[i], cd.loc );

        // calculate rise/set time for Luna )
        RiseSet::getTimes( moonRS[i], RiseSet::MOON, jd[i], cd.loc );

#if defined( PROGRESS_BAR )
        fputc( '.', stderr );
#endif
    }
    fputc( '\n', stderr );

    printHeading(cd);

    // print data for each day
    //
    char buf[256];
    for( int i=0; i<end; i++ ) {

        if (g_html) {
            if ( !(i&1) )
                fprintf( g_fp, "<TR CLASS=\"bar\">\n  <TD>" );
            else
                fprintf( g_fp, "<TR>\n  <TD>" );
        }

        // print day
        char* p = printDay( buf, jd_start, i, false );

        // print darkest hours
        p = printDarkness(p, i, astTwi, moonRS);

        // check for lunar & solar quarters and DST, print if found
        DST dstDay = DST_NONE;
        if ( dstStart == jd_start+i )
            dstDay = DST_START;
        else if ( dstEnd == jd_start+i )
            dstDay = DST_END;

        p = printEvents(p, i, jd, cd.loc, dstDay);

        // print rise/set times for Luna
        p = printTime( p, moonRS[i].TP_RISE );
        p = printTime( p, moonRS[i].TP_SET );

        // print set time for the sun
        p = printTime( p, sunRS[i].TP_SET );

        // print end of Astronomical Twilight */
        p = printTime( p, astTwi[i].TP_END );

        // next day
        p = printDay( p, jd_start, i+1, i == end-1 );
        if (!g_tabDelimited && !g_html)
            *p++ = ' ';

        // print start of Astronomical Twilight */
        p = printTime( p, astTwi[i+1].TP_START );

        // print rise time for the sun     (last column)
        p = printTime( p, sunRS[i+1].TP_RISE, false );

        if (g_html)
            strcpy( p, "</TD>\n</TR>\n" );
        else {
            *p++ = '\n';
            *p = 0;
        }

        fputs( buf, g_fp );
    }
    if (g_html)
        fputs( "</TABLE>\n</BODY>\n</HTML>\n", g_fp );
}
Exemplo n.º 7
0
void SabreController::setDateCursor( uint8_t value )
{
	cli();
	
	if (this->CursorPosition != 0 && value != 0)
	{
		if (CursorPosition == 1)
		{
			printDay();
		}
		else if (CursorPosition == 2)
		{
			printMonth();
		}
		else
		{
			printYear();
		}
	}
	
	Helper::SetPointerValue(value, &CursorPosition, 3, 0);
	
	if (this->CursorPosition > 0 && this->TimerEnabled == false)
	{
		this->TimerEnabled = true;
		printLockSymbol(0, 1);
		
		//set timer1 interrupt at 1Hz
		startTimer();
	}
	else if (this->CursorPosition == 0 && this->TimerEnabled)
	{
		OLED.write(0x20);
		printPointer();
		stopTimer(); // stop timer
		saveDateTime();
	}

	if (CursorPosition == 1)
	{
		OLED.setCursor(4, 2);
		if (value == 0)
		{
			OLED.write(0x5F);
			OLED.write(0x5F);
		}
	}
	else if (CursorPosition == 2)
	{
		OLED.setCursor(7, 2);
		if (value == 0)
		{
			OLED.write(0x5F);
			OLED.write(0x5F);
		}
	}
	else if (CursorPosition == 3)
	{
		OLED.setCursor(10, 2);
		if (value == 0)
		{
			for (uint8_t i = 0; i < 4; i++)
			{
				OLED.write(0x5F);
			}
		}
	}
	
	sei();
}