mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-27 07:34:20 +00:00
fix for #40500. get search / filters to work with "age in days" and "is".
r=hwaara, sr=bienvenu
This commit is contained in:
parent
2f71e7646c
commit
a619450d80
@ -1019,43 +1019,50 @@ nsresult nsMsgSearchTerm::MatchDate (PRTime dateToMatch, PRBool *pResult)
|
|||||||
|
|
||||||
nsresult nsMsgSearchTerm::MatchAge (PRTime msgDate, PRBool *pResult)
|
nsresult nsMsgSearchTerm::MatchAge (PRTime msgDate, PRBool *pResult)
|
||||||
{
|
{
|
||||||
if (!pResult)
|
if (!pResult)
|
||||||
return NS_ERROR_NULL_POINTER;
|
return NS_ERROR_NULL_POINTER;
|
||||||
|
|
||||||
PRBool result = PR_FALSE;
|
PRBool result = PR_FALSE;
|
||||||
nsresult err = NS_OK;
|
nsresult err = NS_OK;
|
||||||
|
|
||||||
|
PRTime now = PR_Now();
|
||||||
|
PRTime cutOffDay;
|
||||||
|
|
||||||
PRTime now = PR_Now();
|
PRInt64 microSecondsPerSecond, secondsInDays, microSecondsInDays;
|
||||||
PRTime cutOffDay;
|
|
||||||
|
|
||||||
PRInt64 microSecondsPerSecond, secondsInDays, microSecondsInDays;
|
|
||||||
|
|
||||||
LL_I2L(microSecondsPerSecond, PR_USEC_PER_SEC);
|
LL_I2L(microSecondsPerSecond, PR_USEC_PER_SEC);
|
||||||
LL_UI2L(secondsInDays, 60 * 60 * 24 * m_value.u.age);
|
LL_UI2L(secondsInDays, 60 * 60 * 24 * m_value.u.age);
|
||||||
LL_MUL(microSecondsInDays, secondsInDays, microSecondsPerSecond);
|
LL_MUL(microSecondsInDays, secondsInDays, microSecondsPerSecond);
|
||||||
|
|
||||||
LL_SUB(cutOffDay, now, microSecondsInDays); // = now - term->m_value.u.age * 60 * 60 * 24;
|
LL_SUB(cutOffDay, now, microSecondsInDays); // = now - term->m_value.u.age * 60 * 60 * 24;
|
||||||
// so now cutOffDay is the PRTime cut-off point. Any msg with a time less than that will be past the age .
|
// so now cutOffDay is the PRTime cut-off point. Any msg with a time less than that will be past the age .
|
||||||
|
|
||||||
switch (m_operator)
|
switch (m_operator)
|
||||||
{
|
{
|
||||||
case nsMsgSearchOp::IsGreaterThan: // is older than
|
case nsMsgSearchOp::IsGreaterThan: // is older than
|
||||||
if (LL_CMP(msgDate, <, cutOffDay))
|
if (LL_CMP(msgDate, <, cutOffDay))
|
||||||
result = PR_TRUE;
|
result = PR_TRUE;
|
||||||
break;
|
break;
|
||||||
case nsMsgSearchOp::IsLessThan: // is younger than
|
case nsMsgSearchOp::IsLessThan: // is younger than
|
||||||
if (LL_CMP(msgDate, >, cutOffDay))
|
if (LL_CMP(msgDate, >, cutOffDay))
|
||||||
result = PR_TRUE;
|
result = PR_TRUE;
|
||||||
break;
|
break;
|
||||||
case nsMsgSearchOp::Is:
|
case nsMsgSearchOp::Is:
|
||||||
NS_ASSERTION(PR_FALSE, "not supported yet");
|
PRExplodedTime msgDateExploded;
|
||||||
break;
|
PRExplodedTime cutOffDayExploded;
|
||||||
default:
|
if (NS_SUCCEEDED(GetLocalTimes(msgDate, cutOffDay, msgDateExploded, cutOffDayExploded)))
|
||||||
NS_ASSERTION(PR_FALSE, "invalid compare op comparing msg age");
|
{
|
||||||
}
|
if ((msgDateExploded.tm_mday == cutOffDayExploded.tm_mday) &&
|
||||||
*pResult = result;
|
(msgDateExploded.tm_month == cutOffDayExploded.tm_month) &&
|
||||||
return err;
|
(msgDateExploded.tm_year == cutOffDayExploded.tm_year))
|
||||||
|
result = PR_TRUE;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
NS_ASSERTION(PR_FALSE, "invalid compare op comparing msg age");
|
||||||
|
}
|
||||||
|
*pResult = result;
|
||||||
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user