2021-10-27 15:15:47 +02:00
|
|
|
#ifndef DATE_H
|
|
|
|
#define DATE_H
|
|
|
|
|
2024-12-11 15:54:56 +01:00
|
|
|
#include <iostream>
|
|
|
|
|
2021-10-27 15:15:47 +02:00
|
|
|
class Date {
|
|
|
|
public:
|
2024-12-11 15:54:56 +01:00
|
|
|
Date(); // dagens datum
|
|
|
|
Date(int y, int m, int d); // yyyy-mm-dd
|
|
|
|
int getYear() const; // returnerar året
|
|
|
|
int getMonth() const; // returnerar månaden
|
|
|
|
int getDay() const; // returnerar dagen
|
|
|
|
void next(); // går till nästa dag
|
|
|
|
|
|
|
|
// Overloaded operators
|
|
|
|
friend std::ostream& operator<<(std::ostream& os, const Date& date);
|
|
|
|
friend std::istream& operator>>(std::istream& is, Date& date);
|
|
|
|
|
2021-10-27 15:15:47 +02:00
|
|
|
private:
|
2024-12-11 15:54:56 +01:00
|
|
|
int year; // året (fyra siffror)
|
|
|
|
int month; // månaden (1-12)
|
|
|
|
int day; // dagen (1-...)
|
|
|
|
static int daysPerMonth[12]; // antal dagar i varje månad
|
|
|
|
static bool isLeapYear(int year); // kontrollera skottår
|
2021-10-27 15:15:47 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|