117234Salanb/****************************************************************************
217234Salanb** libebml : parse EBML files, see http://embl.sourceforge.net/
317234Salanb**
417234Salanb** <file/class description>
517234Salanb**
617234Salanb** Copyright (C) 2002-2005 Steve Lhomme.  All rights reserved.
717234Salanb**
817234Salanb** This library is free software; you can redistribute it and/or
917234Salanb** modify it under the terms of the GNU Lesser General Public
1017234Salanb** License as published by the Free Software Foundation; either
1117234Salanb** version 2.1 of the License, or (at your option) any later version.
1217234Salanb**
1317234Salanb** This library is distributed in the hope that it will be useful,
1417234Salanb** but WITHOUT ANY WARRANTY; without even the implied warranty of
1517234Salanb** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1617234Salanb** Lesser General Public License for more details.
1717234Salanb**
1817234Salanb** You should have received a copy of the GNU Lesser General Public
1917234Salanb** License along with this library; if not, write to the Free Software
2017234Salanb** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
2117234Salanb**
2217234Salanb** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.
2317234Salanb**
2417234Salanb** Contact license@matroska.org if any conditions of this licensing are
2517234Salanb** not clear to you.
2617234Salanb**
2717234Salanb**********************************************************************/
2817234Salanb
2917234Salanb/*!
30	\file
31	\version \$Id: EbmlDate.cpp 1079 2005-03-03 13:18:14Z robux4 $
32	\author Steve Lhomme     <robux4 @ users.sf.net>
33*/
34#include <cassert>
35
36#include "ebml/EbmlDate.h"
37
38START_LIBEBML_NAMESPACE
39
40const uint64 EbmlDate::UnixEpochDelay = 978307200; // 2001/01/01 00:00:00 UTC
41
42EbmlDate::EbmlDate(const EbmlDate & ElementToClone)
43:EbmlElement(ElementToClone)
44{
45	myDate = ElementToClone.myDate;
46}
47
48uint64 EbmlDate::ReadData(IOCallback & input, ScopeMode ReadFully)
49{
50	if (ReadFully != SCOPE_NO_DATA)
51	{
52		if (Size != 0) {
53			assert(Size == 8);
54			binary Buffer[8];
55			input.readFully(Buffer, Size);
56
57			big_int64 b64;
58			b64.Eval(Buffer);
59
60			myDate = b64;
61			bValueIsSet = true;
62		}
63	}
64
65	return Size;
66}
67
68uint32 EbmlDate::RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact)
69{
70	if (Size != 0) {
71		assert(Size == 8);
72		big_int64 b64(myDate);
73
74		output.writeFully(&b64.endian(),Size);
75	}
76
77	return Size;
78}
79
80END_LIBEBML_NAMESPACE
81