예제 #1
0
void Store::markTasksOverdue() {

	string todayDay = currentDay();
	string todayMonth = currentMonth();
	string todayYear = currentYear();
	string taskDate;

	for(int i = 0; i < taskList.size(); i++) {

		string conjoint = todayYear + todayMonth + todayDay; 
		if(!taskList[i].endDate.empty()) {
			taskDate = taskList[i].endDate;
		} else {
			taskDate = taskList[i].startDate;
		}

		if(taskDate.size() == 8 && taskDate < conjoint && taskList[i].isDone ==  false) {
			taskList[i].isRed = true; 
		}

		else
			taskList[i].isRed = false;
	}

}
예제 #2
0
int main() {
    struct date d;
    int N;

    printf("Enter a date: ");
    scanf("%d-%d-%d", &d.year, &d.month, &d.day);

    if (!validate(d)) {
        printf("\nInvalid date");
        return 0;
    }

    printf("\n\nYear: %d", currentYear(d));
    printf("\n\nPrevious year: %d", previousYear(d));

    printf("\n\nMonth: %d", currentMonth(d));
    printf("\n\nMonth name: %s", monthName(d));
    printf("\n\nPrevious month name: %s", prevMonthName(d));

    printf("\n\nDay: %d", currentDay(d));
    printf("\n\nDay name: %s", dayOfWeek(d));
    printf("\n\nDay index: %d", dayIndex(d));


    printf("\n\nDATE BEFORE N DAYS: ");
    printf("\nEnter value for N: ");
    scanf("%d", &N);
    if (N < 0) {
        return 0;
    }
    struct date before = dateBeforeNDays(d, N);
    printf("\nDate before N days: %04d-%02d-%02d", before.year, before.month, before.day);


    printf("\n\nDAYS BETWEEN DATES: ");
    printf("\nEnter another date: ");
    struct date d1;
    scanf("%d-%d-%d", &d1.year, &d1.month, &d1.day);
    if (!validate(d1)) {
        printf("\nInvalid date");
        return 0;
    }
    printf("\nDays between dates: %d days", daysBetweenDates(d, d1));

    printf("\n");

    return 0;
}
예제 #3
0
void Store::markTasksDueToday() {
	log.log("Store: changing due status");

	string todayDay = currentDay();
	string todayMonth = currentMonth();
	string todayYear = currentYear();


	for(int i = 0; i <  taskList.size(); i++) {

		if(getDay(i) == todayDay  && getMonth(i) == todayMonth && getYear(i) == todayYear) {
			taskList[i].isBold = true;
		}
		else {
			taskList[i].isBold = false;
		}
	}

	markTasksOverdue();
}
예제 #4
0
vector<string> Store::getDateTomorrow() {

	string todayDay = currentDay();
	string todayMonth = currentMonth();
	string todayYear = currentYear();

	if (todayDay[0] == 0)
        todayDay = todayDay[1];
	if (todayMonth[0] == 0)
        todayMonth = todayMonth[1];

	int days[] = {31,28,31,30,31,30,31,31,30,31,30,31};

	int valueDay = atoi(todayDay.c_str());
	int valueMonth = atoi(todayMonth.c_str());
	int valueYear = atoi(todayYear.c_str());

	valueDay++;

	if ( valueDay > days[valueMonth-1]){
		
		valueDay = 1;
		valueMonth++;

		if ( valueMonth > 12 ) {

			valueYear++; 
			valueMonth=1;
		}
	 }

	// stream used for the conversion
	ostringstream convert1;   

	convert1 << valueDay;

	string tomorrowDay = convert1.str();

	if(tomorrowDay.length() == 1)
		tomorrowDay.insert(0, "0");
	
	ostringstream convert2;

	convert2 << valueMonth;

	string tomorrowMonth = convert2.str();

	if (tomorrowMonth.length() == 1)
        tomorrowMonth.insert(0, "0");

	ostringstream convert3;

	convert3 << valueYear;

	string tomorrowYear = convert3.str();

	vector<string> returnedVector;

	returnedVector.push_back(tomorrowDay);
	returnedVector.push_back(tomorrowMonth);
	returnedVector.push_back(tomorrowYear);

	return returnedVector;
}