mirror of
https://github.com/robertkrimen/otto
synced 2025-10-12 20:27:30 +08:00
Date() => string (Not an object)
This commit is contained in:
parent
345c4705f9
commit
7624bc44fe
|
@ -7,6 +7,12 @@ import (
|
|||
// Date
|
||||
|
||||
func builtinDate(call FunctionCall) Value {
|
||||
if len(call.ArgumentList) == 0 {
|
||||
// Should make this prettier
|
||||
date := &_dateObject{}
|
||||
date.Set(newDateTime([]Value{}))
|
||||
return toValue(date.Time().Format(time_.RFC1123))
|
||||
}
|
||||
return toValue(call.runtime.newDate(newDateTime(call.ArgumentList)))
|
||||
}
|
||||
|
||||
|
|
|
@ -89,6 +89,9 @@ func TestDate(t *testing.T) {
|
|||
test(`abc = new Date(12564504e5); abc.setFullYear(2010); abc.toUTCString()`, time.Format(format))
|
||||
|
||||
test(`new Date("2001-01-01T10:01:02.000").getTime()`, "978343262000")
|
||||
|
||||
// Date()
|
||||
test(`typeof Date()`, "string")
|
||||
}
|
||||
|
||||
func TestDate_parse(t *testing.T) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user