/****************************************************************************/
/*	Copyright (c) 2009, Bendor Research Pty. Ltd. All rights reserved.		*/
/*	This software is released under the GNU General Public License, version	*/
/*	3, with the exemptions that 1) the header files installed by this 	 	*/
/*	package can be included in closed-source code and 2) the libraries		*/
/*	built by this package can be statically linked into a closed-source 	*/
/*	binary. See the file LICENSE for the details.							*/
/*	This software is provided "AS IS", without any warranty or guarantee.	*/
/*	By using this software you acknowledge that neither Bendor Research nor	*/
/*	any of its personnel or affiliates can be held liable for any damages,	*/
/*	including, but not limited to, loss of business, loss of money, loss of */
/*	life, loss of reputation, arising out of this software being faulty or	*/
/*	not performing as advertised, even if Bendor Research was aware of such	*/
/*	faults in the software. You use this software at your own risk, any and */
/*	all liabilities that arise out of your using this software are strictly	*/
/*	yours.																	*/
/****************************************************************************/

#ifndef _TIME_H
#define	_TIME_H

/** @addtogroup time */
/** @{ */

/**
*	Internal representation of time.
*
*	A 32-bit unsigned integer is used to store the number of seconds
*	since the Epoch (1970-01-01 00:00:00 UTC). The value 0xffffffff
*	is not allowed, it is reserved to signal errors. The 32-bit
*	unsigned int will not roll over before 2106.
*/

typedef unsigned long time_t;

#define	TIME_INVALID	((time_t)-1)	//!< Indicates that a time is not valid

/**
*	Broken down date and time structure.
*
*	@attention
*	The C standard specifies the fields all being type int. This implementation
*	defines the fields as unsigned numbers and only as wide as they must be,
*	to save memory.
*/

struct tm {

	signed	 int	tm_gmtoff;	//!< Seconds East of UTC (-43199 - +43199)
	unsigned short	tm_yday;	//!< Days since 1st Jan			 (0 - 365)
	unsigned char	tm_wday;	//!< Days since Sunday			 (0 -   6)
	unsigned char	tm_year;	//!< Year - 1900				(70 - 206)
	unsigned char	tm_mon;		//!< Months since Jan			 (0 -  11)
	unsigned char	tm_mday;	//!< Day of the month, 			 (1 -  31)
	unsigned char	tm_hour;	//!< Hours since midnight 		 (0 -  23)
	unsigned char	tm_min;		//!< Minutes after the hour		 (0 -  59)
	unsigned char	tm_sec;		//!< Seconds after the minute 	 (0 -  59)
};

time_t		mktime( const struct tm *tm );
struct tm	*gmtime( time_t t, struct tm *tm );
struct tm	*localtime( time_t t, struct tm *tm );

/** @} */

#endif

