Obsolete Members for QDateTime

以下成员源于类 QDateTime 已过时。 提供它们是为使旧源代码能继续工作。强烈建议不要在新代码中使用它们。

公共函数

(obsolete) void setTime_t (uint seconds )
(obsolete) uint toTime_t () const

静态公共成员

(obsolete) QDateTime fromTime_t (uint seconds )
(obsolete) QDateTime fromTime_t (uint seconds , Qt::TimeSpec spec , int offsetSeconds = 0)
(obsolete) QDateTime fromTime_t (uint seconds , const QTimeZone & timeZone )

成员函数文档编制

[static] QDateTime QDateTime:: fromTime_t ( uint seconds )

Returns a datetime whose date and time are the number of seconds that have passed since 1970-01-01T00:00:00, Coordinated Universal Time ( Qt::UTC ) and converted to Qt::LocalTime . On systems that do not support time zones, the time will be set as if local time were Qt::UTC .

注意: This function is deprecated. Please use fromSecsSinceEpoch () in new code.

该函数在 Qt 4.2 引入。

另请参阅 toTime_t () 和 setTime_t ().

[static] QDateTime QDateTime:: fromTime_t ( uint seconds , Qt::TimeSpec spec , int offsetSeconds = 0)

Returns a datetime whose date and time are the number of seconds that have passed since 1970-01-01T00:00:00, Coordinated Universal Time ( Qt::UTC ) and converted to the given spec .

spec 不是 Qt::OffsetFromUTC 那么 offsetSeconds 会被忽略。若 spec is Qt::OffsetFromUTC offsetSeconds is 0 then the spec will be set to Qt::UTC , i.e. an offset of 0 seconds.

注意: This function is deprecated. Please use fromSecsSinceEpoch () in new code.

该函数在 Qt 5.2 引入。

另请参阅 toTime_t () 和 setTime_t ().

[static] QDateTime QDateTime:: fromTime_t ( uint seconds , const QTimeZone & timeZone )

Returns a datetime whose date and time are the number of seconds that have passed since 1970-01-01T00:00:00, Coordinated Universal Time ( Qt::UTC ) 和采用给定 timeZone .

注意: This function is deprecated. Please use fromSecsSinceEpoch () in new code.

该函数在 Qt 5.2 引入。

另请参阅 toTime_t () 和 setTime_t ().

void QDateTime:: setTime_t ( uint seconds )

Sets the date and time given the number of seconds that have passed since 1970-01-01T00:00:00, Coordinated Universal Time ( Qt::UTC ). On systems that do not support time zones this function will behave as if local time were Qt::UTC .

注意: This function is deprecated. For new code, use setSecsSinceEpoch ().

另请参阅 toTime_t ().

uint QDateTime:: toTime_t () const

Returns the datetime as the number of seconds that have passed since 1970-01-01T00:00:00, Coordinated Universal Time ( Qt::UTC ).

On systems that do not support time zones, this function will behave as if local time were Qt::UTC .

注意: This function returns a 32-bit unsigned integer and is deprecated.

If the date is outside the range 1970-01-01T00:00:00 to 2106-02-07T06:28:14, this function returns -1 cast to an unsigned integer (i.e., 0xFFFFFFFF).

To get an extended range, use toMSecsSinceEpoch () 或 toSecsSinceEpoch ().

另请参阅 toSecsSinceEpoch (), toMSecsSinceEpoch (),和 setTime_t ().