/**************************************************************************** * [S]imulated [M]edieval [A]dventure multi[U]ser [G]ame | * * -----------------------------------------------------------| \\._.// * * SmaugWiz (C) 1998 by Russ Pillsbury (Windows NT version) | (0...0) * * -----------------------------------------------------------| ).:.( * * SMAUG (C) 1994, 1995, 1996 by Derek Snider | {o o} * * -----------------------------------------------------------| / ' ' \ * * SMAUG code team: Thoric, Altrag, Blodkai, Narn, Haus, |~'~.VxvxV.~'~* * Scryn, Swordbearer, Rennard, Tricops, and Gorog. | * * ------------------------------------------------------------------------ * * Merc 2.1 Diku Mud improvments copyright (C) 1992, 1993 by Michael * * Chastain, Michael Quan, and Mitchell Tse. * * Original Diku Mud copyright (C) 1990, 1991 by Sebastian Hammer, * * Michael Seifert, Hans Henrik Staerfeldt, Tom Madsen, and Katja Nyboe. * * ------------------------------------------------------------------------ * * Time & Date Interface file * ****************************************************************************/ #ifndef SWTIME_H #define SWTIME_H #pragma warning( disable: 4244 ) class CSwTime { public: CSwTime () { *this = 0; bManual = FALSE; } CSwTime (int y, int mo, int d, int h, int min, int s = 0) { *this = CTime (y, mo, d, h, min, s); bManual = FALSE; } CSwTime (const CSwTime& t) { m_time = t.m_time; bManual = t.bManual; } CSwTime (const CTime& t) { *this = t; } CString GetString () { CTime t (m_time); return t.Format ("%a %b %d %Y %H:%M:%S"); } void SetCurrentTime () { GetSystemTime (&m_time); } // UTC void SetSecond (int s) { m_time.wSecond = s; } void SetMinute (int m) { m_time.wMinute = m; } void SetHour (int h) { m_time.wHour = h; } CTime GetCtime () { return CTime (m_time); } int GetSecond () { return m_time.wSecond; } int GetMinute () { return m_time.wMinute; } int GetHour () { return m_time.wHour; } int GetDay () { return m_time.wDay; } int GetMonth () { return m_time.wMonth; } int GetYear () { return m_time.wYear; } long GetTotalSeconds () { CTimeSpan ts (CTime (m_time).GetTime ()); return ts.GetTotalSeconds (); } const CSwTime& operator= (const CSwTime& t) { m_time = t.m_time; bManual = t.bManual; return *this; } const CSwTime& operator= (int t) { CTime ct (t); *this = ct; return *this; } const CSwTime& operator= (long t) { CTime ct (t); *this = ct; return *this; } const CSwTime& operator= (tm t) { CTime ct (mktime (&t)); *this = ct; return *this; } const CSwTime& operator= (const CTime& t) { m_time.wMilliseconds = 0; m_time.wSecond = t.GetSecond (); m_time.wMinute = t.GetMinute (); m_time.wHour = t.GetHour (); m_time.wDay = t.GetDay (); m_time.wMonth = t.GetMonth (); m_time.wYear = t.GetYear (); m_time.wDayOfWeek = t.GetDayOfWeek (); return *this; } BOOL operator< (CSwTime& t) { return CTime (m_time) < CTime (t.m_time); } BOOL operator> (CSwTime& t) { return CTime (m_time) > CTime (t.m_time); } BOOL operator>= (CSwTime& t) { return CTime (m_time) >= CTime (t.m_time); } BOOL operator<= (CSwTime& t) { return CTime (m_time) <= CTime (t.m_time); } void operator+= (int days) { CTime t1 (m_time); t1 += CTimeSpan ((long) days, 0,0,0); *this = t1; } void operator+= (CTimeSpan ts) { CTime t (m_time); t += ts; *this = t; } CSwTime operator+ (int i) { CTime t (m_time); t += i; return CSwTime (t); } CTime operator+ (CSwTime& t) { CTime t1 (m_time); CTimeSpan t2 (CTime (t.m_time).GetTime ()); return t1 + t2; } CTimeSpan operator- (CSwTime& t) { CTime t1 (m_time); CTime t2 (t.m_time); return t1 - t2; } BOOL IsManual () { return bManual; } void SetManual (BOOL f) { bManual = f; } BOOL IsZero () { return CTime (m_time) == 0; } private: SYSTEMTIME m_time; // CString m_ts; BOOL bManual; // used for reboot time }; #endif