summaryrefslogtreecommitdiff
path: root/core/pim/datebook/datebookweek.cpp
Side-by-side diff
Diffstat (limited to 'core/pim/datebook/datebookweek.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/datebookweek.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/core/pim/datebook/datebookweek.cpp b/core/pim/datebook/datebookweek.cpp
index e9fcc39..6532ba4 100644
--- a/core/pim/datebook/datebookweek.cpp
+++ b/core/pim/datebook/datebookweek.cpp
@@ -567,97 +567,97 @@ void DateBookWeek::setTotalWeeks( int numWeeks )
int DateBookWeek::totalWeeks() const
{
return header->spinWeek->maxValue();
}
void DateBookWeek::slotWeekChanged( bool onMonday )
{
bStartOnMonday = onMonday;
view->setStartOfWeek( bStartOnMonday );
header->setStartOfWeek( bStartOnMonday );
redraw();
}
void DateBookWeek::slotClockChanged( bool ap )
{
ampm = ap;
}
// return the date at the beginning of the week...
QDate DateBookWeek::weekDate() const
{
return dateFromWeek( _week, year, bStartOnMonday );
}
// this used to only be needed by datebook.cpp, but now we need it inside
// week view since
// we need to be able to figure out our total number of weeks on the fly...
// this is probably the best place to put it..
// For Weeks that start on Monday... (EASY!)
// At the moment we will use ISO 8601 method for computing
// the week. Granted, other countries use other methods,
// bet we aren't doing any Locale stuff at the moment. So,
// this should pass. This Algorithim is public domain and
// available at:
// http://personal.ecu.edu/mccartyr/ISOwdALG.txt
// the week number is return, and the year number is returned in year
// for Instance 2001/12/31 is actually the first week in 2002.
// There is a more mathematical definition, but I will implement it when
// we are pass our deadline.
// For Weeks that start on Sunday... (ahh... home rolled)
// okay, if Jan 1 is on Friday or Saturday,
// it will go to the pervious
// week...
bool calcWeek( const QDate &d, int &week, int &year,
- bool startOnMonday = false )
+ bool startOnMonday )
{
int weekNumber;
int yearNumber;
// remove a pesky warning, (Optimizations on g++)
weekNumber = -1;
int jan1WeekDay = QDate(d.year(), 1, 1).dayOfWeek();
int dayOfWeek = d.dayOfWeek();
if ( !d.isValid() )
return false;
if ( startOnMonday ) {
// find the Jan1Weekday;
if ( d.dayOfYear() <= ( 8 - jan1WeekDay) && jan1WeekDay > 4 ) {
yearNumber = d.year() - 1;
if ( jan1WeekDay == 5 || ( jan1WeekDay == 6 && QDate::leapYear(yearNumber) ) )
weekNumber = 53;
else
weekNumber = 52;
} else
yearNumber = d.year();
if ( yearNumber == d.year() ) {
int totalDays = 365;
if ( QDate::leapYear(yearNumber) )
totalDays++;
if ( ((totalDays - d.dayOfYear()) < (4 - dayOfWeek) )
|| (jan1WeekDay == 7) && (totalDays - d.dayOfYear()) < 3) {
yearNumber++;
weekNumber = 1;
}
}
if ( yearNumber == d.year() ) {
int j = d.dayOfYear() + (7 - dayOfWeek) + ( jan1WeekDay - 1 );
weekNumber = j / 7;
if ( jan1WeekDay > 4 )
weekNumber--;
}
} else {
// it's better to keep these cases separate...
if ( d.dayOfYear() <= (7 - jan1WeekDay) && jan1WeekDay > 4
&& jan1WeekDay != 7 ) {
yearNumber = d.year() - 1;
if ( jan1WeekDay == 6
|| (jan1WeekDay == 7 && QDate::leapYear(yearNumber) ) ) {
weekNumber = 53;
}else
weekNumber = 52;