Ignore:
Timestamp:
May 13, 2008, 5:38:21 PM (17 years ago)
Author:
[email protected]
Message:

2008-05-13 Anders Carlsson <[email protected]>

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):
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/date_object.cpp

    r33038 r33422  
    8989    virtual JSValue *callAsFunction(ExecState *, JSObject *thisObj, const List &args);
    9090
    91     enum { Parse, UTC };
     91    enum { Parse, UTC, Now };
    9292
    9393private:
     
    492492  putDirectFunction(new DateObjectFuncImp(exec, funcProto, DateObjectFuncImp::Parse, 1, exec->propertyNames().parse), DontEnum);
    493493  putDirectFunction(new DateObjectFuncImp(exec, funcProto, DateObjectFuncImp::UTC, 7, exec->propertyNames().UTC), DontEnum);
     494  putDirectFunction(new DateObjectFuncImp(exec, funcProto, DateObjectFuncImp::Now, 0, exec->propertyNames().now), DontEnum);
    494495  putDirect(exec->propertyNames().length, 7, ReadOnly|DontDelete|DontEnum);
    495496}
     
    569570JSValue *DateObjectFuncImp::callAsFunction(ExecState* exec, JSObject*, const List& args)
    570571{
    571   if (id == Parse) {
     572  if (id == Parse)
    572573    return jsNumber(parseDate(args[0]->toString(exec)));
    573   }
    574   else { // UTC
     574  else if (id == Now)
     575    return jsNumber(getCurrentUTCTime());
     576  } else { // UTC
    575577    int n = args.size();
    576578    if (isnan(args[0]->toNumber(exec))
Note: See TracChangeset for help on using the changeset viewer.