/* Main program */ void main() { // testar monthName() for (int i = 1; i < 13; i++) { printf("%s \n", monthName(i)); } printf("\n"); // testar isLeapYear() for (int i = 2000; i < 2010; i++) printf("%d is leap year? %d\n", i, isLeapYear(i)); printf("\n"); // testar monthDays() for (int i = 2000; i < 2010; i++) printf("There are %d days in februari %d\n",monthDays(2, i), i); printf("\n"); printf("There are %d days in december 2015", monthDays(12,2015)); printf("\n\n"); // testar firstDayOfMonth() och dayName() for (int i = 1; i < 13; i++) printf("The first day in %s is %s.\n", monthName(i), dayName(firstDayOfMonth(i, 2015))); printf("\n"); system("pause"); }
QString KCalendarSystem::monthName( const QDate &date, MonthNameFormat format ) const { if ( isValid( date ) ) { return monthName( month( date ), year( date ), format ); } return QString(); }
int main(void) { enum month aMonth; printf ("Enter month number: "); scanf ("%i", &aMonth); //printf ("%s\n", months[aMonth]); printf ("%s\n", monthName(aMonth)); return 0; }
QString QDate::toString() const { int y, m, d; jul2greg( jd, y, m, d ); QString buf = dayName(dayOfWeek()); buf += ' '; buf += monthName(m); QString t; t.sprintf( " %d %d", d, y); buf += t; return buf; }
std::string DateTime::toString() { std::stringstream ss; ss << year << " " << monthName(month) << " " << day << " (" << weekDayName(weekday) << ") " << hour << ":"; if(minute < 10) ss << "0"; ss << minute; return ss.str(); }
int main(){ char * monad = monthName(4); printf("%s", monad); //int leapyear = isLeapYear(1990); //printf("%d", leapyear); //system("pause"); char *svar = weekday(0); printf("%s", svar); system("pause"); }
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; }
QString AsemanCalendarConverterCore::paperString(const QDateTime &d, const QString &format) { const DateProperty & dp = getDate(d.date()); QString res = format; res.replace("HH", QString::number(d.time().hour()).rightJustified(2,'0')); res.replace("hh", QString::number(d.time().hour()%12).rightJustified(2,'0')); res.replace("H", QString::number(d.time().hour())); res.replace("h", QString::number(d.time().hour()%12)); res.replace("mm", QString::number(d.time().minute()).rightJustified(2,'0')); res.replace("m", QString::number(d.time().minute())); res.replace("ss", QString::number(d.time().second()).rightJustified(2,'0')); res.replace("s", QString::number(d.time().second())); res.replace("yyyy", QString::number(dp.year)); res.replace("yy", QString::number(dp.year).right(2)); res.replace("dddd", dayName(dp.day_of_week)); res.replace("MMMM", monthName(dp.month)); res.replace("dd", QString::number(dp.day).rightJustified(2,'0')); res.replace("MM", QString::number(dp.month).rightJustified(2,'0')); return res; }
unsigned int Date::monthDays(unsigned int month, unsigned int year) { if (month < 1 || month > 12) { return 0; } unsigned int days = 0; std::string currentMonth = monthName(month); if (currentMonth == monthName(2))//check if this is February { days = leapYear(year)?FEB_LEAP:FEB_NOT_LEAP; } else if (currentMonth == monthName(4) || currentMonth == monthName(6) || currentMonth == monthName(9) || currentMonth == monthName(11)) //30 days months { days = 30; } else { days = 31; } return days; }
// ### Fixme TQString KCalendarSystemHebrew::monthNamePossessive(int month, int year, bool shortName) const { return "of " + monthName(month, year, shortName); }
// Ok TQString KCalendarSystemHebrew::monthName(const TQDate& date, bool shortName) const { return monthName(month(date), year(date), shortName); }
const char* MSMBSDate::nameOfMonth(void) const { return monthName(month());}
QString AsemanCalendarConverterCore::historyString(const QDate &d) { const DateProperty & dp = getDate(d); QString res = QString("%1 %2 %3 - %4").arg(dp.year).arg(monthName(dp.month)).arg(dp.day).arg(dayName(dp.day_of_week)); return res; }
QString AsemanCalendarConverterCore::littleString(const QDate &d) { const DateProperty & dp = getDate(d); QString res = QString("%1 %2 %3").arg(dp.day).arg(monthName(dp.month)).arg(dp.year); return res; }
QString AsemanCalendarConverterCore::paperString(const QDateTime &dt) { const DateProperty & dp = getDate(dt.date()); QString res = QString("%1, %2 %3 %4, %5").arg(dayName(dp.day_of_week)).arg(dp.day).arg(monthName(dp.month)).arg(dp.year).arg(dt.time().toString("hh:mm")); return res; }