QTimeZone of QT6

1. Introduction

QTimeZone identifies the relationship between time representation and UTC, and can also represent UTC, local time and a fixed offset from UTC.

QTimeZone (since Qt 6.5) unifies their representation with the general time system, where a time zone commonly supported by most operating systems is designated as local time.

Summary: Simply put, QTimeZone is a class specially used by qt to solve the problem of system time zone and time zone offset.

2. Time classification

UTC (Coodinated Universal Time), Coordinated Universal Time, is also known as Universal Unified Time, Universal Standard Time, and International Coordinated Time. It is now a global time standard, and all parts of the world agree to synchronize their time.

GMT (Greenwich Mean Time), Greenwich Mean Time (also known as Greenwich Mean Time). It stipulates that the time when the sun passes by the Royal Greenwich Observatory in the suburbs of London, England is 12 noon every day. The Royal Observatory of Greenwich began to conduct astronomical observations in the seventeenth century, and chose a meridian passing through the center of the meridian of the Greenwich Observatory in London, England, as the zero-degree reference line. This line is called the Greenwich Meridian for short.

Local time, which is equal to the local time in our (or used) time zone, defined by the offset from Coordinated Universal Time (UTC). This offset can be expressed as UTC- or UTC+ followed by the hours and minutes of the offset.

GMT is Coordinated Universal Time, based on the solar time at the Royal Greenwich Observatory in England, until it was replaced by UTC in 1972. UTC is the current world standard time, which is more accurate than GMT. It is timed in atomic time and used globally.

Three, qt6.5 introduces common methods

1. Initialize QTimeZone::LocalTime and QTimeZone::UTC

 2. In seconds, return the time representation of the fixed offset;

QTimeZone QTimeZone::fromDurationAheadOfUtc(std::chrono::seconds offset)

QTimeZone QTimeZone::fromSecondsAheadOfUtc(int offset)

3. Convert this QTimeZone to an object whose timeSpec  () is Qt::TimeZone ;

QTimeZone QTimeZone::asBackendZone() const

4.  Return true if it is Qt::UTC  or  Qt::OffsetFromUTC ;

bool QTimeZone::isUtcOrFixedOffset(Qt::TimeSpec spec)

5. Return true if it is Qt::UTC  or  Qt::OffsetFromUTC ;

bool QTimeZone::isUtcOrFixedOffset() const

To sum up, QTimeZone is used to deal with time representation, including dealing with time zone conversion, offset fixed amount, time zone offset and other international time issues.

Guess you like

Origin blog.csdn.net/yanchenyu365/article/details/130829357