Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/corelib/tools/qdatetime.cpp

    r79 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information ([email protected])
     4** All rights reserved.
     5** Contact: Nokia Corporation ([email protected])
    56**
    67** This file is part of the QtCore module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you
     37** @nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    5050#include "qdebug.h"
    5151#if defined(Q_OS_WIN32) || defined(Q_OS_WINCE)
    52 #include <windows.h>
     52#include <windows.h>
    5353#endif
    5454#ifndef Q_WS_WIN
     
    7272#if defined(Q_WS_MAC)
    7373#include <private/qcore_mac_p.h>
     74
     75
     76
     77
    7478#endif
    7579
     
    194198    \brief The QDate class provides date functions.
    195199
    196     \ingroup time
    197     \mainclass
    198200
    199201    A QDate object contains a calendar date, i.e. year, month, and day
     
    11311133    GetLocalTime(&st);
    11321134    d.jd = julianDayFromDate(st.wYear, st.wMonth, st.wDay);
     1135
     1136
     1137
     1138
     1139
     1140
    11331141#else
    11341142    // posix compliant system
     
    14121420    \brief The QTime class provides clock time functions.
    14131421
    1414     \ingroup time
    1415     \mainclass
    14161422
    14171423    A QTime object contains a clock time, i.e. the number of hours,
     
    18281834    ct.startTick = GetTickCount() % MSECS_PER_DAY;
    18291835#endif
     1836
     1837
     1838
     1839
     1840
     1841
    18301842#elif defined(Q_OS_UNIX) || (defined(Q_OS_OS2) && defined(Q_CC_GNU))
    18311843    // posix compliant system
     
    18431855    t = localtime(&ltime);
    18441856#endif
     1857
    18451858
    18461859    ct.mds = MSECS_PER_HOUR * t->tm_hour + MSECS_PER_MIN * t->tm_min + 1000 * t->tm_sec
     
    18491862    time_t ltime; // no millisecond resolution
    18501863    ::time(&ltime);
    1851     tm *t = 0;
    1852     t = localtime(&ltime);
     1864    const tm *const t = localtime(&ltime);
    18531865    ct.mds = MSECS_PER_HOUR * t->tm_hour + MSECS_PER_MIN * t->tm_min + 1000 * t->tm_sec;
    18541866#endif
     
    20762088    \brief The QDateTime class provides date and time functions.
    20772089
    2078     \ingroup time
    2079     \mainclass
    20802090
    20812091    A QDateTime object contains a calendar date and a clock time (a
     
    22012211*/
    22022212QDateTime::QDateTime()
    2203 {
    2204     d = new QDateTimePrivate;
     2213    : d(new QDateTimePrivate)
     2214{
    22052215}
    22062216
     
    22122222
    22132223QDateTime::QDateTime(const QDate &date)
    2214 {
    2215     d = new QDateTimePrivate;
     2224    : d(new QDateTimePrivate)
     2225{
    22162226    d->date = date;
    22172227    d->time = QTime(0, 0, 0);
     
    22262236
    22272237QDateTime::QDateTime(const QDate &date, const QTime &time, Qt::TimeSpec spec)
    2228 {
    2229     d = new QDateTimePrivate;
     2238    : d(new QDateTimePrivate)
     2239{
    22302240    d->date = date;
    22312241    d->time = date.isValid() && !time.isValid() ? QTime(0, 0, 0) : time;
     
    22382248
    22392249QDateTime::QDateTime(const QDateTime &other)
    2240 {
    2241     d = other.d;
    2242     d->ref.ref();
     2250    : d(other.d)
     2251{
    22432252}
    22442253
     
    22482257QDateTime::~QDateTime()
    22492258{
    2250     if (!d->ref.deref())
    2251         delete d;
    22522259}
    22532260
     
    22592266QDateTime &QDateTime::operator=(const QDateTime &other)
    22602267{
    2261     qAtomicAssign(d, other.d);
     2268    ;
    22622269    return *this;
    22632270}
     
    25052512        buf += QString::number(d->date.day());
    25062513#else
    2507         QString winstr;
    2508         QT_WA({
    2509             TCHAR out[255];
    2510             GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_ILDATE, out, 255);
    2511             winstr = QString::fromUtf16((ushort*)out);
    2512         } , {
    2513             char out[255];
    2514             GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_ILDATE, (char*)&out, 255);
    2515             winstr = QString::fromLocal8Bit(out);
    2516         });
     2514        wchar_t out[255];
     2515        GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_ILDATE, out, 255);
     2516        QString winstr = QString::fromWCharArray(out);
    25172517        switch (winstr.toInt()) {
    25182518        case 1:
     
    28912891            + st.wMilliseconds;
    28922892    return QDateTime(d, t);
     2893
     2894
    28932895#else
    28942896#if defined(Q_OS_UNIX) || (defined(Q_OS_OS2) && defined(Q_CC_GNU))
     
    33003302void QDateTime::detach()
    33013303{
    3302     qAtomicDetach(d);
     3304    );
    33033305}
    33043306
     
    37183720    res.tm_year = sysTime.wYear - 1900;
    37193721    brokenDown = &res;
     3722
     3723
     3724
     3725
     3726
     3727
     3728
     3729
     3730
     3731
     3732
     3733
     3734
     3735
     3736
     3737
     3738
     3739
     3740
     3741
     3742
    37203743#elif !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS)
    37213744    // use the reentrant version of localtime() where available
     
    37633786    localTM.tm_year = fakeDate.year() - 1900;
    37643787    localTM.tm_isdst = (int)isdst;
    3765 #if defined(Q_OS_WINCE)
     3788#if defined(Q_OS_WINCE)
    37663789    time_t secsSince1Jan1970UTC = toTime_tHelper(fakeDate, time);
    37673790#else
     
    37883811    res.tm_isdst = (int)isdst;
    37893812    brokenDown = &res;
     3813
     3814
     3815
     3816
     3817
     3818
     3819
     3820
     3821
     3822
     3823
     3824
     3825
     3826
     3827
     3828
     3829
     3830
     3831
     3832
     3833
    37903834#elif !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS)
    37913835    // use the reentrant version of gmtime() where available
     
    38353879QDebug operator<<(QDebug dbg, const QDate &date)
    38363880{
    3837     dbg.nospace() << "QDate(" << date.toString() << ")";
     3881    dbg.nospace() << "QDate(" << date.toString() << ;
    38383882    return dbg.space();
    38393883}
     
    38413885QDebug operator<<(QDebug dbg, const QTime &time)
    38423886{
    3843     dbg.nospace() << "QTime(" << time.toString() << ")";
     3887    dbg.nospace() << "QTime(" << time.toString() << ;
    38443888    return dbg.space();
    38453889}
     
    38473891QDebug operator<<(QDebug dbg, const QDateTime &date)
    38483892{
    3849     dbg.nospace() << "QDateTime(" << date.toString() << ")";
     3893    dbg.nospace() << "QDateTime(" << date.toString() << ;
    38503894    return dbg.space();
    38513895}
     
    44004444        qWarning("QDateTimeParser::sectionMaxSize: Invalid section %s",
    44014445                 sectionName(s).toLatin1().constData());
     4446
     4447
     4448
     4449
     4450
     4451
     4452
    44024453    }
    44034454    return -1;
     
    46904741                const FieldInfo fi = fieldInfo(index);
    46914742                if ((fi & (Numeric|FixedWidth)) == (Numeric|FixedWidth)) {
    4692                     const QString newText = QString(QLatin1String("%1")).arg(num, sn.count, 10, QLatin1Char('0'));
     4743                    const QString newText = QString).arg(num, sn.count, 10, QLatin1Char('0'));
    46934744                    input.replace(pos, used, newText);
    46944745                    used = sn.count;
Note: See TracChangeset for help on using the changeset viewer.