Obsolete Members for QDate

QDate 类的以下成员已被废弃。提供这些成员是为了确保旧源代码能够继续运行。我们强烈建议不要在新代码中使用它们。

公共函数

(deprecated in 6.9) QDateTime endOfDay(Qt::TimeSpec spec, int offsetSeconds = 0) const
(deprecated in 6.9) QDateTime startOfDay(Qt::TimeSpec spec, int offsetSeconds = 0) const

成员函数文档

[deprecated in 6.9] QDateTime QDate::endOfDay(Qt::TimeSpec spec, int offsetSeconds = 0) const

自 6.9 版本起,此函数已弃用。我们强烈建议不要在新代码中使用它。

请改用endOfDay(const QTimeZone &) 。

返回该日的结束时刻。

一天何时结束取决于时间的描述方式:对于与UTC时差较大的时区,每一天开始和结束的时间较早;对于与UTC时差较小的时区,每一天开始和结束的时间较晚。可用的时间表示形式可以通过spec 和offsetSeconds (除非spec 为Qt::OffsetSeconds,否则将被忽略)或通过时区来指定。

通常,一天的结束时间是午夜 24:00 之前的一毫秒: 然而,如果当地时间的变换导致给定的日期跳过了该时刻(例如,夏令时“春前进”跳过了 23:00 及随后的一小时),则返回该日内的实际最晚时间。

当spec 为Qt::OffsetFromUTC 时,offsetSeconds 将返回该隐含时区相对于UTC的偏移量。由于UTC及此类时区不存在时区转换,因此在此类情况下,一天的结束时间为QTime(23, 59, 59, 999)。

在极少数情况下,如果某个日期被完全跳过(这发生在国际日期变更线以东的时区切换到以西时),则返回结果将无效。将Qt::TimeZone 作为spec 传入(而非传入QTimeZone )也会产生无效结果,同样,结束时间超出QDateTime 可表示范围的日期也会导致无效结果。

该函数重载了QDate::endOfDay()。

[deprecated in 6.9] QDateTime QDate::startOfDay(Qt::TimeSpec spec, int offsetSeconds = 0) const

自 6.9 版起,该函数已被废弃。我们强烈建议不要在新代码中使用它。

请改用 `startOfDay(const QTimeZone &) `。

返回该日的起始时刻。

一天的开始时间取决于时间的描述方式:对于与UTC偏移量较大的时区,每一天的开始和结束时间较早;对于与UTC偏移量较小的时区,则开始和结束时间较晚。可用的时间表示形式既可以通过spec 和offsetSeconds (除非spec 为Qt::OffsetSeconds,否则将被忽略)来指定,也可以通过时区来指定。

通常,一天的开始是午夜 00:00;但是,如果当地时间的变更导致给定日期跳过了该午夜(例如,夏令时“春前进”跳过了当天第一小时),则返回该天实际的最早时间。

当spec 为Qt::OffsetFromUTC 时,offsetSeconds 返回该时区相对于UTC的偏移量。由于UTC及此类时区没有时区转换,因此在此类情况下,一天的开始时间为QTime (0, 0)。

在极少数情况下,若某日期被完全跳过(例如当位于国际日期变更线以东的时区切换至以西时),返回值将无效。若将Qt::TimeZone 作为spec 传入(而非传入QTimeZone ),也将产生无效结果;同样,起始时间超出QDateTime 可表示范围的日期也会导致无效结果。

该函数重载了QDate::startOfDay()。

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.