Commit 6bdff067 authored by andersca@apple.com's avatar andersca@apple.com

2008-05-13 Anders Carlsson <andersca@apple.com>

        Reviewed by Sam.

        <rdar://problem/5933644> Implement Date.now
        
        Implement Date.now which returns the number of milliseconds since the epoch.
        
        * kjs/CommonIdentifiers.h:
        * kjs/date_object.cpp:
        (KJS::DateObjectFuncImp::):
        (KJS::DateObjectImp::DateObjectImp):
        (KJS::DateObjectFuncImp::callAsFunction):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@33422 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 8a814004
2008-05-13 Anders Carlsson <andersca@apple.com>
Reviewed by Sam.
<rdar://problem/5933644> Implement Date.now
Implement Date.now which returns the number of milliseconds since the epoch.
* kjs/CommonIdentifiers.h:
* kjs/date_object.cpp:
(KJS::DateObjectFuncImp::):
(KJS::DateObjectImp::DateObjectImp):
(KJS::DateObjectFuncImp::callAsFunction):
2008-05-13 Kevin McCullough <kmccullough@apple.com>
Giving credit where credit is due.
......
......@@ -55,6 +55,7 @@ namespace WTF {
macro(message) \
macro(multiline) \
macro(name) \
macro(now) \
macro(parse) \
macro(propertyIsEnumerable) \
macro(prototype) \
......
......@@ -88,7 +88,7 @@ public:
virtual JSValue *callAsFunction(ExecState *, JSObject *thisObj, const List &args);
enum { Parse, UTC };
enum { Parse, UTC, Now };
private:
int id;
......@@ -491,6 +491,7 @@ DateObjectImp::DateObjectImp(ExecState* exec, FunctionPrototype* funcProto, Date
putDirect(exec->propertyNames().prototype, dateProto, DontEnum|DontDelete|ReadOnly);
putDirectFunction(new DateObjectFuncImp(exec, funcProto, DateObjectFuncImp::Parse, 1, exec->propertyNames().parse), DontEnum);
putDirectFunction(new DateObjectFuncImp(exec, funcProto, DateObjectFuncImp::UTC, 7, exec->propertyNames().UTC), DontEnum);
putDirectFunction(new DateObjectFuncImp(exec, funcProto, DateObjectFuncImp::Now, 0, exec->propertyNames().now), DontEnum);
putDirect(exec->propertyNames().length, 7, ReadOnly|DontDelete|DontEnum);
}
......@@ -568,10 +569,11 @@ DateObjectFuncImp::DateObjectFuncImp(ExecState* exec, FunctionPrototype* funcPro
// ECMA 15.9.4.2 - 3
JSValue *DateObjectFuncImp::callAsFunction(ExecState* exec, JSObject*, const List& args)
{
if (id == Parse) {
if (id == Parse)
return jsNumber(parseDate(args[0]->toString(exec)));
}
else { // UTC
else if (id == Now)
return jsNumber(getCurrentUTCTime());
} else { // UTC
int n = args.size();
if (isnan(args[0]->toNumber(exec))
|| isnan(args[1]->toNumber(exec))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment