Commit Graph

48 Commits

Author SHA1 Message Date
Edward Welbourne
b55f10b2a0 Convert a table iteration to use ranged-for
The loop used an int counter that was initialized from a size_t,
provoking a warning from MSVC. Since the indexing is irrelevant in any
case, use a ranged-for loop. Since the loop was formerly in decreasing
index order, reverse the table being iterated so that entries remain
in their prior order.

Change-Id: I79b93c5a3f39a502b0cae83215b8e3665d0e17f5
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-15 15:44:51 +01:00
Edward Welbourne
0828014b44 Fix an inaccurate comment and update a test case
The offset fields for tst_QTimeZone::specificTransition() had a
comment claiming they are in minutes; they are in fact in seconds, so
fix that. At the same time, Moscow hasn't had a time-zone change since
2017, so the end-date for one of the test intervals can be nudged a
little closer to the present without harm.

Change-Id: I66822cb758f7e00d6added801466a6745be3e31a
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-02-09 20:46:24 +00:00
Edward Welbourne
7039fb1e42 Skip QTimeZone::checkOffset() if there are no valid zones to test
Change-Id: I62df34fe40b8e89b99912e8ad0d1d2f2f11fd71e
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2021-11-26 02:14:52 +01:00
Edward Welbourne
6705707088 Use a local check-macro to save lots of repetition in time-zone tests
Tests of QTimeZone::dispayName() were burying most of what was
interesting in the variations among them by repetition of a large
amount of boilerplate. Package the repetition in a macro so that
the differences between checks are more evident.

Change-Id: I23bcafab641b7d3bed50248ba5313250c150d30c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-11-10 14:10:20 +01:00
Edward Welbourne
e9e0862051 Correct and clarify some comments
Change-Id: I011b04cf0dccea51c00c597c8dff74d574fe36ad
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-11-08 17:05:25 +01:00
Edward Welbourne
4b4bc388de Express 64-bit integral constants consistently
Use the Q_INT64_C() macro and qint64()-as-function instead of C-style
casts.

Change-Id: I9d169715da96a49898e9c9e2a6d3ee5182e1d91c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-11-08 17:05:25 +01:00
Edward Welbourne
f4b19f8bba Give symbolic names to some constants used in time-zone tests
Where std::numeric_limits<...>::min() is used used as invalid value
for an API return, save it as a named constant so that the comparisons
are against an informative name, rather than leaving the reader to
guess the significance of the min-value.

Change-Id: Ia99c75e21856f65cb4494120d05eed36f5fc2d50
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-11-08 17:05:25 +01:00
Edward Welbourne
7a4b586f4b Remove conditioning on Android embedded
It is no longer handled separately from Android.
This effectively reverts commit 6d50f746fe

Change-Id: Ic2d75b8c5a09895810913311ab2fe3355d4d2983
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2021-09-17 17:30:14 +02:00
Edward Welbourne
35412acd88 Use time-zone transition data before 1970 as well as after
QDateTime has long followed a convention of ignoring what it knows
about time-zone transitions before the epoch. This produces unhelpful
artefacts (such as an ahistorical spring-forward skipping the first
hour of 1970 in Europe/London, which was in permanent DST at the time)
and complicates the code. It documented that DST transitions were
ignored, but in fact ignored all transitions prior to 1970 and simply
assumed that the current time-zone properties (half a century later)
applied to all times before 1970.

This appears to be based on the fact that the MS APIs using time_t all
limit their range to after 1970. Given that we have to resort to
"other means" to deal with times after the end of time_t, when it's
only 32-bit (and after year 3000, on MS systems), we have the means in
place to handle times outside the range supported by the system APIs,
so have no need to mimic this restriction. (Those means are not as
robust as we might want, but they are less bad than assuming that the
present zone properites were always in effect prior to 1970.) On
macOS, the time_t functions only reach back to the start of 1900; it
reaches to the end of its time_t range and Linux covers the whole
range. Given this variety, the range is now auto-detected the first
time it is needed (based on some quick and dirty heuristics).

