Commit Graph

121 Commits

Author SHA1 Message Date
Vadim Zeitlin
a4940bf696 Extract wxLocaleSetter from the tests into a private header
This will allow using this class in the library code too.

No real changes yet, this is a pure refactoring.

This commit is best viewed using git --color-moved option.
2021-08-07 18:04:22 +02:00
Paul Cornett
c82e13068a Fix comment typo 2021-03-17 10:30:34 -07:00
PB
f57f214122 Remove BCC-specific hdrstop pragma from everywhere 2020-10-12 21:58:37 +02:00
Vadim Zeitlin
3ab187f75f Add a test for "%e" to wxDateTime::ParseFormat()
See https://github.com/wxWidgets/wxWidgets/pull/1842
2020-05-09 23:23:31 +02:00
Vadim Zeitlin
2cf0537722 Correct the test for ParseFormat() with fall back date
This was added back in b5f85206a9 (fix ParseFormat("%d") to set the date
it finds (#10002), 2008-09-26), but the test didn't do what the comment
said and didn't use the default date object it added.

Fix this now to finally do what was intended all these years ago.
2020-05-09 23:22:13 +02:00
Vadim Zeitlin
c26353f13f Add another workaround for failures in wxDateTime::UNow test
If current time doesn't have the milliseconds parts, we need to sleep
for a little before retrying.
2019-11-13 15:39:36 +01:00
Vadim Zeitlin
1b063e1dea Add a delay before calling wxDateTime::UNow() again in the test
Retrying immediately wasn't very useful, as the times must have been the
same during all loop iterations anyhow, so add a sleep to try to finally
fix the sporadic test failure on Travis.
2019-10-23 11:43:53 +02:00
Vadim Zeitlin
3d488ef8a3 Replace INFO() with WARN() in wxDateTime::UNow() unit test
Another desperate attempt to understand how are failures such as the one
at https://travis-ci.org/wxWidgets/wxWidgets/jobs/601043830 possible.
2019-10-22 15:12:39 +02:00
Vadim Zeitlin
8d962b0121 Add a diagnostic message to wxDateTime::UNow() unit test
Try to understand what's going in Travis CI builds.
2019-10-19 23:05:32 +02:00
Vadim Zeitlin
c4e914784a Guard against Now() and UNow() returning different second values
Avoid spurious error in the unit test by calling Now() and UNow() a few
times in a row until they return the same second, as we may be unlucky
enough for this not to be the case when we call them just once.
2019-10-19 20:02:42 +02:00
Vadim Zeitlin
c92f9e0a17 Document that wxDateTime::UNow() returns time in local time zone
This is its actual behaviour and it's the right thing to do, as it's
consistent with Now() -- even though the documentation wrongly stated
otherwise (since 324ab5e2db).

Also add a unit test checking that UNow() == Now(), except for the
milliseconds.

See #14148.

Closes #18524.

Closes https://github.com/wxWidgets/wxWidgets/pull/1594
2019-10-07 12:27:28 +02:00
Vadim Zeitlin
5488a1438f Globally replace vadim@wxwindows.org with vadim@wxwidgets.org
The old email address is invalid since many years and shouldn't be used
any longer.

No real changes.
2019-04-22 14:12:05 +02:00
Vadim Zeitlin
2a907769fb Suppress all -Wmissing-field-initializers in the test suite
There were many dozens of such warnings given for the various arrays
used in the tests and it just doesn't seem feasible nor desirable to fix
them all, so just suppress the warnings for all these arrays to get rid
of them with recent (7+?) versions of gcc.
2019-02-02 17:25:37 +01:00
Vadim Zeitlin
15a97924b6 Simplify wxDateTime ticks test by only using UTC times
Converting to another time zone and dealing with DST is completely
useless here, ticks values are always in UTC, so we can just use UTC
values from the beginning.
2017-12-02 14:38:45 +01:00
Vadim Zeitlin
179dced0e0 Include testdate.h before catch.hpp in unit tests
This ensures that dates are printed out correctly if comparing them
fails.

It might be better to avoid always including this header, but this is
the simplest solution.
2017-12-02 14:38:19 +01:00
Vadim Zeitlin
322144299d Use wxDateTime::TimeZone::IsLocal() in the unit test
No real changes, as this doesn't affect this test, but use the new
IsLocal() method instead of comparing the time zone offset with the time
zone, which doesn't work correctly for BST.
2017-11-30 17:53:52 +01:00
Vadim Zeitlin
d49784b0a2 Disable wxDateTime tests failing due to TZ offset changes
wxDateTime timezone-related methods always use the current timezone
offset, while other methods, using CRT, use correct value for the given
date, which may be different.

This discrepancy accounted for test failures in Europe/Minsk time zone
as Belarus has switched from UTC+2 to UTC+3 since 1999 date used in the
test.

It is impossible to really fix the problem easily, so just skip the test
in this case and also mention this bug in the documentation.

See #15370.
2017-11-30 17:44:41 +01:00
Vadim Zeitlin
d3a01e3fe6 Show more information in other DateTimeTestCase tests too
Show the loop variable when doing checks inside a loop to make it more
obvious for which test case the failures occur.

Also use CHECK(), instead of REQUIRE(), to which CPPUNIT_ASSERT_EQUAL
expands, to continue with the other loop iterations after failure.
2017-11-29 23:55:13 +01:00
Vadim Zeitlin
4868ec0893 Show more information if DateTimeTestCase::TestTimeFormat() fails
No real changes, just show the variable values if any checks fail and
also continue running the test for the other data points even if one of
them fails.
2017-11-29 23:19:01 +01:00
Vadim Zeitlin
c7c30504c8 Do nothing when converting wxDateTime to/from local time zone
In particular, do not (unexpectedly) adjust time by the DST.

Closes #16585.

See #10445.
2017-11-29 23:18:57 +01:00
Vadim Zeitlin
543c522cb8 Explicitly disambiguate local time zone from UTC
Don't rely on time zone offset to check whether it is local as this
doesn't, and can't, work for the local time zone in Great Britain which
uses the same offset as UTC, but does use DST, unlike the latter.

Add a unit test (albeit disabled by default) checking that the code that
previously didn't work correctly in BST does work now (run the tests
using "TZ=Europe/London ./test wxDateTime-BST-bugs" under Unix to test).

Closes #14317, #17220.

See #10445.
2017-11-29 23:02:22 +01:00
Vadim Zeitlin
5b2f7aa96d Remove IsDST() check in wxDateTime DST unit test
IsDST() returns 0 for the DST end date itself, which is wrong, but
doesn't seem to be directly relevant for this test.
2017-11-28 23:59:21 +01:00
Vadim Zeitlin
13c3b5cbd1 Use different sections for wxDateTime DST test
Try to make it more clear where exactly does it fail on buildbot.
2017-11-28 23:40:51 +01:00
Vadim Zeitlin
efb8d82c8a Provide more information if wxDateTime DST test fails
Show the original date and the date after modification.
2017-11-28 23:19:26 +01:00
Vadim Zeitlin
369e6f6554 Use "datetime" tag for all wxDateTime unit tests
Make it possible to run all these tests at once (and no other ones)
easily.
2017-11-28 23:09:51 +01:00
Vadim Zeitlin
e23ff6fded Add tests for wxDateTime setters around DST end time
Check that setting the other date components doesn't change its hour.

See https://github.com/wxWidgets/wxWidgets/pull/367
2017-11-28 23:05:45 +01:00
Paul Cornett
d76e627341 More use of wxFALLTHROUGH 2017-11-02 08:56:29 -07:00
Vadim Zeitlin
ebf30adeb6 Avoid calling strftime() with an invalid format string
This results in an assertion from MSVC CRT implementation which was
somehow consumed by CppUnit but with the switch to Catch resulted in a
test failure.
2017-11-02 01:53:23 +01:00
Paul Cornett
3a9fc640e4 Don't crash on trailing '%' in wxDateTime::Format(). See #17931 2017-08-01 08:35:58 -07:00
Dimitri Schoolwerth
9b9f8ac468 Extend limits of allowed time zone offsets 2017-06-23 02:02:19 +04:00
Dimitri Schoolwerth
af309e6d96 Add minus sign (U+2212) as a time zone offset indicator 2017-06-23 02:02:19 +04:00
Dimitri Schoolwerth
1a5163a882 Add time zone parsing support for only specifying HH 2017-06-23 02:02:19 +04:00
Dimitri Schoolwerth
101433190f Add time zone parsing support for HH:MM 2017-06-23 02:02:19 +04:00
Dimitri Schoolwerth
a3a4e7c638 Add time zone parsing support for 'Z' (UTC indicator) 2017-06-23 02:02:19 +04:00
Dimitri Schoolwerth
51cfb64ecb Add test for wxDateTime time zone parsing 2017-06-23 02:02:19 +04:00
Vadim Zeitlin
f6d9d7962e Revert wrong fix for wxDateTime timezone conversion to/from local
This reverts commit aaddf6be7f as it broke
handling of dates when local time zone is BST, whose offset not counting DST
is 0, as for UTC, but which still should be handled as local timezone,
see #17220.

With the current wxDateTime handling of time zones, FromTimezone(Local)
doesn't make much sense anyhow, so abandon attempts to try making it work as
to really do it we need to specify the time zone being converted from too, as
explained in the second point of #10445.

See #16585.
2017-04-19 17:07:44 +02:00
Vadim Zeitlin
ffcdcc1617 Make wxTimeSpan::operator-() const
Due to an oversight, it wasn't declared as const, making it impossible to
subtract from a const wxTimeSpan object.

Fix this and add a unit test verifying that this compiles and works as
expected.

Closes #17583.
2016-06-30 19:09:04 +02:00
Dimitri Schoolwerth
8f8d58d193 Use wx-prefixed macros throughout the repository.
Change {DECLARE,IMPLEMENT}_*CLASS and {DECLARE,BEGIN,END}_EVENT_TABLE
occurrences to use the wx-prefixed version of the macros.
2015-04-23 22:00:35 +04:00
Vadim Zeitlin
31d1644daa Finally do fix use of wxTranslateFromUnicodeFormat() in the unit test.
Don't reference the never defined function in the test any more.

(This does) close #16118.
2015-04-10 17:51:01 +02:00
Vadim Zeitlin
806317dfcc Really really fix use of wxTranslateFromUnicodeFormat() in the unit test.
Don't build this test at all under Unix, where this function doesn't exist.

(Really really) closes #16118.
2015-04-10 17:01:29 +02:00
Vadim Zeitlin
ffcc18580e Really fix use of wxTranslateFromUnicodeFormat() in the unit test.
Update the function declaration in the test too.

(Really) closes #16118.
2015-04-10 16:24:58 +02:00
Dimitri Schoolwerth
adbc9863b2 Handle quotes in wxTranslateFromUnicodeFormat.
When parsing Unicode date formats text inside single quotes should not be
escaped and instead treated as literal text. In addition two single quotes
(either inside or outside quoted text) should be interpreted as a single
quote.

Fixes #16118.
2015-04-09 04:39:35 +04:00
Vadim Zeitlin
0a8ea54125 Fix typo in DateTimeTestCase::TestParseRFC822() method name.
No real changes, just s/Parce/Parse/
2015-02-26 00:17:26 +01:00
Vadim Zeitlin
29b68052bb Add support for "%V" and "%G" to wxDateTime::Format().
This is useful for creating ISO 8601 week number based stamps.

Closes #11857.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76988 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2014-08-03 12:47:36 +00:00
Vadim Zeitlin
17d698cca5 Consistently handle DST start time in wxDateTime::Set().
Always move the dates invalid due to DST (i.e. falling into the "missing" hour
on the DST start date) forward, as GNU libc does, even when using a different
CRT implementation, such as MSVC one which moves the invalid dates backwards.

This seems more expected and also fixes an especially bad problem which
happened due to moving the date backwards in Brazilian time zone where DST
starts at midnight as doing this changed the day and totally broke ParseDate()
assumption that setting wxDateTime to 00:00:00 at the given date really did
set it to this date.

Closes #15419.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74777 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2013-09-08 18:00:58 +00:00
Vadim Zeitlin
3f66f6a5b3 Remove all lines containing cvs/svn "$Id$" keyword.
This keyword is not expanded by Git which means it's not replaced with the
correct revision value in the releases made using git-based scripts and it's
confusing to have lines with unexpanded "$Id$" in the released files. As
expanding them with Git is not that simple (it could be done with git archive
and export-subst attribute) and there are not many benefits in having them in
the first place, just remove all these lines.

If nothing else, this will make an eventual transition to Git simpler.

Closes #14487.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74602 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2013-07-26 16:02:46 +00:00
Vadim Zeitlin
2747a51b24 Restore ability to parse hours only with wxDateTime::ParseTime().
This was accidentally removed in r51059, but worked in 2.8 and so should
continue to work.

Also add a unit test to ensure that this doesn't get broken again in the
future.

Closes #15204.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73988 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2013-05-15 13:05:49 +00:00
Vadim Zeitlin
12ce0a7402 Fix wxDateTime::GetWeekOfYear() for the days in the last week of the year.
The code took into account the possibility that the days in the beginning of
the year might belong to the last week of the previous year but not that the
days at the end of the year could belong to the first week of the next year.

Closes #14973.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73402 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2013-01-20 02:09:48 +00:00
Vadim Zeitlin
f4370376b6 Fix bugs in the recently added wxDateTime::DiffAsDateSpan().
Correct the test for negative spans less than a month and use the correct
month for computing the number of days in it.

Also add unit tests for problematic cases.

Closes #14704.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72616 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2012-10-04 22:48:30 +00:00
Vadim Zeitlin
77dd7daad2 Add wxDateTime::DiffAsDateSpan().
This method returns the difference between the dates as wxDateSpan, unlike the
existing Subtract() and overloaded operator-() that return wxTimeSpan.

Closes #14704.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72600 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2012-10-01 09:55:05 +00:00