summaryrefslogtreecommitdiffabout
authorulf69 <ulf69>2004-10-18 03:01:17 (UTC)
committer ulf69 <ulf69>2004-10-18 03:01:17 (UTC)
commit1712d92ea25b220273859d985bc7211fa7a97a39 (patch) (unidiff)
tree00b603af10b0da8d757ffec5c29f73953fbf03e0
parent2fd3f09238a624b1a91793d43b5f3653e2b34763 (diff)
downloadkdepimpi-1712d92ea25b220273859d985bc7211fa7a97a39.zip
kdepimpi-1712d92ea25b220273859d985bc7211fa7a97a39.tar.gz
kdepimpi-1712d92ea25b220273859d985bc7211fa7a97a39.tar.bz2
return a real empty value in readDateTime
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kdecore/klocale.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/microkde/kdecore/klocale.cpp b/microkde/kdecore/klocale.cpp
index 8b4513e..27acfec 100644
--- a/microkde/kdecore/klocale.cpp
+++ b/microkde/kdecore/klocale.cpp
@@ -214,258 +214,262 @@ QString KLocale::formatTime(const QTime &pTime, bool includeSecs, IntDateFormat
214 case 'S': 214 case 'S':
215 if (includeSecs) 215 if (includeSecs)
216 put_it_in( buffer, index, pTime.second() ); 216 put_it_in( buffer, index, pTime.second() );
217 else 217 else
218 { 218 {
219 // we remove the seperator sign before the seconds and 219 // we remove the seperator sign before the seconds and
220 // assume that works everywhere 220 // assume that works everywhere
221 --index; 221 --index;
222 break; 222 break;
223 } 223 }
224 break; 224 break;
225 case 'k': 225 case 'k':
226 number = pTime.hour(); 226 number = pTime.hour();
227 case 'l': 227 case 'l':
228 // to share the code 228 // to share the code
229 if ( rst.at( format_index ).unicode() == 'l' ) 229 if ( rst.at( format_index ).unicode() == 'l' )
230 number = (pTime.hour() + 11) % 12 + 1; 230 number = (pTime.hour() + 11) % 12 + 1;
231 if ( number / 10 ) 231 if ( number / 10 )
232 buffer[index++] = number / 10 + '0'; 232 buffer[index++] = number / 10 + '0';
233 buffer[index++] = number % 10 + '0'; 233 buffer[index++] = number % 10 + '0';
234 break; 234 break;
235 case 'p': 235 case 'p':
236 { 236 {
237 QString s; 237 QString s;
238 if ( pTime.hour() >= 12 ) 238 if ( pTime.hour() >= 12 )
239 put_it_in( buffer, index, i18n("pm") ); 239 put_it_in( buffer, index, i18n("pm") );
240 else 240 else
241 put_it_in( buffer, index, i18n("am") ); 241 put_it_in( buffer, index, i18n("am") );
242 break; 242 break;
243 } 243 }
244 default: 244 default:
245 buffer[index++] = rst.at( format_index ); 245 buffer[index++] = rst.at( format_index );
246 break; 246 break;
247 } 247 }
248 escape = false; 248 escape = false;
249 } 249 }
250 } 250 }
251 QString ret( buffer, index ); 251 QString ret( buffer, index );
252 delete [] buffer; 252 delete [] buffer;
253 return ret; 253 return ret;
254} 254}
255 255
256QString KLocale::formatDate(const QDate &pDate, bool shortFormat, IntDateFormat intIntDateFormat) const 256QString KLocale::formatDate(const QDate &pDate, bool shortFormat, IntDateFormat intIntDateFormat) const
257{ 257{
258 const QString rst = shortFormat?dateFormatShort(intIntDateFormat):dateFormat(intIntDateFormat); 258 const QString rst = shortFormat?dateFormatShort(intIntDateFormat):dateFormat(intIntDateFormat);
259 259
260 // I'm rather safe than sorry 260 // I'm rather safe than sorry
261 QChar *buffer = new QChar[rst.length() * 3 / 2 + 50]; 261 QChar *buffer = new QChar[rst.length() * 3 / 2 + 50];
262 262
263 unsigned int index = 0; 263 unsigned int index = 0;
264 bool escape = false; 264 bool escape = false;
265 int number = 0; 265 int number = 0;
266 266
267 for ( uint format_index = 0; format_index < rst.length(); ++format_index ) 267 for ( uint format_index = 0; format_index < rst.length(); ++format_index )
268 { 268 {
269 if ( !escape ) 269 if ( !escape )
270 { 270 {
271 if ( rst.at( format_index ).unicode() == '%' ) 271 if ( rst.at( format_index ).unicode() == '%' )
272 escape = true; 272 escape = true;
273 else 273 else
274 buffer[index++] = rst.at( format_index ); 274 buffer[index++] = rst.at( format_index );
275 } 275 }
276 else 276 else
277 { 277 {
278 switch ( rst.at( format_index ).unicode() ) 278 switch ( rst.at( format_index ).unicode() )
279 { 279 {
280 case '%': 280 case '%':
281 buffer[index++] = '%'; 281 buffer[index++] = '%';
282 break; 282 break;
283 case 'Y': 283 case 'Y':
284 put_it_in( buffer, index, pDate.year() / 100 ); 284 put_it_in( buffer, index, pDate.year() / 100 );
285 case 'y': 285 case 'y':
286 put_it_in( buffer, index, pDate.year() % 100 ); 286 put_it_in( buffer, index, pDate.year() % 100 );
287 break; 287 break;
288 case 'n': 288 case 'n':
289 number = pDate.month(); 289 number = pDate.month();
290 case 'e': 290 case 'e':
291 // to share the code 291 // to share the code
292 if ( rst.at( format_index ).unicode() == 'e' ) 292 if ( rst.at( format_index ).unicode() == 'e' )
293 number = pDate.day(); 293 number = pDate.day();
294 if ( number / 10 ) 294 if ( number / 10 )
295 buffer[index++] = number / 10 + '0'; 295 buffer[index++] = number / 10 + '0';
296 buffer[index++] = number % 10 + '0'; 296 buffer[index++] = number % 10 + '0';
297 break; 297 break;
298 case 'm': 298 case 'm':
299 put_it_in( buffer, index, pDate.month() ); 299 put_it_in( buffer, index, pDate.month() );
300 break; 300 break;
301 case 'b': 301 case 'b':
302 put_it_in( buffer, index, monthName(pDate.month(), true) ); 302 put_it_in( buffer, index, monthName(pDate.month(), true) );
303 break; 303 break;
304 case 'B': 304 case 'B':
305 put_it_in( buffer, index, monthName(pDate.month(), false) ); 305 put_it_in( buffer, index, monthName(pDate.month(), false) );
306 break; 306 break;
307 case 'd': 307 case 'd':
308 put_it_in( buffer, index, pDate.day() ); 308 put_it_in( buffer, index, pDate.day() );
309 break; 309 break;
310 case 'a': 310 case 'a':
311 put_it_in( buffer, index, weekDayName(pDate.dayOfWeek(), true) ); 311 put_it_in( buffer, index, weekDayName(pDate.dayOfWeek(), true) );
312 break; 312 break;
313 case 'A': 313 case 'A':
314 put_it_in( buffer, index, weekDayName(pDate.dayOfWeek(), false) ); 314 put_it_in( buffer, index, weekDayName(pDate.dayOfWeek(), false) );
315 break; 315 break;
316 default: 316 default:
317 buffer[index++] = rst.at( format_index ); 317 buffer[index++] = rst.at( format_index );
318 break; 318 break;
319 } 319 }
320 escape = false; 320 escape = false;
321 } 321 }
322 } 322 }
323 QString ret( buffer, index ); 323 QString ret( buffer, index );
324 delete [] buffer; 324 delete [] buffer;
325 return ret; 325 return ret;
326} 326}
327 327
328QString KLocale::formatDateTime(const QDateTime &pDateTime, 328QString KLocale::formatDateTime(const QDateTime &pDateTime,
329 bool shortFormat, 329 bool shortFormat,
330 bool includeSeconds, 330 bool includeSeconds,
331 IntDateFormat intIntDateFormat) const 331 IntDateFormat intIntDateFormat) const
332{ 332{
333 QString format("%1 %2"); 333 QString format("%1 %2");
334 334
335 if ( intIntDateFormat == Default ) 335 if ( intIntDateFormat == Default )
336 format = "%1 %2"; 336 format = "%1 %2";
337 else if ( intIntDateFormat == Format1 ) 337 else if ( intIntDateFormat == Format1 )
338 format = "%1 %2"; 338 format = "%1 %2";
339 else if ( intIntDateFormat == ISODate ) 339 else if ( intIntDateFormat == ISODate )
340 format = "%1T%2"; 340 format = "%1T%2";
341 341
342 return format.arg(formatDate( pDateTime.date(), shortFormat, intIntDateFormat )) 342 QString res = format.arg(formatDate( pDateTime.date(), shortFormat, intIntDateFormat ))
343 .arg(formatTime( pDateTime.time(), includeSeconds , intIntDateFormat )); 343 .arg(formatTime( pDateTime.time(), includeSeconds , intIntDateFormat ));
344
345 //qDebug("KLocale::formatDateTime transformed %s, into %s", pDateTime.toString().latin1(), res.latin1() );
346
347 return res;
344} 348}
345 349
346QString KLocale::formatDateTime(const QDateTime &pDateTime, IntDateFormat intIntDateFormat) const 350QString KLocale::formatDateTime(const QDateTime &pDateTime, IntDateFormat intIntDateFormat) const
347{ 351{
348 return formatDateTime(pDateTime, true, true, intIntDateFormat); 352 return formatDateTime(pDateTime, true, true, intIntDateFormat);
349} 353}
350 354
351QDate KLocale::readDate(const QString &intstr, bool* ok) const 355QDate KLocale::readDate(const QString &intstr, bool* ok) const
352{ 356{
353 QDate date; 357 QDate date;
354 date = readDate(intstr, true, ok); 358 date = readDate(intstr, true, ok);
355 if (date.isValid()) return date; 359 if (date.isValid()) return date;
356 return readDate(intstr, false, ok); 360 return readDate(intstr, false, ok);
357} 361}
358 362
359QDate KLocale::readDate(const QString &intstr, bool shortFormat, bool* ok) const 363QDate KLocale::readDate(const QString &intstr, bool shortFormat, bool* ok) const
360{ 364{
361 QString fmt = (shortFormat ? dateFormatShort() : dateFormat()).simplifyWhiteSpace(); 365 QString fmt = (shortFormat ? dateFormatShort() : dateFormat()).simplifyWhiteSpace();
362 return readDate( intstr, fmt, ok ); 366 return readDate( intstr, fmt, ok );
363} 367}
364 368
365QDate KLocale::readDate(const QString &intstr, const QString &fmt, bool* ok) const 369QDate KLocale::readDate(const QString &intstr, const QString &fmt, bool* ok) const
366{ 370{
367 //kdDebug(173) << "KLocale::readDate intstr=" << intstr << " fmt=" << fmt << endl; 371 //kdDebug(173) << "KLocale::readDate intstr=" << intstr << " fmt=" << fmt << endl;
368 QString str = intstr.simplifyWhiteSpace().lower(); 372 QString str = intstr.simplifyWhiteSpace().lower();
369 int day = -1, month = -1; 373 int day = -1, month = -1;
370 // allow the year to be omitted if not in the format 374 // allow the year to be omitted if not in the format
371 int year = QDate::currentDate().year(); 375 int year = QDate::currentDate().year();
372 uint strpos = 0; 376 uint strpos = 0;
373 uint fmtpos = 0; 377 uint fmtpos = 0;
374 378
375 while (fmt.length() > fmtpos || str.length() > strpos) 379 while (fmt.length() > fmtpos || str.length() > strpos)
376 { 380 {
377 if ( !(fmt.length() > fmtpos && str.length() > strpos) ) 381 if ( !(fmt.length() > fmtpos && str.length() > strpos) )
378 goto error; 382 goto error;
379 383
380 QChar c = fmt.at(fmtpos++); 384 QChar c = fmt.at(fmtpos++);
381 385
382 if (c != '%') { 386 if (c != '%') {
383 if (c.isSpace()) 387 if (c.isSpace())
384 strpos++; 388 strpos++;
385 else if (c != str.at(strpos++)) 389 else if (c != str.at(strpos++))
386 goto error; 390 goto error;
387 continue; 391 continue;
388 } 392 }
389 393
390 // remove space at the begining 394 // remove space at the begining
391 if (str.length() > strpos && str.at(strpos).isSpace()) 395 if (str.length() > strpos && str.at(strpos).isSpace())
392 strpos++; 396 strpos++;
393 397
394 c = fmt.at(fmtpos++); 398 c = fmt.at(fmtpos++);
395 switch (c) 399 switch (c)
396 { 400 {
397 case 'a': 401 case 'a':
398 case 'A': 402 case 'A':
399 // this will just be ignored 403 // this will just be ignored
400 { // Cristian Tache: porting to Win: Block added because of "j" redefinition 404 { // Cristian Tache: porting to Win: Block added because of "j" redefinition
401 for (int j = 1; j < 8; j++) { 405 for (int j = 1; j < 8; j++) {
402 QString s = weekDayName(j, c == 'a').lower(); 406 QString s = weekDayName(j, c == 'a').lower();
403 int len = s.length(); 407 int len = s.length();
404 if (str.mid(strpos, len) == s) 408 if (str.mid(strpos, len) == s)
405 strpos += len; 409 strpos += len;
406 } 410 }
407 break; 411 break;
408 } 412 }
409 case 'b': 413 case 'b':
410 case 'B': 414 case 'B':
411 { // Cristian Tache: porting to Win: Block added because of "j" redefinition 415 { // Cristian Tache: porting to Win: Block added because of "j" redefinition
412 for (int j = 1; j < 13; j++) { 416 for (int j = 1; j < 13; j++) {
413 QString s = monthName(j, c == 'b').lower(); 417 QString s = monthName(j, c == 'b').lower();
414 int len = s.length(); 418 int len = s.length();
415 if (str.mid(strpos, len) == s) { 419 if (str.mid(strpos, len) == s) {
416 month = j; 420 month = j;
417 strpos += len; 421 strpos += len;
418 } 422 }
419 } 423 }
420 break; 424 break;
421 } 425 }
422 case 'd': 426 case 'd':
423 case 'e': 427 case 'e':
424 day = readInt(str, strpos); 428 day = readInt(str, strpos);
425 if (day < 1 || day > 31) 429 if (day < 1 || day > 31)
426 goto error; 430 goto error;
427 431
428 break; 432 break;
429 433
430 case 'n': 434 case 'n':
431 case 'm': 435 case 'm':
432 month = readInt(str, strpos); 436 month = readInt(str, strpos);
433 if (month < 1 || month > 12) 437 if (month < 1 || month > 12)
434 goto error; 438 goto error;
435 439
436 break; 440 break;
437 441
438 case 'Y': 442 case 'Y':
439 case 'y': 443 case 'y':
440 year = readInt(str, strpos); 444 year = readInt(str, strpos);
441 if (year < 0) 445 if (year < 0)
442 goto error; 446 goto error;
443 // Qt treats a year in the range 0-100 as 1900-1999. 447 // Qt treats a year in the range 0-100 as 1900-1999.
444 // It is nicer for the user if we treat 0-68 as 2000-2068 448 // It is nicer for the user if we treat 0-68 as 2000-2068
445 if (year < 69) 449 if (year < 69)
446 year += 2000; 450 year += 2000;
447 else if (c == 'y') 451 else if (c == 'y')
448 year += 1900; 452 year += 1900;
449 453
450 break; 454 break;
451 } 455 }
452 } 456 }
453 //kdDebug(173) << "KLocale::readDate day=" << day << " month=" << month << " year=" << year << endl; 457 //kdDebug(173) << "KLocale::readDate day=" << day << " month=" << month << " year=" << year << endl;
454 if ( year != -1 && month != -1 && day != -1 ) 458 if ( year != -1 && month != -1 && day != -1 )
455 { 459 {
456 if (ok) *ok = true; 460 if (ok) *ok = true;
457 return QDate(year, month, day); 461 return QDate(year, month, day);
458 } 462 }
459 error: 463 error:
460 if (ok) *ok = false; 464 if (ok) *ok = false;
461 return QDate(); // invalid date 465 return QDate(); // invalid date
462} 466}
463 467
464QTime KLocale::readTime(const QString &intstr, bool *ok) const 468QTime KLocale::readTime(const QString &intstr, bool *ok) const
465{ 469{
466 QTime _time; 470 QTime _time;
467 _time = readTime(intstr, true, ok); 471 _time = readTime(intstr, true, ok);
468 if (_time.isValid()) return _time; 472 if (_time.isValid()) return _time;
469 return readTime(intstr, false, ok); 473 return readTime(intstr, false, ok);
470} 474}
471 475
@@ -476,268 +480,274 @@ QTime KLocale::readTime(const QString &intstr, bool seconds, bool *ok) const
476 if (!seconds) 480 if (!seconds)
477 Format.replace(QRegExp(QString::fromLatin1(".%S")), QString::null); 481 Format.replace(QRegExp(QString::fromLatin1(".%S")), QString::null);
478 482
479 int hour = -1, minute = -1, second = seconds ? -1 : 0; // don't require seconds 483 int hour = -1, minute = -1, second = seconds ? -1 : 0; // don't require seconds
480 484
481 bool g_12h = false; 485 bool g_12h = false;
482 bool pm = false; 486 bool pm = false;
483 uint strpos = 0; 487 uint strpos = 0;
484 uint Formatpos = 0; 488 uint Formatpos = 0;
485 489
486 while (Format.length() > Formatpos || str.length() > strpos) 490 while (Format.length() > Formatpos || str.length() > strpos)
487 { 491 {
488 if ( !(Format.length() > Formatpos && str.length() > strpos) ) goto error; 492 if ( !(Format.length() > Formatpos && str.length() > strpos) ) goto error;
489 493
490 QChar c = Format.at(Formatpos++); 494 QChar c = Format.at(Formatpos++);
491 495
492 if (c != '%') 496 if (c != '%')
493 { 497 {
494 if (c.isSpace()) 498 if (c.isSpace())
495 strpos++; 499 strpos++;
496 else if (c != str.at(strpos++)) 500 else if (c != str.at(strpos++))
497 goto error; 501 goto error;
498 continue; 502 continue;
499 } 503 }
500 504
501 // remove space at the begining 505 // remove space at the begining
502 if (str.length() > strpos && str.at(strpos).isSpace()) 506 if (str.length() > strpos && str.at(strpos).isSpace())
503 strpos++; 507 strpos++;
504 508
505 c = Format.at(Formatpos++); 509 c = Format.at(Formatpos++);
506 switch (c) 510 switch (c)
507 { 511 {
508 case 'p': 512 case 'p':
509 { 513 {
510 QString s; 514 QString s;
511 s = i18n("pm").lower(); 515 s = i18n("pm").lower();
512 int len = s.length(); 516 int len = s.length();
513 if (str.mid(strpos, len) == s) 517 if (str.mid(strpos, len) == s)
514 { 518 {
515 pm = true; 519 pm = true;
516 strpos += len; 520 strpos += len;
517 } 521 }
518 else 522 else
519 { 523 {
520 s = i18n("am").lower(); 524 s = i18n("am").lower();
521 len = s.length(); 525 len = s.length();
522 if (str.mid(strpos, len) == s) { 526 if (str.mid(strpos, len) == s) {
523 pm = false; 527 pm = false;
524 strpos += len; 528 strpos += len;
525 } 529 }
526 else 530 else
527 goto error; 531 goto error;
528 } 532 }
529 } 533 }
530 break; 534 break;
531 535
532 case 'k': 536 case 'k':
533 case 'H': 537 case 'H':
534 g_12h = false; 538 g_12h = false;
535 hour = readInt(str, strpos); 539 hour = readInt(str, strpos);
536 if (hour < 0 || hour > 23) 540 if (hour < 0 || hour > 23)
537 goto error; 541 goto error;
538 542
539 break; 543 break;
540 544
541 case 'l': 545 case 'l':
542 case 'I': 546 case 'I':
543 g_12h = true; 547 g_12h = true;
544 hour = readInt(str, strpos); 548 hour = readInt(str, strpos);
545 if (hour < 1 || hour > 12) 549 if (hour < 1 || hour > 12)
546 goto error; 550 goto error;
547 551
548 break; 552 break;
549 553
550 case 'M': 554 case 'M':
551 minute = readInt(str, strpos); 555 minute = readInt(str, strpos);
552 if (minute < 0 || minute > 59) 556 if (minute < 0 || minute > 59)
553 goto error; 557 goto error;
554 558
555 break; 559 break;
556 560
557 case 'S': 561 case 'S':
558 second = readInt(str, strpos); 562 second = readInt(str, strpos);
559 if (second < 0 || second > 59) 563 if (second < 0 || second > 59)
560 goto error; 564 goto error;
561 565
562 break; 566 break;
563 } 567 }
564 } 568 }
565 if (g_12h) 569 if (g_12h)
566 { 570 {
567 hour %= 12; 571 hour %= 12;
568 if (pm) hour += 12; 572 if (pm) hour += 12;
569 } 573 }
570 574
571 if (ok) *ok = true; 575 if (ok) *ok = true;
572 return QTime(hour, minute, second); 576 return QTime(hour, minute, second);
573 577
574 error: 578 error:
575 if (ok) *ok = false; 579 if (ok) *ok = false;
576 return QTime(-1, -1, -1); // return invalid date if it didn't work 580 return QTime(-1, -1, -1); // return invalid date if it didn't work
577 // This will be removed in the near future, since it gives a warning on stderr. 581 // This will be removed in the near future, since it gives a warning on stderr.
578 // The presence of the bool* (since KDE-3.0) removes the need for an invalid QTime. 582 // The presence of the bool* (since KDE-3.0) removes the need for an invalid QTime.
579} 583}
580 584
581QDateTime KLocale::readDateTime(const QString &intstr, 585QDateTime KLocale::readDateTime(const QString &intstr,
582 IntDateFormat intIntDateFormat, 586 IntDateFormat intIntDateFormat,
583 bool* ok) const 587 bool* ok) const
584{ 588{
585 bool ok1, ok2; 589 bool ok1, ok2;
586 590
587 // AT the moment we can not read any other format then ISODate 591 // AT the moment we can not read any other format then ISODate
588 if ( intIntDateFormat != ISODate ) 592 if ( intIntDateFormat != ISODate )
589 { 593 {
590 qDebug("KLocale::readDateTime, only ISODate is supported."); 594 qDebug("KLocale::readDateTime, only ISODate is supported.");
591 return QDateTime(); 595 return QDateTime();
592 } 596 }
593 597
594 int pos = intstr.find("T"); 598 int pos = intstr.find("T");
595 QString date = intstr.left(pos); 599 QString date = intstr.left(pos);
596 QString time = intstr.mid(pos+1); 600 QString time = intstr.mid(pos+1);
597 601
598 QString dformat = dateFormat(intIntDateFormat); 602 QString dformat = dateFormat(intIntDateFormat);
599 QString tformat = timeFormat(intIntDateFormat); 603 QString tformat = timeFormat(intIntDateFormat);
600 604
601 QDate m_date = readDate(date, dformat, &ok1); 605 QDate m_date = readDate(date, dformat, &ok1);
602 QTime m_time = readTime(time, tformat, &ok2); 606 QTime m_time = readTime(time, tformat, &ok2);
603 607
608 QDateTime m_dt;
609
604 if (ok) 610 if (ok)
605 { 611 {
606 if ((ok1 == false) || (ok2 == false)) 612 if ((ok1 == false) || (ok2 == false))
607 *ok = false; 613 *ok = false;
608 else 614 else
609 *ok = true; 615 *ok = true;
610 } 616 }
611 QDateTime m_dt;
612 m_dt.setDate(m_date);
613 m_dt.setTime(m_time);
614 617
615 qDebug("KLocale::readDateTime() transformed %s into %s (%s), %s (%s) : err1=%i, err2=%i", intstr.latin1(), date.latin1(), dformat.latin1(), time.latin1(), tformat.latin1(), ok1, ok2); 618 //only set values if both operations returned true.
619 if ((ok1 == true) && (ok2 == true))
620 {
621 m_dt.setDate(m_date);
622 m_dt.setTime(m_time);
623 }
624
625 //qDebug("KLocale::readDateTime() transformed %s into %s (%s), %s (%s) : err1=%i, err2=%i", intstr.latin1(), date.latin1(), dformat.latin1(), time.latin1(), tformat.latin1(), ok1, ok2);
616 return m_dt; 626 return m_dt;
617} 627}
618 628
619QDate KLocale::readDate(const QString &intstr, 629QDate KLocale::readDate(const QString &intstr,
620 IntDateFormat intIntDateFormat, 630 IntDateFormat intIntDateFormat,
621 bool* ok) const 631 bool* ok) const
622{ 632{
623 bool ok1; 633 bool ok1;
624 634
625 QString dformat = dateFormat(intIntDateFormat); 635 QString dformat = dateFormat(intIntDateFormat);
626 636
627 QDate m_date = readDate(intstr, dformat, &ok1); 637 QDate m_date = readDate(intstr, dformat, &ok1);
628 638
629 if (ok) 639 if (ok)
630 *ok = ok1; 640 *ok = ok1;
631 641
632 //qDebug("KLocale::readDate() transformed %s into %s (%s), %s (%s) : err1=%i, err2=%i", intstr.latin1(), date.latin1(), dformat.latin1(), time.latin1(), tformat.latin1(), ok1, ok2); 642 //qDebug("KLocale::readDate() transformed %s into %s (%s), %s (%s) : err1=%i, err2=%i", intstr.latin1(), date.latin1(), dformat.latin1(), time.latin1(), tformat.latin1(), ok1, ok2);
633 return m_date; 643 return m_date;
634} 644}
635 645
636 646
637bool KLocale::use12Clock() const 647bool KLocale::use12Clock() const
638{ 648{
639 return !mHourF24Format ;; 649 return !mHourF24Format ;;
640} 650}
641 651
642bool KLocale::weekStartsMonday() const 652bool KLocale::weekStartsMonday() const
643{ 653{
644 return mWeekStartsMonday; 654 return mWeekStartsMonday;
645} 655}
646 656
647int KLocale::weekStartDay() const 657int KLocale::weekStartDay() const
648{ 658{
649 if ( mWeekStartsMonday ) 659 if ( mWeekStartsMonday )
650 return 1; 660 return 1;
651 return 7; 661 return 7;
652} 662}
653 663
654QString KLocale::weekDayName(int i,bool shortName) const 664QString KLocale::weekDayName(int i,bool shortName) const
655{ 665{
656 if ( shortName ) 666 if ( shortName )
657 switch ( i ) 667 switch ( i )
658 { 668 {
659 case 1: return i18n("Monday", "Mon"); 669 case 1: return i18n("Monday", "Mon");
660 case 2: return i18n("Tuesday", "Tue"); 670 case 2: return i18n("Tuesday", "Tue");
661 case 3: return i18n("Wednesday", "Wed"); 671 case 3: return i18n("Wednesday", "Wed");
662 case 4: return i18n("Thursday", "Thu"); 672 case 4: return i18n("Thursday", "Thu");
663 case 5: return i18n("Friday", "Fri"); 673 case 5: return i18n("Friday", "Fri");
664 case 6: return i18n("Saturday", "Sat"); 674 case 6: return i18n("Saturday", "Sat");
665 case 7: return i18n("Sunday", "Sun"); 675 case 7: return i18n("Sunday", "Sun");
666 } 676 }
667 else 677 else
668 switch ( i ) 678 switch ( i )
669 { 679 {
670 case 1: return i18n("Monday"); 680 case 1: return i18n("Monday");
671 case 2: return i18n("Tuesday"); 681 case 2: return i18n("Tuesday");
672 case 3: return i18n("Wednesday"); 682 case 3: return i18n("Wednesday");
673 case 4: return i18n("Thursday"); 683 case 4: return i18n("Thursday");
674 case 5: return i18n("Friday"); 684 case 5: return i18n("Friday");
675 case 6: return i18n("Saturday"); 685 case 6: return i18n("Saturday");
676 case 7: return i18n("Sunday"); 686 case 7: return i18n("Sunday");
677 } 687 }
678 688
679 return QString::null; 689 return QString::null;
680} 690}
681 691
682QString KLocale::monthName(int i,bool shortName) const 692QString KLocale::monthName(int i,bool shortName) const
683{ 693{
684 if ( shortName ) 694 if ( shortName )
685 switch ( i ) 695 switch ( i )
686 { 696 {
687 case 1: return i18n("January", "Jan"); 697 case 1: return i18n("January", "Jan");
688 case 2: return i18n("February", "Feb"); 698 case 2: return i18n("February", "Feb");
689 case 3: return i18n("March", "Mar"); 699 case 3: return i18n("March", "Mar");
690 case 4: return i18n("April", "Apr"); 700 case 4: return i18n("April", "Apr");
691 case 5: return i18n("May short", "May"); 701 case 5: return i18n("May short", "May");
692 case 6: return i18n("June", "Jun"); 702 case 6: return i18n("June", "Jun");
693 case 7: return i18n("July", "Jul"); 703 case 7: return i18n("July", "Jul");
694 case 8: return i18n("August", "Aug"); 704 case 8: return i18n("August", "Aug");
695 case 9: return i18n("September", "Sep"); 705 case 9: return i18n("September", "Sep");
696 case 10: return i18n("October", "Oct"); 706 case 10: return i18n("October", "Oct");
697 case 11: return i18n("November", "Nov"); 707 case 11: return i18n("November", "Nov");
698 case 12: return i18n("December", "Dec"); 708 case 12: return i18n("December", "Dec");
699 } 709 }
700 else 710 else
701 switch (i) 711 switch (i)
702 { 712 {
703 case 1: return i18n("January"); 713 case 1: return i18n("January");
704 case 2: return i18n("February"); 714 case 2: return i18n("February");
705 case 3: return i18n("March"); 715 case 3: return i18n("March");
706 case 4: return i18n("April"); 716 case 4: return i18n("April");
707 case 5: return i18n("May long", "May"); 717 case 5: return i18n("May long", "May");
708 case 6: return i18n("June"); 718 case 6: return i18n("June");
709 case 7: return i18n("July"); 719 case 7: return i18n("July");
710 case 8: return i18n("August"); 720 case 8: return i18n("August");
711 case 9: return i18n("September"); 721 case 9: return i18n("September");
712 case 10: return i18n("October"); 722 case 10: return i18n("October");
713 case 11: return i18n("November"); 723 case 11: return i18n("November");
714 case 12: return i18n("December"); 724 case 12: return i18n("December");
715 } 725 }
716 726
717 return QString::null; 727 return QString::null;
718} 728}
719 729
720QString KLocale::country() const 730QString KLocale::country() const
721{ 731{
722 return QString::null; 732 return QString::null;
723} 733}
724 734
725QString KLocale::dateFormat(IntDateFormat intIntDateFormat) const 735QString KLocale::dateFormat(IntDateFormat intIntDateFormat) const
726{ 736{
727 const IntDateFormat dformat = (intIntDateFormat == Undefined)?mIntDateFormat:intIntDateFormat; 737 const IntDateFormat dformat = (intIntDateFormat == Undefined)?mIntDateFormat:intIntDateFormat;
728 738
729 if ( dformat == ISODate ) 739 if ( dformat == ISODate )
730 return "%Y-%m-%d"; 740 return "%Y-%m-%d";
731 741
732 if ( QApplication::desktop()->width() < 480 ) { 742 if ( QApplication::desktop()->width() < 480 ) {
733 if ( dformat == Default ) 743 if ( dformat == Default )
734 return "%a %d %b %Y"; 744 return "%a %d %b %Y";
735 else if ( dformat == Format1 ) 745 else if ( dformat == Format1 )
736 return "%a %b %d %Y"; 746 return "%a %b %d %Y";
737 } else { 747 } else {
738 if ( dformat == Default ) 748 if ( dformat == Default )
739 return "%A %d %B %Y"; 749 return "%A %d %B %Y";
740 else if ( dformat == Format1 ) 750 else if ( dformat == Format1 )
741 return "%A %B %d %Y"; 751 return "%A %B %d %Y";
742 752
743 } 753 }