// -*- c++ -*-

/*
 * Jakelib2 - General purpose C++ library
 * Copyright (C) 2001 Florian Wolff  (florian@donuz.de)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * $Id: Date.h,v 1.16 2003/09/20 12:38:02 florian Exp $
 */

#ifndef INCLUDE_JAKELIB2_UTIL_DATE_H
# define INCLUDE_JAKELIB2_UTIL_DATE_H

#ifdef HAVE_TIME_H
# include <time.h>
#endif

namespace jakelib {
  namespace text {
    class DateFormat;
  }

  namespace util {

    /**
     * \c Date is a thin wrapper around a milliseconds value.
     * 
     * A Date is represented by a \c jlong value specifying the number
     * of milliseconds since Jan 1st, 1970.
     *
     * @class Date
     * @version $Id: Date.h,v 1.16 2003/09/20 12:38:02 florian Exp $
     * @author Florian 'Overflo' Wolff (florian@donuz.de)
     */
    class Date : public jakelib::lang::Object
    {
    public:

      /**
       * Creates a new \c Date object for the current time.
       */
      Date();

      /**
       * Creates a new \c Date object for the specified number
       * of milliseconds since Jan 1st, 1970.
       */
      Date(jlong millis);

      /**
       * Returns a human-readable string representation of this Date.
       */
      jakelib::lang::String* toString();

      /**
       * Returns the milliseconds value.
       */
      jlong getTime();

      /**
       * Determines wheter this Date is after the specified Date.
       */
      jboolean after(Date *date);  

      /**
       * Determines wheter this Date is before the specified Date.
       */
      jboolean before(Date *date);

      /**
       * Compares this Date to another object.
       */
      jboolean equals(jakelib::lang::Object *obj);

    protected:

      /** Holds the millisecond value. */
      jlong millis;

      /** Holds the DateFormat used by \c toString(). */
      static jakelib::text::DateFormat *dateFormatter;

      JAKELIB_DECLARE_CLASS(Date);
    };

  }
}
#endif

