@@ -2,6 +2,7 @@ package goja
import (
"math"
+ "reflect"
"time"
)
@@ -135,6 +136,10 @@ func (d *dateObject) toPrimitive() Value {
return d.toPrimitiveString()
}
+func (d *dateObject) exportType() reflect.Type {
+ return typeTime
+}
+
func (d *dateObject) export(*objectExportCtx) interface{} {
if d.isSet() {
return d.time()
@@ -421,3 +421,14 @@ func TestDateToJSON(t *testing.T) {
`
testScript1(SCRIPT, intToValue(1), t)
+func TestDateExportType(t *testing.T) {
+ vm := New()
+ v, err := vm.RunString(`new Date()`)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if typ := v.ExportType(); typ != typeTime {
+ t.Fatal(typ)