Diffstat (limited to 'core/pim/datebook/datebookweek.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/pim/datebook/datebookweek.cpp | 2 |
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 | |||
@@ -591,49 +591,49 @@ QDate DateBookWeek::weekDate() const | |||
591 | 591 | ||
592 | // this used to only be needed by datebook.cpp, but now we need it inside | 592 | // this used to only be needed by datebook.cpp, but now we need it inside |
593 | // week view since | 593 | // week view since |
594 | // we need to be able to figure out our total number of weeks on the fly... | 594 | // we need to be able to figure out our total number of weeks on the fly... |
595 | // this is probably the best place to put it.. | 595 | // this is probably the best place to put it.. |
596 | 596 | ||
597 | // For Weeks that start on Monday... (EASY!) | 597 | // For Weeks that start on Monday... (EASY!) |
598 | // At the moment we will use ISO 8601 method for computing | 598 | // At the moment we will use ISO 8601 method for computing |
599 | // the week. Granted, other countries use other methods, | 599 | // the week. Granted, other countries use other methods, |
600 | // bet we aren't doing any Locale stuff at the moment. So, | 600 | // bet we aren't doing any Locale stuff at the moment. So, |
601 | // this should pass. This Algorithim is public domain and | 601 | // this should pass. This Algorithim is public domain and |
602 | // available at: | 602 | // available at: |
603 | // http://personal.ecu.edu/mccartyr/ISOwdALG.txt | 603 | // http://personal.ecu.edu/mccartyr/ISOwdALG.txt |
604 | // the week number is return, and the year number is returned in year | 604 | // the week number is return, and the year number is returned in year |
605 | // for Instance 2001/12/31 is actually the first week in 2002. | 605 | // for Instance 2001/12/31 is actually the first week in 2002. |
606 | // There is a more mathematical definition, but I will implement it when | 606 | // There is a more mathematical definition, but I will implement it when |
607 | // we are pass our deadline. | 607 | // we are pass our deadline. |
608 | 608 | ||
609 | // For Weeks that start on Sunday... (ahh... home rolled) | 609 | // For Weeks that start on Sunday... (ahh... home rolled) |
610 | // okay, if Jan 1 is on Friday or Saturday, | 610 | // okay, if Jan 1 is on Friday or Saturday, |
611 | // it will go to the pervious | 611 | // it will go to the pervious |
612 | // week... | 612 | // week... |
613 | 613 | ||
614 | bool calcWeek( const QDate &d, int &week, int &year, | 614 | bool calcWeek( const QDate &d, int &week, int &year, |
615 | bool startOnMonday = false ) | 615 | bool startOnMonday ) |
616 | { | 616 | { |
617 | int weekNumber; | 617 | int weekNumber; |
618 | int yearNumber; | 618 | int yearNumber; |
619 | 619 | ||
620 | // remove a pesky warning, (Optimizations on g++) | 620 | // remove a pesky warning, (Optimizations on g++) |
621 | weekNumber = -1; | 621 | weekNumber = -1; |
622 | int jan1WeekDay = QDate(d.year(), 1, 1).dayOfWeek(); | 622 | int jan1WeekDay = QDate(d.year(), 1, 1).dayOfWeek(); |
623 | int dayOfWeek = d.dayOfWeek(); | 623 | int dayOfWeek = d.dayOfWeek(); |
624 | 624 | ||
625 | if ( !d.isValid() ) | 625 | if ( !d.isValid() ) |
626 | return false; | 626 | return false; |
627 | 627 | ||
628 | if ( startOnMonday ) { | 628 | if ( startOnMonday ) { |
629 | // find the Jan1Weekday; | 629 | // find the Jan1Weekday; |
630 | if ( d.dayOfYear() <= ( 8 - jan1WeekDay) && jan1WeekDay > 4 ) { | 630 | if ( d.dayOfYear() <= ( 8 - jan1WeekDay) && jan1WeekDay > 4 ) { |
631 | yearNumber = d.year() - 1; | 631 | yearNumber = d.year() - 1; |
632 | if ( jan1WeekDay == 5 || ( jan1WeekDay == 6 && QDate::leapYear(yearNumber) ) ) | 632 | if ( jan1WeekDay == 5 || ( jan1WeekDay == 6 && QDate::leapYear(yearNumber) ) ) |
633 | weekNumber = 53; | 633 | weekNumber = 53; |
634 | else | 634 | else |
635 | weekNumber = 52; | 635 | weekNumber = 52; |
636 | } else | 636 | } else |
637 | yearNumber = d.year(); | 637 | yearNumber = d.year(); |
638 | if ( yearNumber == d.year() ) { | 638 | if ( yearNumber == d.year() ) { |
639 | int totalDays = 365; | 639 | int totalDays = 365; |