possible fix for created to/from string

This commit is contained in:
SamGondelman 2019-01-07 11:10:36 -08:00
parent b5b7574c48
commit d57e3b57aa
2 changed files with 10 additions and 12 deletions

View file

@ -339,6 +339,12 @@ void EntityItemProperties::setBillboardModeFromString(const QString& materialMap
}
}
QString EntityItemProperties::getCreatedAsString() const {
auto created = QDateTime::fromMSecsSinceEpoch(getCreated() / 1000.0f, Qt::UTC); // usec per msec
created.setTimeSpec(Qt::OffsetFromUTC);
return created.toString(Qt::ISODate);
}
EntityPropertyFlags EntityItemProperties::getChangedProperties() const {
EntityPropertyFlags changedProperties;
@ -1391,13 +1397,7 @@ QScriptValue EntityItemProperties::copyToScriptValue(QScriptEngine* engine, bool
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_DIMENSIONS, dimensions);
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_ROTATION, rotation);
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_REGISTRATION_POINT, registrationPoint);
{
COPY_PROPERTY_TO_QSCRIPTVALUE_GETTER(PROP_CREATED, created, [this]() {
auto created = QDateTime::fromMSecsSinceEpoch(getCreated() / 1000.0f, Qt::UTC); // usec per msec
created.setTimeSpec(Qt::OffsetFromUTC);
return created.toString(Qt::ISODate);
}());
}
COPY_PROPERTY_TO_QSCRIPTVALUE_GETTER(PROP_CREATED, created, getCreatedAsString());
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_LAST_EDITED_BY, lastEditedBy);
COPY_PROPERTY_TO_QSCRIPTVALUE_GETTER(PROP_ENTITY_HOST_TYPE, entityHostType, getEntityHostTypeAsString());
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_OWNING_AVATAR_ID, owningAvatarID);
@ -1775,10 +1775,7 @@ void EntityItemProperties::copyFromScriptValue(const QScriptValue& object, bool
COPY_PROPERTY_FROM_QSCRIPTVALUE(rotation, quat, setRotation);
COPY_PROPERTY_FROM_QSCRIPTVALUE(registrationPoint, vec3, setRegistrationPoint);
if (!honorReadOnly) {
COPY_PROPERTY_FROM_QSCRIPTVALUE_GETTER(created, QDateTime, setCreated, [this]() {
auto result = QDateTime::fromMSecsSinceEpoch(_created / 1000, Qt::UTC); // usec per msec
return result;
});
COPY_PROPERTY_FROM_QSCRIPTVALUE_GETTER(created, QString, setCreatedFromString, getCreatedAsString);
COPY_PROPERTY_FROM_QSCRIPTVALUE(lastEditedBy, QUuid, setLastEditedBy);
COPY_PROPERTY_FROM_QSCRIPTVALUE_ENUM(entityHostType, EntityHostType);
COPY_PROPERTY_FROM_QSCRIPTVALUE(owningAvatarID, QUuid, setOwningAvatarID);

View file

@ -381,7 +381,8 @@ public:
void setLocationDirty() { _positionChanged = true; _rotationChanged = true; }
void setCreated(QDateTime& v) { _created = v.toMSecsSinceEpoch() * 1000; }
void setCreatedFromString(QString& v) { _created = QDateTime::fromString(v, Qt::ISODate).toMSecsSinceEpoch() * 1000; }
QString getCreatedAsString() const;
bool hasTransformOrVelocityChanges() const;
void clearTransformOrVelocityChanges();