本文整理汇总了C++中CTimeSpan::Days方法的典型用法代码示例。如果您正苦于以下问题:C++ CTimeSpan::Days方法的具体用法?C++ CTimeSpan::Days怎么用?C++ CTimeSpan::Days使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CTimeSpan
的用法示例。
在下文中一共展示了CTimeSpan::Days方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UpdateTradeExtended
void CSpaceObject::UpdateTradeExtended (const CTimeSpan &ExtraTime)
// UpdateTradeExtended
//
// Update trade after a long time.
{
// Refresh inventory, if necessary
CTradingDesc *pTradeOverride = GetTradeDescOverride();
CDesignType *pType = GetType();
CTradingDesc *pTrade = (pType ? pType->GetTradingDesc() : NULL);
if ((pTrade || pTradeOverride) && ExtraTime.Days() > 0 && !IsAbandoned())
{
// Compute the percent of the inventory that need to refresh
int iRefreshPercent;
if (ExtraTime.Days() >= DAYS_TO_REFRESH_INVENTORY)
iRefreshPercent = 100;
else
iRefreshPercent = 100 * ExtraTime.Days() / DAYS_TO_REFRESH_INVENTORY;
// Do it
if (pTradeOverride)
pTradeOverride->RefreshInventory(this, iRefreshPercent);
if (pTrade)
pTrade->RefreshInventory(this, iRefreshPercent);
}
}
示例2: CTimeSpan
const CTimeSpan operator- (const CTimeSpan &op1, const CTimeSpan &op2)
// Operator -
//
// Subtract op2 from op1 (op1 must be greater than op2)
{
LONGLONG time1 = (op1.Days() * SECONDS_PER_DAY * 1000) + op1.Milliseconds();
LONGLONG time2 = (op2.Days() * SECONDS_PER_DAY * 1000) + op2.Milliseconds();
LONGLONG result = (time1 >= time2 ? time1 - time2 : time2 - time1);
return CTimeSpan((int)(result / (SECONDS_PER_DAY * 1000)), (int)(result % (SECONDS_PER_DAY * 1000)));
}
示例3: timeAddTime
CTimeDate timeAddTime (const CTimeDate &StartTime, const CTimeSpan &Addition)
// timeAddTime
//
// Adds a timespan to a timedate
{
int iDaysSince1AD = StartTime.DaysSince1AD();
int iMillisecondsSinceMidnight = StartTime.MillisecondsSinceMidnight();
// Add
iDaysSince1AD += Addition.Days();
iMillisecondsSinceMidnight += Addition.MillisecondsSinceMidnight();
if (iMillisecondsSinceMidnight >= SECONDS_PER_DAY * 1000)
{
iDaysSince1AD++;
iMillisecondsSinceMidnight -= SECONDS_PER_DAY * 1000;
}
return CTimeDate(iDaysSince1AD, iMillisecondsSinceMidnight);
}
示例4: timeSubtractTime
CTimeDate timeSubtractTime (const CTimeDate &StartTime, const CTimeSpan &Subtraction)
// timeSubtractTime
//
// Subtracts time from timedate
{
int iDaysSince1AD = StartTime.DaysSince1AD();
int iMillisecondsSinceMidnight = StartTime.MillisecondsSinceMidnight();
// Add
iDaysSince1AD -= Subtraction.Days();
if (Subtraction.MillisecondsSinceMidnight() > iMillisecondsSinceMidnight)
{
iMillisecondsSinceMidnight += SECONDS_PER_DAY * 1000;
iDaysSince1AD--;
}
iMillisecondsSinceMidnight -= Subtraction.MillisecondsSinceMidnight();
return CTimeDate(iDaysSince1AD, iMillisecondsSinceMidnight);
}
示例5: OnProcessMessage
//.........这里部分代码省略.........
SendMessageReplyError(MSG_ERROR_UNABLE_TO_COMPLY, ERR_SCOPE_REQUIRED);
return false;
}
// User data
CDatum dUserData = Msg.dPayload;
CDatum dAuthDesc;
if (m_bActual)
dAuthDesc = dUserData.GetElement(FIELD_AUTH_DESC);
else
dAuthDesc = dUserData.GetElement(strPattern("%s%s", m_sScope, FIELD_AUTH_DESC));
// If we have no authdesc, then we can't continue. This is likely
// because the client is in a sandbox that the user has not registered
// with. We treat it the same as a username/password failure.
if (dAuthDesc.IsNil())
{
SendMessageReplyError(MSG_ERROR_DOES_NOT_EXIST, ERR_INVALID_USERNAME_OR_PASSWORD);
return false;
}
// If we've failed more than 5 consecutive times, we may need to delay
// the next login attempt.
if ((int)dUserData.GetElement(FIELD_LOGIN_FAILURE_COUNT) > MAX_LOGIN_ATTEMPTS)
{
CDateTime LastLoginFailure = dUserData.GetElement(FIELD_LAST_LOGIN_FAILURE_ON);
CTimeSpan TimeSinceLastFailure = timeSpan(LastLoginFailure, CDateTime(CDateTime::Now));
// If it has not been at least 1 hour, we return an error.
if (TimeSinceLastFailure.Days() == 0 && TimeSinceLastFailure.Seconds() < LOGIN_TIMEOUT)
{
// Timeout
SendMessageReplyError(MSG_ERROR_DOES_NOT_EXIST, ERR_FAILURE_TIMEOUT);
return false;
}
}
// If we have straight credentials, then just compare
bool bSuccess;
if (!dCredentials.IsNil())
bSuccess = ((const CIPInteger &)dCredentials == (const CIPInteger &)dAuthDesc.GetElement(FIELD_CREDENTIALS));
// Otherwise, we compare against the challenge
else if (!dChallengeCredentials.IsNil())
{
// Get the challenge. If not provided then we get it from the user
// record.
CDatum dChallenge = GetOriginalMsg().dPayload.GetElement(2);
if (dChallenge.IsNil())
{
// Get the expiration time of the challenge
const CDateTime &Expires = dAuthDesc.GetElement(FIELD_CHALLENGE_EXPIRATION);
if (Expires < CDateTime(CDateTime::Now))
{
SendMessageReplyError(MSG_ERROR_DOES_NOT_EXIST, ERR_INVALID_USERNAME_OR_PASSWORD);
return false;
}