![]() |
Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
|
\inmodule QtCore More...
#include <qtimezone.h>
Public Types | |
enum | Initialization { LocalTime , UTC } |
Public Member Functions | |
QTimeZone () noexcept | |
Create a null/invalid time zone instance. | |
Q_IMPLICIT | QTimeZone (Initialization spec) noexcept |
QTimeZone (const QTimeZone &other) noexcept | |
Copy constructor: copy other to this. | |
QTimeZone (QTimeZone &&other) noexcept | |
Move constructor of this from other. | |
~QTimeZone () | |
Destroys the time zone. | |
QTimeZone & | operator= (const QTimeZone &other) |
Assignment operator, assign other to this. | |
void | swap (QTimeZone &other) noexcept |
\memberswap{time zone instance} | |
bool | isValid () const |
Returns true if this time zone is valid. | |
constexpr Qt::TimeSpec | timeSpec () const noexcept |
constexpr int | fixedSecondsAheadOfUtc () const noexcept |
constexpr bool | isUtcOrFixedOffset () const noexcept |
Static Public Member Functions | |
static QTimeZone | fromDurationAheadOfUtc (std::chrono::seconds offset) |
Returns a time representation at a fixed offset, in seconds, ahead of UTC. | |
static QTimeZone | fromSecondsAheadOfUtc (int offset) |
static constexpr bool | isUtcOrFixedOffset (Qt::TimeSpec spec) noexcept |
Static Public Attributes | |
static constexpr int | MinUtcOffsetSecs = -16 * 3600 |
static constexpr int | MaxUtcOffsetSecs = +16 * 3600 |
Friends | |
class | QTimeZonePrivate |
class | QDateTime |
class | QDateTimePrivate |
Q_CORE_EXPORT bool | comparesEqual (const QTimeZone &lhs, const QTimeZone &rhs) |
Q_CORE_EXPORT QDataStream & | operator<< (QDataStream &ds, const QTimeZone &tz) |
Q_CORE_EXPORT QDebug | operator<< (QDebug dbg, const QTimeZone &tz) |
\inmodule QtCore
QTimeZone identifies how a time representation relates to UTC.
\compares equality
When dates and times are combined, the meaning of the result depends on how time is being represented. There are various international standards for representing time; one of these, UTC, corresponds to the traditional standard of solar mean time at Greenwich (a.k.a. GMT). All other time systems supported by Qt are ultimately specified in relation to UTC. An instance of this class provides a stateless calculator for conversions between UTC and other time representations.
Some time representations are simply defined at a fixed offset to UTC. Others are defined by governments for use within their jurisdictions. The latter are properly known as time zones, but QTimeZone (since Qt 6.5) is unifies their representation with that of general time systems. One time zone generally supported on most operating systems is designated local time; this is presumed to correspond to the time zone within which the user is living.
For time zones other than local time, UTC and those at fixed offsets from UTC, Qt can only provide support when the operating system provides some way to access that information. When Qt is built, the timezone
feature controls whether such information is available. When it is not, some constructors and methods of QTimeZone are excluded from its API; these are documented as depending on feature timezone
. Note that, even when Qt is built with this feature enabled, it may be unavailable to users whose systems are misconfigured, or where some standard packages (for example, the tzdata
package on Linux) are not installed. This feature is enabled by default when time zone information is available.
This class is primarily designed for use in QDateTime; most applications will not need to access this class directly and should instead use an instance of it when constructing a QDateTime.
Definition at line 25 of file qtimezone.h.
The type of the simplest lightweight time representations.
This enumeration identifies a type of lightweight time representation to pass to a QTimeZone constructor, where no further data are required. They correspond to the like-named members of Qt::TimeSpec.
\value LocalTime This time representation corresponds to the one implicitly used by system functions using time_t
and {struct
tm} value to map between local time and UTC time.
\value UTC This time representation, Coordinated Universal Time, is the base representation to which civil time is referred in all supported time representations. It is defined by the International Telecommunication Union.
Enumerator | |
---|---|
LocalTime | |
UTC |
Definition at line 94 of file qtimezone.h.
|
noexcept |
Create a null/invalid time zone instance.
Definition at line 422 of file qtimezone.cpp.
|
inlinenoexcept |
Creates a lightweight instance describing UTC or local time.
Definition at line 97 of file qtimezone.h.
|
noexcept |
Copy constructor: copy other to this.
Definition at line 695 of file qtimezone.cpp.
|
inlinenoexcept |
Move constructor of this from other.
Definition at line 109 of file qtimezone.h.
QTimeZone::~QTimeZone | ( | ) |
Destroys the time zone.
Definition at line 710 of file qtimezone.cpp.
|
inlineconstexprnoexcept |
For a lightweight time representation whose \l timeSpec() is Qt::OffsetFromUTC, this returns the fixed offset from UTC that it describes. For any other time representation it returns 0, even if that time representation does have a constant offset from UTC.
Definition at line 137 of file qtimezone.h.
|
inlinestatic |
Returns a time representation at a fixed offset, in seconds, ahead of UTC.
The offset from UTC must be in the range -16 hours to +16 hours otherwise an invalid time zone will be returned. The returned QTimeZone is a lightweight time representation, not a time zone (backed by system-supplied or standard data).
If the offset is 0, the \l timeSpec() of the returned instance will be Qt::UTC. Otherwise, if offset is valid, timeSpec() is Qt::OffsetFromUTC. An invalid time zone, when returned, has Qt::TimeZone as its timeSpec().
Definition at line 125 of file qtimezone.h.
|
inlinestatic |
Definition at line 132 of file qtimezone.h.
|
inlineconstexprnoexcept |
Returns true
if \l timeSpec() is Qt::UTC or Qt::OffsetFromUTC.
When it is true, the time description does not change over time, such as having seasonal daylight-saving changes, as may happen for local time or a time zone. Knowing this may save the calling code to need for various other checks.
Definition at line 142 of file qtimezone.h.
|
inlinestaticconstexprnoexcept |
Returns true
if spec is Qt::UTC or Qt::OffsetFromUTC.
Definition at line 140 of file qtimezone.h.
bool QTimeZone::isValid | ( | ) | const |
Returns true
if this time zone is valid.
Definition at line 778 of file qtimezone.cpp.
Assignment operator, assign other to this.
Move-assigns other to this QTimeZone instance, transferring the ownership of its data to this instance.
Definition at line 723 of file qtimezone.cpp.
\memberswap{time zone instance}
Definition at line 115 of file qtimezone.h.
|
inlineconstexprnoexcept |
Returns a Qt::TimeSpec identifying the type of time representation.
If the result is Qt::TimeZone, this time description is a time zone (backed by system-supplied or standard data); otherwise, it is a lightweight time representation. If the result is Qt::LocalTime it describes local time: see Qt::TimeSpec for details.
Definition at line 136 of file qtimezone.h.
Definition at line 758 of file qtimezone.cpp.
|
friend |
Definition at line 1709 of file qtimezone.cpp.
Definition at line 1767 of file qtimezone.cpp.
|
friend |
Definition at line 246 of file qtimezone.h.
|
friend |
Definition at line 247 of file qtimezone.h.
|
friend |
Definition at line 245 of file qtimezone.h.
|
staticconstexpr |
Definition at line 90 of file qtimezone.h.
|
staticconstexpr |
Definition at line 87 of file qtimezone.h.