4#include <private/qtimezonelocale_p.h>
5#include <private/qtimezoneprivate_p.h>
8# include <private/qdatetime_p.h>
10# include <private/qtimezonelocale_data_p.h>
11# include <private/qtimezoneprivate_data_p.h>
20constexpr UCalendarDisplayNameType ucalDisplayNameType(QTimeZone::TimeType timeType,
21 QTimeZone::NameType nameType)
26 case QTimeZone::OffsetName:
28 case QTimeZone::ShortName:
29 return timeType == QTimeZone::DaylightTime ? UCAL_SHORT_DST : UCAL_SHORT_STANDARD;
30 case QTimeZone::DefaultName:
31 case QTimeZone::LongName:
32 return timeType == QTimeZone::DaylightTime ? UCAL_DST : UCAL_STANDARD;
34 Q_UNREACHABLE_RETURN(UCAL_STANDARD);
43QString ucalTimeZoneDisplayName(UCalendar *ucal,
44 QTimeZone::TimeType timeType,
45 QTimeZone::NameType nameType,
48 constexpr int32_t BigNameLength = 50;
49 int32_t
size = BigNameLength;
51 auto dst = [&
result]() {
return reinterpret_cast<UChar *
>(
result.data()); };
52 UErrorCode status = U_ZERO_ERROR;
53 const UCalendarDisplayNameType utype = ucalDisplayNameType(timeType, nameType);
56 size = ucal_getTimeZoneDisplayName(ucal, utype, localeCode.constData(),
60 if (
size > BigNameLength || status == U_BUFFER_OVERFLOW_ERROR) {
62 status = U_ZERO_ERROR;
63 size = ucal_getTimeZoneDisplayName(ucal, utype, localeCode.constData(),
67 if (!U_SUCCESS(status))
78QString QTimeZonePrivate::localeName(
qint64 atMSecsSinceEpoch,
int offsetFromUtc,
79 QTimeZone::TimeType timeType,
80 QTimeZone::NameType nameType,
87 if (nameType == QTimeZone::OffsetName)
92 UErrorCode status = U_ZERO_ERROR;
93 UCalendar *ucal = ucal_open(
reinterpret_cast<const UChar *
>(
id.
data()),
id.
size(),
95 if (ucal && U_SUCCESS(status)) {
96 auto tidier =
qScopeGuard([ucal]() { ucal_close(ucal); });
97 return QtTimeZoneLocale::ucalTimeZoneDisplayName(ucal, timeType, nameType, loc);
111QString QTimeZonePrivate::localeName(
qint64 atMSecsSinceEpoch,
int offsetFromUtc,
112 QTimeZone::TimeType timeType,
113 QTimeZone::NameType nameType,
const char * constData() const noexcept
Returns a pointer to the const data stored in the byte array.
\macro QT_RESTRICTED_CAST_FROM_ASCII
static QString fromUtf8(QByteArrayView utf8)
This is an overloaded member function, provided for convenience. It differs from the above function o...
static QString isoOffsetFormat(int offsetFromUtc, QTimeZone::NameType mode=QTimeZone::OffsetName)
virtual int offsetFromUtc(qint64 atMSecsSinceEpoch) const
Q_QML_EXPORT QV4::ReturnedValue locale(QV4::ExecutionEngine *engine, const QString &localeName)
Provides locale specific properties and formatted data.
Combined button and popup list for selecting options.
constexpr Initialization Uninitialized
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
QScopeGuard< typename std::decay< F >::type > qScopeGuard(F &&f)
[qScopeGuard]