#ifndef Date_hpp
#define Date_hpp

#include <time.h>
#include <string>

using namespace std;

// The Date module
// Classes: Date
// 
// Last modified: 2000-06-17

// time_t : Type imported from time.h
// time_type : This type should be always the one used internally here...
typedef time_t time_type;


/**
  This class' objects represent either a point in time ("absolute time value")
  or a time period ("relative").
  A time period can be understood as the difference between two points in time.
  At present, no distinction is made internally betwenn these two semantics;
  so care must be taken on usage of some functions.

  Note: Parts of the interface may change.

  Functionality:
   * An istance may be created with the current date/time or a value of type
     time_t, used by many OS functions.
   * Calculations
   * Generation of string representations.

  Shortcomings (at present):
   * String representations not usable for time periods
   * No string-scanning 
   * Dates before the 'epoch' cannot be used safely!

  @author Michael Weers
  @version 0.54 1998-08-28
  */
class Date {
  protected:
                  time_type t;   // Sekunden nach 1970-01-01 00:00:00 UTC 
    static const  int units= 1;  // Dauer von 1 Sek. in Einheiten von t

  public:   
                  /** Constructs an instance with the current system time*/
                  Date();
                  Date( time_t t);
      virtual     ~Date();

                  time_type getTimeValue()  const;  // gibt Attribut t zurück
                  
                  
                  void add( Date& diff);
                  void sub( Date& diff);
      static      Date difference( Date& d2, Date& d1);

//                   string toDateString( TimeZone& tz);
//                   string toTimeString( TimeZone& tz);

                  /** Generate the date's string representation according to
                   ISO 8601 format,
                   in local time (argument 1 = false) or UTC (argument 1 = true)*/
      virtual     string toString( bool= false)  const;

                  /** Gererate string representation in local time or UTC,
                      with format string as in strftime() */
                  string toString( const string&, bool= false)  const;
};

bool operator == ( const Date& d1, const Date& d2);
bool operator < ( const Date& d1, const Date& d2);
bool operator > ( const Date& d1, const Date& d2);
inline bool operator != ( const Date& d1, const Date& d2) { return !(d1==d2); }
inline bool operator >= ( const Date& d1, const Date& d2) { return !(d1<d2); }
inline bool operator <= ( const Date& d1, const Date& d2) { return !(d1>d2); }


#endif
