24 #include <KLocalizedString>
26 #include <QtCore/QDateTime>
27 #include <QtCore/QSharedData>
29 using namespace KHolidays;
34 ZodiacPrivate( Zodiac::ZodiacType type )
39 ZodiacPrivate(
const ZodiacPrivate &other )
45 Zodiac::ZodiacType mType;
48 Zodiac::Zodiac( ZodiacType type )
49 : d( new ZodiacPrivate( type ) )
53 Zodiac::Zodiac(
const Zodiac &other )
62 Zodiac &Zodiac::operator=(
const Zodiac &other )
64 if ( &other !=
this ) {
71 QString Zodiac::signNameAtDate(
const QDate &date )
const
73 return signName( signAtDate( date ) );
76 QString Zodiac::signName( Zodiac::ZodiacSigns sign )
80 return i18n(
"Aries" );
82 return i18n(
"Taurus" );
84 return i18n(
"Gemini" );
86 return i18n(
"Cancer" );
90 return i18n(
"Virgo" );
92 return i18n(
"Libra" );
94 return i18n(
"Scorpio" );
96 return i18n(
"Sagittarius" );
98 return i18n(
"Capricorn" );
100 return i18n(
"Aquarius" );
102 return i18n(
"Pisces" );
109 Zodiac::ZodiacSigns Zodiac::signAtDate(
const QDate &date )
const
111 QDate startdate, enddate;
113 switch ( d->mType ) {
117 if ( date >= startdate && date <= enddate ) {
121 startdate = enddate.
addDays( 1 );
122 enddate = startdate.
addDays( 29 );
123 if ( date >= startdate && date <= enddate ) {
127 startdate = enddate.
addDays( 1 );
129 if ( date >= startdate && date <= enddate ) {
133 startdate = enddate.
addDays( 1 );
134 enddate = startdate.
addDays( 29 );
135 if ( date >= startdate && date <= enddate ) {
139 startdate = enddate.
addDays( 1 );
140 enddate = startdate.
addDays( 30 );
141 if ( date >= startdate && date <= enddate ) {
145 startdate = enddate.
addDays( 1 );
146 enddate = startdate.
addDays( 30 );
147 if ( date >= startdate && date <= enddate ) {
151 startdate = enddate.
addDays( 1 );
152 enddate = startdate.
addDays( 31 );
153 if ( date >= startdate && date <= enddate ) {
157 startdate = enddate.
addDays( 1 );
158 enddate = startdate.
addDays( 30 );
159 if ( date >= startdate && date <= enddate ) {
163 startdate = enddate.
addDays( 1 );
164 enddate = startdate.
addDays( 30 );
165 if ( date >= startdate && date <= enddate ) {
169 startdate = enddate.
addDays( 1 );
170 enddate = startdate.
addDays( 29 );
171 if ( date >= startdate && date <= enddate ) {
175 startdate = enddate.
addDays( 1 );
176 enddate = startdate.
addDays( 29 );
177 if ( date >= startdate && date <= enddate ) {
181 startdate = enddate.
addDays( 1 );
182 enddate = startdate.
addDays( 29 );
183 if ( date >= startdate && date <= enddate ) {
193 if ( date >= startdate && date <= enddate ) {
197 startdate = enddate.
addDays( 1 );
198 enddate = startdate.
addDays( 28 );
199 if ( date >= startdate && date <= enddate ) {
203 startdate = enddate.
addDays( 1 );
205 if ( date >= startdate && date <= enddate ) {
209 startdate = enddate.
addDays( 1 );
211 if ( date >= startdate && date <= enddate ) {
216 enddate = startdate.
addDays( 30 );
217 if ( date >= startdate && date <= enddate ) {
221 startdate = enddate.
addDays( 1 );
222 enddate = startdate.
addDays( 30 );
223 if ( date >= startdate && date <= enddate ) {
227 startdate = enddate.
addDays( 1 );
228 enddate = startdate.
addDays( 31 );
229 if ( date >= startdate && date <= enddate ) {
233 startdate = enddate.
addDays( 1 );
234 enddate = startdate.
addDays( 30 );
235 if ( date >= startdate && date <= enddate ) {
239 startdate = enddate.
addDays( 1 );
240 enddate = startdate.
addDays( 30 );
241 if ( date >= startdate && date <= enddate ) {
245 startdate = enddate.
addDays( 1 );
246 enddate = startdate.
addDays( 30 );
247 if ( date >= startdate && date <= enddate ) {
251 startdate = enddate.
addDays( 1 );
252 enddate = startdate.
addDays( 29 );
253 if ( date >= startdate && date <= enddate ) {
257 startdate = enddate.
addDays( 1 );
258 enddate = startdate.
addDays( 28 );
259 if ( date >= startdate && date <= enddate ) {
269 QString Zodiac::signSymbol( Zodiac::ZodiacSigns sign )
273 return i18nc(
"zodiac symbol for Aries",
"ram" );
275 return i18nc(
"zodiac symbol for Taurus",
"bull" );
277 return i18nc(
"zodiac symbol for Gemini",
"twins" );
279 return i18nc(
"zodiac symbol for Cancer",
"crab" );
281 return i18nc(
"zodiac symbol for Leo",
"lion" );
283 return i18nc(
"zodiac symbol for Virgo",
"virgin" );
285 return i18nc(
"zodiac symbol for Libra",
"scales" );
287 return i18nc(
"zodiac symbol for Scorpion",
"scorpion" );
289 return i18nc(
"zodiac symbol for Sagittarius",
"archer" );
291 return i18nc(
"zodiac symbol for Capricorn",
"goat" );
293 return i18nc(
"zodiac symbol for Aquarius",
"water carrier" );
295 return i18nc(
"zodiac symbol for Pices",
"fish" );
QDate addDays(int ndays) const