本文整理汇总了C++中JSGlobalObject::dateStructure方法的典型用法代码示例。如果您正苦于以下问题:C++ JSGlobalObject::dateStructure方法的具体用法?C++ JSGlobalObject::dateStructure怎么用?C++ JSGlobalObject::dateStructure使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSGlobalObject
的用法示例。
在下文中一共展示了JSGlobalObject::dateStructure方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IntlDateTimeFormatFuncFormatDateTime
EncodedJSValue JSC_HOST_CALL IntlDateTimeFormatFuncFormatDateTime(ExecState* state)
{
// 12.3.4 DateTime Format Functions (ECMA-402 2.0)
// 1. Let dtf be the this value.
IntlDateTimeFormat* format = jsDynamicCast<IntlDateTimeFormat*>(state->thisValue());
// 2. Assert: Type(dtf) is Object and dtf has an [[initializedDateTimeFormat]] internal slot whose value is true.
if (!format)
return JSValue::encode(throwTypeError(state));
JSValue date = state->argument(0);
double value;
// 3. If date is not provided or is undefined, then
if (date.isUndefined()) {
// a. Let x be %Date_now%().
value = JSValue::decode(dateNow(state)).toNumber(state);
} else {
// 4. Else
// a. Let x be ToNumber(date).
value = date.toNumber(state);
// b. ReturnIfAbrupt(x).
if (state->hadException())
return JSValue::encode(jsUndefined());
}
// 5. Return FormatDateTime(dtf, x).
// 12.3.4 FormatDateTime abstract operation (ECMA-402 2.0)
// 1. If x is not a finite Number, then throw a RangeError exception.
if (!std::isfinite(value))
return JSValue::encode(throwRangeError(state, ASCIILiteral("date value is not finite in DateTimeFormat.format()")));
// FIXME: implement 2 - 9
// Return new Date(value).toString() until properly implemented.
VM& vm = state->vm();
JSGlobalObject* globalObject = state->callee()->globalObject();
DateInstance* d = DateInstance::create(vm, globalObject->dateStructure(), value);
return JSValue::encode(JSValue(d).toString(state));
}