Various CET-specific tests now need adjustments in tests of times
before the introduction of time-zones (when they are in fact on LMT,
not CET). The systemZone() test of QTimeZone can now restore its
pre-zone test cases. Various comments on tests needed updates.

[ChangeLog][QtCore][QDateTime] Available time-zone information is now
used to its full extent, where previously QDateTime used LocalTime's
current standard time for all dates before 1970. Where we have
time-zone information, it is considered reliable, so we use it.  This
changes the "best efforts" used for times outside the range supported
by the system APIs, in most cases giving less misleading results.

Fixes: QTBUG-80421
Change-Id: I7b1df7622dd9be244b0238ed9c08845fb5b32215
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-05-26 18:00:01 +02:00
Edward Welbourne
16c9683718 Revert early return from QTimeZone on invalid ID
This reverts commit ec8808c302 but
retains its test, as the problem it fixed is now solved by having the
TZ backend validate the ID it's passed, so that it now only accepts
valid POSIX zone-descriptions and valid IANA IDs. The former were
being excluded by this check.

Amended a POSIX test to fail with the check in place; it passes now.

Change-Id: I0d5e8c6e0a315ac2509f3d23bebb52aede8f79d0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Robert Löhning <robert.loehning@qt.io>
2021-04-29 14:13:23 +02:00
Edward Welbourne
828f533b32 Check POSIX rules during QTzTimeZone creation
Previously, an apparent POSIX rule would be saved and any defects in
it would only be discovered when trying to use it to generate
transitions. Instead, check that it has the right form during the
initial parsing of its data.

In the process, since checking for DST in the process is trivial,
implement a long-standing TODO to cache hasDaylightTime()'s
answer. The array it scanned was in any case being scanned during
construction, so detecting DST in init()'s scan is trivial; and its
failure to check the POSIX rule mean it failed to notice when zones
entirely specified by a POSIX rule have DST.

Adapt a test using a POSIX-only rule to verify it does know the zone
has DST; it did not, before this change.

Change-Id: I690c013d3331600f7348dae61c35d41e5599da70
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-04-27 14:12:35 +02:00
Edward Welbourne
7fa8315eb1 Fix handling of a POSIX zone rule describing permanent DST
The description necessarily has fake transitions at start and end of
the year, potentially outside the year. These transitions should not
be reported by QTzTimeZonePrivate as transitions, although its data()
must find a "transition" whose data it can use (as in the permanent
standard time case, which could potentially be represented the same
way, although there's a saner way to do so, that the code already
handles) to report the zone's properties.

In the process, fix (and make more straightforward) the convoluted
decision-making code that was deciding which transitions to include in
the returned list. It was assuming invalidMSecs() would be set as the
atMSecsSinceEpoch of a transition, although this is computed in a way
that makes that value most unlikely, even when the result is invalid.
It also rather confusingly mixed < 0 tests as tests for overflow with
the one < 0 test that's about ignoring DST before 1970. Also added
comments to clarify some of what's going on there.

Expanded a recently-added test of a permanent DST zone to verify this
now works correctly.

Change-Id: Ia8d98f433fb1e479dba5479220a62196c30f0244
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-04-27 14:12:35 +02:00
Edward Welbourne
2383e82bcf Correct the parsing of POSIX rule day-of-year fields
There are two formats for such fields: one with a J prefix on a number
in the range 1 to 365, the other with no prefix and a range from 0 to
365. The code mistakenly treated the latter as if its range were from
1 to 366. The J-form doesn't count Feb 29th, so March always starts on
day 60; the code tried to take that into account, but adjusted in the
wrong direction (and this mislead me, in a recent partial fix, into a
fence-post error).

Add a test-case based on the Africa/Casablanca POSIX rule seen on RHEL
8.2, which tripped over the off-by-one error without a J prefix. This
incidentally also tests the J case.

Change-Id: I692ca511e5c960f91a6c21073d3b2f037f5e445f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-04-27 14:12:35 +02:00
Edward Welbourne
605ae62944 Correct the range of allowed hours for a POSIX rule's transition
A POSIX rule's transition time is allowed an hour in the range from
-137 to 137; in particular, a negative hour is allowed, and used by
some Greenland zones using Europe's time-of-transition which, as they
are more than two hours west of Greenwich, happens before midnight.

This means the time of transition can't be represented by a QTime(),
so propagate the int that represents it to the code that consumes it;
and treat parsing failure as an error rather than "correcting" it - if
the transition time is given, it must be valid.

Changed tst_QTimeZone::isTimeZoneIdAvailable()'s verification of
validity to report the name of the zone it thought was invalid.
(A later change, validating POSIX rules, caued this to fail for
America/Nuuk without the present fix.)

Change-Id: I5c9127ac34d878554dd0aca1c1c7338c7e0e1c28
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-04-20 21:33:00 +02:00
Edward Welbourne
ec8808c302 Return early from QTimeZone constructor if alleged IANA ID is invalid
If the ID isn't even valid, don't waste cycles trying to make sense of
it as identifying a time-zone.

Add test of an invalid ID that provoked an integer overflow on trying
to parse it as a POSIX zone specification.

Fixes: QTBUG-92842
Change-Id: Ib80bbb88c11c0484ce0358acabbdc25c5bd8e0b3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-04-20 21:33:00 +02:00
Edward Welbourne
c3aa4cf952 Catch invalid offset returns from QTimeZone backends
If the backends run into an error in computing the offset, they return
INT_MIN; but they are valled via the front-end, which returns zero
when the zone is invalid. So treat INT_MIN returns from the backend
the same as the case of being invalid.

Change-Id: Ic3c4dfe964dbfba4030c770213eca8a63e84736d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-04-16 10:20:11 +02:00
JiDe Zhang
50a7eb8cf7 Add the "Territory" enumerated type for QLocale
The use of "Country" is misleading as some entries in the enumeration
are not countries (eg, HongKong), for all that most are. The Unicode
Consortium's Common Locale Data Repository (CLDR, from which QLocale's
data is taken) calls these territories, so introduce territory-based
names and prepare to deprecate the country-based ones in due course.

[ChangeLog][QtCore][QLocale] QLocale now has Territory as an alias for
its Country enumeration, and associated territory-based names to match
its country-named methods, to better match the usage in relevant
standards. The country-based names shall in due course be deprecated
in favor of the territory-based names.

Fixes: QTBUG-91686
Change-Id: Ia1ae1ad7323867016186fb775c9600cd5113aa42
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-04-15 20:17:49 +08:00
Edward Welbourne
964f91fd25 Make POSIX transition rule parser more robust
The POSIX rule parser used by QTzTimeZonePrivate recklessly assumed
that, if splitting the rule on a dot produced more than one part, it
necessarily produced at least three. That's true for well-formed POSIX
rules, but we should catch the case of malformed rules.

Likewise, when calculating the dates of transitions, splitting the
date rule on dots might produce too few fragments; and the fragments
might not parse as valid numbers, or might be out of range for their
respective fields in a date. Check all these cases, too.

Added a test that crashed previously. Changed
QTimeZone::offsetFromUtc() so that its "return zero on invalid"
applies also to the case where the backend returns invalid, in
support of this.

Fixes: QTBUG-92808
Pick-to: 6.1 6.1.0 6.0 5.15
Change-Id: Ica383a7a987465483341bdef8dcfd42edb6b43d6
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Robert Löhning <robert.loehning@qt.io>
2021-04-14 12:57:30 +02:00
Edward Welbourne
9d3a7c72ad Extend system zone test to check it matches LocalTime
Test we get the same starts of various days. Some coming changes shall
break some of these, but they should all be back to working by the
time we're taking account of DST before 1970 as well as after.

The first two or three test-cases work by accident in most zones, at
present, due to the zone-based code-path ignoring the LMT period
before the zone's first transition; but Europe/Helsinki had a renaming
transition in 1878, so does see its pre-zone offset between then and
the switch to UTC+2 in 1921, leading to failures in exactly the zone
Coin tests.  So suppress these three test-cases pending later fixes.
On Windows, the next text (still pre-epoch) gets bogus zone data for
its LocalTime, so suppress that likewise.

Task-number: QTBUG-80421
Change-Id: I2264e0e436d92112b03264faa410e30057b8f73b
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-03-18 15:30:48 +01:00
Edward Welbourne
e8c52d0e8c Fix transitionEachZone() failures on Android
In QTimeZonePrivate::dataForLocalTime(), mistrust the Android
backend's hasDaylightTime(), as it has a comment saying it only knows
about future transitions, not past. This caller of it really needs to
query "has ever had a transition", which this doesn't answer. Many
zones that have no plans for future transitions have had transitions
in the past; these were failing the transitionEachZone() test.

In the process, refine the test itself, making sure we catch some
quirk cases that shouldn't arise and making the debug message on
failure more informative (while eliding the zone name, as this is part
of the test name anyway, so added to the output by qDebug() itself).

Fixes: QTBUG-69131
Change-Id: I88a0528182c247acb8b6327b40516178e455bcc0
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-02-24 12:08:57 +01:00
Edward Welbourne
6fa9f487db Return early after test-helpers if they fail
The QTimeZone tests have some helper functions to test details of a
QTZP instance; these use QCOMPARE(), so may return early on failure.
The callers then need to notice the failure and, in their turn, also
return.

Change-Id: I0a188e9641ced70c9ffedd95e91f39681fad768a
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2021-02-18 11:21:03 +01:00
Edward Welbourne
60fd2808f6 Skip a timezone transition test on Android
Its back-end lacks transition data, so the test can't possibly
succeed. Make the skip conditional on the tested zone having
transitions, so that the test will come back into play if we ever gain
support for transitions on Android.

Fixes: QTBUG-69129
Change-Id: Ie4f96601b8b18cd496efbde7cf2557875cf3c1c9
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2021-02-18 11:20:23 +01:00
Edward Welbourne
1e3b0d9280 Purge various BLACKLIST entries that are now fixed
Based on BPASS results from recent test-runs.

Task-number: QTBUG-69131
Fixes: QTBUG-87416
Fixes: QTBUG-87662
Task-number: QTBUG-87663
Fixes: QTBUG-88705
Change-Id: I8ebe014517bfa8d124e86b821650b07c591ea16e
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2021-02-02 10:40:44 +01:00
Edward Welbourne
38a72af4fd Fix handling of Sunday in POSIX time-zone rules
Dating from the origins of our support for the zoneinfo file format,
the mapping of POSIX's day-numbering (0 = Sunday through 6 = Saturday,
see [*]) to Qt's (1 = Monday through 7 = Sunday) was done by mapping 0
to 1, when it should have been 7.

[*] http://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html

Corrected a QTimeZone test that trusted the results it got without
checking which day of the week those were: they were all Mondays.
Verified that the corrected dates are in fact Sundays.
Checked the zone abbreviations, too.

Fixes: QTBUG-90553
Pick-to: 6.0 5.15
Change-Id: I84b4b14f9892ff687918cd3c42c7c9807e45313c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2021-02-01 16:28:26 +01:00
Edward Welbourne
6ee13db700 Correct string comparison in Android's IANA ID matching code
It used QString.compare() and assumed it was returning a bool true on
equality, when it actually returns an int that compares to 0 as the
given strings compare. So it should use compare() == 0.

This fixes several of QTimeZone's blacklisted tests on Android and a
crasher, which we dodged with a QSKIP. Added an id-comparison to a
test. Gave two local variables more informative names, made an early
return into a QSKIP so it explains itself.

Fixes: QTBUG-89905
Fixes: QTBUG-69122
Fixes: QTBUG-69132
Fixes: QTBUG-87435
Pick-to: 6.0 5.15
Change-Id: Icf18ed5a810143d6e65d36e34a70e82faac10b8e
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2021-01-18 15:55:15 +01:00
Edward Welbourne
50c63446f5 Fix problems with offset-derived ids for QTimeZone
When creating a time-zone from a UTC+offset name that isn't known to
the system, QTimeZone (since the fix to QTBUG-77738 in 5.15.0) falls
back to constructing a suitable UTC-offset backend; however, the id of
this is not guaranteed to match the id passed in to the constructor.
In all other cases, the id of a QTimeZone does match the id passed to
its constructor.

Some utcOffsetId testcases had different id() than the id passed to
the constructor, due to mismatches where a zone was constructed using
the fall-back but the generated id included its minutes (as :00) or
omitted its seconds. The omission of seconds is clearly a bug, but we
also don't want to include :00 for seconds when it's not needed. So
change QTimeZonePrivate::isoOffsetFormat() to accept a
QTimeZone::NameType to configure how much we include in an id. Its
callers other than the relevant constructor (from offset) still get
minutes, even when :00, but will also get seconds added if that isn't
zero; and the constructor from offset now gets the short form obtained
by omitting all trailing zeros.

Since all valid whole-hour offset names that do include :00 for the
minutes field are in fact known standard offset names, the elision of
minutes will only affect zones created by ID in the case of a
whole-hour offset given without :00 minutes specifier, so these shall
necessarily in fact get the ID passed to the constructor. Creating by
UTC-offset with a name that specifies zero seconds will result in a
QTimeZone instance whose id() differs from what was passed to its
constructor (eliding the :00 seconds and potentially also minutes, if
also zero) but this should be the only case where a QTimeZone's id
doesn't match the one passed to the constructor, when constructed by
id.

Fixed inconsistency between the offset-constructor's declaration
(taking offset as int) and definition (taking qint32) in the process.
Added an id check to the utcOffsetId() testcase. Amended two tests of
offset-derived time-zones' IDs, added comments to make clear how one
of those differs from a matching standard name test and converted two
uses of QCOMPARE(, true) to QVERIFY().

[ChangeLog][QtCore][QTimeZone] QTimeZone instances created by offset
from UTC (in seconds) shall now only include minutes in their ID when
the offset is not a whole number of hours. They shall also include the
seconds in their ID when the offset is not a whole number of minutes.

Pick-to: 6.0 5.15
Task-number: QTBUG-87435
Change-Id: I610e0a78e2aca51e12bfe003497434a998e93dc7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-01-18 15:55:05 +01:00
Joerg Bornemann
ad2da2d27a Remove the qmake project files
Remove the qmake project files for most of Qt.

Leave the qmake project files for examples, because we still test those
in the CI to ensure qmake does not regress.

Also leave the qmake project files for utils and other minor parts that
lack CMake project files.

Task-number: QTBUG-88742
Change-Id: I6cdf059e6204816f617f9624f3ea9822703f73cc
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2021-01-07 15:32:28 +01:00
David Skoland
27d96b4789 Replace QtTest headers with QTest
Complete search and replace of QtTest and QtTest/QtTest with QTest, as
QtTest includes the whole module. Replace all such instances with
correct header includes. See Jira task for more discussion.

Fixes: QTBUG-88831
Change-Id: I981cfae18a1cabcabcabee376016b086d9d01f44
Pick-to: 6.0
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-12-22 15:20:30 +01:00
Assam Boudjelthia
039d3fe4e8 Android: blacklist a list of failing tests for android
We want to re-enable Android tests in QTQAINFRA-3867. However,
many tests are failing already preventing that from happening.
QTBUG-87025 is currently keeping track (links) to all of those
failing tests.

The current proposal is to hide those failing tests, and enable
Android test running in COIN for other tests. After, that try
to fix them one by one, and at the same time we can make sure
no more failing tests go unnoticed.

