Qt 4.8
Public Types | Public Functions | Static Public Functions | Public Variables | List of all members
QDateTimePrivate Class Reference

#include <qdatetime_p.h>

Public Types

enum  Spec {
  LocalUnknown = -1, LocalStandard = 0, LocalDST = 1, UTC = 2,
  OffsetFromUTC = 3
}
 

Public Functions

Spec getLocal (QDate &outDate, QTime &outTime) const
 
void getUTC (QDate &outDate, QTime &outTime) const
 
 QDateTimePrivate ()
 
 QDateTimePrivate (const QDateTimePrivate &other)
 

Static Public Functions

static QDateTime addMSecs (const QDateTime &dt, qint64 msecs)
 
static void addMSecs (QDate &utcDate, QTime &utcTime, qint64 msecs)
 Adds msecs to utcDate and utcTime as appropriate. More...
 

Public Variables

QDate date
 
QAtomicInt ref
 
Spec spec
 
QTime time
 
int utcOffset
 The offset in seconds. More...
 

Detailed Description

Definition at line 79 of file qdatetime_p.h.

Enumerations

◆ Spec

Enumerator
LocalUnknown 
LocalStandard 
LocalDST 
UTC 
OffsetFromUTC 

Definition at line 82 of file qdatetime_p.h.

Constructors and Destructors

◆ QDateTimePrivate() [1/2]

QDateTimePrivate::QDateTimePrivate ( )
inline

Definition at line 84 of file qdatetime_p.h.

◆ QDateTimePrivate() [2/2]

QDateTimePrivate::QDateTimePrivate ( const QDateTimePrivate other)
inline

Definition at line 85 of file qdatetime_p.h.

86  : date(other.date), time(other.time), spec(other.spec), utcOffset(other.utcOffset)
87  {}
int utcOffset
The offset in seconds.
Definition: qdatetime_p.h:102

Functions

◆ addMSecs() [1/2]

QDateTime QDateTimePrivate::addMSecs ( const QDateTime dt,
qint64  msecs 
)
static

Definition at line 2814 of file qdatetime.cpp.

Referenced by QDateTime::addMSecs(), and QDateTime::addSecs().

2815 {
2816  QDate utcDate;
2817  QTime utcTime;
2818  dt.d->getUTC(utcDate, utcTime);
2819 
2820  addMSecs(utcDate, utcTime, msecs);
2821 
2822  return QDateTime(utcDate, utcTime, Qt::UTC).toTimeSpec(dt.timeSpec());
2823 }
The QDate class provides date functions.
Definition: qdatetime.h:55
The QTime class provides clock time functions.
Definition: qdatetime.h:148
void getUTC(QDate &outDate, QTime &outTime) const
Definition: qdatetime.cpp:4422
static QDateTime addMSecs(const QDateTime &dt, qint64 msecs)
Definition: qdatetime.cpp:2814
The QDateTime class provides date and time functions.
Definition: qdatetime.h:216
Qt::TimeSpec timeSpec() const
Returns the time specification of the datetime.
Definition: qdatetime.cpp:2379
QExplicitlySharedDataPointer< QDateTimePrivate > d
Definition: qdatetime.h:294
QDateTime toTimeSpec(Qt::TimeSpec spec) const
Returns a copy of this datetime configured to use the given time specification.
Definition: qdatetime.cpp:2969

◆ addMSecs() [2/2]

void QDateTimePrivate::addMSecs ( QDate utcDate,
QTime utcTime,
qint64  msecs 
)
static

Adds msecs to utcDate and utcTime as appropriate.

It is assumed that utcDate and utcTime are adjusted to UTC.

Since
4.5
Warning
This function is not part of the public interface.

Definition at line 2832 of file qdatetime.cpp.

2833 {
2834  uint dd = utcDate.jd;
2835  int tt = utcTime.ds();
2836  int sign = 1;
2837  if (msecs < 0) {
2838  msecs = -msecs;
2839  sign = -1;
2840  }
2841  if (msecs >= int(MSECS_PER_DAY)) {
2842  dd += sign * (msecs / MSECS_PER_DAY);
2843  msecs %= MSECS_PER_DAY;
2844  }
2845 
2846  tt += sign * msecs;
2847  if (tt < 0) {
2848  tt = MSECS_PER_DAY - tt - 1;
2849  dd -= tt / MSECS_PER_DAY;
2850  tt = tt % MSECS_PER_DAY;
2851  tt = MSECS_PER_DAY - tt - 1;
2852  } else if (tt >= int(MSECS_PER_DAY)) {
2853  dd += tt / MSECS_PER_DAY;
2854  tt = tt % MSECS_PER_DAY;
2855  }
2856 
2857  utcDate.jd = dd;
2858  utcTime.mds = tt;
2859 }
static int sign(int x)
int ds() const
Definition: qdatetime.h:199
unsigned int uint
Definition: qglobal.h:996
int mds
Definition: qdatetime.h:200
uint jd
Definition: qdatetime.h:137

◆ getLocal()

QDateTimePrivate::Spec QDateTimePrivate::getLocal ( QDate outDate,
QTime outTime 
) const

Definition at line 4413 of file qdatetime.cpp.

Referenced by QDateTime::setMSecsSinceEpoch(), QDateTime::setTime_t(), and QDateTime::toTimeSpec().

4414 {
4415  outDate = date;
4416  outTime = time;
4417  if (spec == QDateTimePrivate::UTC)
4418  return utcToLocal(outDate, outTime);
4419  return spec;
4420 }
static QDateTimePrivate::Spec utcToLocal(QDate &date, QTime &time)
Definition: qdatetime.cpp:4228

◆ getUTC()

void QDateTimePrivate::getUTC ( QDate outDate,
QTime outTime 
) const

Definition at line 4422 of file qdatetime.cpp.

Referenced by addMSecs(), QDateTime::msecsTo(), QDateTime::operator<(), QDateTime::operator==(), QDateTime::secsTo(), QDateTime::toMSecsSinceEpoch(), and QDateTime::toTimeSpec().

4423 {
4424  outDate = date;
4425  outTime = time;
4426  const bool isOffset = spec == QDateTimePrivate::OffsetFromUTC;
4427 
4428  if (spec != QDateTimePrivate::UTC && !isOffset)
4429  localToUtc(outDate, outTime, (int)spec);
4430 
4431  if (isOffset)
4432  addMSecs(outDate, outTime, -(qint64(utcOffset) * 1000));
4433 }
static void localToUtc(QDate &date, QTime &time, int isdst)
Definition: qdatetime.cpp:4316
__int64 qint64
Definition: qglobal.h:942
static QDateTime addMSecs(const QDateTime &dt, qint64 msecs)
Definition: qdatetime.cpp:2814
int utcOffset
The offset in seconds.
Definition: qdatetime_p.h:102

Properties

◆ date

QDate QDateTimePrivate::date

◆ ref

QAtomicInt QDateTimePrivate::ref

Definition at line 89 of file qdatetime_p.h.

◆ spec

Spec QDateTimePrivate::spec

◆ time

QTime QDateTimePrivate::time

◆ utcOffset

int QDateTimePrivate::utcOffset

The offset in seconds.

Warning
This function is not part of the public interface.
Since
4.4

Applies only when timeSpec() is OffsetFromUTC.

Definition at line 102 of file qdatetime_p.h.

Referenced by QDateTime::operator==(), QDateTime::setUtcOffset(), QDateTime::toString(), and QDateTime::utcOffset().


The documentation for this class was generated from the following files: