20
21
void KCalendarTest::testTypes()
22
23
const KCalendarSystem *calendar;
24
calendar = KCalendarSystem::create( "coptic" );
25
QCOMPARE( calendar->calendarType(), QString("coptic") );
26
QCOMPARE( calendar->calendarSystem(), KLocale::CopticCalendar );
28
calendar = KCalendarSystem::create( "ethiopian" );
29
QCOMPARE( calendar->calendarType(), QString("ethiopian") );
30
QCOMPARE( calendar->calendarSystem(), KLocale::EthiopianCalendar );
23
32
calendar = KCalendarSystem::create( "gregorian" );
24
33
QCOMPARE( calendar->calendarType(), QString("gregorian") );
34
QCOMPARE( calendar->calendarSystem(), KLocale::QDateCalendar );
26
36
calendar = KCalendarSystem::create( "gregorian-proleptic" );
27
37
QCOMPARE( calendar->calendarType(), QString("gregorian-proleptic") );
38
QCOMPARE( calendar->calendarSystem(), KLocale::GregorianCalendar );
29
40
calendar = KCalendarSystem::create( "hebrew" );
30
41
QCOMPARE( calendar->calendarType(), QString("hebrew") );
42
QCOMPARE( calendar->calendarSystem(), KLocale::HebrewCalendar );
32
44
calendar = KCalendarSystem::create( "hijri" );
33
45
QCOMPARE( calendar->calendarType(), QString("hijri") );
46
QCOMPARE( calendar->calendarSystem(), KLocale::IslamicCivilCalendar );
35
48
calendar = KCalendarSystem::create( "indian-national" );
36
49
QCOMPARE( calendar->calendarType(), QString("indian-national") );
50
QCOMPARE( calendar->calendarSystem(), KLocale::IndianNationalCalendar );
38
52
calendar = KCalendarSystem::create( "jalali" );
39
53
QCOMPARE( calendar->calendarType(), QString("jalali") );
54
QCOMPARE( calendar->calendarSystem(), KLocale::JalaliCalendar );
41
56
calendar = KCalendarSystem::create( "japanese" );
42
57
QCOMPARE( calendar->calendarType(), QString("japanese") );
58
QCOMPARE( calendar->calendarSystem(), KLocale::JapaneseCalendar );
44
60
calendar = KCalendarSystem::create( "julian" );
45
61
QCOMPARE( calendar->calendarType(), QString("julian") );
62
QCOMPARE( calendar->calendarSystem(), KLocale::JulianCalendar );
47
64
calendar = KCalendarSystem::create( "minguo" );
48
65
QCOMPARE( calendar->calendarType(), QString("minguo") );
66
QCOMPARE( calendar->calendarSystem(), KLocale::MinguoCalendar );
50
68
calendar = KCalendarSystem::create( "thai" );
51
69
QCOMPARE( calendar->calendarType(), QString("thai") );
70
QCOMPARE( calendar->calendarSystem(), KLocale::ThaiCalendar );
53
72
calendar = KCalendarSystem::create( "invalid" );
54
73
QCOMPARE( calendar->calendarType(), QString("gregorian") );
74
QCOMPARE( calendar->calendarSystem(), KLocale::QDateCalendar );
56
76
calendar = KCalendarSystem::create( QString() );
57
77
QCOMPARE( calendar->calendarType(), QString("gregorian") );
78
QCOMPARE( calendar->calendarSystem(), KLocale::QDateCalendar );
81
calendar = KCalendarSystem::create( KLocale::QDateCalendar );
82
QCOMPARE( calendar->calendarType(), QString("gregorian") );
83
QCOMPARE( calendar->calendarSystem(), KLocale::QDateCalendar );
85
calendar = KCalendarSystem::create( KLocale::CopticCalendar );
86
QCOMPARE( calendar->calendarType(), QString("coptic") );
87
QCOMPARE( calendar->calendarSystem(), KLocale::CopticCalendar );
89
calendar = KCalendarSystem::create( KLocale::EthiopianCalendar );
90
QCOMPARE( calendar->calendarType(), QString("ethiopian") );
91
QCOMPARE( calendar->calendarSystem(), KLocale::EthiopianCalendar );
93
calendar = KCalendarSystem::create( KLocale::GregorianCalendar );
94
QCOMPARE( calendar->calendarType(), QString("gregorian-proleptic") );
95
QCOMPARE( calendar->calendarSystem(), KLocale::GregorianCalendar );
97
calendar = KCalendarSystem::create( KLocale::HebrewCalendar );
98
QCOMPARE( calendar->calendarType(), QString("hebrew") );
99
QCOMPARE( calendar->calendarSystem(), KLocale::HebrewCalendar );
101
calendar = KCalendarSystem::create( KLocale::IslamicCivilCalendar );
102
QCOMPARE( calendar->calendarType(), QString("hijri") );
103
QCOMPARE( calendar->calendarSystem(), KLocale::IslamicCivilCalendar );
105
calendar = KCalendarSystem::create( KLocale::IndianNationalCalendar );
106
QCOMPARE( calendar->calendarType(), QString("indian-national") );
107
QCOMPARE( calendar->calendarSystem(), KLocale::IndianNationalCalendar );
109
calendar = KCalendarSystem::create( KLocale::JalaliCalendar );
110
QCOMPARE( calendar->calendarType(), QString("jalali") );
111
QCOMPARE( calendar->calendarSystem(), KLocale::JalaliCalendar );
113
calendar = KCalendarSystem::create( KLocale::JapaneseCalendar );
114
QCOMPARE( calendar->calendarType(), QString("japanese") );
115
QCOMPARE( calendar->calendarSystem(), KLocale::JapaneseCalendar );
117
calendar = KCalendarSystem::create( KLocale::JulianCalendar );
118
QCOMPARE( calendar->calendarType(), QString("julian") );
119
QCOMPARE( calendar->calendarSystem(), KLocale::JulianCalendar );
121
calendar = KCalendarSystem::create( KLocale::MinguoCalendar );
122
QCOMPARE( calendar->calendarType(), QString("minguo") );
123
QCOMPARE( calendar->calendarSystem(), KLocale::MinguoCalendar );
125
calendar = KCalendarSystem::create( KLocale::ThaiCalendar );
126
QCOMPARE( calendar->calendarType(), QString("thai") );
127
QCOMPARE( calendar->calendarSystem(), KLocale::ThaiCalendar );
60
130
QStringList lst = KCalendarSystem::calendarSystems();
131
QCOMPARE( lst.count(), 11 );
132
QVERIFY( lst.contains( "coptic" ) );
133
QVERIFY( lst.contains( "ethiopian" ) );
61
134
QVERIFY( lst.contains( "gregorian" ) );
62
135
QVERIFY( lst.contains( "hebrew" ) );
63
136
QVERIFY( lst.contains( "hijri" ) );
68
141
QVERIFY( lst.contains( "minguo" ) );
69
142
QVERIFY( lst.contains( "thai" ) );
144
QList<KLocale::CalendarSystem> list = KCalendarSystem::calendarSystemsList();
145
QCOMPARE( list.count(), 12 );
146
QVERIFY( list.contains( KLocale::QDateCalendar ) );
147
QVERIFY( list.contains( KLocale::CopticCalendar ) );
148
QVERIFY( list.contains( KLocale::EthiopianCalendar ) );
149
QVERIFY( list.contains( KLocale::GregorianCalendar ) );
150
QVERIFY( list.contains( KLocale::HebrewCalendar ) );
151
QVERIFY( list.contains( KLocale::IslamicCivilCalendar ) );
152
QVERIFY( list.contains( KLocale::IndianNationalCalendar ) );
153
QVERIFY( list.contains( KLocale::JalaliCalendar ) );
154
QVERIFY( list.contains( KLocale::JapaneseCalendar ) );
155
QVERIFY( list.contains( KLocale::JulianCalendar ) );
156
QVERIFY( list.contains( KLocale::MinguoCalendar ) );
157
QVERIFY( list.contains( KLocale::ThaiCalendar ) );
159
QCOMPARE( KCalendarSystem::calendarLabel( "coptic" ), QString( "Coptic" ) );
160
QCOMPARE( KCalendarSystem::calendarLabel( "ethiopian" ), QString( "Ethiopian" ) );
71
161
QCOMPARE( KCalendarSystem::calendarLabel( "gregorian" ), QString( "Gregorian" ) );
72
162
QCOMPARE( KCalendarSystem::calendarLabel( "gregorian-proleptic" ), QString( "Gregorian (Proleptic)" ) );
73
163
QCOMPARE( KCalendarSystem::calendarLabel( "hebrew" ), QString( "Hebrew" ) );
74
QCOMPARE( KCalendarSystem::calendarLabel( "hijri" ), QString( "Hijri" ) );
164
QCOMPARE( KCalendarSystem::calendarLabel( "hijri" ), QString( "Islamic / Hijri (Civil)" ) );
75
165
QCOMPARE( KCalendarSystem::calendarLabel( "indian-national" ), QString( "Indian National" ) );
76
166
QCOMPARE( KCalendarSystem::calendarLabel( "jalali" ), QString( "Jalali" ) );
77
167
QCOMPARE( KCalendarSystem::calendarLabel( "japanese" ), QString( "Japanese" ) );
78
168
QCOMPARE( KCalendarSystem::calendarLabel( "julian" ), QString( "Julian" ) );
79
169
QCOMPARE( KCalendarSystem::calendarLabel( "minguo" ), QString( "Taiwanese" ) );
80
170
QCOMPARE( KCalendarSystem::calendarLabel( "thai" ), QString( "Thai" ) );
83
void KCalendarTest::testLocale()
85
KGlobal::locale()->setCalendar( "gregorian" );
86
const KCalendarSystem *calendar = KGlobal::locale()->calendar();
87
QCOMPARE( calendar->calendarType(), QString( "gregorian" ) );
88
KGlobal::locale()->setCalendar( "gregorian-proleptic");
89
calendar = KGlobal::locale()->calendar();
90
QCOMPARE( calendar->calendarType(), QString( "gregorian-proleptic" ) );
91
KGlobal::locale()->setCalendar( "hebrew" );
92
calendar = KGlobal::locale()->calendar();
93
QCOMPARE( calendar->calendarType(), QString( "hebrew" ) );
94
KGlobal::locale()->setCalendar( "hijri" );
95
calendar = KGlobal::locale()->calendar();
96
QCOMPARE( calendar->calendarType(), QString( "hijri" ) );
97
KGlobal::locale()->setCalendar( "indian-national" );
98
calendar = KGlobal::locale()->calendar();
99
QCOMPARE( calendar->calendarType(), QString( "indian-national" ) );
100
KGlobal::locale()->setCalendar( "jalali" );
101
calendar = KGlobal::locale()->calendar();
102
QCOMPARE( calendar->calendarType(), QString( "jalali" ) );
103
KGlobal::locale()->setCalendar( "japanese" );
104
calendar = KGlobal::locale()->calendar();
105
QCOMPARE( calendar->calendarType(), QString( "japanese" ) );
106
KGlobal::locale()->setCalendar( "julian" );
107
calendar = KGlobal::locale()->calendar();
108
QCOMPARE( calendar->calendarType(), QString( "julian" ) );
109
KGlobal::locale()->setCalendar( "minguo" );
110
calendar = KGlobal::locale()->calendar();
111
QCOMPARE( calendar->calendarType(), QString( "minguo" ) );
112
KGlobal::locale()->setCalendar( "thai" );
113
calendar = KGlobal::locale()->calendar();
114
QCOMPARE( calendar->calendarType(), QString( "thai" ) );
172
QCOMPARE( KCalendarSystem::calendarLabel( KLocale::QDateCalendar ), QString( "Gregorian" ) );
173
QCOMPARE( KCalendarSystem::calendarLabel( KLocale::CopticCalendar ), QString( "Coptic" ) );
174
QCOMPARE( KCalendarSystem::calendarLabel( KLocale::EthiopianCalendar ), QString( "Ethiopian" ) );
175
QCOMPARE( KCalendarSystem::calendarLabel( KLocale::GregorianCalendar ), QString( "Gregorian (Proleptic)" ) );
176
QCOMPARE( KCalendarSystem::calendarLabel( KLocale::HebrewCalendar ), QString( "Hebrew" ) );
177
QCOMPARE( KCalendarSystem::calendarLabel( KLocale::IslamicCivilCalendar ), QString( "Islamic / Hijri (Civil)" ) );
178
QCOMPARE( KCalendarSystem::calendarLabel( KLocale::IndianNationalCalendar ), QString( "Indian National" ) );
179
QCOMPARE( KCalendarSystem::calendarLabel( KLocale::JalaliCalendar ), QString( "Jalali" ) );
180
QCOMPARE( KCalendarSystem::calendarLabel( KLocale::JapaneseCalendar ), QString( "Japanese" ) );
181
QCOMPARE( KCalendarSystem::calendarLabel( KLocale::JulianCalendar ), QString( "Julian" ) );
182
QCOMPARE( KCalendarSystem::calendarLabel( KLocale::MinguoCalendar ), QString( "Taiwanese" ) );
183
QCOMPARE( KCalendarSystem::calendarLabel( KLocale::ThaiCalendar ), QString( "Thai" ) );
117
187
void KCalendarTest::testFormatDate()
119
189
KLocale *locale = new KLocale( *KGlobal::locale() );
120
190
locale->setDateFormatShort( "%y-%m-%d" );
121
const KCalendarSystem *calendar = KCalendarSystem::create( "gregorian", locale );
191
const KCalendarSystem *calendar = KCalendarSystem::create( KLocale::QDateCalendar, locale );
123
193
//Test default settings
124
194
QDate testDate( 2005, 10, 20 );
2382
2482
delete calendar;
2485
void KCalendarTest::testKLocalizedDate()
2487
KGlobal::locale()->setDateFormatShort( "%y-%m-%d" );
2488
const KCalendarSystem *calendar = KGlobal::locale()->calendar();
2490
// Set up a bunch of KLocalizedDates and QDates that should be equal
2491
QDate testQDate( 2010, 1, 1 );
2492
KLocalizedDate testKLocalizedDate( testQDate );
2494
// Test KLocalizedDate output calls not in KCalendarSystem
2495
QCOMPARE( KLocalizedDate().isNull(), true );
2496
QCOMPARE( KLocalizedDate().isValid(), false );
2497
QCOMPARE( testKLocalizedDate.isNull(), testQDate.isNull() );
2498
QCOMPARE( testKLocalizedDate.date(), testQDate );
2499
QCOMPARE( testKLocalizedDate.toJulianDay(), testQDate.toJulianDay() );
2500
testKLocalizedDate.setDate( QDate( 2010, 6, 1 ) );
2501
testQDate.setDate( 2010, 6, 1 );
2502
QCOMPARE( testKLocalizedDate.date(), testQDate );
2504
// Test static KLocalizedDate methods
2505
QCOMPARE( KLocalizedDate::currentDate().date(), QDate::currentDate() );
2506
QCOMPARE( KLocalizedDate::fromDate( testQDate ).date(), testQDate );
2507
QCOMPARE( KLocalizedDate::fromJulianDay( 100000 ).date(), QDate::fromJulianDay( 100000 ) );
2509
// Compare KLocalizedDate output to KCalendarSystem output calls
2510
QCOMPARE( testKLocalizedDate.isValid(), calendar->isValid( testQDate ) );
2511
QCOMPARE( testKLocalizedDate.year(), calendar->year( testQDate ) );
2512
QCOMPARE( testKLocalizedDate.month(), calendar->month( testQDate ) );
2513
QCOMPARE( testKLocalizedDate.day(), calendar->day( testQDate ) );
2514
QCOMPARE( testKLocalizedDate.eraName(), calendar->eraName( testQDate ) );
2515
QCOMPARE( testKLocalizedDate.eraYear(), calendar->eraYear( testQDate ) );
2516
QCOMPARE( testKLocalizedDate.yearInEra(), calendar->yearInEra( testQDate ) );
2517
QCOMPARE( testKLocalizedDate.addYears( 5 ).date(), calendar->addYears( testQDate, 5 ) );
2518
QCOMPARE( testKLocalizedDate.addMonths( 5 ).date(), calendar->addMonths( testQDate, 5 ) );
2519
QCOMPARE( testKLocalizedDate.addDays( 5 ).date(), calendar->addDays( testQDate, 5 ) );
2520
QCOMPARE( testKLocalizedDate.monthsInYear(), calendar->monthsInYear( testQDate ) );
2521
QCOMPARE( testKLocalizedDate.weeksInYear(), calendar->weeksInYear( testQDate ) );
2522
QCOMPARE( testKLocalizedDate.daysInYear(), calendar->daysInYear( testQDate ) );
2523
QCOMPARE( testKLocalizedDate.daysInMonth(), calendar->daysInMonth( testQDate ) );
2524
QCOMPARE( testKLocalizedDate.daysInWeek(), calendar->daysInWeek( testQDate ) );
2525
QCOMPARE( testKLocalizedDate.dayOfYear(), calendar->dayOfYear( testQDate ) );
2526
QCOMPARE( testKLocalizedDate.dayOfWeek(), calendar->dayOfWeek( testQDate ) );
2527
QCOMPARE( testKLocalizedDate.week(), calendar->weekNumber( testQDate ) );
2528
QCOMPARE( testKLocalizedDate.isLeapYear(), calendar->isLeapYear( testQDate ) );
2529
QCOMPARE( testKLocalizedDate.firstDayOfYear().date(), calendar->firstDayOfYear( testQDate ) );
2530
QCOMPARE( testKLocalizedDate.lastDayOfYear().date(), calendar->lastDayOfYear( testQDate ) );
2531
QCOMPARE( testKLocalizedDate.firstDayOfMonth().date(), calendar->firstDayOfMonth( testQDate ) );
2532
QCOMPARE( testKLocalizedDate.lastDayOfMonth().date(), calendar->lastDayOfMonth( testQDate ) );
2534
QCOMPARE( testKLocalizedDate.week(KLocale::IsoWeekNumber), calendar->weekNumber( testQDate ) );
2535
QCOMPARE( testKLocalizedDate.weeksInYear(KLocale::IsoWeekNumber), calendar->weeksInYear( testQDate ) );
2537
// Compare KLocalizedDate setDate to KCalendarSystem setDate
2538
testKLocalizedDate.setDate( 2010, 3, 1 );
2539
calendar->setDate( testQDate, 2010, 3, 1 );
2540
QCOMPARE( testKLocalizedDate.date(), testQDate );
2541
testKLocalizedDate.setDate( 2010, 100 );
2542
calendar->setDate( testQDate, 2010, 100 );
2543
QCOMPARE( testKLocalizedDate.date(), testQDate );
2544
testKLocalizedDate.setDate( "AD", 2010, 9, 1 );
2545
calendar->setDate( testQDate, "AD", 2010, 9, 1 );
2546
QCOMPARE( testKLocalizedDate.date(), testQDate );
2547
testKLocalizedDate.setDate( KLocale::IsoWeekNumber, 2010, 15, 1 );
2548
calendar->setDateIsoWeek( testQDate, 2010, 15, 1 );
2549
QCOMPARE( testKLocalizedDate.date(), testQDate );
2550
testKLocalizedDate.setCurrentDate();
2551
testQDate = QDate::currentDate();
2552
QCOMPARE( testKLocalizedDate.date(), testQDate );
2554
// Compare KLocalizedDate getDate to KCalendarSystem getDate
2555
int ky, km, kd, qy, qm, qd;
2556
testKLocalizedDate.getDate( &ky, &km, &kd );
2557
calendar->getDate( testQDate, &qy, &qm, &qd );
2562
// Compare KLocalizedDate format/read to KCalendarSystem format
2563
QCOMPARE( testKLocalizedDate.formatDate(), calendar->formatDate( testQDate ) );
2564
QCOMPARE( testKLocalizedDate.formatDate("%d-%m-%y"), calendar->formatDate( testQDate, "%d-%m-%y" ) );
2565
QCOMPARE( testKLocalizedDate.formatDateComponent(KLocale::Year), calendar->yearString( testQDate ) );
2566
QCOMPARE( testKLocalizedDate.formatDateComponent(KLocale::YearName), calendar->yearString( testQDate ) );
2567
QCOMPARE( testKLocalizedDate.formatDateComponent(KLocale::Month), calendar->monthString( testQDate, KCalendarSystem::ShortFormat ) );
2568
QCOMPARE( testKLocalizedDate.formatDateComponent(KLocale::MonthName), calendar->monthName( testQDate ) );
2569
QCOMPARE( testKLocalizedDate.formatDateComponent(KLocale::Day), calendar->dayString( testQDate, KCalendarSystem::ShortFormat ) );
2570
QCOMPARE( testKLocalizedDate.formatDateComponent(KLocale::DayName), calendar->dayString( testQDate, KCalendarSystem::ShortFormat ) );
2571
QCOMPARE( testKLocalizedDate.formatDateComponent(KLocale::JulianDay), QString::number( testQDate.toJulianDay() ) );
2572
QCOMPARE( testKLocalizedDate.formatDateComponent(KLocale::EraName), calendar->eraName( testQDate ) );
2573
QCOMPARE( testKLocalizedDate.formatDateComponent(KLocale::EraYear), calendar->eraYear( testQDate ) );
2574
QCOMPARE( testKLocalizedDate.formatDateComponent(KLocale::YearInEra), calendar->yearInEraString( testQDate ) );
2575
QCOMPARE( testKLocalizedDate.formatDateComponent(KLocale::DayOfYear), calendar->dayOfYearString( testQDate ) );
2576
QCOMPARE( testKLocalizedDate.formatDateComponent(KLocale::DayOfYearName), calendar->dayOfYearString( testQDate ) );
2577
QCOMPARE( testKLocalizedDate.formatDateComponent(KLocale::DayOfWeek), calendar->dayOfWeekString( testQDate ) );
2578
QCOMPARE( testKLocalizedDate.formatDateComponent(KLocale::DayOfWeekName), calendar->weekDayName( testQDate ) );
2579
QCOMPARE( testKLocalizedDate.formatDateComponent(KLocale::Week), calendar->weekNumberString( testQDate ) );
2582
calendar->weekNumber( testQDate, &weekYear );
2583
calendar->setDate( weekDate, weekYear, 1, 1);
2584
QCOMPARE( testKLocalizedDate.formatDateComponent(KLocale::WeekYear), calendar->yearString( weekDate ) );
2585
QCOMPARE( testKLocalizedDate.formatDateComponent(KLocale::MonthsInYear), calendar->monthsInYearString( testQDate ) );
2586
QCOMPARE( testKLocalizedDate.formatDateComponent(KLocale::WeeksInYear), calendar->weeksInYearString( testQDate ) );
2587
QCOMPARE( testKLocalizedDate.formatDateComponent(KLocale::DaysInYear), calendar->daysInYearString( testQDate ) );
2588
QCOMPARE( testKLocalizedDate.formatDateComponent(KLocale::DaysInMonth), calendar->daysInMonthString( testQDate ) );
2589
QCOMPARE( testKLocalizedDate.formatDateComponent(KLocale::DaysInWeek), calendar->daysInWeekString( testQDate ) );
2591
// Compare KLocalizedDate format/read to KCalendarSystem read
2592
QCOMPARE( testKLocalizedDate.readDate( "2010-01-01" ).date(), calendar->readDate( "2010-01-01" ) );
2593
QCOMPARE( testKLocalizedDate.readDate( "2010-01-01", KLocale::NormalFormat ).date(), calendar->readDate( "2010-01-01", KLocale::NormalFormat ) );
2594
QCOMPARE( testKLocalizedDate.readDate( "2010-01-01", "%y-%m-%d" ).date(), calendar->readDate( "2010-01-01", "%y-%m-%d" ) );
2596
// Test new addOn methods
2597
testKLocalizedDate.addYearsTo( 5 );
2598
testQDate = calendar->addYears( testQDate, 5 );
2599
QCOMPARE( testKLocalizedDate.date(), testQDate );
2600
testKLocalizedDate.addMonthsTo( 5 );
2601
testQDate = calendar->addMonths( testQDate, 5 );
2602
QCOMPARE( testKLocalizedDate.date(), testQDate );
2603
testKLocalizedDate.addDaysTo( 5 );
2604
testQDate = calendar->addDays( testQDate, 5 );
2605
QCOMPARE( testKLocalizedDate.date(), testQDate );
2607
// Set up some dates for comparisons
2608
QDate lowQDate( 2000, 1, 1 );
2609
KLocalizedDate lowKLocalizedDate( lowQDate );
2610
QDate highQDate( 2010, 1, 1 );
2611
KLocalizedDate highKLocalizedDate( highQDate );
2613
// Compare the difference methods
2614
int kdy, kdm, kdd, kdir, qdy, qdm, qdd, qdir;
2615
lowKLocalizedDate.dateDifference( highKLocalizedDate, &kdy, &kdm, &kdd, &kdir );
2616
calendar->dateDifference( lowKLocalizedDate.date(), highKLocalizedDate.date(), &qdy, &qdm, &qdd, &qdir );
2617
QCOMPARE( kdy, qdy );
2618
QCOMPARE( kdm, qdm );
2619
QCOMPARE( kdd, qdd );
2620
QCOMPARE( kdir, qdir );
2621
lowKLocalizedDate.dateDifference( highQDate, &kdy, &kdm, &kdd, &kdir );
2622
calendar->dateDifference( lowKLocalizedDate.date(), highQDate, &qdy, &qdm, &qdd, &qdir );
2623
QCOMPARE( kdy, qdy );
2624
QCOMPARE( kdm, qdm );
2625
QCOMPARE( kdd, qdd );
2626
QCOMPARE( kdir, qdir );
2627
QCOMPARE( lowKLocalizedDate.yearsDifference( highKLocalizedDate ), calendar->yearsDifference( lowQDate, highQDate ) );
2628
QCOMPARE( lowKLocalizedDate.yearsDifference( highQDate ), calendar->yearsDifference( lowQDate, highQDate ) );
2629
QCOMPARE( lowKLocalizedDate.monthsDifference( highKLocalizedDate ), calendar->monthsDifference( lowQDate, highQDate ) );
2630
QCOMPARE( lowKLocalizedDate.monthsDifference( highQDate ), calendar->monthsDifference( lowQDate, highQDate ) );
2631
QCOMPARE( lowKLocalizedDate.daysDifference( highKLocalizedDate ), calendar->daysDifference( lowQDate, highQDate ) );
2632
QCOMPARE( lowKLocalizedDate.daysDifference( highQDate ), calendar->daysDifference( lowQDate, highQDate ) );
2634
// Test new operators
2635
QCOMPARE( lowKLocalizedDate == lowKLocalizedDate, true );
2636
QCOMPARE( lowKLocalizedDate == highKLocalizedDate, false );
2637
QCOMPARE( lowKLocalizedDate == lowQDate, true );
2638
QCOMPARE( lowKLocalizedDate == highQDate, false );
2639
QCOMPARE( lowKLocalizedDate != lowKLocalizedDate, false );
2640
QCOMPARE( lowKLocalizedDate != highKLocalizedDate, true );
2641
QCOMPARE( lowKLocalizedDate != lowQDate, false );
2642
QCOMPARE( lowKLocalizedDate != highQDate, true );
2643
QCOMPARE( highKLocalizedDate < lowKLocalizedDate, false );
2644
QCOMPARE( lowKLocalizedDate < highKLocalizedDate, true );
2645
QCOMPARE( highKLocalizedDate < lowQDate, false );
2646
QCOMPARE( lowKLocalizedDate < highQDate, true );
2647
QCOMPARE( highKLocalizedDate <= lowKLocalizedDate, false );
2648
QCOMPARE( lowKLocalizedDate <= lowKLocalizedDate, true );
2649
QCOMPARE( lowKLocalizedDate <= highKLocalizedDate, true );
2650
QCOMPARE( highKLocalizedDate <= lowQDate, false );
2651
QCOMPARE( lowKLocalizedDate <= lowQDate, true );
2652
QCOMPARE( lowKLocalizedDate <= highQDate, true );
2653
QCOMPARE( highKLocalizedDate > lowKLocalizedDate, true );
2654
QCOMPARE( lowKLocalizedDate > highKLocalizedDate, false );
2655
QCOMPARE( highKLocalizedDate > lowQDate, true );
2656
QCOMPARE( lowKLocalizedDate > highQDate, false );
2657
QCOMPARE( highKLocalizedDate >= lowKLocalizedDate, true );
2658
QCOMPARE( lowKLocalizedDate >= lowKLocalizedDate, true );
2659
QCOMPARE( lowKLocalizedDate >= highKLocalizedDate, false );
2660
QCOMPARE( highKLocalizedDate >= lowQDate, true );
2661
QCOMPARE( lowKLocalizedDate >= lowQDate, true );
2662
QCOMPARE( lowKLocalizedDate >= highQDate, false );
2664
// Test changing Calendar System
2665
KCalendarSystem *hijri = KCalendarSystem::create( KLocale::IslamicCivilCalendar );
2666
testKLocalizedDate.setCalendarSystem( KLocale::IslamicCivilCalendar );
2667
QCOMPARE( testKLocalizedDate.year(), hijri->year( testQDate ) );
2669
// Test copy of calendar object
2671
KLocalizedDate test2 = testKLocalizedDate;
2674
testKLocalizedDate.day();
2676
KLocalizedDate newOne = testKLocalizedDate.currentDate();
2678
newOne = KLocalizedDate::currentDate();