Task-number: QTBUG-87025
Change-Id: Ic1fe9fdd167cbcfd99efce9a09c69c344a36bbe4
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-04 12:27:49 +02:00
Edward Welbourne
f2cd9d9ddb Fix blatant typo in QTimeZone test
This revealed that the test was always broken; it had simply never
actually been checked.

Done-with: Andreas Buhr <andreas.buhr@qt.io>
Change-Id: I85ac7ba30738fa3b41bf8440a059ee3fabb4726b
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Andreas Buhr <andreas.buhr@qt.io>
2020-10-19 17:44:32 +02:00
Alexandru Croitor
403213240c CMake: Regenerate projects to use new qt_internal_ API
Modify special case locations to use the new API as well.
Clean up some stale .prev files that are not needed anymore.
Clean up some project files that are not used anymore.

Task-number: QTBUG-86815
Change-Id: I9947da921f98686023c6bb053dfcc101851276b5
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2020-09-23 16:59:06 +02:00
Edward Welbourne
14f3f419b0 Fix crash on serializing default-constructed QTimeZone
The serialization code neglected to check against null.  Sinze zones
are saved either by IANA ID or in our special OffsetFromUtc format,
representing an invalid zone by a string that cannot possibly be a
valid IANA ID will do.

Fixes: QTBUG-86019
Pick-to: 5.15
Pick-to: 5.12
Change-Id: I6882026403d00f8b254aab34c645f1cf8f9fcc2d
Reviewed-by: Taylor Braun-Jones <taylor@braun-jones.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-23 09:55:29 +02:00
Alexandru Croitor
e9a328bc0e CMake: Regenerate tests with new qt_ prefixed APIs
Use pro2cmake with '--api-version 2' to force regenerate
projects to use the new prefixed qt_foo APIs.

Change-Id: I055c4837860319e93aaa6b09d646dda4fc2a4069
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-07-09 09:38:35 +02:00
Edward Welbourne
c30e0c656f Update tests/auto/corelib/time/'s CMake config
Recent changes in .pro files hadn't been propagated.
Re-ran pro2cmake.py and saved the results.

Change-Id: I91e4cd513329bce10ce8cbd0ddae8240af050213
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-07-02 15:35:17 +02:00
Edward Welbourne
f6d1be7c66 Use ranged for loops in place of foreach in QTimeZone tests
This (and use of Q_SLOTS for the test slots) makes it possible to
enable QT_NO_KEYWORDS and QT_NO_FOREACH in all the corelib/time/
tests.

Change-Id: I85fd358f3d1a72c9269d5260d0224640c1751f2d
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2020-06-23 16:59:45 +02:00
Lars Knoll
66f06a930d Make QLocale(QString) explicit
We should not implicitly convert a QString to a QLocale object. It can
easily create unwanted side effects.

Change-Id: I7bd9b4a4e4512c0e60176ee4d241d172f00fdc32
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2020-04-01 09:29:26 +01:00
Alexandru Croitor
0d177053b9 Regenerate projects one last time before merge
Change-Id: Ia24cf56b79ca6dacd370a7e397024e9b663e0167
Reviewed-by: Liang Qi <liang.qi@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2020-02-12 17:30:49 +00:00
Leander Beernaert
502d3d6744 Merge remote-tracking branch 'origin/dev' into merge-dev
Change-Id: I31b761cfd5ea01373c60d02a5da8c33398d34739
2020-01-24 13:17:33 +01:00
Ulf Hermann
e62d04b933 Merge remote-tracking branch 'origin/5.14' into 5.15
Conflicts:
	src/corelib/serialization/qcborvalue.cpp

Change-Id: I675a3029955c96e81a33ed9d98b72b55b6784b52
2019-12-03 06:57:05 +01:00
Edward Welbourne
cfd2f3c46e Work around macOS's inconsistency in naming of India's time-zone
macOS fails to create a zone for the name its own systemTimeZone
claims to have (see new comment). So make sure we do consistently
recognize the name systemTimeZoneId() returns, using systemTimeZone
from which we got its name.

Add minimal testing of system time-zone.

