forked from janbodnar/Qt5-Code-Examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnofdays.cpp
More file actions
41 lines (35 loc) · 1.2 KB
/
Copy pathnofdays.cpp
File metadata and controls
41 lines (35 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <QTextStream>
#include <QDate>
int main(void) {
QTextStream out(stdout);
QList<QString> months;
months.append("January");
months.append("February");
months.append("March");
months.append("April");
months.append("May");
months.append("June");
months.append("July");
months.append("August");
months.append("September");
months.append("October");
months.append("November");
months.append("December");
QDate dt1 { 2020, 9, 18 };
QDate dt2 { 2020, 2, 11 };
QDate dt3 { 2020, 5, 1 };
QDate dt4 { 2020, 12, 11 };
QDate dt5 { 2020, 2, 29 };
out << "There are " << dt1.daysInMonth() << " days in "
<< months.at(dt1.month()-1) << endl;
out << "There are " << dt2.daysInMonth() << " days in "
<< months.at(dt2.month()-1) << endl;
out << "There are " << dt3.daysInMonth() << " days in "
<< months.at(dt3.month()-1) << endl;
out << "There are " << dt4.daysInMonth() << " days in "
<< months.at(dt4.month()-1) << endl;
out << "There are " << dt5.daysInMonth() << " days in "
<< months.at(dt5.month()-1) << endl;
out << "There are " << dt1.daysInYear() << " days in year "
<< QString::number(dt1.year()) << endl;
}