mirror of
https://github.com/robertkrimen/otto.git
synced 2025-12-24 12:58:05 +08:00
@@ -100,8 +100,10 @@ func builtinDate_getTime(call FunctionCall) Value {
|
||||
}
|
||||
|
||||
func builtinDate_setTime(call FunctionCall) Value {
|
||||
date := dateObjectOf(call.thisObject())
|
||||
object := call.thisObject()
|
||||
date := dateObjectOf(object)
|
||||
date.Set(toFloat(call.Argument(0)))
|
||||
object.value = date
|
||||
return date.Value()
|
||||
}
|
||||
|
||||
|
||||
17
date_test.go
17
date_test.go
@@ -421,3 +421,20 @@ func TestDate_setFullYear(t *testing.T) {
|
||||
test(`Date.prototype.setFullYear.length`, "3")
|
||||
test(`Date.prototype.setUTCFullYear.length`, "3")
|
||||
}
|
||||
|
||||
func TestDate_setTime(t *testing.T) {
|
||||
Terst(t)
|
||||
|
||||
defer mockTimeLocal(Time.UTC)()
|
||||
|
||||
test := runTest()
|
||||
|
||||
test(`
|
||||
var abc = new Date(1999, 6, 1);
|
||||
var def = new Date();
|
||||
def.setTime(abc.getTime());
|
||||
[ def, abc.valueOf() == def.valueOf() ];
|
||||
`, "Thu, 01 Jul 1999 00:00:00 UTC,true")
|
||||
|
||||
test(`Date.prototype.setTime.length`, "1")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user