Logo Search packages:      
Sourcecode: qt4-x11 version File versions

QDate QDate::currentDate (  )  [static]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Returns the current date, as reported by the system clock.

See also:
QTime::currentTime(), QDateTime::currentDateTime()

Definition at line 945 of file qdatetime.cpp.

References jd.

Referenced by Window::createDateTimeEdits(), MainWindow::createLetter(), QDateTime::currentDateTime(), Q3DateEdit::fix(), MainWindow::insertCalendar(), MainWindow::newLetter(), and QCalendarWidget::showToday().

{
    QDate d;
#if defined(Q_OS_WIN)
    SYSTEMTIME st;
    memset(&st, 0, sizeof(SYSTEMTIME));
    GetLocalTime(&st);
    d.jd = julianDayFromDate(st.wYear, st.wMonth, st.wDay);
#else
    // posix compliant system
    time_t ltime;
    time(&ltime);
    tm *t = 0;

#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS)
    // use the reentrant version of localtime() where available
    tm res;
    t = localtime_r(&ltime, &res);
#else
    t = localtime(&ltime);
#endif // !QT_NO_THREAD && _POSIX_THREAD_SAFE_FUNCTIONS

    d.jd = julianDayFromDate(t->tm_year + 1900, t->tm_mon + 1, t->tm_mday);
#endif
    return d;
}


Generated by  Doxygen 1.6.0   Back to index