fixed wxDateTime::SetToWeekDayInSameWeek(Sun, Monday_First)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@32875 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -9,8 +9,9 @@ All:
|
|||||||
|
|
||||||
- wxURI::GetUser() only returns the user name now, use GetUserInfo() to get
|
- wxURI::GetUser() only returns the user name now, use GetUserInfo() to get
|
||||||
user and password as in 2.5.4; wxURI::GetPassword() added.
|
user and password as in 2.5.4; wxURI::GetPassword() added.
|
||||||
- Added wxDebugReport class.
|
- added wxDebugReport class.
|
||||||
- added wxTempFileOutputStream by Stas Sergeev
|
- added wxTempFileOutputStream by Stas Sergeev
|
||||||
|
- fixed wxDateTime::SetToWeekDayInSameWeek(Sun, Monday_First)
|
||||||
|
|
||||||
All (GUI):
|
All (GUI):
|
||||||
|
|
||||||
|
@@ -1822,8 +1822,9 @@ wxDateTime& wxDateTime::SetToWeekDayInSameWeek(WeekDay weekday, WeekFlags flags)
|
|||||||
{
|
{
|
||||||
wxDATETIME_CHECK( weekday != Inv_WeekDay, _T("invalid weekday") );
|
wxDATETIME_CHECK( weekday != Inv_WeekDay, _T("invalid weekday") );
|
||||||
|
|
||||||
int wdayThis = GetWeekDay();
|
int wdayDst = weekday,
|
||||||
if ( weekday == wdayThis )
|
wdayThis = GetWeekDay();
|
||||||
|
if ( wdayDst == wdayThis )
|
||||||
{
|
{
|
||||||
// nothing to do
|
// nothing to do
|
||||||
return *this;
|
return *this;
|
||||||
@@ -1837,21 +1838,23 @@ wxDateTime& wxDateTime::SetToWeekDayInSameWeek(WeekDay weekday, WeekFlags flags)
|
|||||||
// the logic below based on comparing weekday and wdayThis works if Sun (0)
|
// the logic below based on comparing weekday and wdayThis works if Sun (0)
|
||||||
// is the first day in the week, but breaks down for Monday_First case so
|
// is the first day in the week, but breaks down for Monday_First case so
|
||||||
// we adjust the week days in this case
|
// we adjust the week days in this case
|
||||||
if( flags == Monday_First )
|
if ( flags == Monday_First )
|
||||||
{
|
{
|
||||||
if ( wdayThis == Sun )
|
if ( wdayThis == Sun )
|
||||||
wdayThis += 7;
|
wdayThis += 7;
|
||||||
|
if ( wdayDst == Sun )
|
||||||
|
wdayDst += 7;
|
||||||
}
|
}
|
||||||
//else: Sunday_First, nothing to do
|
//else: Sunday_First, nothing to do
|
||||||
|
|
||||||
// go forward or back in time to the day we want
|
// go forward or back in time to the day we want
|
||||||
if ( weekday < wdayThis )
|
if ( wdayDst < wdayThis )
|
||||||
{
|
{
|
||||||
return Subtract(wxDateSpan::Days(wdayThis - weekday));
|
return Subtract(wxDateSpan::Days(wdayThis - wdayDst));
|
||||||
}
|
}
|
||||||
else // weekday > wdayThis
|
else // weekday > wdayThis
|
||||||
{
|
{
|
||||||
return Add(wxDateSpan::Days(weekday - wdayThis));
|
return Add(wxDateSpan::Days(wdayDst - wdayThis));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user