void Taskmanager::setDay(Day &day, Day &dDay, string inputData)
{
	int size = inputData.size();

	string inputYear = inputData.substr(0, size - 4);
	string inputMonth = inputData.substr(size - 4, 2);
	string inputDate = inputData.substr(size - 2, 2);

	int year = atoi(inputYear.c_str());
	int month = atoi(inputMonth.c_str());
	int date = atoi(inputDate.c_str());

	if (date > day.getLastDay(month) || month > 12)
	{
		string error = "잘못된 날짜 입력";
		throw error;
	}

	day.setDay(year, month, date);

	if (isExistDDay)
	{
		setDDay(day, dDay);
	}
}
예제 #2
0
bool Controller::compareDays( Day first, Day second )
{
	if( weekDays[first.getName().toLower().left(2)] < weekDays[second.getName().toLower().left(2)] )
		return true;
	else
		return false;
}
void Taskmanager::setDDay(Day &day, Day &dDay)
{
	isExistDDay = true;

	dDay.setDay(day.getYear(), day.getMonth(), day.getDate());

	if (oper == '+')
	{
		dDay += difference;
	}
	else
	{
		dDay -= difference;
	}
}
예제 #4
0
파일: Day.hpp 프로젝트: gfannes/gubg.algo
 inline std::vector<Quarter> quarters(Day from, const size_t nr)
 {
     std::vector<Quarter> qs;
     Quarter q;
     while (qs.size() != nr)
     {
         q.insert(from);
         ++from;
         if (from.day() == 1 && (from.month()%3) == 1)
         {
             qs.push_back(q);
             q.clear();
         }
     }
     return qs;
 }
void Taskmanager::initializeDay(Day &day)
{
	time_t timeInfo;

	//struct tm *t;
	struct tm t;

	time(&timeInfo);
	//t = localtime(&timeInfo);
	localtime_s(&t, &timeInfo);

	int year = t.tm_year + 1900;		//1900기준이므로
	int month = t.tm_mon + 1;			//0월부터시작이므로
	int date = t.tm_mday;

	day.setDay(year, month, date);
}
int main()
{

Event breakfast = Event(900,1000,"Breakfast");
Event dinner = Event(1700,1800,"Dinner");
Event lunch = Event(1200,1300,"Lunch");

#ifdef simpleTest
        // simple test program
        // -----
        // /*
        Day *aDay = new Day();
        
        aDay->scheduleEvent(breakfast);
        aDay->scheduleEvent(lunch);
	aDay->scheduleEvent(dinner);
        
        aDay->printDay();
        return 0;
#else
        Event multipleEvents[3];
        multipleEvents[0] = breakfast;
        multipleEvents[1] = lunch;
        multipleEvents[2] = dinner;
        
        // permute all combinations of adding events
        int testCount = 1;
        for (int i=0;i<3;i++){
                for(int j=0;j<3;j++){
                        if (i==j) continue;
                        for(int k=0;k<3;k++){
                                if (i==k || j==k) continue;
                                
                                cout << "Test: " << testCount << " ------------------\n";
                                Day *aDay = new Day();
                                
                                aDay->scheduleEvent(multipleEvents[i]);
                                aDay->scheduleEvent(multipleEvents[j]);
                                aDay->scheduleEvent(multipleEvents[k]);
                                
                                aDay->printDay();
                                cout << "..................\n";
                                cout << "CSV:\n";
                                cout << aDay->exportDay();
                                cout << "..................\n\n";
                                
                                // cancel the lunch event
                                aDay->cancelEvent(multipleEvents[1]);
                                
                                aDay->printDay();
                                cout << "------------------\n\n";
                                delete aDay;
                                testCount++;
                        }
                }
        }
        return 0;
#endif
}
예제 #7
0
파일: huefile.cpp 프로젝트: caomw/sgps
Day HUEFile::read (bool saveData) {

    Options * opt =  Options::Instance();

    Day d;
    fstream stored;

    int col = opt->getColumnNumber();
    if (col > 4)
        column = col;     ////////////GUARDO LA COLUMNA QUE COGERE Y LUEGO USARÉ

    switch (column){	/////////////PONGO EL LIMITE PARA SUNRISE Y SUNSET
        case 4: sslimit = 9;
                break;
        case 5: sslimit = 0.9;
                break;
        case 6: sslimit = 0.3;
                break;
        case 7: sslimit = 0.1; ////NO TIENE UN LIMITE POR ABAJO
                break;
        case 8: sslimit = 0.1;
                break;
        case 9: sslimit = 10;
                break;
        case 10: sslimit = 20;
                break;
        case 11: sslimit = 30;
                break;
        case 12: sslimit = 15;
                break;
        case 13: sslimit = 0.1;
                break;
        case 14: sslimit = 0.1;
                break;
    }

    stored.open(ppath.c_str(), fstream::in);


    if (stored.good()) {
        //TODO: Improve these lines with "getline" command. Much easier to understand.

        float latitude, longitude;
        stored >> longitude >> latitude;
        Coordinates c;
        c.latitude = latitude;
        c.longitude = longitude;
        d.setRealCoordinates(c);


        string s;
        stored >> s;
        d.setStation (s);

        //The file pointer is moved to the day position.
        int day, moth;
        stored>>day>>moth;
        if (moth==3){//Si el mes es 3(marzo), cuento los 28 dias de febrero, y los 31 de enero
            day = day +28+31;
        }
        else if (moth<=7 && moth%2==0 && moth !=2){
            day = day + (moth/2)*31 + (moth/2-1)*30 + 28;//Si el mes es par antes de julio, cuento la mitad de meses 31, febrero con 28, y los demas con 30
        }
        else if (moth>7 && moth%2==0){
            day = day + (moth/2+1)*31 + (moth/2-2)*30 + 28;//Si el mes es par despues de julio, cuento la mitad mas 1 de meses 31(por agosto), febrero con 28, y los demas con 30
        }
        else if (moth<=7 && moth%2!=0 && moth !=1 && moth !=3){
            day = day + (moth/2-1)*30 + (moth/2+1)*31 + 28;
        }
        else if (moth>7 && moth%2!=0){
            day = day + (moth/2-1)*30 + (moth/2+1)*31 + 28;
        }
        else if (moth == 1){
            day = day;
        }
        else if (moth == 2){
            day = day + 31;
        }
        d.setDay(day);


        //The file pointer is moved to the year position.
        int year;
        stored >> year;
        d.setYear(year);


        stored >> elevation;

        float hour, min, seconds, auxvalues, transitions=0;
        float a;

        while(!stored.eof())
        {

            stored >> hour >> min >> seconds;

            hour = hour + min/60;
            hour = hour + seconds/3600;//pass seconds to hours

            times.push_back(hour);


            for (int i=4; i<column; i++){
                stored >> a;
            }

            stored >> auxvalues;
            values.push_back(auxvalues);


            for(int z=column; z<14; z++){
                stored >> a;
            }

        }


        File::setSkipFile(0);
        d.setTransitions(0);
        float sunrise = File::findSunrise(times, values);
        float sunset = File::findSunset(times, values);
        d.setSunrise(sunrise);
        d.setSunset(sunset);

        // Not saved by default (consumes time and a lot of memory).
        if (saveData) {
            d.setTimes (times);
            d.setValues (values);
        }


        if (opt->getConsoleOp() == true || opt->getFileReadedOp() == true){
            Console::validFiles (name, ppath, File::getSkipFile());
        }
        if (opt->getConsoleOp() == true){
            Console::placeInfo(d, values.size());
        }
        if (opt->getLoggerOp() == true){
            Logger::placeInfo(d, values.size());
            Logger::validFiles(name, ppath, File::getSkipFile(), d);//save in a file the number of valid files
        }

        return d;

    }
예제 #8
0
파일: Day.cpp 프로젝트: ajaniv/softwarebook
Integer
Day::daysBetween(const Day& other) const
{
	return abs(getValue() - other.getValue());
}
예제 #9
0
void Controller::notifyDayMenu()
{
	if( currentWeek.isEmpty() )
	{
		return;
	}

	int day = QDate::currentDate().dayOfWeek() - 1;
	if( currentWeek.getDays().size() <= (size_t)day )				// not all days have menus
		return;

	Day currentDay;
	for( int i = 0 ; i < 5 ; i++ )
	{
		QString dayName = currentWeek.getDays()[ i ].getName();
		if( currentWeek.getDays()[ i ].getName().toLower().contains( kDayNames[ day ] ) )
		{
			currentDay = currentWeek.getDays()[ i ];
			break;
		}
	}
	if( currentDay.getDishes().size() == 0  )		// current day doesn't have a menu
		return;

	// ! Only for debug purposes !
	currentDay.getDishes()[0].setUserSelected( true );
	for( size_t i = 1 ; i < currentDay.getDishes().size() ; i++ )
	{
		if( currentDay.getDishes()[i].getCourseNum() != currentDay.getDishes()[0].getCourseNum() )
		{	
			currentDay.getDishes()[i].setUserSelected( true );
			break;
		}
	}

	for( size_t i = 0 ; i < currentDay.getDishes().size() ; i++ )
	{
		if( currentDay.getDishes()[i].getUserSelected() )
		{
			QString todayMenu = "Azi ai:\n" + currentDay.getDishes()[i].getName() + " ( " + currentDay.getDishes()[i].getIdentifier() + " )";

			emit notify( todayMenu, currentDay.getDishes()[i].getPixmap() );
		}
	}
}