Ignore:
Timestamp:
Sep 29, 2010, 9:31:22 AM (15 years ago)
Author:
[email protected]
Message:

2010-09-29 Caio Marcelo de Oliveira Filho <[email protected]>

Reviewed by Andreas Kling.

[Qt] QScriptEngine should have an API for creating Date objects
https://bugs.webkit.org/show_bug.cgi?id=41667

Implement newDate(), isDate() and toDateTime() functions. Use the
QDateTime::{to,set}MSecsSinceEpoch() functions to do the
calculations.

  • api/qscriptengine.cpp: (QScriptEngine::newDate):
  • api/qscriptengine.h:
  • api/qscriptengine_p.cpp: (QScriptEnginePrivate::newDate):
  • api/qscriptengine_p.h: (QScriptEnginePrivate::isDate):
  • api/qscriptoriginalglobalobject_p.h: (QScriptOriginalGlobalObject::QScriptOriginalGlobalObject): need to keep track of Date Constructor and Prototype. (QScriptOriginalGlobalObject::~QScriptOriginalGlobalObject): ditto. (QScriptOriginalGlobalObject::isDate): use the Date Constructor and Prototype to identify Date values.
  • api/qscriptvalue.cpp: (QScriptValue::isDate): (QScriptValue::toDateTime):
  • api/qscriptvalue.h:
  • api/qscriptvalue_p.h: (QScriptValuePrivate::isDate): (QScriptValuePrivate::toDateTime):
  • tests/qscriptengine/tst_qscriptengine.cpp: (tst_QScriptEngine::newDate):
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/qt/api/qscriptvalue.cpp

    r62921 r68651  
    322322{
    323323    return d_ptr->isArray();
     324}
     325
     326/*!
     327    Returns true if this QScriptValue is an object of the Date class;
     328    otherwise returns false.
     329
     330    \sa QScriptEngine::newDate()
     331*/
     332bool QScriptValue::isDate() const
     333{
     334    return d_ptr->isDate();
    324335}
    325336
     
    486497{
    487498    return QScriptValuePrivate::get(d_ptr->toObject());
     499}
     500
     501/*!
     502    Returns a QDateTime representation of this value, in local time.
     503    If this QScriptValue is not a date, or the value of the date is
     504    NaN (Not-a-Number), an invalid QDateTime is returned.
     505
     506    \sa isDate()
     507*/
     508QDateTime QScriptValue::toDateTime() const
     509{
     510    return d_ptr->toDateTime();
    488511}
    489512
Note: See TracChangeset for help on using the changeset viewer.