2
3
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-14 10:37:41 -04:00

Change the fSecs field of plUnifiedTime from UInt32 to time_t.

This fixes various date formatting problems when building on a system where time_t is 64-bit (e.g. Visual Studio 2010), and, as a bonus, extends the range past 2038 on such systems.

The wire protocol is left at 32-bit for now, we might change that to 64 when other reasons to break compatibility have accumulated.
This commit is contained in:
Christian Walther
2011-06-18 20:45:17 +02:00
parent 569f6aa101
commit 9adb8efd5d
9 changed files with 45 additions and 51 deletions

View File

@ -602,7 +602,7 @@ UInt32 cyMisc::GetAgeTime( void )
UInt32 cyMisc::GetDniTime(void)
time_t cyMisc::GetDniTime(void)
{
const plUnifiedTime utime = plNetClientMgr::GetInstance()->GetServerTime();
if ( utime.GetSecs() != 0)
@ -611,7 +611,7 @@ UInt32 cyMisc::GetDniTime(void)
return 0;
}
UInt32 cyMisc::GetServerTime(void)
time_t cyMisc::GetServerTime(void)
{
const plUnifiedTime utime = plNetClientMgr::GetInstance()->GetServerTime();
return utime.GetSecs();
@ -626,10 +626,10 @@ float cyMisc::GetAgeTimeOfDayPercent(void)
#define kOneHour (UInt32)3600
#define kOneDay (UInt32)86400
UInt32 cyMisc::ConvertGMTtoDni(UInt32 gtime)
time_t cyMisc::ConvertGMTtoDni(time_t gtime)
{
// convert to mountain time
UInt32 dtime = gtime - kMST;
time_t dtime = gtime - kMST;
plUnifiedTime utime = plUnifiedTime();
utime.SetSecs(dtime);
// check for daylight savings time in New Mexico and adjust
@ -638,10 +638,10 @@ UInt32 cyMisc::ConvertGMTtoDni(UInt32 gtime)
plUnifiedTime dstStart = plUnifiedTime();
dstStart.SetGMTime(utime.GetYear(),4,1,2,0,0);
// find first Sunday after 4/1 (first sunday of April)
UInt32 days_to_go = 7 - dstStart.GetDayOfWeek();
int days_to_go = 7 - dstStart.GetDayOfWeek();
if (days_to_go == 7)
days_to_go = 0;
UInt32 dstStartSecs = dstStart.GetSecs() + days_to_go * kOneDay;
time_t dstStartSecs = dstStart.GetSecs() + days_to_go * kOneDay;
plUnifiedTime dstEnd = plUnifiedTime();
dstEnd.SetGMTime(utime.GetYear(),10,25,1,0,0);
@ -649,7 +649,7 @@ UInt32 cyMisc::ConvertGMTtoDni(UInt32 gtime)
days_to_go = 7 - dstEnd.GetDayOfWeek();
if (days_to_go == 7)
days_to_go = 0;
UInt32 dstEndSecs = dstEnd.GetSecs() + days_to_go * kOneDay;
time_t dstEndSecs = dstEnd.GetSecs() + days_to_go * kOneDay;
if ( dtime > dstStartSecs && dtime < dstEndSecs )
// add hour for daylight savings time

View File

@ -274,9 +274,9 @@ public:
static PyObject* GetPrevAgeInfo();
// current time in current age
static UInt32 GetAgeTime( void );
static UInt32 GetDniTime(void);
static UInt32 ConvertGMTtoDni(UInt32 time);
static UInt32 GetServerTime( void ); // returns the current server time in GMT
static time_t GetDniTime(void);
static time_t ConvertGMTtoDni(time_t time);
static time_t GetServerTime( void ); // returns the current server time in GMT
static float GetAgeTimeOfDayPercent(void);
/////////////////////////////////////////////////////////////////////////////

View File

@ -59,12 +59,12 @@ PYTHON_GLOBAL_METHOD_DEFINITION_NOARGS(PtGetPrevAgeInfo, "Returns ptAgeInfoStruc
PYTHON_GLOBAL_METHOD_DEFINITION_NOARGS(PtGetDniTime, "Returns current D'Ni time")
{
return PyLong_FromUnsignedLong(cyMisc::GetDniTime());
return PyLong_FromUnsignedLong((unsigned long)cyMisc::GetDniTime());
}
PYTHON_GLOBAL_METHOD_DEFINITION_NOARGS(PtGetServerTime, "Returns the current time on the server (which is GMT)")
{
return PyLong_FromUnsignedLong(cyMisc::GetServerTime());
return PyLong_FromUnsignedLong((unsigned long)cyMisc::GetServerTime());
}
PYTHON_GLOBAL_METHOD_DEFINITION(PtGMTtoDniTime, args, "Params: gtime\nConverts GMT time (passed in) to D'Ni time")
@ -75,7 +75,7 @@ PYTHON_GLOBAL_METHOD_DEFINITION(PtGMTtoDniTime, args, "Params: gtime\nConverts G
PyErr_SetString(PyExc_TypeError, "PtGMTtoDniTime expects a long");
PYTHON_RETURN_ERROR;
}
return PyLong_FromUnsignedLong(cyMisc::ConvertGMTtoDni(gtime));
return PyLong_FromUnsignedLong((unsigned long)cyMisc::ConvertGMTtoDni(gtime));
}
PYTHON_GLOBAL_METHOD_DEFINITION(PtGetClientName, args, "Params: avatarKey=None\nThis will return the name of the client that is owned by the avatar\n"

View File

@ -55,10 +55,10 @@ UInt32 pyDniInfoSource::GetAgeTime( void ) const
if (!node)
return 0;
unsigned result;
UInt32 result;
VaultAgeInfoNode ageInfo(node);
if (const plUnifiedTime * utime = ageInfo.GetAgeTime())
result = utime->GetSecs();
result = (UInt32)utime->GetSecs();
else
result = 0;
node->DecRef();