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 42 43 44 45
|
#include <vector>
#include <cmath>
#include <string>
#include <iostream>
#include <stdexcept>
#include <limits>
namespace Chrono {
enum class Month {
jan=1, feb,mar,apr,may,jun,jul,aug,sep,oct,nov,dec
};
class Date {
public:
class Invalid{};
Date(int y, Month m, int d);
int day() const { return d; }
Month month() const { return m; }
int year() const { return y; }
void add_day(int n);
void add_month(int n);
void add_year(int n);
private:
int y;
Month m;
int d;
};
bool is_date(int y, Month m, int d);
bool leapyear(int y);
bool operator==(const Date& a, const Date& b);
bool operator!=(const Date& a, const Date& b);
std::ostream& operator<<(std::ostream& os, const Date& d);
std::istream& operator>>(std::istream& is, Date& dd);
int day_of_week(const Date& d);
Date next_Sunday(const Date d);
Date next_weekday(const Date& d);
}
|