Changeset 8 for trunk/src/tools/qdatetime.cpp
- Timestamp:
- Nov 16, 2005, 8:36:46 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/tools/qdatetime.cpp
r7 r8 51 51 #endif 52 52 53 #if defined(Q_OS_OS2) 54 #include <unidef.h> 55 #include <sys/timeb.h> 56 #endif 57 53 58 static const uint FIRST_DAY = 2361222; // Julian day for 1752-09-14 54 59 static const int FIRST_YEAR = 1752; // ### wrong for many countries … … 515 520 } 516 521 #endif 517 #ifndef Q_WS_WIN 522 #if defined(Q_OS_OS2) 523 UniChar buffer[256]; 524 tm tt; 525 memset( &tt, 0, sizeof( tm ) ); 526 tt.tm_mon = month - 1; 527 LocaleObject lo = qt_os2DefLocaleObj(); 528 if (lo) 529 if ( UniStrftime( lo, buffer, sizeof( buffer ) / sizeof( UniChar ), 530 (UniChar *)L"%b", &tt ) 531 ) 532 return QString::fromUcs2( buffer ); 533 #elif !defined(Q_WS_WIN) 518 534 char buffer[255]; 519 535 tm tt; … … 561 577 } 562 578 #endif 563 #ifndef Q_WS_WIN 579 #if defined(Q_OS_OS2) 580 UniChar buffer[256]; 581 tm tt; 582 memset( &tt, 0, sizeof( tm ) ); 583 tt.tm_mon = month - 1; 584 LocaleObject lo = qt_os2DefLocaleObj(); 585 if (lo) 586 if ( UniStrftime( lo, buffer, sizeof( buffer ) / sizeof( UniChar ), 587 (UniChar *)L"%B", &tt ) 588 ) 589 return QString::fromUcs2( buffer ); 590 #elif !defined(Q_WS_WIN) 564 591 char buffer[255]; 565 592 tm tt; … … 615 642 } 616 643 #endif 617 #ifndef Q_WS_WIN 644 #if defined(Q_OS_OS2) 645 UniChar buffer[256]; 646 tm tt; 647 memset( &tt, 0, sizeof( tm ) ); 648 tt.tm_wday = ( weekday == 7 ) ? 0 : weekday; 649 LocaleObject lo = qt_os2DefLocaleObj(); 650 if (lo) 651 if ( UniStrftime( lo, buffer, sizeof( buffer ) / sizeof( UniChar ), 652 (UniChar *)L"%a", &tt ) 653 ) 654 return QString::fromUcs2( buffer ); 655 #elif !defined(Q_WS_WIN) 618 656 char buffer[255]; 619 657 tm tt; … … 663 701 } 664 702 #endif 665 #ifndef Q_WS_WIN 703 #if defined(Q_OS_OS2) 704 UniChar buffer[256]; 705 tm tt; 706 memset( &tt, 0, sizeof( tm ) ); 707 tt.tm_wday = ( weekday == 7 ) ? 0 : weekday; 708 LocaleObject lo = qt_os2DefLocaleObj(); 709 if (lo) 710 if ( UniStrftime( lo, buffer, sizeof( buffer ) / sizeof( UniChar ), 711 (UniChar *)L"%A", &tt ) 712 ) 713 return QString::fromUcs2( buffer ); 714 #elif !defined(Q_WS_WIN) 666 715 char buffer[255]; 667 716 tm tt; … … 729 778 case Qt::LocalDate: 730 779 { 731 #ifndef Q_WS_WIN 780 #if defined(Q_OS_OS2) 781 tm tt; 782 memset( &tt, 0, sizeof( tm ) ); 783 UniChar buf[256]; 784 tt.tm_mday = day(); 785 tt.tm_mon = month() - 1; 786 tt.tm_year = year() - 1900; 787 788 LocaleObject lo = qt_os2DefLocaleObj(); 789 if (lo) 790 if ( UniStrftime( lo, buf, sizeof( buf ) / sizeof( UniChar ), 791 (UniChar *)L"%x", &tt ) 792 ) 793 return QString::fromUcs2( buf ); 794 #elif !defined(Q_WS_WIN) 732 795 tm tt; 733 796 memset( &tt, 0, sizeof( tm ) ); … … 1395 1458 case Qt::LocalDate: 1396 1459 { 1397 #ifndef Q_WS_WIN 1460 #if defined(Q_OS_OS2) 1461 tm tt; 1462 memset( &tt, 0, sizeof( tm ) ); 1463 UniChar buf[256]; 1464 tt.tm_sec = second(); 1465 tt.tm_min = minute(); 1466 tt.tm_hour = hour(); 1467 1468 LocaleObject lo = qt_os2DefLocaleObj(); 1469 if (lo) 1470 if ( UniStrftime( lo, buf, sizeof( buf ) / sizeof( UniChar ), 1471 (UniChar *)L"%X", &tt ) 1472 ) 1473 return QString::fromUcs2( buf ); 1474 #elif !defined(Q_WS_WIN) 1398 1475 tm tt; 1399 1476 memset( &tt, 0, sizeof( tm ) ); … … 1743 1820 ct->ds = (uint)( MSECS_PER_HOUR * t->tm_hour + MSECS_PER_MIN * t->tm_min + 1744 1821 1000 * t->tm_sec + tv.tv_usec / 1000 ); 1822 #elif defined(Q_OS_OS2) 1823 timeb ltime; 1824 ::ftime( <ime ); 1825 tm *t; 1826 if ( ts == Qt::LocalTime ) 1827 t = localtime( <ime.time ); 1828 else 1829 t = gmtime( <ime.time ); 1830 ct->ds = (uint) ( MSECS_PER_HOUR * t->tm_hour + MSECS_PER_MIN * t->tm_min + 1831 1000 * t->tm_sec + ltime.millitm ); 1745 1832 #else 1746 1833 time_t ltime; // no millisecond resolution … … 1748 1835 tm *t; 1749 1836 if ( ts == Qt::LocalTime ) 1750 localtime( <ime );1837 t = localtime( <ime ); 1751 1838 else 1752 gmtime( <ime );1839 t = gmtime( <ime ); 1753 1840 ct->ds = (uint) ( MSECS_PER_HOUR * t->tm_hour + MSECS_PER_MIN * t->tm_min + 1754 1841 1000 * t->tm_sec );
Note:
See TracChangeset
for help on using the changeset viewer.