Creating Custom Calendar with Jambi

59 views Asked by At

When making customize calendar, how can I set a date and get the total days of that month? Or even get the week day of that specific date? Like April is 30 Days, May is 31 days, February every 4 years is 29 days and week days are different every year.

I'm using Jambi (Qt 4.7 in java) and I want to make calendar with few QComboBox, and I use QDate to get the current date like so:

//return current year
QDate.currentDate().year();

//return total days in current month
QDate.currentDate().daysInMonth();

//return current month
QDate.currentDate().month();

//return current day in month
QDate.currentDate().day();

//return current day in week
QDate.currentDate().dayOfWeek();

The thing is that what I'm getting is current information.

  1. How can I ask like in year 2020, month February, how many days are in there?
  2. And 10th, February, 2020 is which day in week?

I looked into QData documentation, I couldn't find any option to set date so i can get info from it, any ideas?

1

There are 1 answers

3
Smar On BEST ANSWER

Just use the constructor to pass the date you want?

For example:

QDate date = new QDate(202, 2, 1);
date.daysInMonth();