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 &) instead. Returns the end-moment of the day. When a day ends depends on a how time is described: each day starts and ends earlier for those with higher offsets from UTC and later for those with lower offsets from UTC. The time representation to use can be specified either by a \a spec and \a offsetSeconds (ignored unless \a spec is Qt::OffsetSeconds) or by a time zone. Usually, the end of the day is one millisecond before the midnight, 24:00: however, if a local time transition causes the given date to skip over that moment (e.g. a DST spring-forward skipping over 23:00 and the following hour), the actual latest time in the day is returned. When \a spec is Qt::OffsetFromUTC, \a offsetSeconds gives the implied zone's offset from UTC. As UTC and such zones have no transitions, the end of the day is QTime(23, 59, 59, 999) in these cases. In the rare case of a date that was entirely skipped (this happens when a zone east of the international date-line switches to being west of it), the return shall be invalid. Passing Qt::TimeZone as \a spec (instead of passing a QTimeZone) will also produce an invalid result, as shall dates that end outside the range representable by QDateTime.

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

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

这是一个重载函数。

请使用startOfDay(const QTimeZone &) 代替。

返回一天的开始时刻。

一天的开始时间取决于对时间的描述:从UTC 出发的偏差越大,一天的开始和结束时间就越早;从UTC 出发的偏差越小,一天的开始和结束时间就越晚。使用的时间表示可以通过specoffsetSeconds (除非spec 是 Qt::OffsetSeconds,否则忽略)或时区指定。

通常,一天的开始时间是午夜 00:00:但是,如果本地时间转换导致给定日期跳过午夜(例如,DST 向前跳过一天中的第一个小时),则会返回一天中实际最早的时间。

specQt::OffsetFromUTC 时,offsetSeconds 将给出一个隐含的区从 UTC 的偏移量。由于 UTC 和此类区没有转换,因此在这些情况下,一天的开始时间是QTime(0, 0)。

在极少数情况下,如果日期被完全跳过(当国际日期变更线以东的区切换到国际日期变更线以西时就会发生这种情况),则返回无效。将Qt::TimeZone 作为spec 传递(而不是传递QTimeZone )也会产生无效结果,开始日期超出QDateTime 可表示范围的日期也会产生无效结果。

© 2025 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.