summaryrefslogtreecommitdiff
path: root/core/pim/datebook/datebookweekheaderimpl.cpp
Unidiff
Diffstat (limited to 'core/pim/datebook/datebookweekheaderimpl.cpp') (more/less context) (show whitespace changes)
-rw-r--r--core/pim/datebook/datebookweekheaderimpl.cpp26
1 files changed, 1 insertions, 25 deletions
diff --git a/core/pim/datebook/datebookweekheaderimpl.cpp b/core/pim/datebook/datebookweekheaderimpl.cpp
index fd792e2..ff7626f 100644
--- a/core/pim/datebook/datebookweekheaderimpl.cpp
+++ b/core/pim/datebook/datebookweekheaderimpl.cpp
@@ -107,3 +107,3 @@ void DateBookWeekHeader::setDate(const QDate &d) {
107 tr("w")+":"+QString::number( week ) +")"); 107 tr("w")+":"+QString::number( week ) +")");
108 emit dateChanged(year,week); 108 emit dateChanged(date);
109} 109}
@@ -115,25 +115 @@ void DateBookWeekHeader::setStartOfWeek( bool onMonday )
115} }
116
117// dateFromWeek
118// compute the date from the week in the year
119QDate dateFromWeek( int week, int year, bool startOnMonday )
120{
121 QDate d;
122 d.setYMD( year, 1, 1 );
123 int dayOfWeek = d.dayOfWeek();
124 if ( startOnMonday ) {
125 if ( dayOfWeek <= 4 ) {
126 d = d.addDays( ( week - 1 ) * 7 - dayOfWeek + 1 );
127 } else {
128 d = d.addDays( (week) * 7 - dayOfWeek + 1 );
129 }
130 } else {
131 if ( dayOfWeek <= 4 || dayOfWeek == 7) {
132 d = d.addDays( ( week - 1 ) * 7 - dayOfWeek % 7 );
133 } else {
134 d = d.addDays( ( week ) * 7 - dayOfWeek % 7 );
135 }
136 }
137 return d;
138}
139