Fixes: QTBUG-80173
Change-Id: I42f21efbd7c439158fee954d555414bb180e7f8f
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2019-11-28 14:16:33 +01:00
Qt Forward Merge Bot
adc7bbe910 Merge remote-tracking branch 'origin/5.14' into 5.15
Conflicts:
	src/gui/rhi/qshader.cpp
	tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp

Change-Id: I1c4ae718eb3592a0a0a90af9d11553f3ab68cad5
2019-11-15 16:29:40 +01:00
Edward Welbourne
ad11cab484 Allow longer time-zone components on Android
Android uses its own time-zone naming, which includes a zone called
"Canada/East-Saskatchewan", whose second component is 17 characters
long. This violates a rule in the IANA naming scheme for zones, that
limits components to 14 characters each. So tweak the isValidId()
check to allow Android its long names.

Android has added Outer Mongolian time-zones, which are as borked as
many others in 1970, so blacklist those transitionEachZone() tests.

Fixes: QTBUG-69128
Change-Id: I46f674f095431335b16900860d83b624257ae3bb
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
2019-11-14 10:47:57 +01:00
Edward Welbourne
17b8a49fde Move some tests of QTimeZonePrivate::isValidId() to where they belong
They were tucked away in the back-end of the isTimeZoneIdAvailable()
test, but a separate isValidId() test had been added more recently,
which made some (arguably all) of them redundant. Reworked this test
in the process, so that the QSKIP() happens in _data() once instead of
in the test that's never run because there are no data rows.

Change-Id: Icaa6227ace9a1aa944d085691cdcfb3adf4a51dc
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2019-11-13 10:52:00 +01:00
Alexandru Croitor
440286655e Merge remote-tracking branch 'origin/dev' into wip/cmake
Change-Id: I4a78428a8ea273b6960792e3b8043f816fa37fcf
2019-10-14 17:46:34 +02:00
Frederik Gladhorn
b3b2c799f8 cmake: add tests in corelib/time
Change-Id: Idcd5d1be7503b50a43954c1b209e48a32cc8eaa9
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-10-04 06:30:36 +00:00
Edward Welbourne
b26ac46c59 Add support for UTC[+-]\d+(:\d+){,2} time zone IDs
We presently only support the UTC-based offset timezones that are
listed in the CLDR; and it doesn't make sense to list more than these
in the list of available zones. However, if someone sets their TZ
environment variable to a conformant UTC-offset string, we should make
sense of it even if CLDR doesn't mention it. Only do so as final
fall-back, as backends may handle the givne name better (some such IDs
appear in the windows-compatibility list, for example).

Added tests for the new UTC-offset time-zone names.
Removed one test that relied on them not being supported.

[ChangeLog][QtCore][QTimeZone] The constructor can now handle general
UTC-offset zone names. The reported id() of such a zone shall be in
canonical form, so might not match the ID passed to the constructor.

Fixes: QTBUG-77738
Change-Id: I9a0aa68281a345c4717915c8a8fbc2978490d0aa
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2019-09-16 17:06:28 +02:00
Edward Welbourne
1f60e587e7 Move some time-zone validity tests to where they belong
In tst_QTimeZone::isTimeZoneIdAvailable(), a block of tests of
QTimeZonePrivate::isValidId() overlapped with what
tst_QTimeZone::isValidId_data() tests; so move out of the former and
adapt to use by the latter. At the same time, check that each
allegedly available zone *is* available enough that we can create it
and it's valid.

Change-Id: I3f7c8e2e3fbfb201747c7b769d691d7f17fc6b2a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2019-09-16 17:06:03 +02:00
Edward Welbourne
548513a4bd Separate out the time, zone, date code from corelib/tools/
We'll be adding calendar code here as well, and tools/ was getting
rather crowded, so it looks like time to move out a reasonably
coherent sub-bundle of it all.

Change-Id: I7e8030f38c31aa307f519dd918a43fc44baa6aa1
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2019-06-06 15:54:32 +02:00