Skip to content

Issues with parsing Go time.Time fields #549

@leonore

Description

@leonore

The package seems to suggest it supports go time.Time objects and parsing them into Javascript dates, however with a minimal working example this doesn't seem to work:

	vm := otto.New()

	vm.Set("subject", time.Date(2024, 1, 15, 10, 30, 45, 0, time.UTC))
	value, err := vm.Run(`
	console.log("The value of subject is " + typeof(subject));
	console.log("The subject is " + subject.toISOString());
	subject;
	`)
	if err != nil {
		return err
	}
	spew.Dump(value)

outputs:

The value of subject is object
TypeError: "toISOString" is not a function

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions