Website Summary Files Commits Branches @commit @diff @stats
path: root / Week02 / Exercise01 / date.cpp
blob: ffc051e39ea64e8c108ac908f5a6fdf49485d613 (plain) (blame)
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
#include <iostream>
#include "date.h"

const char* monthName(unsigned month) {
	switch (month) {
		case  1: return "Jan";
		case  2: return "Feb";
		case  3: return "Mar";
		case  4: return "Apr";
		case  5: return "May";
		case  6: return "Jun";
		case  7: return "Jul";
		case  8: return "Aug";
		case  9: return "Sep";
		case 10: return "Oct";
		case 11: return "Nov";
		case 12: return "Dec";

		default: return nullptr;
	}
}

void printDate(const Date& d) {
	std::cout << d.day << '/' << monthName(d.month) << '/' << d.year;
}

Date readDate() {
	Date d;
	std::cin >> d.day >> d.month >> d.year;
	return d;
}