// This may look like C code, but it's really -*- C++ -*-
/*
 * Copyright (C) 2007 Koen Deforche, Kessel-Lo, Belgium.
 *
 * See the LICENSE file for terms of use.
 */
#ifndef WDATE_H_
#define WDATE_H_

#include <WDllDefs.h>
#include <exception>
#include <string>

namespace boost {
  namespace gregorian {
    class date;
  }
}

namespace Wt {

/*! \brief Exception thrown when an invalid WDate is constructed.
 */
class WT_API InvalidDateException : public std::exception
{
public:
  InvalidDateException(const std::string what);
  ~InvalidDateException() throw();

  const char *what() const throw() { return what_.c_str(); }

private:
  std::string what_;
};

/*! \brief A gregorian calendar date (year/month/day).
 */
class WT_API WDate
{
public:
  /*! \brief Specify a date by year, month (1-12), and day (1-31)
   */
  WDate(int year, int month, int day);

  /*! \brief Year
   */
  int year() const { return year_; }

  /*! \brief Month (1-12)
   */
  int month() const { return month_; }

  /*! \brief Day of month (1-31)
   */
  int day() const { return day_; }

  /*! \brief Compare two dates.
   */
  bool operator< (const WDate& other) const;

  /*! \brief Compare two dates.
   */
  bool operator> (const WDate& other) const;

  /*! \brief Compare two dates.
   */
  bool operator== (const WDate& other) const;

  /*! \brief Compare two dates.
   */
  bool operator!= (const WDate& other) const;

  /*! \brief A sentinel for 'no date'
   */
  static WDate NoDate;

private:
  WDate();

  int year_;
  int month_;
  int day_;
};

}

#endif // WDATE_H_
