aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4dateobject.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Use QDate::startOfDay() rather than QDateTime(,QTime(0, 0),)Edward Welbourne2020-11-121-3/+2
| | | | | | | | Makes no difference in this case, as it's UTC, but is terser and perhaps slightly clearer. Change-Id: I7de315def2f45ec4a12d2a682e5d1d7a4d0a3e6d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QML: Make date parsing more lenientFabian Kosmale2020-10-291-0/+2
| | | | | | | | | | | This fixes a regression from Qt 5 to Qt 6, because QDateTime is now apparently more strict in its parsing of RFC2822Date. The string in the test-case is not valid according to that spec, but JS engines like V8 still accept it, and so did we in Qt 5. Fixes: QTBUG-87610 Change-Id: I2c6eb2087e4845b04fa0dc4f7aa9a229b3428a43 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* V4 Date: pass QDate, QTime by value, not by const referenceEdward Welbourne2020-09-011-1/+1
| | | | | | | They're value types, packaging qint64 and int respectively. Change-Id: I78a0097f77238751ac3ef9f928537f719a6d05d6 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qv4dateobject.cpp: USE_QTZ_SYSTEM_TIMEZONE on more platformsUlf Hermann2020-06-251-2/+19
| | | | | | | | | | | | | The only platform where we may have a semi-adequate native implementation of the time/date functions is windows. On all other platforms we should use QTimeZone::systemTimeZone() if possible as that at least gives us correct results when the system time zone doesn't change at runtime. Fixes: QTBUG-84474 Pick-to: 5.15 Change-Id: I34b01e12a751ee1c9b17735810e62e2e847f8446 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QtQml: Use unicode character literalsUlf Hermann2020-06-031-10/+10
| | | | | | | This avoids the warnings on conversion to QChar. Change-Id: Ib774f24592d6f09a531c60bb6fa6e5bdbec88120 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Reduce Qt Declarative's use of QDateTime's locale-dependent APIsFabian Kosmale2020-01-301-3/+3
| | | | | | | | | | | [ChangeLog][QtQml] Qt.formatDateTime, Qt.formatDate and Qt.formatTime now support formatting according to a locale and an optional locale format type. If locale dependent formatting is desired, this method should be used instead of the locale-related DateFormat enum members. Fixes: QTBUG-81631 Change-Id: I971231644ebbeaccbf54dd8f036adf4d31547301 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* V4: Check for exceptions before we use the result of a JS callUlf Hermann2020-01-231-1/+1
| | | | | | | | If the call resulted in an exception the return value is undefined. Task-number: QTBUG-81581 Change-Id: Ibfdd5e1229cf5437f270232d3b1a91308adeec72 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Merge remote-tracking branch 'origin/5.13' into 5.14Liang Qi2019-10-101-5/+20
|\ | | | | | | | | | | | | | | Conflicts: src/plugins/scenegraph/openvg/qsgopenvgcontext.cpp tests/auto/quick/qquickpathview/tst_qquickpathview.cpp Change-Id: I117c8d62b21800329d1035021d312d9924f83a1b
| * Be more fussy about the MakeDay() calculationEdward Welbourne2019-10-081-5/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The ES Date spec goes into minute detail about doing various algorithms in the dumbest possible way (like InLeapYear() calling DaysInYear(), rather than the other way round) but, in MakeDay(), leaves the implementation to solve the problem of finding the start of the first day of a specified month in a given year. So exercise the freedom we have in that to be a little more robust; and actually check we have met the conditions the spec requires, returning NaN (as specified) if not. Added tests for some denormal dates and date-times and for a date mentioned in QTBUG-78996. Task-number: QTBUG-78996 Change-Id: I8d9a841dd1f1d9995273a3de8f6f9130207c7c2b Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* | Convert a few sizeof(array)/sizeof(element0) fors to range forsAlbert Astals Cid2019-10-041-2/+1
| | | | | | | | | | | | | | | | Increases readability Change-Id: I46d82fac83e538988cea79a053d70b954a3cb9f1 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Convert QTime to V4 Date on a date with no DST in forceEdward Welbourne2019-09-271-7/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Sadly the third centennary of Cassini's birth isn't such a good date after all, since round-tripping will ignore DST on the QDateTime leg but include it in V4's implementation of ES's ill-conceived spec for handling DST and time-zone transitions; and June 8th is in summer for much of the world. So use a date which (as far as I can tell) appears to have been DST-free everywhere; and after the start of 1970 so that, even if we find ourselves working with a zone in which it did have DST, we'll apply DST consistently during round-tripping. Fixes: QTBUG-78706 Change-Id: I25be2548e2c97eae2c4f6c5bbe661dea2f35aaba Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* | Fix tst_qqmllocale::timeZoneUpdated() test on AndroidJan Arve Sæther2019-07-181-1/+1
| | | | | | | | | | | | | | | | | | Switching to the POSIX implementation of DaylightSavingTA() fixes it Fixes: QTBUG-77052 Task-number: QTBUG-73512 Change-Id: I24804f193ac6f85eb6764f656d351cdc272c7987 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* | Remove some unneeded includesUlf Hermann2019-07-081-2/+0
|/ | | | | | Change-Id: Id05059dfc9910dad206e511b08f18487e241e508 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Merge remote-tracking branch 'origin/5.12' into devQt Forward Merge Bot2018-11-241-6/+12
|\ | | | | | | Change-Id: I57e4b762dcccf2f7f6e4b659f6fc8c40465d3322
| * Ensure our builtin constructors are subclassableLars Knoll2018-11-221-6/+12
| | | | | | | | | | | | | | | | | | Respect the newTarget passed into those constructors and make sure we set up the proto chain correctly. Change-Id: I3d12c7dbef4b33660a6715d73e9fb0f89105167a Fixes: QTBUG-71138 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* | Stop using deprecated Qt:LocaleDateEdward Welbourne2018-09-211-3/+3
|/ | | | | | | | | | The Q(Date|Time)+::toString() methods to which it was passed all, at present, treat it the same as DefaultLocaleShortDate, so replace it with that. It's possible we should use the long format instead, but that would be a behavior change. Change-Id: I238ecd0bf0782f0c930ffee8bce23e2881922fed Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Cleanups in Value/PrimitiveLars Knoll2018-09-171-13/+13
| | | | | | | | | | | | Get rid of Primitive and move the corresponding methods directly into Value. Mark many methods in Value as constexpr and turn Value into a POD type again. Keep Primitive as a pure alias to Value for source compatibility of other modules that might be using it. Change-Id: Icb47458947dd3482c8852e95782123ea4346f5ec Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix Date.Utc()Lars Knoll2018-09-071-16/+43
| | | | | Change-Id: Iefba82adbf8f7b944079d165054e9dfe4461ac77 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix toLocaleString implementations in (Typed)Array.prototypeLars Knoll2018-08-231-1/+1
| | | | | Change-Id: Idcabd68b1651ad3cae315a16cb0e1361cba21253 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix handling of out-of-range year in Date's toISOString()Edward Welbourne2018-07-031-1/+1
| | | | | | | | | | ECMAScript 2015 clarified the handling of out-of-range years, requiring that an exception be raised: http://www.ecma-international.org/ecma-262/7.0/index.html#sec-corrections-and-clarifications-in-ecmascript-2015-with-possible-compatibility-impact http://www.ecma-international.org/ecma-262/7.0/index.html#sec-date.prototype.toisostring Change-Id: I91d76703705f3919d2ee77557e36af362db1adf9 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Apply TimeClip() in a few places it was missingEdward Welbourne2018-07-031-3/+3
| | | | | | | | | When parsing or converting from a QDateTime, we didn't always check that the resulting Date object was within range (1e8 days either side of the start of 1970). Change-Id: I1bee69f9070829f68998d576c19907a827fabc39 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Implement support for new.targetLars Knoll2018-07-031-1/+1
| | | | | | | | | Support the new.target meta property in the codegen, and add support for passing the newtarget into the constructor vtable methods and the execution context. Change-Id: I62ea58e5e92d894035a76e35776203e9837c383b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Prefix vtable methods with virtualLars Knoll2018-07-031-2/+2
| | | | | | | | | Turns out that the overloading of vtable methods and regular ones is problematic in some cases. So let's rather make it explicit which methods are part of the vtable, and which aren't. Change-Id: Ifee32a26104d30f3c82bca8b5a9cdea2d4f4f526 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Clean up the property key API in StringOrSymbolLars Knoll2018-07-021-3/+3
| | | | | | | | | | | | | | Get rid of makeIdentifier(), as toPropertyKey() will take care of it. Rename identifier() to propertyKey() and check that the key is valid. Remove String/StringOrSymbol::asArrayIndex(), we don't need it anymore. Change-Id: I3c490fabc1475c9ea288b49b1638b6fa1bc237b7 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Replace Identifier by PropertyKeyLars Knoll2018-07-021-1/+1
| | | | | | | | Change all uses of Identifier to use the new PropertyKey class and get rid of Identifier. Change-Id: Ib7e83b06a3c923235e145b6e083fe980dc240452 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Implement toPrimitive() the way the ES7 spec wants itLars Knoll2018-05-281-0/+18
| | | | | | | | Add Dat.prototype[Symbol.toPrimitive] and make use of those methods in the toPrimitive implementation. Change-Id: I82a9a94dcae6822100de364373b3f4de1e3d749b Reviewed-by: Robin Burchell <robin.burchell@crimson.no>
* Merge remote-tracking branch 'origin/5.11' into devLiang Qi2018-05-111-1/+1
|\ | | | | | | | | | | | | | | | | Conflicts: src/qml/compiler/qv4compilerscanfunctions.cpp tools/tools.pro Done-with: Lars Knoll <lars.knoll@qt.io> Change-Id: Ia77ee6ede6fc9760ce5a03d68079579a63e5a02f
| * Fix build without features.timezoneTasuku Suzuki2018-05-111-1/+1
| | | | | | | | | | | | Change-Id: Id40b7a9394a9027551a1334e9e520630e8967cb7 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
* | Cleanup creation code for builtin functionsLars Knoll2018-05-021-3/+1
| | | | | | | | | | | | | | | | Centralize the code in FunctionObject::createBuiltinFunction and setup function names and length properties there. Change-Id: I21f1d42b475070ee091d96d97387149af1dc47f2 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Remove static localTZA variableLars Knoll2018-05-021-52/+51
|/ | | | | | | | | This one leads to lots of complaints from thread sanitizers as we're writing to it from multiple threads. Move it into the engine to avoid the noise. Change-Id: I081eeb1de80e623c68fcbd17df1875943c6c019c Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Get rid of BuiltinFunctionLars Knoll2018-01-151-1/+1
| | | | | | | It's now unused. Change-Id: Id2941c212d488c9b0933fa06aac9922b9db13a05 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Raise minimum supported MSVC version to 2015Friedemann Kleint2018-01-061-1/+1
| | | | | | | | | | | | Remove code for older versions and streamline #ifdefs. Remove the helpers macros Q_STATIC_ASSERT_FOR_SANE_COMPILERS and V4_ASSERT_IS_TRIVIAL. Task-number: QTBUG-40658 Task-number: QTBUG-51673 Change-Id: Ifa4fab653b10ce7858739adef08364cddc6507cf Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Merge remote-tracking branch 'origin/wip/new-backend' into devSimon Hausmann2017-11-211-263/+333
|\ | | | | | | | | | | | | | | | | | | | | Conflicts: src/qml/compiler/qv4isel_moth.cpp src/qml/compiler/qv4jsir_p.h src/qml/jsruntime/qv4engine_p.h src/qml/jsruntime/qv4vme_moth.cpp tests/auto/qml/qml.pro Change-Id: Ia7b6ec24c7fcbcbb1786d9e798d2df294020ae37
| * Convert Date methods to new calling conventionLars Knoll2017-11-131-150/+145
| | | | | | | | | | Change-Id: I5b80eb9d9f18b113a04461fc8b5217a3695269a4 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
| * Change signature for call/callAsConstructorLars Knoll2017-11-071-12/+12
| | | | | | | | | | Change-Id: I159b57acc7a2133ef1ad545aa84e792c63449a57 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
| * Rename the construct 'virtual' method to callAsConstructorLars Knoll2017-11-071-1/+1
| | | | | | | | | | | | | | To make it consistent with the rest of the engine. Change-Id: I57b98fa26134f9864c663f47371ef3e9ca16ac9c Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
| * Further cleanup JSCallDataLars Knoll2017-11-071-1/+1
| | | | | | | | | | | | | | Avoid allocations on the JS stack if possible Change-Id: I344cd6dceb6264314f9d22c94db22b22d1d24d14 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
| * Simplify JSCallData constructionLars Knoll2017-11-071-1/+1
| | | | | | | | | | Change-Id: Ic53532edae9a209aa7125af6f00a9d993d74f1a3 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
| * Get rid of JSCallData::call()Lars Knoll2017-11-071-3/+3
| | | | | | | | | | Change-Id: I6b99e9a7102b3dcb6a7699f54b6456eba6248699 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
| * Rename JSCall to JSCallDataLars Knoll2017-11-071-1/+1
| | | | | | | | | | | | | | | | As, this is going to change in a simple stack based structure to keep pointers to the data to pass to calls. Change-Id: Ia9aa3f81ee3eeba36affd16aac7b2fe97d59aea9 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
| * Change CallData::argc to be a QV4::ValueErik Verbruggen2017-09-191-43/+43
| | | | | | | | | | | | | | | | | | | | | | Instead of mimicking a Value. This makes sure that argc now stays correct even when anything on Value changes. Most of the change is mechanical: replace callData->argc by callData->argc(). Change-Id: I521831ae1ffb3966bad6589c18d7a373e13439d7 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
| * Always set the correct FunctionObject when calling JS functionsLars Knoll2017-09-021-3/+3
| | | | | | | | | | | | | | | | | | Renamed ScopedCallData to JSCall, enforced passing a JS FunctionObject to it, and added call() and callAsConstructor() methods to it. Change-Id: I30db65c9765c2896b5909fe2105c0934c6dad861 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
| * Move ScopedCallData and ScopedStackFrame into a separate fileLars Knoll2017-09-011-0/+1
| | | | | | | | | | Change-Id: I9ae42aa7a811aa93fe0950725e9d253a0c5e8dba Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
| * Remove Scope::result and convert calling convention for builtinsLars Knoll2017-08-081-181/+254
| | | | | | | | | | | | | | | | Allow for faster calling of builtins, and completely avoid scope creation in many cases. Change-Id: I0f1681e19e9908db10def85a74e134a87fc2e44c Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
| * Change function signatures for call/construct backLars Knoll2017-08-041-5/+6
| | | | | | | | | | | | | | | | Change those back again to return a value. This will be required to avoid creation of Scope objects between JS function calls. Change-Id: I05cb5cf8fd0c13dcefa60d213ccd5983fab57ea3 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* | V4 Date.ParseString(): use array in place of QStringListEdward Welbourne2017-11-141-50/+51
| | | | | | | | | | | | | | | | Converted a QStringList of formats (constructed on each affected call to the function) to a const array (needing no heap or run-time). Change-Id: Ia6b32a306620e3ea4dd0ec1456f6b66bc8aba322 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | V4 Date.ParseString(): fix UTC-ness of date-only formatsEdward Welbourne2017-11-141-18/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ECMA-262 stipulates that date-only formats should be treated as UTC, while date-times are handled as standard time, if no time zone is explicitly given. Tidied up the parser a bit in the process and documented what the spec says. Fixed some broken test-cases. Handling of date-times without zone as local time is a correction since edition 5.1 of ECMA-262 (which said to handle it as UTC): http://www.ecma-international.org/ecma-262/7.0/index.html#sec-corrections-and-clarifications-in-ecmascript-2015-with-possible-compatibility-impact We were previously handling both dates and date-times as local time, violating the old spec for both and the revised spec for dates. Task-number: QTBUG-56787 Change-Id: I557789d855b910ca6a859fca396af1a0205c9417 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | V4 Date: fix what we can within ECMA 262's limitationsEdward Welbourne2017-11-141-39/+80
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use QDateTime and QTimeZone to simplify code (when we can). Note which defective methods are so because the ECMAScript spec requires those defects, reference my bug report against those defects. Fix currentTime to return a UTC time. Fix getLocalTZA to actually deliver the standard offset, without daylight-saving corrections. Fix DaylightSavingTA(t) to return the difference between current standard time offset and pertinent total offset at time t (explaining why that's the least broken answer), rather than assuming DST is one hour when active. (In some places it's half an hour, in some places two hours; and the bugs in the spec break UTC() and LocalTime() if we only return actual DST offset, without adjusting for historical changes to standard offset.) Fix tests to use actual IANA IDs for zones. Change QTime-to-Time conversion to use a modernish date, for which time-zone data is likely to at least be consistently handled, instead of MakeDay(0, 0, 0); that's (nominal proleptic Gregorian) 2 BC, December 31st (represented denormally) for which any time-zone data we have is artificial and contrived. I chose Cassini's third centennary, as it's not likely to be near any zone transitions and is within the era of sane time-zone data. Task-number: QTBUG-56787 Change-Id: I5f21ee2010070a5c1798134fdd2915a723208fd9 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* DateObject: Add a bunch of exception checksRobin Burchell2017-02-071-0/+28
| | | | | | | | | | | | | | | | | | | | | | | | The ES6 spec specifies ReturnIfAbrupt between each of these steps, covering cases where for instance some strange person passes an Object to the setYear function, with a valueOf that throws. This improves our pass rate on built-ins/Date/prototype on the ES6 tests significantly. Before: === Summary === - Ran 1144 tests - Passed 1076 tests (94.1%) - Failed 68 tests (5.9%) After: === Summary === - Ran 1144 tests - Passed 1110 tests (97.0%) - Failed 34 tests (3.0%) Change-Id: I616d5727eb6ae197699aa4021631f17c7346de27 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Date.prototype: Fixes for ES6 complianceRobin Burchell2017-02-071-4/+19
| | | | | | | | | | | | * Don't return -0 from TimeClip (20.3.1.15, 1) * Mark length configurable (19.2.4.1) * toUTCString and toGMTString must be the the same object (B.2.4.3) Brings us a bit closer to passing tests. Still some failures in other areas. Change-Id: I905216b8653ac0b33cb27e6b773616521fbb5daa Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>