/*

Copyright (c) 2002-2005, Yauheni Akhotnikau
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

- Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

- Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.

- The name of the author may not be used to endorse or promote products derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.

*/

/*!
	\since v.1.4.0-b2
	\file oess_1/io/custom/ace/h/Date_Time.h
	\brief Адаптация ввода/вывода типа ACE_Date_Time в ObjESSty потоки.
*/

#if !defined( OESS_1__IO__CUSTOM__ACE__DATE_TIME_HPP )
#define OESS_1__IO__CUSTOM__ACE__DATE_TIME_HPP 

#include <ace/Date_Time.h>

#include <oess_1/io/h/stream.hpp>

/*!
	\since v.1.4.0-b2
	\brief Оператор сдвига значения ACE_Date_Time в ObjESSty поток.

	Формат представления:
	- oess_1::short_t year
	- oess_1::char_t month
	- oess_1::char_t day
	- oess_1::char_t hour
	- oess_1::char_t minute
	- oess_1::char_t seconds
	- oess_1::int_t microsec
	- oess_1::char_t wday
*/
inline oess_1::io::ostream_t &
operator<<( oess_1::io::ostream_t & out, const ACE_Date_Time & d )
	{
		return ( out
				<< static_cast< oess_1::short_t >( d.year() )
				<< static_cast< oess_1::char_t >( d.month() )
				<< static_cast< oess_1::char_t >( d.day() )
				<< static_cast< oess_1::char_t >( d.hour() )
				<< static_cast< oess_1::char_t >( d.minute() )
				<< static_cast< oess_1::char_t >( d.second() )
				<< static_cast< oess_1::int_t >( d.microsec() )
				<< static_cast< oess_1::char_t >( d.weekday() ) );
	}

/*!
	\since v.1.4.0-b2
	\brief Оператор сдвига значения ACE_Date_Time из ObjESSty потока.

	Формат представления ACE_Date_Time описан в операторе сдвига в поток.
*/
inline oess_1::io::istream_t &
operator>>( oess_1::io::istream_t & in, ACE_Date_Time & d )
	{
		oess_1::short_t  year;
		oess_1::char_t month, day, hour, minute, seconds, weekday;
		oess_1::int_t microsec;

		in >> year >> month >> day >> hour >> minute >> seconds
				>> microsec >> weekday;
		d = ACE_Date_Time( day, month, year, hour, minute, seconds,
				microsec, weekday );

		return in;
	}

#endif

