Kaydet (Commit) 31eee6b3 authored tarafından Markus Mohrhard's avatar Markus Mohrhard

handle last week/next week betweek different years, fdo#58340

üst 1e65f017
...@@ -1684,24 +1684,40 @@ bool ScCondDateFormatEntry::IsValid( const ScAddress& rPos ) const ...@@ -1684,24 +1684,40 @@ bool ScCondDateFormatEntry::IsValid( const ScAddress& rPos ) const
return true; return true;
break; break;
case condformat::LASTWEEK: case condformat::LASTWEEK:
if( rActDate.GetYear() == aCellDate.GetYear() ) if( rActDate.GetDayOfWeek() != SUNDAY )
{ {
if( rActDate.GetWeekOfYear( SUNDAY ) == aCellDate.GetWeekOfYear( SUNDAY ) + 1 ) Date aBegin(rActDate - 8 - static_cast<long>(rActDate.GetDayOfWeek()));
return true; Date aEnd(rActDate - 2 -static_cast<long>(rActDate.GetDayOfWeek()));
return aCellDate.IsBetween( aBegin, aEnd );
}
else
{
Date aBegin(rActDate - 8);
Date aEnd(rActDate - 1);
return aCellDate.IsBetween( aBegin, aEnd );
} }
break; break;
case condformat::THISWEEK: case condformat::THISWEEK:
if( rActDate.GetYear() == aCellDate.GetYear() ) if( rActDate.GetDayOfWeek() != SUNDAY )
{ {
if( rActDate.GetWeekOfYear( SUNDAY ) == aCellDate.GetWeekOfYear( SUNDAY ) ) Date aBegin(rActDate - 1 - static_cast<long>(rActDate.GetDayOfWeek()));
return true; Date aEnd(rActDate + 5 - static_cast<long>(rActDate.GetDayOfWeek()));
return aCellDate.IsBetween( aBegin, aEnd );
}
else
{
Date aEnd( rActDate + 6);
return aCellDate.IsBetween( rActDate, aEnd );
} }
break; break;
case condformat::NEXTWEEK: case condformat::NEXTWEEK:
if( rActDate.GetYear() == aCellDate.GetYear() ) if( rActDate.GetDayOfWeek() != SUNDAY )
{ {
if( rActDate.GetWeekOfYear( SUNDAY ) == aCellDate.GetWeekOfYear( SUNDAY ) - 1 ) return aCellDate.IsBetween( rActDate + 6 - static_cast<long>(rActDate.GetDayOfWeek()), rActDate + 12 - static_cast<long>(rActDate.GetDayOfWeek()) );
return true; }
else
{
return aCellDate.IsBetween( rActDate + 7, rActDate + 13 );
} }
break; break;
case condformat::LASTMONTH: case condformat::LASTMONTH:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment