以下成員源於類 QDateTime 被棄用。 提供它們是為使舊源代碼能繼續工作。強烈建議不要在新代碼中使用它們。
(deprecated (6.9))
|
QDateTime (QDate date , QTime time , Qt::TimeSpec spec , int offsetSeconds = 0) |
(deprecated (6.9))
void
|
setOffsetFromUtc (int offsetSeconds ) |
(deprecated (6.9))
void
|
setTimeSpec (Qt::TimeSpec spec ) |
(deprecated (6.9))
QDateTime
|
toTimeSpec (Qt::TimeSpec spec ) const |
(deprecated (6.9))
QDateTime
|
fromMSecsSinceEpoch (qint64 msecs , Qt::TimeSpec spec , int offsetSeconds = 0) |
(deprecated (6.9))
QDateTime
|
fromSecsSinceEpoch (qint64 secs , Qt::TimeSpec spec , int offsetSeconds = 0) |
This function is deprecated since 6.9. We strongly advise against using it in new code.
使用
QDateTime(date, time)
or
QDateTime(date, time, QTimeZone::fromSecondsAheadOfUtc(offsetSeconds))
.
構造日期時間采用給定 date and time , using the time representation implied by spec and offsetSeconds 秒。
若 date 有效和 time is not, the time will be set to midnight.
若 spec 不是 Qt::OffsetFromUTC then offsetSeconds will be ignored. If spec is Qt::OffsetFromUTC and offsetSeconds 為 0 那麼 timeSpec () 會被設為 Qt::UTC , i.e. an offset of 0 seconds.
若 spec is Qt::TimeZone then the spec will be set to Qt::LocalTime , i.e. the current system time zone. To create a Qt::TimeZone datetime use the correct constructor.
若 date lies outside the range of dates representable by QDateTime, the result is invalid. If spec is Qt::LocalTime and the system's time-zone skipped over the given date and time, the result is invalid.
[static]
QDateTime
QDateTime::
fromMSecsSinceEpoch
(
qint64
msecs
,
Qt::TimeSpec
spec
,
int
offsetSeconds
= 0)
This function is deprecated since 6.9. We strongly advise against using it in new code.
這是重載函數。
傳遞 QTimeZone instead, or omit spec and offsetSeconds .
Returns a datetime representing a moment the given number msecs of milliseconds after the start, in UTC, of the year 1970, described as specified by spec and offsetSeconds .
Note that there are possible values for msecs that lie outside the valid range of QDateTime , both negative and positive. The behavior of this function is undefined for those values.
若 spec 不是 Qt::OffsetFromUTC 那麼 offsetSeconds 會被忽略。若 spec is Qt::OffsetFromUTC 和 offsetSeconds is 0 then Qt::UTC will be used as the spec , since UTC has zero offset.
若 spec is Qt::TimeZone then Qt::LocalTime will be used in its place, equivalent to using the current system time zone (but differently represented).
另請參閱 fromSecsSinceEpoch (), toMSecsSinceEpoch (),和 setMSecsSinceEpoch ().
[static]
QDateTime
QDateTime::
fromSecsSinceEpoch
(
qint64
secs
,
Qt::TimeSpec
spec
,
int
offsetSeconds
= 0)
This function is deprecated since 6.9. We strongly advise against using it in new code.
這是重載函數。
傳遞 QTimeZone instead, or omit spec and offsetSeconds .
Returns a datetime representing a moment the given number secs of seconds after the start, in UTC, of the year 1970, described as specified by spec and offsetSeconds .
Note that there are possible values for secs that lie outside the valid range of QDateTime , both negative and positive. The behavior of this function is undefined for those values.
若 spec 不是 Qt::OffsetFromUTC 那麼 offsetSeconds 會被忽略。若 spec is Qt::OffsetFromUTC 和 offsetSeconds is 0 then Qt::UTC will be used as the spec , since UTC has zero offset.
若 spec is Qt::TimeZone then Qt::LocalTime will be used in its place, equivalent to using the current system time zone (but differently represented).
另請參閱 fromMSecsSinceEpoch (), toSecsSinceEpoch (),和 setSecsSinceEpoch ().
This function is deprecated since 6.9. We strongly advise against using it in new code.
使用 setTimeZone ( QTimeZone::fromSecondsAheadOfUtc (offsetSeconds)) instead
設置 timeSpec () 到 Qt::OffsetFromUTC and the offset to offsetSeconds . The datetime may refer to a different point in time.
The maximum and minimum offset is 14 positive or negative hours. If offsetSeconds is larger or smaller than that, then the result is undefined.
若 offsetSeconds 為 0 那麼 timeSpec () 會被設為 Qt::UTC .
另請參閱 setTimeZone (), isValid (), offsetFromUtc (),和 toOffsetFromUtc ().
This function is deprecated since 6.9. We strongly advise against using it in new code.
使用 setTimeZone () 代替
Sets the time specification used in this datetime to spec . The datetime may refer to a different point in time.
若 spec is Qt::OffsetFromUTC 那麼 timeSpec () 會被設為 Qt::UTC , i.e. an effective offset of 0.
若 spec is Qt::TimeZone then the spec will be set to Qt::LocalTime , i.e. the current system time zone.
範例:
QDateTime local(QDateTime::currentDateTime()); qDebug() << "Local time is:" << local; QDateTime UTC(local); UTC.setTimeSpec(Qt::UTC); qDebug() << "UTC time is:" << UTC; qDebug() << "There are" << local.secsTo(UTC) << "seconds difference between the datetimes.";
另請參閱 setTimeZone (), timeSpec (), toTimeSpec (), setDate (),和 setTime ().
This function is deprecated since 6.9. We strongly advise against using it in new code.
使用 toTimeZone () 代替。
Returns a copy of this datetime converted to the given time spec .
The result represents the same moment in time as, and is equal to, this datetime.
若 spec is Qt::OffsetFromUTC 那麼它被設為 Qt::UTC . To set to a fixed offset from UTC, use toTimeZone () 或 toOffsetFromUtc ().
若 spec is Qt::TimeZone 那麼它被設為 Qt::LocalTime , i.e. the local Time Zone. To set a specified time-zone, use toTimeZone ().
範例:
QDateTime local(QDateTime::currentDateTime()); QDateTime UTC(local.toTimeSpec(Qt::UTC)); qDebug() << "Local time is:" << local; qDebug() << "UTC time is:" << UTC; qDebug() << "No difference between times:" << local.secsTo(UTC);
另請參閱 setTimeSpec (), timeSpec (),和 toTimeZone ().