void AgendaView::backMonthPressed() { setCurrentMonth(currentMonth() == AgendaView::Jan ? AgendaView::Dec : (Month)(currentMonth() - 1)); m_monthLabel->setText(months[currentMonth()].toUpper()); m_monthLabel->repaint(); }
void AgendaView::forwardMonthPressed() { setCurrentMonth(currentMonth() == AgendaView::Dec ? AgendaView::Jan : (Month)(currentMonth() + 1)); m_monthLabel->setText(months[currentMonth()].toUpper()); m_monthLabel->repaint(); }
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; } }
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; }
void CalendarModel::updateWeekDaysArray() { // Find first day of week for current year/month QDate date(m_current_year, m_current_month, 1); int first_day_of_week = date.dayOfWeek(); date = date.addDays( - first_day_of_week + (m_first_day_of_week - 1) % DAYS + 1); if (date.month() == currentMonth()) date = date.addDays(-DAYS); for(int i=0; i<WEEKS; i++){ // Weeks for(int j=0; j<DAYS; j++) { // Days m_week_days[i][j] = date; date = date.addDays(1); } } reset(); }
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(); }
WWidget* WCalendar::renderCell(WWidget* widget, const WDate& date) { WText* t = dynamic_cast<WText*>(widget); if (!t) { t = new WText(); t->setInline(false); t->setTextFormat(PlainText); } #ifndef WT_TARGET_JAVA char buf[30]; #else char *buf; #endif // WT_TARGET_JAVA Utils::itoa(date.day(), buf); t->setText(WString::fromUTF8(buf)); std::string styleClass; if (isInvalid(date)) styleClass += " Wt-cal-oor"; else if (date.month() != currentMonth()) styleClass += " Wt-cal-oom"; if (isSelected(date)) styleClass += " Wt-cal-sel"; WDate currentDate = WDate::currentDate(); if (date.day() == currentDate.day() && date.month() == currentDate.month() && date.year() == currentDate.year()) { if (!isSelected(date)) styleClass += " Wt-cal-now"; t->setToolTip(WString::tr("Wt.WCalendar.today")); } else t->setToolTip(""); t->setStyleClass(styleClass.c_str()); return t; }
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; }
AgendaView::AgendaView(QWidget *parent) :SIView(parent) { const QDateTime &dateTime = QDateTime::currentDateTime(); setCurrentMonth((Month)(dateTime.date().month() - 1)); setObjectName(QString().sprintf("AgendaView%p", parent)); QWidget *centralWidget = new QWidget(this); centralWidget->setObjectName(QString().sprintf("%p", centralWidget)); resize(QApplication::desktop()->width(), 436); setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); setMinimumWidth(QApplication::desktop()->width()); setMinimumHeight(436); centralWidget->setStyleSheet(QString("QWidget#%1 { background-image: url(:/images/res/fondo_base.png); }").arg(centralWidget->objectName())); //centralWidget->setStyleSheet(QString("QWidget#%1 { background-image: url(:/images/res/screens/agenda.png); }").arg(centralWidget->objectName())); centralWidget->resize(size()); centralWidget->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); centralWidget->setMinimumWidth(QApplication::desktop()->width()); centralWidget->setMinimumHeight(436); m_monthLabel = new QLabel(centralWidget); m_monthLabel->setObjectName(QString().sprintf("monthLabel%p", m_monthLabel)); m_monthLabel->setGeometry(QRect(0, 19, 360, 20)); m_monthLabel->setStyleSheet(QString::fromUtf8("QLabel#%1 { font: 75 20px \"AvantGardeMdITCTT\"; color: rgb(222,222,222) }").arg(m_monthLabel->objectName())); m_monthLabel->setWordWrap(false); m_monthLabel->setAlignment(Qt::AlignVCenter|Qt::AlignHCenter); m_monthLabel->setText(months[currentMonth()].toUpper()); QPushButton *buttonLeft = new QPushButton(centralWidget); buttonLeft->setObjectName("buttonLeft"); buttonLeft->setGeometry(0, 0, 54, 54); buttonLeft->setText(""); buttonLeft->setFlat(true); buttonLeft->setStyleSheet(QString("QPushButton#buttonLeft { background-color: rgba(255,0,0,0); color: rgb(222, 222, 222); font: 75 20px \"AvantGardeMdITCTT\"; }")); connect(buttonLeft, SIGNAL(clicked()), this, SLOT(backMonthPressed())); QPushButton *buttonRight = new QPushButton(centralWidget); buttonRight->setObjectName("buttonRight"); buttonRight->setGeometry(306, 0, 54, 54); buttonRight->setText(""); buttonRight->setFlat(true); buttonRight->setStyleSheet(QString("QPushButton#buttonRight { background-color: rgba(255,0,0,0); color: rgb(222, 222, 222); font: 75 20px \"AvantGardeMdITCTT\"; }")); connect(buttonRight, SIGNAL(clicked()), this, SLOT(forwardMonthPressed())); m_calendarWidget = new CustomCalendarWidget(centralWidget); m_calendarWidget->setObjectName(QString::fromUtf8("calendarWidget")); m_calendarWidget->setGeometry(QRect(5, 20, 350, 325)); m_calendarWidget->setGridVisible(false); m_calendarWidget->setSelectionMode(QCalendarWidget::SingleSelection); m_calendarWidget->setVerticalHeaderFormat(QCalendarWidget::NoVerticalHeader); m_calendarWidget->setHorizontalHeaderFormat(QCalendarWidget::ShortDayNames); m_calendarWidget->setNavigationBarVisible(true); m_calendarWidget->setDateEditEnabled(false); m_calendarWidget->setLocale(QLocale(QLocale::Spanish, QLocale::Argentina)); m_calendarWidget->setAutoFillBackground(false); m_calendarWidget->setStyleSheet(QString("CustomCalendarWidget#calendarWidget { background-color: rgba(0,255,0,0); alternate-background-color: rgba(255, 255, 0, 0); selection-color: rgb(255, 255, 0); font: 75 20px \"AvantGardeMdITCTT\"; }")); QTextCharFormat format; format.setForeground(QColor(190,190,190)); format.setBackground(QColor(255,0,0,0)); format.setFontCapitalization(QFont::AllLowercase); m_calendarWidget->setHeaderTextFormat(format); format.setForeground(QColor(150,150,150)); format.setBackground(QColor(255,0,0,0)); format.setFontPointSize(6); m_calendarWidget->setWeekdayTextFormat(Qt::Monday, format); m_calendarWidget->setWeekdayTextFormat(Qt::Tuesday, format); m_calendarWidget->setWeekdayTextFormat(Qt::Wednesday, format); m_calendarWidget->setWeekdayTextFormat(Qt::Thursday, format); m_calendarWidget->setWeekdayTextFormat(Qt::Friday, format); m_calendarWidget->setWeekdayTextFormat(Qt::Saturday, format); m_calendarWidget->setWeekdayTextFormat(Qt::Sunday, format); m_calendarWidget->setDateList(&GlobalDataObject::instance().datesExercisedList()); connect(m_calendarWidget, SIGNAL(clicked(QDate)), this, SLOT(dateSelected(QDate))); QWidget *labelTip = new QWidget(centralWidget); labelTip->setObjectName(QString().sprintf("labelTip%p", labelTip)); labelTip->setGeometry(0, 375, 264, 26); labelTip->setStyleSheet(QString("QWidget#%1 { image: url(:/images/res/agenda_tip.png); }").arg(labelTip->objectName())); labelTip->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); }