//: C02:Date.h
// From "Thinking in C++, Volume 2", by Bruce Eckel & Chuck Allison.
// (c) 1995-2004 MindView, Inc. All Rights Reserved.
// See source code use permissions stated in the file 'License.txt',
// distributed with the code package available at www.MindView.net.
#ifndef DATE_H
#define DATE_H
#include <string>
#include <stdexcept>
#include <iosfwd>

class Datum {
  int year, month, day;
  int compare(const Datum&) const;
  static int daysInPrevMonth(int year, int mon);
public:
  // Třída pro výpočet data
  struct Trvani {
    int roky, mesice, dny;
    Trvani(int y, int m, int d)
    : roky(y), mesice(m) ,dny(d) {}
  };
  // Třída výjimky
  struct DateError : public std::logic_error {
    DateError(const std::string& msg = "")
      : std::logic_error(msg) {}
  };
  Datum();
  Datum(int, int, int) throw(DateError);
  Datum(const std::string&) throw(DateError);
  int getRok() const;
  int getMesic() const;
  int getDen() const;
  std::string toString() const;
  friend Trvani trvani(const Datum&, const Datum&);
  friend bool operator<(const Datum&, const Datum&);
  friend bool operator<=(const Datum&, const Datum&);
  friend bool operator>(const Datum&, const Datum&);
  friend bool operator>=(const Datum&, const Datum&);
  friend bool operator==(const Datum&, const Datum&);
  friend bool operator!=(const Datum&, const Datum&);
  friend std::ostream& operator<<(std::ostream&,
                                  const Datum&);
  friend std::istream& operator>>(std::istream&, Datum&);
};
#endif // DATE_H ///:~
