~ubuntu-branches/ubuntu/oneiric/kde4libs/oneiric-proposed

« back to all changes in this revision

Viewing changes to kdecore/date/klocalizeddate.cpp

  • Committer: Package Import Robot
  • Author(s): Philip Muškovac
  • Date: 2011-07-08 00:08:34 UTC
  • mto: This revision was merged to the branch mainline in revision 247.
  • Revision ID: package-import@ubuntu.com-20110708000834-dr9a8my4iml90qe5
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
};
43
43
 
44
44
KLocalizedDatePrivate::KLocalizedDatePrivate(const QDate &date, const KCalendarSystem *calendar, bool manageCalendar)
45
 
            : QSharedData(),
46
 
              m_date(date),
47
 
              m_calendar(calendar),
48
 
              m_manageCalendar(manageCalendar)
 
45
                     : QSharedData(),
 
46
                       m_date(date),
 
47
                       m_calendar(calendar),
 
48
                       m_manageCalendar(manageCalendar)
49
49
{
50
50
}
51
51
 
52
52
KLocalizedDatePrivate::KLocalizedDatePrivate(const KLocalizedDatePrivate &rhs)
53
 
            : QSharedData(rhs),
54
 
              m_date(rhs.m_date),
55
 
              m_calendar(rhs.m_calendar),
56
 
              m_manageCalendar(rhs.m_manageCalendar)
 
53
                     : QSharedData(rhs),
 
54
                       m_date(rhs.m_date),
 
55
                       m_calendar(rhs.m_calendar),
 
56
                       m_manageCalendar(rhs.m_manageCalendar)
57
57
{
58
58
    // If we're managing the calendar object, then take a copy,
59
59
    // i.e. user called setCalendarSystem() rather than passing a custom one into the constructor
60
 
    if(m_manageCalendar) {
 
60
    if (m_manageCalendar) {
61
61
        m_calendar =  KCalendarSystem::create(m_calendar->calendarSystem(), new KLocale(*m_calendar->locale()));
62
62
    }
63
63
}
69
69
    m_manageCalendar = rhs.m_manageCalendar;
70
70
    // If we're managing the calendar object, then take a copy,
71
71
    // i.e. user called setCalendarSystem() rather than passing a custom one into the constructor
72
 
    if(rhs.m_manageCalendar) {
 
72
    if (rhs.m_manageCalendar) {
73
73
        m_calendar =  KCalendarSystem::create(m_calendar->calendarSystem(), new KLocale(*m_calendar->locale()));
74
74
    }
75
75
    return *this;
91
91
 *****************************************************************************/
92
92
 
93
93
KLocalizedDate::KLocalizedDate(const QDate &date, const KCalendarSystem *calendarSystem)
94
 
     : d(new KLocalizedDatePrivate(date, calendarSystem, false))
 
94
              : d(new KLocalizedDatePrivate(date, calendarSystem, false))
95
95
{
96
96
}
97
97
 
98
98
KLocalizedDate::KLocalizedDate(int year, int month, int day, const KCalendarSystem *calendarSystem)
99
 
     : d(new KLocalizedDatePrivate(QDate(), calendarSystem, false))
 
99
              : d(new KLocalizedDatePrivate(QDate(), calendarSystem, false))
100
100
{
101
101
    setDate(year, month, day);
102
102
}
103
103
 
104
104
KLocalizedDate::KLocalizedDate(const KLocalizedDate &rhs)
105
 
     : d(new KLocalizedDatePrivate(*rhs.d))
 
105
              : d(new KLocalizedDatePrivate(*rhs.d))
106
106
{
107
107
}
108
108
 
148
148
 
149
149
const KCalendarSystem *KLocalizedDate::calendar() const
150
150
{
151
 
    if ( d->m_calendar ) {
 
151
    if (d->m_calendar) {
152
152
        return d->m_calendar;
153
153
    }
154
154
    return  KGlobal::locale()->calendar();
167
167
 
168
168
bool KLocalizedDate::isValid() const
169
169
{
170
 
    return calendar()->isValid( date() );
 
170
    return calendar()->isValid(date());
171
171
}
172
172
 
173
173
/*****************************************************************************
297
297
 
298
298
int KLocalizedDate::week(int *yearNum) const
299
299
{
300
 
    return calendar()->weekNumber(date(), yearNum);
 
300
    return calendar()->week(date(), yearNum);
301
301
}
302
302
 
303
303
int KLocalizedDate::week(KLocale::WeekNumberSystem weekNumberSystem, int *yearNum) const
304
304
{
305
 
    Q_UNUSED(weekNumberSystem);
306
 
    return calendar()->weekNumber(date(), yearNum);
 
305
    return calendar()->week(date(), weekNumberSystem, yearNum);
307
306
}
308
307
 
309
308
int KLocalizedDate::monthsInYear() const
318
317
 
319
318
int KLocalizedDate::weeksInYear(KLocale::WeekNumberSystem weekNumberSystem) const
320
319
{
321
 
    Q_UNUSED(weekNumberSystem);
322
 
    return calendar()->weeksInYear(date());
 
320
    return calendar()->weeksInYear(date(), weekNumberSystem);
323
321
}
324
322
 
325
323
int KLocalizedDate::daysInYear() const
454
452
}
455
453
 
456
454
void KLocalizedDate::dateDifference(const KLocalizedDate &toDate,
457
 
                           int *yearsDiff, int *monthsDiff, int *daysDiff, int *direction) const
 
455
                                    int *yearsDiff, int *monthsDiff, int *daysDiff, int *direction) const
458
456
{
459
457
    dateDifference(toDate.date(), yearsDiff, monthsDiff, daysDiff, direction);
460
458
}
461
459
 
462
460
void KLocalizedDate::dateDifference(const QDate &toDate,
463
 
                           int *yearsDiff, int *monthsDiff, int *daysDiff, int *direction) const
 
461
                                    int *yearsDiff, int *monthsDiff, int *daysDiff, int *direction) const
464
462
{
465
463
    calendar()->dateDifference(date(), toDate, yearsDiff, monthsDiff, daysDiff, direction);
466
464
}
606
604
 
607
605
QDebug operator<<(QDebug dbg, const KLocalizedDate &date)
608
606
{
609
 
    if (date.calendar()->calendarType() == QLatin1String("gregorian")) {
 
607
    if (date.calendar()->calendarSystem() == KLocale::QDateCalendar) {
610
608
        dbg.nospace() << "KLocalizedDate(" << date.formatDate(KLocale::IsoDate) << ", "
611
609
                      << date.calendar()->calendarLabel() << ')';
612
610
    } else {