//	Zinc Application Framework - Z_TIME.HPP
//	COPYRIGHT (C) 1990-1999.  All Rights Reserved.
//	Zinc Software Incorporated.  Pleasant Grove, Utah  USA

#if !defined(Z_TIME_HPP)
#define Z_TIME_HPP
#include <z_utime.hpp>

// --------------------------------------------------------------------------
// ----- ZafTimeData --------------------------------------------------------
// --------------------------------------------------------------------------

class ZAF_EXPORT ZafTimeData : public ZafUTimeData
{
public:
	// -- General members ---
	ZafTimeData(void);
	ZafTimeData(int hour, int minute, int second, int milliSecond);
	ZafTimeData(const ZafIChar *string, const ZafIChar *format = ZAF_NULLP(ZafIChar));
	ZafTimeData(const ZafTimeData &copy);
	ZafTimeData(const ZafUTimeData &copy);
	virtual ~ZafTimeData(void);

	// --- Persistence ---
	virtual ZafData *Duplicate(void);
#if defined(USE_ZAF_PERSISTENCE)
	ZafTimeData(const ZafIChar *name, ZafDataPersistence &persist);
	static ZafElement *Read(const ZafIChar *name, ZafDataPersistence &persist);
	virtual void Write(ZafDataPersistence &persist);
#endif

	// --- Attributes & data access ---
	// get
	virtual int FormattedText(ZafIChar *buffer, int maxLength, const ZafIChar *format = 0) const;
	virtual void Time(int *hour, int *minute, int *second, int *milliSecond = ZAF_NULLP(int));
	virtual long Value(void) const;
	// set
	virtual void Clear(void);
	virtual ZafError SetTime(int hour, int minute, int second, int milliSecond);
	virtual ZafError SetTime(const ZafIChar *buffer, const ZafIChar *format);
	virtual ZafError SetTime(const ZafTimeData &time);

	// --- Class identification ---
	static ZafClassID classID;
	static ZafClassNameChar ZAF_FARDATA className[];
	virtual ZafClassID ClassID(void) const { return (classID); }
	virtual ZafClassName ClassName(void) const { return (className); }
	virtual bool IsA(ZafClassID compareID) const;
	virtual bool IsA(ZafClassName compareName) const;

protected:
#if defined(USE_ZAF_PERSISTENCE)
	// --- Persistent members --
	virtual ZafDataConstructor ReadFunction(void) { return (ZafTimeData::Read); }
#endif

	virtual void Add(const ZafUTimeData &utime);
	virtual void Subtract(const ZafUTimeData &utime);
};

#endif // Z_TIME_HPP

