bool cal2::showtodomark(QDate date) { if(date.year()!=cur_date.year() || date.month()!=cur_date.month()) return false; QDate firstday(date.year(),date.month(),1); labels[date.day()+firstday.dayOfWeek()-1]->btodo->show(); return true; }
void mkmonthr(int y, int m, int jd_flag, struct monthlines *mlines) { struct tm tm; /* for strftime printing local names of * months */ date dt; /* handy date */ int dw; /* width of numbers */ int first; /* first day of month */ int firstm; /* first day of first week of month */ int i, j, k, l; /* just indices */ int last; /* the first day of next month */ int jan1 = 0; /* the first day of this year */ char *ds; /* pointer to day strings (daystr or * jdaystr) */ /* Set name of month. */ memset(&tm, 0, sizeof(tm)); tm.tm_mon = m; wcsftime(mlines->name, sizeof(mlines->name) / sizeof(mlines->name[0]), L"%OB", &tm); mlines->name[0] = towupper(mlines->name[0]); /* * Set first and last to the day number of the first day of this * month and the first day of next month respectively. Set jan1 to * the day number of the first day of this year. */ first = firstday(y, m + 1); if (m == 11) last = firstday(y + 1, 1); else last = firstday(y, m + 2); if (jd_flag) jan1 = firstday(y, 1); /* * Set firstm to the day number of monday of the first week of * this month. (This might be in the last month) */ firstm = first - weekday(first); /* Set ds (daystring) and dw (daywidth) according to the jd_flag. */ if (jd_flag) { ds = jdaystr; dw = 4; } else { ds = daystr; dw = 3; } /* * Fill the lines with day of month or day of year (julian day) * line index: i, each line is one weekday. column index: j, each * column is one day number. print column index: k. */ for (i = 0; i != 7; i++) { l = 0; for (j = firstm + i, k = 0; j < last; j += 7, k += dw) { if (j >= first) { if (jd_flag) dt.d = j - jan1 + 1; else sdater(j, &dt); if (j == highlightdate && !flag_nohighlight && isatty(STDOUT_FILENO)) highlight(mlines->lines[i] + k, ds + dt.d * dw, dw, &l); else memcpy(mlines->lines[i] + k + l, ds + dt.d * dw, dw); } else memcpy(mlines->lines[i] + k + l, " ", dw); } mlines->lines[i][k + l] = '\0'; mlines->extralen[i] = l; } /* fill the weeknumbers. */ if (flag_weeks) { for (j = firstm, k = 0; j < last; k += dw, j += 7) if (j <= nswitch) memset(mlines->weeks + k, ' ', dw); else memcpy(mlines->weeks + k, ds + week(j, &i)*dw, dw); mlines->weeks[k] = '\0'; } }