Commit 175d46f1 authored by paroga@webkit.org's avatar paroga@webkit.org

Move GregorianDateTime from JSC to WTF namespace

https://bugs.webkit.org/show_bug.cgi?id=91948

Reviewed by Geoffrey Garen.

Moving GregorianDateTime into the WTF namespace allows us to us to
use it in WebCore too. The new class has the same behaviour as the
old struct. Only the unused timeZone member has been removed.

Source/JavaScriptCore:

* runtime/DateConstructor.cpp:
* runtime/DateConversion.cpp:
* runtime/DateConversion.h:
* runtime/DateInstance.h:
* runtime/DatePrototype.cpp:
* runtime/JSDateMath.cpp:
* runtime/JSDateMath.h:

Source/WebCore:

* bridge/qt/qt_runtime.cpp:
(JSC::Bindings::convertValueToQVariant):
(JSC::Bindings::convertQVariantToValue):
* bridge/qt/qt_runtime_qt4.cpp:
(JSC::Bindings::convertValueToQVariant):
(JSC::Bindings::convertQVariantToValue):

Source/WTF:

* GNUmakefile.list.am:
* WTF.gypi:
* WTF.pro:
* WTF.vcproj/WTF.vcproj:
* WTF.xcodeproj/project.pbxproj:
* wtf/CMakeLists.txt:
* wtf/GregorianDateTime.h: Added.
(GregorianDateTime):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@123425 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 315ca9fc
2012-07-23 Patrick Gansterer <paroga@webkit.org>
Move GregorianDateTime from JSC to WTF namespace
https://bugs.webkit.org/show_bug.cgi?id=91948
Reviewed by Geoffrey Garen.
Moving GregorianDateTime into the WTF namespace allows us to us to
use it in WebCore too. The new class has the same behaviour as the
old struct. Only the unused timeZone member has been removed.
* runtime/DateConstructor.cpp:
* runtime/DateConversion.cpp:
* runtime/DateConversion.h:
* runtime/DateInstance.h:
* runtime/DatePrototype.cpp:
* runtime/JSDateMath.cpp:
* runtime/JSDateMath.h:
2012-07-23 Filip Pizlo <fpizlo@apple.com>
Property storage should grow in reverse address direction, to support butterflies
......
......@@ -136,13 +136,13 @@ JSObject* constructDate(ExecState* exec, JSGlobalObject* globalObject, const Arg
else {
GregorianDateTime t;
int year = JSC::toInt32(doubleArguments[0]);
t.year = (year >= 0 && year <= 99) ? year : year - 1900;
t.month = JSC::toInt32(doubleArguments[1]);
t.monthDay = (numArgs >= 3) ? JSC::toInt32(doubleArguments[2]) : 1;
t.hour = JSC::toInt32(doubleArguments[3]);
t.minute = JSC::toInt32(doubleArguments[4]);
t.second = JSC::toInt32(doubleArguments[5]);
t.isDST = -1;
t.setYear((year >= 0 && year <= 99) ? year : year - 1900);
t.setMonth(JSC::toInt32(doubleArguments[1]));
t.setMonthDay((numArgs >= 3) ? JSC::toInt32(doubleArguments[2]) : 1);
t.setHour(JSC::toInt32(doubleArguments[3]));
t.setMinute(JSC::toInt32(doubleArguments[4]));
t.setSecond(JSC::toInt32(doubleArguments[5]));
t.setIsDST(-1);
double ms = (numArgs >= 7) ? doubleArguments[6] : 0;
value = gregorianDateTimeToMS(exec, t, ms, false);
}
......@@ -214,12 +214,12 @@ static EncodedJSValue JSC_HOST_CALL dateUTC(ExecState* exec)
GregorianDateTime t;
int year = JSC::toInt32(doubleArguments[0]);
t.year = (year >= 0 && year <= 99) ? year : year - 1900;
t.month = JSC::toInt32(doubleArguments[1]);
t.monthDay = (n >= 3) ? JSC::toInt32(doubleArguments[2]) : 1;
t.hour = JSC::toInt32(doubleArguments[3]);
t.minute = JSC::toInt32(doubleArguments[4]);
t.second = JSC::toInt32(doubleArguments[5]);
t.setYear((year >= 0 && year <= 99) ? year : year - 1900);
t.setMonth(JSC::toInt32(doubleArguments[1]));
t.setMonthDay((n >= 3) ? JSC::toInt32(doubleArguments[2]) : 1);
t.setHour(JSC::toInt32(doubleArguments[3]));
t.setMinute(JSC::toInt32(doubleArguments[4]));
t.setSecond(JSC::toInt32(doubleArguments[5]));
double ms = (n >= 7) ? doubleArguments[6] : 0;
return JSValue::encode(jsNumber(timeClip(gregorianDateTimeToMS(exec, t, ms, true))));
}
......
......@@ -58,38 +58,38 @@ namespace JSC {
void formatDate(const GregorianDateTime &t, DateConversionBuffer& buffer)
{
snprintf(buffer, DateConversionBufferSize, "%s %s %02d %04d",
weekdayName[(t.weekDay + 6) % 7],
monthName[t.month], t.monthDay, t.year + 1900);
weekdayName[(t.weekDay() + 6) % 7],
monthName[t.month()], t.monthDay(), t.year() + 1900);
}
void formatDateUTCVariant(const GregorianDateTime &t, DateConversionBuffer& buffer)
{
snprintf(buffer, DateConversionBufferSize, "%s, %02d %s %04d",
weekdayName[(t.weekDay + 6) % 7],
t.monthDay, monthName[t.month], t.year + 1900);
weekdayName[(t.weekDay() + 6) % 7],
t.monthDay(), monthName[t.month()], t.year() + 1900);
}
void formatTime(const GregorianDateTime &t, DateConversionBuffer& buffer)
{
int offset = abs(gmtoffset(t));
int offset = abs(t.utcOffset());
char timeZoneName[70];
struct tm gtm = t;
strftime(timeZoneName, sizeof(timeZoneName), "%Z", &gtm);
if (timeZoneName[0]) {
snprintf(buffer, DateConversionBufferSize, "%02d:%02d:%02d GMT%c%02d%02d (%s)",
t.hour, t.minute, t.second,
gmtoffset(t) < 0 ? '-' : '+', offset / (60*60), (offset / 60) % 60, timeZoneName);
t.hour(), t.minute(), t.second(),
t.utcOffset() < 0 ? '-' : '+', offset / (60*60), (offset / 60) % 60, timeZoneName);
} else {
snprintf(buffer, DateConversionBufferSize, "%02d:%02d:%02d GMT%c%02d%02d",
t.hour, t.minute, t.second,
gmtoffset(t) < 0 ? '-' : '+', offset / (60*60), (offset / 60) % 60);
t.hour(), t.minute(), t.second(),
t.utcOffset() < 0 ? '-' : '+', offset / (60*60), (offset / 60) % 60);
}
}
void formatTimeUTC(const GregorianDateTime &t, DateConversionBuffer& buffer)
{
snprintf(buffer, DateConversionBufferSize, "%02d:%02d:%02d GMT", t.hour, t.minute, t.second);
snprintf(buffer, DateConversionBufferSize, "%02d:%02d:%02d GMT", t.hour(), t.minute(), t.second());
}
} // namespace JSC
......@@ -42,10 +42,11 @@
#ifndef DateConversion_h
#define DateConversion_h
#include <wtf/GregorianDateTime.h>
namespace JSC {
class ExecState;
struct GregorianDateTime;
static const unsigned DateConversionBufferSize = 100;
typedef char DateConversionBuffer[DateConversionBufferSize];
......
......@@ -23,10 +23,6 @@
#include "JSWrapperObject.h"
namespace WTF {
struct GregorianDateTime;
}
namespace JSC {
class DateInstance : public JSWrapperObject {
......
......@@ -203,8 +203,8 @@ double getUTCOffset(ExecState* exec)
double gregorianDateTimeToMS(ExecState* exec, const GregorianDateTime& t, double milliSeconds, bool inputIsUTC)
{
double day = dateToDaysFrom1970(t.year + 1900, t.month, t.monthDay);
double ms = timeToMS(t.hour, t.minute, t.second, milliSeconds);
double day = dateToDaysFrom1970(t.year() + 1900, t.month(), t.monthDay());
double ms = timeToMS(t.hour(), t.minute(), t.second(), milliSeconds);
double result = (day * WTF::msPerDay) + ms;
if (!inputIsUTC) { // convert to UTC
......@@ -228,17 +228,16 @@ void msToGregorianDateTime(ExecState* exec, double ms, bool outputIsUTC, Gregori
}
const int year = msToYear(ms);
tm.second = msToSeconds(ms);
tm.minute = msToMinutes(ms);
tm.hour = msToHours(ms);
tm.weekDay = msToWeekDay(ms);
tm.yearDay = dayInYear(ms, year);
tm.monthDay = dayInMonthFromDayInYear(tm.yearDay, isLeapYear(year));
tm.month = monthFromDayInYear(tm.yearDay, isLeapYear(year));
tm.year = year - 1900;
tm.isDST = dstOff != 0.0;
tm.utcOffset = static_cast<long>((dstOff + utcOff) / WTF::msPerSecond);
tm.timeZone = nullptr;
tm.setSecond(msToSeconds(ms));
tm.setMinute(msToMinutes(ms));
tm.setHour(msToHours(ms));
tm.setWeekDay(msToWeekDay(ms));
tm.setYearDay(dayInYear(ms, year));
tm.setMonthDay(dayInMonthFromDayInYear(tm.yearDay(), isLeapYear(year)));
tm.setMonth(monthFromDayInYear(tm.yearDay(), isLeapYear(year)));
tm.setYear(year - 1900);
tm.setIsDST(dstOff != 0.0);
tm.setUtcOffset(static_cast<long>((dstOff + utcOff) / WTF::msPerSecond));
}
double parseDateFromNullTerminatedCharacters(ExecState* exec, const char* dateString)
......
......@@ -44,12 +44,12 @@
#define JSDateMath_h
#include <wtf/DateMath.h>
#include <wtf/GregorianDateTime.h>
namespace JSC {
class ExecState;
class UString;
struct GregorianDateTime;
void msToGregorianDateTime(ExecState*, double, bool outputIsUTC, GregorianDateTime&);
double gregorianDateTimeToMS(ExecState*, const GregorianDateTime&, double, bool inputIsUTC);
......@@ -57,88 +57,6 @@ double getUTCOffset(ExecState*);
double parseDateFromNullTerminatedCharacters(ExecState*, const char* dateString);
double parseDate(ExecState*, const UString&);
// Intentionally overridding the default tm of the system.
// The members of tm differ on various operating systems.
struct GregorianDateTime {
WTF_MAKE_NONCOPYABLE(GregorianDateTime);
public:
GregorianDateTime()
: second(0)
, minute(0)
, hour(0)
, weekDay(0)
, monthDay(0)
, yearDay(0)
, month(0)
, year(0)
, isDST(0)
, utcOffset(0)
{
}
operator tm() const
{
tm ret;
memset(&ret, 0, sizeof(ret));
ret.tm_sec = second;
ret.tm_min = minute;
ret.tm_hour = hour;
ret.tm_wday = weekDay;
ret.tm_mday = monthDay;
ret.tm_yday = yearDay;
ret.tm_mon = month;
ret.tm_year = year;
ret.tm_isdst = isDST;
#if HAVE(TM_GMTOFF)
ret.tm_gmtoff = static_cast<long>(utcOffset);
#endif
#if HAVE(TM_ZONE)
ret.tm_zone = timeZone.get();
#endif
return ret;
}
void copyFrom(const GregorianDateTime& rhs)
{
second = rhs.second;
minute = rhs.minute;
hour = rhs.hour;
weekDay = rhs.weekDay;
monthDay = rhs.monthDay;
yearDay = rhs.yearDay;
month = rhs.month;
year = rhs.year;
isDST = rhs.isDST;
utcOffset = rhs.utcOffset;
if (rhs.timeZone) {
int inZoneSize = strlen(rhs.timeZone.get()) + 1;
timeZone = adoptArrayPtr(new char[inZoneSize]);
strncpy(timeZone.get(), rhs.timeZone.get(), inZoneSize);
} else
timeZone = nullptr;
}
int second;
int minute;
int hour;
int weekDay;
int monthDay;
int yearDay;
int month;
int year;
int isDST;
int utcOffset;
OwnArrayPtr<char> timeZone;
};
static inline int gmtoffset(const GregorianDateTime& t)
{
return t.utcOffset;
}
} // namespace JSC
#endif // JSDateMath_h
2012-07-23 Patrick Gansterer <paroga@webkit.org>
Move GregorianDateTime from JSC to WTF namespace
https://bugs.webkit.org/show_bug.cgi?id=91948
Reviewed by Geoffrey Garen.
Moving GregorianDateTime into the WTF namespace allows us to us to
use it in WebCore too. The new class has the same behaviour as the
old struct. Only the unused timeZone member has been removed.
* GNUmakefile.list.am:
* WTF.gypi:
* WTF.pro:
* WTF.vcproj/WTF.vcproj:
* WTF.xcodeproj/project.pbxproj:
* wtf/CMakeLists.txt:
* wtf/GregorianDateTime.h: Added.
(GregorianDateTime):
2012-07-23 Rob Buis <rbuis@rim.com>
[BlackBerry] Merge createThreadInternal implementations
......
......@@ -52,6 +52,7 @@ wtf_sources += \
Source/WTF/wtf/Forward.h \
Source/WTF/wtf/Functional.h \
Source/WTF/wtf/GetPtr.h \
Source/WTF/wtf/GregorianDateTime.h \
Source/WTF/wtf/HashCountedSet.h \
Source/WTF/wtf/HashFunctions.h \
Source/WTF/wtf/HashIterators.h \
......
......@@ -34,6 +34,7 @@
'wtf/Forward.h',
'wtf/Functional.h',
'wtf/GetPtr.h',
'wtf/GregorianDateTime.h',
'wtf/HashCountedSet.h',
'wtf/HashFunctions.h',
'wtf/HashIterators.h',
......
......@@ -61,6 +61,7 @@ HEADERS += \
Forward.h \
Functional.h \
GetPtr.h \
GregorianDateTime.h \
HashCountedSet.h \
HashFunctions.h \
HashIterators.h \
......
......@@ -796,6 +796,10 @@
RelativePath="..\wtf\GetPtr.h"
>
</File>
<File
RelativePath="..\wtf\GregorianDateTime.h"
>
</File>
<File
RelativePath="..\wtf\HashCountedSet.h"
>
......
This diff is collapsed.
......@@ -28,6 +28,7 @@ SET(WTF_HEADERS
FixedArray.h
Forward.h
GetPtr.h
GregorianDateTime.h
HashCountedSet.h
HashFunctions.h
HashIterators.h
......
/*
* Copyright (C) 2012 Patrick Gansterer <paroga@paroga.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef WTF_GregorianDateTime_h
#define WTF_GregorianDateTime_h
#include <wtf/text/CString.h>
namespace WTF {
class GregorianDateTime {
WTF_MAKE_NONCOPYABLE(GregorianDateTime);
public:
GregorianDateTime()
: m_year(0)
, m_month(0)
, m_yearDay(0)
, m_monthDay(0)
, m_weekDay(0)
, m_hour(0)
, m_minute(0)
, m_second(0)
, m_utcOffset(0)
, m_isDST(0)
{
}
inline int year() const { return m_year; }
inline int month() const { return m_month; }
inline int yearDay() const { return m_yearDay; }
inline int monthDay() const { return m_monthDay; }
inline int weekDay() const { return m_weekDay; }
inline int hour() const { return m_hour; }
inline int minute() const { return m_minute; }
inline int second() const { return m_second; }
inline int utcOffset() const { return m_utcOffset; }
inline int isDST() const { return m_isDST; }
inline void setYear(int year) { m_year = year; }
inline void setMonth(int month) { m_month = month; }
inline void setYearDay(int yearDay) { m_yearDay = yearDay; }
inline void setMonthDay(int monthDay) { m_monthDay = monthDay; }
inline void setWeekDay(int weekDay) { m_weekDay = weekDay; }
inline void setHour(int hour) { m_hour = hour; }
inline void setMinute(int minute) { m_minute = minute; }
inline void setSecond(int second) { m_second = second; }
inline void setUtcOffset(int utcOffset) { m_utcOffset = utcOffset; }
inline void setIsDST(int isDST) { m_isDST = isDST; }
operator tm() const
{
tm ret;
memset(&ret, 0, sizeof(ret));
ret.tm_year = m_year;
ret.tm_mon = m_month;
ret.tm_yday = m_yearDay;
ret.tm_mday = m_monthDay;
ret.tm_wday = m_weekDay;
ret.tm_hour = m_hour;
ret.tm_min = m_minute;
ret.tm_sec = m_second;
ret.tm_isdst = m_isDST;
#if HAVE(TM_GMTOFF)
ret.tm_gmtoff = static_cast<long>(m_utcOffset);
#endif
return ret;
}
void copyFrom(const GregorianDateTime& other)
{
m_year = other.m_year;
m_month = other.m_month;
m_yearDay = other.m_yearDay;
m_monthDay = other.m_monthDay;
m_weekDay = other.m_weekDay;
m_hour = other.m_hour;
m_minute = other.m_minute;
m_second = other.m_second;
m_utcOffset = other.m_utcOffset;
m_isDST = other.m_isDST;
}
private:
int m_year;
int m_month;
int m_yearDay;
int m_monthDay;
int m_weekDay;
int m_hour;
int m_minute;
int m_second;
int m_utcOffset;
int m_isDST;
};
} // namespace WTF
using WTF::GregorianDateTime;
#endif // WTF_GregorianDateTime_h
2012-07-23 Patrick Gansterer <paroga@webkit.org>
Move GregorianDateTime from JSC to WTF namespace
https://bugs.webkit.org/show_bug.cgi?id=91948
Reviewed by Geoffrey Garen.
Moving GregorianDateTime into the WTF namespace allows us to us to
use it in WebCore too. The new class has the same behaviour as the
old struct. Only the unused timeZone member has been removed.
* bridge/qt/qt_runtime.cpp:
(JSC::Bindings::convertValueToQVariant):
(JSC::Bindings::convertQVariantToValue):
* bridge/qt/qt_runtime_qt4.cpp:
(JSC::Bindings::convertValueToQVariant):
(JSC::Bindings::convertQVariantToValue):
2012-07-23 Mark Pilgrim <pilgrim@chromium.org>
[Chromium] Move layoutTestMode to WebCore
......@@ -504,13 +504,13 @@ QVariant convertValueToQVariant(ExecState* exec, JSValue value, QMetaType::Type
GregorianDateTime gdt;
msToGregorianDateTime(exec, date->internalNumber(), true, gdt);
if (hint == QMetaType::QDateTime) {
ret = QDateTime(QDate(gdt.year + 1900, gdt.month + 1, gdt.monthDay), QTime(gdt.hour, gdt.minute, gdt.second), Qt::UTC);
ret = QDateTime(QDate(gdt.year() + 1900, gdt.month() + 1, gdt.monthDay()), QTime(gdt.hour(), gdt.minute(), gdt.second()), Qt::UTC);
dist = 0;
} else if (hint == QMetaType::QDate) {
ret = QDate(gdt.year + 1900, gdt.month + 1, gdt.monthDay);
ret = QDate(gdt.year() + 1900, gdt.month() + 1, gdt.monthDay());
dist = 1;
} else {
ret = QTime(gdt.hour + 1900, gdt.minute, gdt.second);
ret = QTime(gdt.hour() + 1900, gdt.minute(), gdt.second());
dist = 2;
}
} else if (type == Number) {
......@@ -518,13 +518,13 @@ QVariant convertValueToQVariant(ExecState* exec, JSValue value, QMetaType::Type
GregorianDateTime gdt;
msToGregorianDateTime(exec, b, true, gdt);
if (hint == QMetaType::QDateTime) {
ret = QDateTime(QDate(gdt.year + 1900, gdt.month + 1, gdt.monthDay), QTime(gdt.hour, gdt.minute, gdt.second), Qt::UTC);
ret = QDateTime(QDate(gdt.year() + 1900, gdt.month() + 1, gdt.monthDay()), QTime(gdt.hour(), gdt.minute(), gdt.second()), Qt::UTC);
dist = 6;
} else if (hint == QMetaType::QDate) {
ret = QDate(gdt.year + 1900, gdt.month + 1, gdt.monthDay);
ret = QDate(gdt.year() + 1900, gdt.month() + 1, gdt.monthDay());
dist = 8;
} else {
ret = QTime(gdt.hour, gdt.minute, gdt.second);
ret = QTime(gdt.hour(), gdt.minute(), gdt.second());
dist = 10;
}
#ifndef QT_NO_DATESTRING
......@@ -874,13 +874,13 @@ JSValue convertQVariantToValue(ExecState* exec, PassRefPtr<RootObject> root, con
// Dates specified this way are in local time (we convert DateTimes above)
GregorianDateTime dt;
dt.year = date.year() - 1900;
dt.month = date.month() - 1;
dt.monthDay = date.day();
dt.hour = time.hour();
dt.minute = time.minute();
dt.second = time.second();
dt.isDST = -1;
dt.setYear(date.year() - 1900);
dt.setMonth(date.month() - 1);
dt.setMonthDay(date.day());
dt.setHour(time.hour());
dt.setMinute(time.minute());
dt.setSecond(time.second());
dt.setIsDST(-1);
double ms = gregorianDateTimeToMS(exec, dt, time.msec(), /*inputIsUTC*/ false);
return DateInstance::create(exec, exec->lexicalGlobalObject()->dateStructure(), trunc(ms));
......
......@@ -504,13 +504,13 @@ QVariant convertValueToQVariant(ExecState* exec, JSValue value, QMetaType::Type
GregorianDateTime gdt;
msToGregorianDateTime(exec, date->internalNumber(), true, gdt);
if (hint == QMetaType::QDateTime) {
ret = QDateTime(QDate(gdt.year + 1900, gdt.month + 1, gdt.monthDay), QTime(gdt.hour, gdt.minute, gdt.second), Qt::UTC);
ret = QDateTime(QDate(gdt.year() + 1900, gdt.month() + 1, gdt.monthDay()), QTime(gdt.hour(), gdt.minute(), gdt.second()), Qt::UTC);
dist = 0;
} else if (hint == QMetaType::QDate) {
ret = QDate(gdt.year + 1900, gdt.month + 1, gdt.monthDay);
ret = QDate(gdt.year() + 1900, gdt.month() + 1, gdt.monthDay());
dist = 1;
} else {
ret = QTime(gdt.hour + 1900, gdt.minute, gdt.second);
ret = QTime(gdt.hour() + 1900, gdt.minute(), gdt.second());
dist = 2;
}
} else if (type == Number) {
......@@ -518,13 +518,13 @@ QVariant convertValueToQVariant(ExecState* exec, JSValue value, QMetaType::Type
GregorianDateTime gdt;
msToGregorianDateTime(exec, b, true, gdt);
if (hint == QMetaType::QDateTime) {
ret = QDateTime(QDate(gdt.year + 1900, gdt.month + 1, gdt.monthDay), QTime(gdt.hour, gdt.minute, gdt.second), Qt::UTC);
ret = QDateTime(QDate(gdt.year() + 1900, gdt.month() + 1, gdt.monthDay()), QTime(gdt.hour(), gdt.minute(), gdt.second()), Qt::UTC);
dist = 6;
} else if (hint == QMetaType::QDate) {
ret = QDate(gdt.year + 1900, gdt.month + 1, gdt.monthDay);
ret = QDate(gdt.year() + 1900, gdt.month() + 1, gdt.monthDay());
dist = 8;
} else {
ret = QTime(gdt.hour, gdt.minute, gdt.second);
ret = QTime(gdt.hour(), gdt.minute(), gdt.second());
dist = 10;
}
#ifndef QT_NO_DATESTRING
......@@ -874,13 +874,13 @@ JSValue convertQVariantToValue(ExecState* exec, PassRefPtr<RootObject> root, con
// Dates specified this way are in local time (we convert DateTimes above)
GregorianDateTime dt;
dt.year = date.year() - 1900;
dt.month = date.month() - 1;
dt.monthDay = date.day();
dt.hour = time.hour();
dt.minute = time.minute();
dt.second = time.second();
dt.isDST = -1;
dt.setYear(date.year() - 1900);
dt.setMonth(date.month() - 1);
dt.setMonthDay(date.day());
dt.setHour(time.hour());
dt.setMinute(time.minute());
dt.setSecond(time.second());
dt.setIsDST(-1);
double ms = gregorianDateTimeToMS(exec, dt, time.msec(), /*inputIsUTC*/ false);
return DateInstance::create(exec, exec->lexicalGlobalObject()->dateStructure(), trunc(ms));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment