cyphesis/modules/DateTime.cpp
Al Riddoch 2ccfaadef3 2001-04-14 Al Riddoch <alriddoch@zepler.org>
* Substantial re-work of object model. Moved many attributes out
	  of BaseEntity class. Changed WoldRouter so it now handles
	  objects in terms of Entity, rather than BaseEntity.

	* Code cleanups, including removing reduntant includes, and
	  getting rid of C style comments.

	* Fixed the way attributes are handled in Set operations and
	  when merging from an Atlas::Message::Object. This fixed
	  problem with setting gender of characters.

	* rulesets/Pedestrian.*, rulesets/Movement.*: Re-named
	  Movement variables to make them clearer. Added in
	  separate handling for collisions from moving to
	  target position. Modified collision handling so
	  objects can slide next to each other.

	* rulesets/Thing.cpp, rulesets/Character.cpp: Cleaned up and
	  rationalised movement code. Much shorter, faster and
	  more compact than before.

	* Made better use of iterators throughout, eliminating unnecessary
	  lookups, and copying of data.

	* Moved all virtual functions out of header files, making
	  less work for the linker.

	* Made more use of const references to avoid the need to copy
	  data before being able to inspect it.

Al Riddoch <alriddoch@zepler.org>
2001-04-16 16:26:44 +00:00

44 lines
1.4 KiB
C++

// This file may be redistributed and modified only under the terms of
// the GNU General Public License (See COPYING for details).
// Copyright (C) 2000,2001 Alistair Riddoch
#include "DateTime.h"
// date_pat=re.compile("^|[-:]|\s+");
unsigned int DateTime::m_spm = 60; // seconds per minute
unsigned int DateTime::m_mph = 60; // minutes per hour
unsigned int DateTime::m_hpd = 24; // hours per day
unsigned int DateTime::m_dpm = 28; // days per month
unsigned int DateTime::m_mpy = 12; // months per year
DateTime::DateTime(char * date_time)
{
// extract numbers from string
//(DateTime::year,DateTime::month,DateTime::day,;
//DateTime::hour,DateTime::minute,DateTime::second)=\;
//map(float,date_pat.split(date_time));
}
DateTime::DateTime(int yr, int mn, int da, int hr, int mt, int sc) :
m_second(sc), m_minute(mt), m_hour(hr), m_day(da), m_month(mn), m_year(yr)
{
}
double DateTime::seconds()
{
return m_second+
m_minute*m_spm+
m_hour*m_spm*m_mph+
(m_day-1)*m_spm*m_mph*m_hpd+
(m_month-1)*m_spm*m_mph*m_hpd*m_dpm+
m_year*m_spm*m_mph*m_hpd*m_dpm*m_mpy;
}
string DateTime::asString()
{
//Convert date into string
//return "%04i-%02i-%02i %02i:%02i:%04.1f" %
//(DateTime::year,DateTime::month,DateTime::day,;
//DateTime::hour,DateTime::minute,DateTime::second);
}