6
// System Utilities Common API
7
#include <sysutil/sysutil_common.h>
8
#include <sysutil/sysutil_sysparam.h>
13
NTimeStamp::NTimeStamp()
18
NTimeStamp::~NTimeStamp()
30
t_s64 NTimeStamp::GetJulianDayNumber(void) const
32
t_s64 JDN = m_Day - 32075L +
33
1461L * (m_Year + 4800L + (m_Month - 14L) / 12L) / 4L +
34
367L * (m_Month - 2L - ((m_Month - 14L) / 12L) * 12L) / 12L -
35
3L * ((m_Year + 4900L - (m_Month - 14L) / 12L) / 100L) / 4L;
39
t_f64 NTimeStamp::GetJulianDate() const
41
t_f64 JD = GetJulianDayNumber() + (m_Hour - 12)/1440.0f + m_Minute/1440.0f + m_Second/86400.0f;
45
unsigned int NTimeStamp::GetSecondOfDay(void) const
47
return m_Hour * 60 * 60 + m_Minute * 60 + m_Second;
50
bool NTimeStamp::operator == (NTimeStamp& Other) const
52
bool b = (m_Year == Other.m_Year) &&
53
(m_Day == Other.m_Day) &&
54
(m_Month == Other.m_Month) &&
55
(m_Hour == Other.m_Hour) &&
56
(m_Minute == Other.m_Minute) &&
57
(m_Second == Other.m_Second);
61
bool NTimeStamp::operator != (NTimeStamp& Other) const
68
bool NTimeStamp::operator < (NTimeStamp& Other) const
70
t_f64 JD = GetJulianDate();
71
if(JD < Other.GetJulianDate())
76
bool NTimeStamp::operator > (NTimeStamp& Other) const
78
t_f64 JD = GetJulianDate();
79
if(JD > Other.GetJulianDate())
84
bool NTimeStamp::operator >= (NTimeStamp& Other) const
86
t_f64 JD = GetJulianDate();
87
if(JD >= Other.GetJulianDate())
92
bool NTimeStamp::operator <= (NTimeStamp& Other) const
94
t_f64 JD = GetJulianDate();
95
if(JD <= Other.GetJulianDate())
100
void NTimeStamp::GetTime()
102
GetLocalTime(m_Year, m_Month, m_Day, m_Hour, m_Minute, m_Second, m_MicroSecond);
106
Returns the time formatted in a string.
108
const TCHAR* GetFormattedLocalTime()
110
static TCHAR Result[1024];
119
unsigned int MicroSec;
121
GetLocalTime(Year, Month, Day, Hour, Minute, Second, MicroSec);
123
_stprintf_s(Result, 1024, TEXT("%d:%d:%d: %d/%d/%d"), Hour, Minute, Second, Day, Month, Year);
125
_stprintf(Result, TEXT("%d:%d:%d: %d/%d/%d"), Hour, Minute, Second, Day, Month, Year);
131
void SleepSeconds(float Seconds)
134
::Sleep((DWORD)(Seconds * 1000.0));
138
void SleepMilliSeconds(float MilliSeconds)
141
::Sleep((DWORD)(MilliSeconds));
146
// Return the system time.
148
void GetLocalTime(unsigned int& Year,
154
unsigned int& MicroSec)
156
#ifdef INL_OS_WINDOWS
166
MicroSec = st.wMilliseconds*1000;
168
#elif (defined INL_PS3)
170
cellRtcGetCurrentClockLocalTime(&st);
177
MicroSec = st.microsecond;
179
#elif (defined INL_OS_LINUX) || (defined INL_OS_MACOSX)
183
localtime_r(&dt, &dc);
185
Year = dc.tm_year - 100 + 2000;
186
Month = dc.tm_mon + 1;
197
void GetUTCTime(unsigned int& Year,
203
unsigned int& MicroSec)
207
::GetSystemTime(&st);
215
MicroSec = st.wMilliseconds*1000;
217
#elif (defined INL_PS3)
219
cellRtcGetCurrentClock(&st, 0); // 0 for UTC time(at Greenwich)
226
MicroSec = st.microsecond;
228
#elif (defined INL_OS_LINUX) || (defined INL_OS_MACOSX)
234
Year = dc.tm_year - 100 + 2000;
235
Month = dc.tm_mon + 1;
250
_get_timezone(&seconds);
251
t_long hour = seconds / 3600;
255
int minutetimezone = 0;
256
cellSysutilGetSystemParamInt(CELL_SYSUTIL_SYSTEMPARAM_ID_TIMEZONE, &minutetimezone);
257
t_long hour = minutetimezone / 60;
265
void SleepForMilliseconds(unsigned int Milliseconds)
267
#if defined(INL_OS_WINDOWS)
270
#elif defined(INL_OS_LINUX)
271
int ret = usleep(Milliseconds*1000);
274
nuxDebugMsg(TEXT("[SleepForMilliseconds] usleep has failed."));
277
#error Sleep(milliseconds) is not implemented for this platform.
b'\\ No newline at end of file'