Ignore:
Timestamp:
Nov 16, 2005, 8:36:46 PM (20 years ago)
Author:
dmik
Message:

Transferred Qt for OS/2 version 3.3.1-rc5 sources from the CVS

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/tools/qdatetime.cpp

    r7 r8  
    5151#endif
    5252
     53#if defined(Q_OS_OS2)
     54#include <unidef.h>
     55#include <sys/timeb.h>
     56#endif
     57
    5358static const uint FIRST_DAY     = 2361222;      // Julian day for 1752-09-14
    5459static const int  FIRST_YEAR    = 1752;         // ### wrong for many countries
     
    515520    }
    516521#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)
    518534    char buffer[255];
    519535    tm tt;
     
    561577    }
    562578#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)
    564591    char buffer[255];
    565592    tm tt;
     
    615642    }
    616643#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)
    618656    char buffer[255];
    619657    tm tt;
     
    663701    }
    664702#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)
    666715    char buffer[255];
    667716    tm tt;
     
    729778    case Qt::LocalDate:
    730779        {
    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)
    732795            tm tt;
    733796            memset( &tt, 0, sizeof( tm ) );
     
    13951458    case Qt::LocalDate:
    13961459        {
    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)
    13981475            tm tt;
    13991476            memset( &tt, 0, sizeof( tm ) );
     
    17431820    ct->ds = (uint)( MSECS_PER_HOUR * t->tm_hour + MSECS_PER_MIN * t->tm_min +
    17441821                     1000 * t->tm_sec + tv.tv_usec / 1000 );
     1822#elif defined(Q_OS_OS2)
     1823    timeb ltime;
     1824    ::ftime( &ltime );
     1825    tm *t;
     1826    if ( ts == Qt::LocalTime )
     1827        t = localtime( &ltime.time );
     1828    else
     1829        t = gmtime( &ltime.time );
     1830    ct->ds = (uint) ( MSECS_PER_HOUR * t->tm_hour + MSECS_PER_MIN * t->tm_min +
     1831                      1000 * t->tm_sec + ltime.millitm );
    17451832#else
    17461833    time_t ltime; // no millisecond resolution
     
    17481835    tm *t;
    17491836    if ( ts == Qt::LocalTime )
    1750         localtime( &ltime );
     1837        t = localtime( &ltime );
    17511838    else
    1752         gmtime( &ltime );
     1839        t = gmtime( &ltime );
    17531840    ct->ds = (uint) ( MSECS_PER_HOUR * t->tm_hour + MSECS_PER_MIN * t->tm_min +
    17541841                      1000 * t->tm_sec );
Note: See TracChangeset for help on using the changeset viewer.