summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/tools/qtime/tst_qtime.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Separate out the time, zone, date code from corelib/tools/Edward Welbourne2019-06-061-803/+0
| | | | | | | | | | 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>
* Use the QTime API less clumsilyEdward Welbourne2019-04-011-2/+3
| | | | | | | | | | | | | Various patterns seem to have been copied, notably counting time from QTime(0, 0) rather than using QTime::msecsSinceStartOfDay() and its setter. Unsuitable value types also put in an appearance, and QTime()'s parameters after the first two default to 0 anyway. Corrected a lie in QTime()'s default constructor doc; it does not work the same as QTime(0, 0) at all. Change-Id: Icf1a10052a049e68fd0f665958f36dbe75ac46d5 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Raise the upper bound on years to 9999Edward Welbourne2017-11-301-0/+1
| | | | | | | | | | | | | | | | | Test-case taken from bug-report; fits in as an easy row in an existing data-driven test. Add similar tests for date-time and time; and an isValid test on the end of year 9999. The date-time parser was using the end of year 7999 as maximum value for dates and date-times; extend this to year 9999, as I can see no reason not to. [ChangeLog][QtCore][QDateTime] Years up to 9999 can now be parsed without error (previously 8000 and beyond were treated as invalid) in all formats (not only in ISO format). Widgets handling dates now support dates to 9999, likewise. Task-number: QTBUG-64401 Change-Id: I518cfa6c2cb4ecc5a85b896dc9e56b4fdd8a8bb1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QLocale: fix handling of milliseconds in string format and documentThiago Macieira2017-07-071-6/+9
| | | | | | | | | | | | | [ChangeLog][QtCore][QLocale] Fixed the conversion of QTime to string form and parsing from string form to always treat the value as the decimal fraction of the seconds component. That is, the string format ".z" produces/parses ".2" for 200 milliseconds and ".002" for 2 milliseconds. Use of "z" or "zzz" is discouraged outside decimal fractions to avoid surprises. Task-number: QTBUG-53565 Change-Id: Ia19de85ad35e4eb7bb95fffd14792caf9b4a5156 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Make sure to use C locale during time tests that assume itEdward Welbourne2017-02-201-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | Some format and parse tests for time and date-time depended on locale but had test data for the C locale (so fail if the test-environment has, e.g., LANG=de_DE@utf8). So impose the C locale (until Qt 6). The date-time test did *some* attempts at fixing for locale, but failed to handle am/pm; and we do have "### Qt 6" comments in Q(Date|Time)+::fromString indicating that we intend to switch these methods to use the C locale by default (which shall fix this once and for all). So rip out the incomplete localization now and test we work properly at least when the locale used *is* C. Add a comment to the matching QDate test to rip out its (presently adequate) matching code once we do get to Qt 6 and make fromString() use the C locale. QDateTimeParser uses systemLocale(), which is initialized the first time it gets accessed; so we need to frob the locale *early*; doing so in the test-class constructor is about as early as we conveniently can; and seems to work (while doing it in individual tests does not). (There is no point rolling back at the end; the QSystemLocale global has been set up by then, so the roll-back would merely leave the global out of sync with setlocale() and the environment.) Task-number: QTBUG-58728 Change-Id: Ifa6778a80276050a099387a6dab15a1096be7561 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* Add Qt::ISODateWithMs date format, with support in QTime/Date/DateTimeTor Arne Vestbø2016-10-201-0/+3
| | | | | | | | | | The Qt::ISODate format strips milliseconds, so a new format is introduced that keeps the milliseconds. A new format was chosen over fixing the existing format due to the behavioral change of suddenly having ms as part of Qt::ISODate. Change-Id: If8b852daed068cce8eee9b61a7cd4576bc763443 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Updated license headersJani Heikkinen2016-01-211-17/+12
| | | | | | | | | | | | | From Qt 5.7 -> tools & applications are lisenced under GPL v3 with some exceptions, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new GPL-EXCEPT header instead of LGPL21 one (in those files which will be under GPL 3 with exceptions) Change-Id: I42a473ddc97101492a60b9287d90979d9eb35ae1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Avoid overflow in QTime::addSecs with too big a number of secondsThiago Macieira2015-08-191-0/+2
| | | | | | | | | | QDateTime::addSecs needs to do something similar, but not identical because it needs the number of days too. And then there are daylight savings transitions... Task-number: QTBUG-47717 Change-Id: I7de033f80b0e4431b7f1ffff13f976f4f5e5a059 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@theqtcompany.com>
* Update copyright headersJani Heikkinen2015-02-111-7/+7
| | | | | | | | | | | | | | | | | | Qt copyrights are now in The Qt Company, so we could update the source code headers accordingly. In the same go we should also fix the links to point to qt.io. Outdated header.LGPL removed (use header.LGPL21 instead) Old header.LGPL3 renamed to header.LGPL3-COMM to match actual licensing combination. New header.LGPL-COMM taken in the use file which were using old header.LGPL3 (src/plugins/platforms/android/extract.cpp) Added new header.LGPL3 containing Commercial + LGPLv3 + GPLv2 license combination Change-Id: I6f49b819a8a20cc4f88b794a8f6726d975e8ffbe Reviewed-by: Matti Paaso <matti.paaso@theqtcompany.com>
* Update license headers and add new license filesMatti Paaso2014-09-241-19/+11
| | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 - Removed LICENSE.GPL Change-Id: Iec3406e3eb3f133be549092015cefe33d259a3f2 Reviewed-by: Iikka Eklund <iikka.eklund@digia.com>
* Use the short time format of the current locale on WindowsThiago Macieira2013-12-161-4/+12
| | | | | | | | Windows 7 and later have LOCALE_SSHORTTIME, which is what we need. Task-number: QTBUG-33718 Change-Id: I4c3f113d17102a37fb752de56f06b312f27c7887 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
* Revert 15da0a5af20fe6771bcb94ef8d46edbd5c8fb64c.Mitch Curtis2013-09-191-8/+8
| | | | | | | | | | It apparently breaks users' applications. Task-number: QTBUG-33487 Change-Id: Iaeceb3a02b5c7b9ab839c14693aaffcdf9394bc6 Reviewed-by: John Layt <jlayt@kde.org> Reviewed-by: hjk <hjk121@nokiamail.com>
* QTime - Add public api for get/set msecs since start of dayJohn Layt2013-09-131-0/+46
| | | | | | | | | | | | | Add new public api to get and set the number of msecs since the start of the day. Modify QDateTime to use the new msecs api. [ChangeLog][QtCore][QTime] Added new methods fromMSecsSinceStartOfDay() to create a new QTime from an msecs value, and msecsSinceStartOfDay() to return the QTime as the number of msecs since the start of the day. Change-Id: I285b725b883f1f5524fda87ca81bd64ed99fe6f4 Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Mitch Curtis <mitch.curtis@digia.com>
* QDateTime - Clean up Qt::DateFormat formatting and parsingJohn Layt2013-09-061-0/+4
| | | | | | | | | | | | | | | | Clean-up the implementation of toString() and fromString() methods in QDate, QTime and QDateTime code to be more consistent in ISODate and TextDate behavior, especially when handling TimeSpec. Reformat some code so all methods are consistent in appearance and function to make maintenance easier. This changes some corner-case behavior in TextDate and ISODate, but this either fixes bugs or makes the behavior match the documentation. Change-Id: I457aa1d7cd4f448cd9f8a2e80ec635f3cb98e58c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Mitch Curtis <mitch.curtis@digia.com>
* Add the RFC2822Date formatKevin Ottens2013-07-241-0/+54
| | | | | | | | | | | QDateTime can now be converted to strings compliant to RFC 2822. Additionally, it supports RFC 850 and RFC 1036 during parsing. By having them all together, all type of dates found in exchanged messages on the internet (including USENET) get supported. Change-Id: I771066c23f409d20b31b7d802f37852ea68ca2a0 Reviewed-by: David Faure <david.faure@kdab.com> Reviewed-by: Frederik Gladhorn <frederik.gladhorn@digia.com>
* Make QTime::toString output milliseconds for Qt::TextDate, Qt::ISODate.Mitch Curtis2013-06-031-14/+16
| | | | | | | | | | | | | | | Section 4.2.2.4 of ISO 8601 allows for decimal fraction representations of dates and times. Currently, when calling QDateTime::toString(Qt::TextDate) or QDateTime::toString(Qt::ISODate), the milliseconds will be omitted. However, QDateTime::fromString(str, Qt::TextDate) and QDateTime::fromString(str, Qt::ISODate) already support decimal fraction representations, so this patch just adds this support to QTime::toString, and hence QDateTime::toString(). Task-number: QTBUG-30250 Change-Id: If58e4b3d3105322c51d11a76b832e5e634d8991f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Update copyright year in Digia's license headersSergio Ahumada2013-01-181-1/+1
| | | | | Change-Id: Ic804938fc352291d011800d21e549c10acac66fb Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Core: Remove declaration of built-in and automatic metatypes.Stephen Kelly2013-01-041-1/+0
| | | | | | | | These types are either built-in or 'automatically declared' and so don't need to be explicitly declared as metatypes. Change-Id: I54523eb854619917123d8816d3cd6c3a1f5b4c55 Reviewed-by: David Faure <david.faure@kdab.com>
* Improve QTime test coverage.Mitch Curtis2012-10-241-0/+11
| | | | | | | Change-Id: If47de3dc047ac4f8a4a1498cf225e03bbbf4110e Reviewed-by: Mitch Curtis <mitch.curtis@digia.com> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com> Reviewed-by: Jon Severinsson <jon@severinsson.net>
* Change copyrights from Nokia to DigiaIikka Eklund2012-09-221-24/+24
| | | | | | | | Change copyrights and license headers from Nokia to Digia Change-Id: If1cc974286d29fd01ec6c19dd4719a67f4c3f00e Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Sergio Ahumada <sergio.ahumada@digia.com>
* Disregard milliseconds in QTime::secsTo().Mitch Curtis2012-08-211-0/+4
| | | | | | | | | | | | | | | | "The documentation states that "secsTo() does not take into account any milliseconds", however, this is not the case. Given times 12:30:01.500 and 12:30:02.400 secsTo returns 0. If milliseconds are not taken into account, I would expect this to return 1 (i.e. interprets the times as 12:30:01 and 12:30:02 thus truncating the milliseconds)." Note that tests were also written for QDateTime::secsTo(), as it uses QTime::secsTo internally. This addresses Javier's issue in the comments of QTBUG-9304. Task-number: QTBUG-9304 Change-Id: I9efe0c8f710db859c1d086d67ba3e5b349a56c4e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Write qHash functions for QDate, QTime and QDateTime.Mitch Curtis2012-07-121-0/+2
| | | | | | | | These functions didn't exist - this patch implements them. Task-number: QTBUG-23079 Change-Id: I9eb6e238531d5cda878f5f2cdd27bab30aa60669 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Improve QDate, QTime, QDateTime auto tests.Mitch Curtis2012-07-061-23/+25
| | | | | | | | Add more test data, merging operator!= tests in with operator== to take advantage of added data. Change-Id: If0426a3d01b8800cb7363385dbf3bcb21af5ed8f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Make QDateTime::fromString()/Time::fromString() adhere to ISO 8601.Mitch Curtis2012-06-201-10/+11
| | | | | | | | | | | | | | | | | | Currently QDateTime::fromString and QTime::fromString do not correctly handle fractional minutes and, in some cases, fractional seconds. In the case of reading fractional minutes, it has been decided to ignore invalid characters outside of the 5 character portion that we're interested in (see code comments in fromStringImpl() for info on why we read 5 digits). The motive is that there is a performance penalty for calling mid to get the portion of surplus string and also for converting to it to a float. This is also in line with what QDate does with surplus characters, for example. Task-number: QTBUG-14418 Task-number: QTBUG-25387 Change-Id: Ib742fe80686aff3c3770b995678cf838fb4e3bb4 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Clean up and consolidate QDateTime-related tests.Mitch Curtis2012-06-121-44/+68
| | | | | | | | | | Some test functions that only test QDate and QTime were in tst_qdatetime.cpp. Upon moving these into tst_qdate.cpp and tst_qtime.cpp, there were already some similar tests so I consolidated them. Change-Id: I5f8758bf8b4804ae9d3a482f49d21de9f7a1dc03 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QDateTime: Add validity checksJohn Layt2012-01-311-0/+8
| | | | | | | Check the validity of date/time before attempting to perform maths. Change-Id: Ia6a2caf07c6c36f7d7fac713a77bc4eb456c6ed6 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Remove "All rights reserved" line from license headers.Jason McDonald2012-01-301-1/+1
| | | | | | | | | | As in the past, to avoid rewriting various autotests that contain line-number information, an extra blank line has been inserted at the end of the license text to ensure that this commit does not change the total number of lines in the license header. Change-Id: I311e001373776812699d6efc045b5f742890c689 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Update contact information in license headers.Jason McDonald2012-01-231-1/+1
| | | | | | | Replace Nokia contact email address with Qt Project website. Change-Id: I431bbbf76d7c27d8b502f87947675c116994c415 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Update copyright year in license headers.Jason McDonald2012-01-051-1/+1
| | | | | Change-Id: I02f2c620296fcd91d4967d58767ea33fc4e1e7dc Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Remove TESTED_CLASS/TESTED_FILES comments from tests.Jason McDonald2011-12-061-3/+0
| | | | | | | | | These comments were mostly empty or inaccurate. Appropriate naming of tests and appropriate placement of tests within the directory tree provide more reliable indicators of what is being tested. Change-Id: Ib6bf373d9e79917e4ab1417ee5c1264a2c2d7027 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Cleanup corelib autotestsJason McDonald2011-11-071-43/+0
| | | | | | | Remove redundant empty constructors, destructors and test functions. Change-Id: Idb51368895e67ec3fc0345a9a5d33d77730c051b Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Remove DEPENDS_ON from qtestlib API.Jason McDonald2011-10-191-18/+0
| | | | | | | | | | The DEPENDS_ON macro didn't do anything and has misled many users to think that they can write test functions that depend on other test functions. Task-number: QTBUG-21851 Change-Id: Ibe65b2d5d88bb81b6a0ebbe0b220f7d409a1446c Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Moving relevant tests to corelib/toolsHolger Ihrig2011-09-011-0/+689
Task-number: QTBUG-21066 Change-Id: I650f8f7826b9feea7c1484f06e03e10c68ec2b65 Reviewed-on: http://codereview.qt.nokia.com/3712 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Sergio Ahumada <sergio.ahumada@nokia.com>