I want to find the day of the week of a specific date in Qt. For example: 1/05/2010 - Sunday.
Is it possible to find the day of the week using the date?
QDate date; date.setDate(2010,5,1); int day = date.dayOfWeek(); QString weekDay = QDate::longDayName(day);
This is not verified. But hope it works. Check it out and let me know.
int QDate :: dayOfWeek () const
Returns the day of the week (1 to 7) for this date.
For instance,
QDate date; date.setDate(2010, 5, 1); switch (date.dayOfWeek()) { case 1: // Monday break; // etc... }
I think you need a QDate class and a dayOfWeek function.
int QDate :: dayOfWeek () constReturns the day of the week (1 to 7) for this date.