00001 // ===================================================================== 00021 // ===================================================================== 00022 #ifndef __TSYSTEMCLOCK_HH 00023 #define __TSYSTEMCLOCK_HH 00024 00025 #include "Tglobals.h" 00026 00027 00047 class TSystemClock 00048 { 00049 00050 private: 00051 // elapsed time in second from 1970/1/1/00:00:00 00052 // 現在時刻を聞いたら,必ず theLastRequiredTime = theTime これがUpdate() 00053 // 任意の時刻を尋ねてもこれは起こらない 00054 Tint theAllocatedTime; 00055 Tint theLastUpdateTime; 00056 Tint theTime; 00057 00058 public: 00059 TSystemClock(); 00060 TSystemClock( const TSystemClock& right ); 00061 ~TSystemClock(); 00062 00063 public: 00064 const TSystemClock& operator=( const TSystemClock& right ); 00065 friend Tostream& operator<<( Tostream& tos, const TSystemClock& right ); 00066 00067 public: 00068 Tstring WhatTimeIsItNow(); 00069 Tstring WhatTimeIsIt( Tint second = -1 ); 00070 Tstring WhenAllocated(); 00071 Tstring WhenUpdate(); 00072 Tint GetElapsedTime( const Tstring& unit = Tsec ); 00073 Tint GetElapsedTimeOfLastUpdate( const Tstring& unit = Tsec ); 00074 Tint GetYear( Tint second = -1 ); 00075 Tint GetMonth( Tint second = -1 ); 00076 Tint GetDay( Tint second = -1 ); 00077 Tint GetHour( Tint second = -1 ); 00078 Tint GetMinute( Tint second = -1 ); 00079 Tint GetSecond( Tint second = -1 ); 00080 Tint Update(); 00081 00082 public: 00083 Tint GetAllocatedTime() const; 00084 Tint GetLastUpdateTime() const; 00085 Tint GetTime() const; 00086 00087 }; 00088 00089 inline Tint TSystemClock::GetAllocatedTime() const 00090 { 00091 return theAllocatedTime; 00092 } 00093 00094 inline Tint TSystemClock::GetLastUpdateTime() const 00095 { 00096 return theLastUpdateTime; 00097 } 00098 00099 inline Tint TSystemClock::GetTime() const 00100 { 00101 return theTime; 00102 } 00103 00104 #endif