summaryrefslogtreecommitdiff
path: root/libopie/pim/orecur.cpp
Side-by-side diff
Diffstat (limited to 'libopie/pim/orecur.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/orecur.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/libopie/pim/orecur.cpp b/libopie/pim/orecur.cpp
index e3b45b4..eae1fdc 100644
--- a/libopie/pim/orecur.cpp
+++ b/libopie/pim/orecur.cpp
@@ -315,196 +315,196 @@ bool ORecur::p_nextOccurrence( const QDate& from, QDate& next ) {
iday = start().day();
imonth = start().month();
iyear = from.year(); // after all, we want to start in this year
diff = 1;
if(imonth == 2 && iday > 28) {
/* leap year, and it counts, calculate actual frequency */
if(freq % 4)
if (freq % 2)
freq = freq * 4;
else
freq = freq * 2;
/* else divides by 4 already, leave freq alone */
diff = 4;
}
a = from.year() - start().year();
if(a % freq) {
a = freq - (a % freq);
iyear = iyear + a;
}
/* under the assumption we won't hit one of the special not-leap years twice */
if(!QDate::isValid(iyear, imonth, iday)) {
/* must have been skipping by leap years and hit one that wasn't, (e.g. 2100) */
iyear += freq;
}
if(QDate(iyear, imonth, iday) >= from) {
next = QDate(iyear, imonth, iday);
if ((next > endDate()) && hasEndDate() )
return FALSE;
return TRUE;
}
/* iyear == from.year(), need to advance again */
iyear += freq;
/* under the assumption we won't hit one of the special not-leap years twice */
if(!QDate::isValid(iyear, imonth, iday)) {
/* must have been skipping by leap years and hit one that wasn't, (e.g. 2100) */
iyear += freq;
}
next = QDate(iyear, imonth, iday);
if ((next > endDate()) && hasEndDate() )
return FALSE;
return TRUE;
default:
return FALSE;
}
}
ORecur::RepeatType ORecur::type()const{
return data->type;
}
int ORecur::frequency()const {
return data->freq;
}
int ORecur::position()const {
return data->pos;
}
char ORecur::days() const{
return data->days;
}
bool ORecur::hasEndDate()const {
return data->hasEnd;
}
QDate ORecur::endDate()const {
return data->end;
}
QDate ORecur::start()const{
return data->start;
}
QDateTime ORecur::createdDateTime()const {
return data->create;
}
int ORecur::repetition()const {
return data->rep;
}
QString ORecur::service()const {
return data->app;
}
ORecur::ExceptionList& ORecur::exceptions() {
return data->list;
}
void ORecur::setType( const RepeatType& z) {
checkOrModify();
data->type = z;
}
void ORecur::setFrequency( int freq ) {
checkOrModify();
data->freq = freq;
}
void ORecur::setPosition( int pos ) {
checkOrModify();
data->pos = pos;
}
void ORecur::setDays( char c ) {
checkOrModify();
data->days = c;
}
void ORecur::setEndDate( const QDate& dt) {
checkOrModify();
data->end = dt;
}
void ORecur::setCreatedDateTime( const QDateTime& t) {
checkOrModify();
data->create = t;
}
void ORecur::setHasEndDate( bool b) {
checkOrModify();
data->hasEnd = b;
}
void ORecur::setRepitition( int rep ) {
checkOrModify();
data->rep = rep;
}
void ORecur::setService( const QString& app ) {
checkOrModify();
data->app = app;
}
void ORecur::setStart( const QDate& dt ) {
checkOrModify();
data->start = dt;
}
void ORecur::checkOrModify() {
if ( data->count != 1 ) {
data->deref();
Data* d2 = new Data;
d2->days = data->days;
d2->type = data->type;
d2->freq = data->freq;
d2->pos = data->pos;
d2->hasEnd = data->hasEnd;
d2->end = data->end;
d2->create = data->create;
d2->rep = data->rep;
d2->app = data->app;
d2->list = data->list;
d2->start = data->start;
data = d2;
}
}
QString ORecur::toString()const {
QString buf;
buf += " rtype=\"";
switch ( data->type ) {
case ORecur::Daily:
buf += "Daily";
break;
case ORecur::Weekly:
buf += "Weekly";
break;
case ORecur::MonthlyDay:
buf += "MonthlyDay";
break;
case ORecur::MonthlyDate:
buf += "MonthlyDate";
break;
case ORecur::Yearly:
buf += "Yearly";
break;
default:
buf += "NoRepeat";
break;
}
buf += "\"";
if (data->days > 0 )
buf += " rweekdays=\"" + QString::number( static_cast<int>( data->days ) ) + "\"";
if ( data->pos != 0 )
buf += " rposition=\"" + QString::number(data->pos ) + "\"";
buf += " rfreq=\"" + QString::number( data->freq ) + "\"";
buf += " rhasenddate=\"" + QString::number( static_cast<int>( data->hasEnd ) ) + "\"";
if ( data->hasEnd )
buf += " enddt=\""
+ QString::number( OTimeZone::utc().fromUTCDateTime( QDateTime( data->end, QTime(12,0,0) ) ) )
+ "\"";
buf += " created=\"" + QString::number( OTimeZone::utc().fromUTCDateTime( data->create ) ) + "\"";
if ( data->list.isEmpty() ) return buf;
// save exceptions list here!!
ExceptionList::ConstIterator it;
ExceptionList list = data->list;
buf += " exceptions=\"";
QDate date;
for ( it = list.begin(); it != list.end(); ++it ) {
date = (*it);
if ( it != list.begin() ) buf += " ";
buf += QCString().sprintf("%04d%02d%02d", date.year(), date.month(), date.day() );
}
- buf += "\"";
+ buf += "\" ";
return buf;
}