Back to index

lightning-sunbird  0.9+nobinonly
Defines | Typedefs | Enumerations | Functions | Variables
jsdate.c File Reference
#include "jsstddef.h"
#include <ctype.h>
#include <locale.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include "jstypes.h"
#include "jsprf.h"
#include "prmjtime.h"
#include "jsutil.h"
#include "jsapi.h"
#include "jsconfig.h"
#include "jscntxt.h"
#include "jsdate.h"
#include "jsinterp.h"
#include "jsnum.h"
#include "jsobj.h"
#include "jsstr.h"
#include "jsdtoa.h"

Go to the source code of this file.

Defines

#define HalfTimeDomain   8.64e15
#define HoursPerDay   24.0
#define MinutesPerDay   (HoursPerDay * MinutesPerHour)
#define MinutesPerHour   60.0
#define SecondsPerDay   (MinutesPerDay * SecondsPerMinute)
#define SecondsPerHour   (MinutesPerHour * SecondsPerMinute)
#define SecondsPerMinute   60.0
#define msPerDay   (SecondsPerDay * msPerSecond)
#define msPerHour   (SecondsPerHour * msPerSecond)
#define msPerMinute   (SecondsPerMinute * msPerSecond)
#define msPerSecond   1000.0
#define Day(t)   floor((t) / msPerDay)
#define DaysInYear(y)
#define DayFromYear(y)
#define TimeFromYear(y)   (DayFromYear(y) * msPerDay)
#define InLeapYear(t)   (JSBool) (DaysInYear(YearFromTime(t)) == 366)
#define DayWithinYear(t, year)   ((intN) (Day(t) - DayFromYear(year)))
#define DayFromMonth(m, leap)   firstDayOfMonth[leap][(intN)m];
#define MakeTime(hour, min, sec, ms)   ((((hour) * MinutesPerHour + (min)) * SecondsPerMinute + (sec)) * msPerSecond + (ms))
#define MakeDate(day, time)   ((day) * msPerDay + (time))
#define AdjustTime(t)   fmod(LocalTZA + DaylightSavingTA(t), msPerDay)
#define LocalTime(t)   ((t) + AdjustTime(t))
#define TIMECLIP(d)
#define MAXARGS   7
#define CYCLE_YEARS   2800L

Typedefs

typedef enum formatspec formatspec

Enumerations

enum  formatspec { FORMATSPEC_FULL, FORMATSPEC_DATE, FORMATSPEC_TIME }

Functions

static jsdouble TimeWithinDay (jsdouble t)
static jsint YearFromTime (jsdouble t)
static intN MonthFromTime (jsdouble t)
static intN DateFromTime (jsdouble t)
static intN WeekDay (jsdouble t)
static jsdouble MakeDay (jsdouble year, jsdouble month, jsdouble date)
static jsint EquivalentYearForDST (jsint year)
static jsdouble DaylightSavingTA (jsdouble t)
static jsdouble UTC (jsdouble t)
static intN HourFromTime (jsdouble t)
static intN MinFromTime (jsdouble t)
static intN SecFromTime (jsdouble t)
static intN msFromTime (jsdouble t)
static JSBool date_regionMatches (const char *s1, int s1off, const jschar *s2, int s2off, int count, int ignoreCase)
static jsdouble date_msecFromDate (jsdouble year, jsdouble mon, jsdouble mday, jsdouble hour, jsdouble min, jsdouble sec, jsdouble msec)
static JSBool date_UTC (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool date_parseString (JSString *str, jsdouble *result)
static JSBool date_parse (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool date_now (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static jsdoubledate_getProlog (JSContext *cx, JSObject *obj, jsval *argv)
static JSBool date_getTime (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool date_getYear (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool date_getFullYear (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool date_getUTCFullYear (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool date_getMonth (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool date_getUTCMonth (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool date_getDate (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool date_getUTCDate (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool date_getDay (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool date_getUTCDay (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool date_getHours (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool date_getUTCHours (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool date_getMinutes (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool date_getUTCMinutes (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool date_getUTCSeconds (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool date_getUTCMilliseconds (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool date_getTimezoneOffset (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool date_setTime (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool date_makeTime (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, uintN maxargs, JSBool local, jsval *rval)
static JSBool date_setMilliseconds (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool date_setUTCMilliseconds (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool date_setSeconds (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool date_setUTCSeconds (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool date_setMinutes (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool date_setUTCMinutes (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool date_setHours (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool date_setUTCHours (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool date_makeDate (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, uintN maxargs, JSBool local, jsval *rval)
static JSBool date_setDate (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool date_setUTCDate (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool date_setMonth (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool date_setUTCMonth (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool date_setFullYear (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool date_setUTCFullYear (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool date_setYear (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool date_toGMTString (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static void new_explode (jsdouble timeval, PRMJTime *split, JSBool findEquivalent)
static JSBool date_format (JSContext *cx, jsdouble date, formatspec format, jsval *rval)
static JSBool date_toLocaleHelper (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval, char *format)
static JSBool date_toLocaleString (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool date_toLocaleDateString (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool date_toLocaleTimeString (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool date_toLocaleFormat (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool date_toTimeString (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool date_toDateString (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool date_toSource (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool date_toString (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool date_valueOf (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static jsdoubledate_constructor (JSContext *cx, JSObject *obj)
static JSBool Date (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
JSObjectjs_InitDateClass (JSContext *cx, JSObject *obj)
 js_NewDateObjectMsec (JSContext *cx, jsdouble msec_time)
 js_NewDateObject (JSContext *cx, int year, int mon, int mday, int hour, int min, int sec)
 js_DateIsValid (JSContext *cx, JSObject *obj)
 js_DateGetYear (JSContext *cx, JSObject *obj)
 js_DateGetMonth (JSContext *cx, JSObject *obj)
 js_DateGetDate (JSContext *cx, JSObject *obj)
 js_DateGetHours (JSContext *cx, JSObject *obj)
 js_DateGetMinutes (JSContext *cx, JSObject *obj)
 js_DateGetSeconds (JSContext *cx, JSObject *obj)
 js_DateSetYear (JSContext *cx, JSObject *obj, int year)
 js_DateSetMonth (JSContext *cx, JSObject *obj, int month)
 js_DateSetDate (JSContext *cx, JSObject *obj, int date)
 js_DateSetHours (JSContext *cx, JSObject *obj, int hours)
 js_DateSetMinutes (JSContext *cx, JSObject *obj, int minutes)
 js_DateSetSeconds (JSContext *cx, JSObject *obj, int seconds)
 js_DateGetMsecSinceEpoch (JSContext *cx, JSObject *obj)

Variables

static jsdouble firstDayOfMonth [2][12]
static jsint yearStartingWith [2][7]
static jsdouble LocalTZA
JSClass js_DateClass
 end of ECMA 'support' functions
static const char * wtb []
static int ttb []
static char js_NaN_date_str [] = "Invalid Date"
static const char * days []
static const char * months []
static JSFunctionSpec date_static_methods []
static JSFunctionSpec date_methods []

Define Documentation

Definition at line 418 of file jsdate.c.

#define CYCLE_YEARS   2800L
#define Day (   t)    floor((t) / msPerDay)

Definition at line 174 of file jsdate.c.

#define DayFromMonth (   m,
  leap 
)    firstDayOfMonth[leap][(intN)m];

Definition at line 224 of file jsdate.c.

Value:
(365 * ((y)-1970) + floor(((y)-1969)/4.0)            \
                         - floor(((y)-1901)/100.0) + floor(((y)-1601)/400.0))

Definition at line 192 of file jsdate.c.

Value:
((y) % 4 == 0 && ((y) % 100 || ((y) % 400 == 0))  \
                         ? 366 : 365)

Definition at line 186 of file jsdate.c.

#define DayWithinYear (   t,
  year 
)    ((intN) (Day(t) - DayFromYear(year)))

Definition at line 213 of file jsdate.c.

#define HalfTimeDomain   8.64e15

Definition at line 149 of file jsdate.c.

#define HoursPerDay   24.0

Definition at line 150 of file jsdate.c.

#define InLeapYear (   t)    (JSBool) (DaysInYear(YearFromTime(t)) == 366)

Definition at line 211 of file jsdate.c.

#define LocalTime (   t)    ((t) + AdjustTime(t))

Definition at line 420 of file jsdate.c.

#define MakeDate (   day,
  time 
)    ((day) * msPerDay + (time))

Definition at line 338 of file jsdate.c.

#define MakeTime (   hour,
  min,
  sec,
  ms 
)    ((((hour) * MinutesPerHour + (min)) * SecondsPerMinute + (sec)) * msPerSecond + (ms))

Definition at line 314 of file jsdate.c.

#define MAXARGS   7

Definition at line 560 of file jsdate.c.

Definition at line 151 of file jsdate.c.

#define MinutesPerHour   60.0

Definition at line 152 of file jsdate.c.

Definition at line 168 of file jsdate.c.

Definition at line 169 of file jsdate.c.

Definition at line 170 of file jsdate.c.

#define msPerSecond   1000.0

Definition at line 171 of file jsdate.c.

Definition at line 153 of file jsdate.c.

Definition at line 154 of file jsdate.c.

Definition at line 155 of file jsdate.c.

#define TIMECLIP (   d)
Value:
((JSDOUBLE_IS_FINITE(d) \
                      && !((d < 0 ? -d : d) > HalfTimeDomain)) \
                     ? js_DoubleToInteger(d + (+0.)) : *cx->runtime->jsNaN)

Definition at line 464 of file jsdate.c.

Definition at line 194 of file jsdate.c.


Typedef Documentation

typedef enum formatspec formatspec

Enumeration Type Documentation

enum formatspec
Enumerator:
FORMATSPEC_FULL 
FORMATSPEC_DATE 
FORMATSPEC_TIME 

Definition at line 1610 of file jsdate.c.


Function Documentation

static JSBool Date ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
) [static]

Definition at line 2007 of file jsdate.c.

{
    jsdouble *date;
    JSString *str;
    jsdouble d;

    /* Date called as function. */
    if (!(cx->fp->flags & JSFRAME_CONSTRUCTING)) {
        int64 us, ms, us2ms;
        jsdouble msec_time;

        /* NSPR 2.0 docs say 'We do not support PRMJ_NowMS and PRMJ_NowS',
         * so compute ms from PRMJ_Now.
         */
        us = PRMJ_Now();
        JSLL_UI2L(us2ms, PRMJ_USEC_PER_MSEC);
        JSLL_DIV(ms, us, us2ms);
        JSLL_L2D(msec_time, ms);

        return date_format(cx, msec_time, FORMATSPEC_FULL, rval);
    }

    /* Date called as constructor. */
    if (argc == 0) {
        int64 us, ms, us2ms;
        jsdouble msec_time;

        date = date_constructor(cx, obj);
        if (!date)
            return JS_FALSE;

        us = PRMJ_Now();
        JSLL_UI2L(us2ms, PRMJ_USEC_PER_MSEC);
        JSLL_DIV(ms, us, us2ms);
        JSLL_L2D(msec_time, ms);

        *date = msec_time;
    } else if (argc == 1) {
        if (!JSVAL_IS_STRING(argv[0])) {
            /* the argument is a millisecond number */
            if (!js_ValueToNumber(cx, argv[0], &d))
                return JS_FALSE;
            date = date_constructor(cx, obj);
            if (!date)
                return JS_FALSE;
            *date = TIMECLIP(d);
        } else {
            /* the argument is a string; parse it. */
            date = date_constructor(cx, obj);
            if (!date)
                return JS_FALSE;

            str = js_ValueToString(cx, argv[0]);
            if (!str)
                return JS_FALSE;

            if (!date_parseString(str, date))
                *date = *cx->runtime->jsNaN;
            *date = TIMECLIP(*date);
        }
    } else {
        jsdouble array[MAXARGS];
        uintN loop;
        jsdouble double_arg;
        jsdouble day;
        jsdouble msec_time;

        for (loop = 0; loop < MAXARGS; loop++) {
            if (loop < argc) {
                if (!js_ValueToNumber(cx, argv[loop], &double_arg))
                    return JS_FALSE;
                /* if any arg is NaN, make a NaN date object
                   and return */
                if (!JSDOUBLE_IS_FINITE(double_arg)) {
                    date = date_constructor(cx, obj);
                    if (!date)
                        return JS_FALSE;
                    *date = *cx->runtime->jsNaN;
                    return JS_TRUE;
                }
                array[loop] = js_DoubleToInteger(double_arg);
            } else {
                if (loop == 2) {
                    array[loop] = 1; /* Default the date argument to 1. */
                } else {
                    array[loop] = 0;
                }
            }
        }

        date = date_constructor(cx, obj);
        if (!date)
            return JS_FALSE;

        /* adjust 2-digit years into the 20th century */
        if (array[0] >= 0 && array[0] <= 99)
            array[0] += 1900;

        day = MakeDay(array[0], array[1], array[2]);
        msec_time = MakeTime(array[3], array[4], array[5], array[6]);
        msec_time = MakeDate(day, msec_time);
        msec_time = UTC(msec_time);
        *date = TIMECLIP(msec_time);
    }
    return JS_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static jsdouble* date_constructor ( JSContext cx,
JSObject obj 
) [static]

Definition at line 1995 of file jsdate.c.

{
    jsdouble *date;

    date = js_NewDouble(cx, 0.0, 0);
    if (!date)
        return NULL;
    OBJ_SET_SLOT(cx, obj, JSSLOT_PRIVATE, DOUBLE_TO_JSVAL(date));
    return date;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static JSBool date_format ( JSContext cx,
jsdouble  date,
formatspec  format,
jsval rval 
) [static]

Definition at line 1616 of file jsdate.c.

{
    char buf[100];
    JSString *str;
    char tzbuf[100];
    JSBool usetz;
    size_t i, tzlen;
    PRMJTime split;

    if (!JSDOUBLE_IS_FINITE(date)) {
        JS_snprintf(buf, sizeof buf, js_NaN_date_str);
    } else {
        jsdouble local = LocalTime(date);

        /* offset from GMT in minutes.  The offset includes daylight savings,
           if it applies. */
        jsint minutes = (jsint) floor(AdjustTime(date) / msPerMinute);

        /* map 510 minutes to 0830 hours */
        intN offset = (minutes / 60) * 100 + minutes % 60;

        /* print as "Wed Nov 05 19:38:03 GMT-0800 (PST) 1997" The TZA is
         * printed as 'GMT-0800' rather than as 'PST' to avoid
         * operating-system dependence on strftime (which
         * PRMJ_FormatTimeUSEnglish calls, for %Z only.)  win32 prints
         * PST as 'Pacific Standard Time.'  This way we always know
         * what we're getting, and can parse it if we produce it.
         * The OS TZA string is included as a comment.
         */

        /* get a timezone string from the OS to include as a
           comment. */
        new_explode(date, &split, JS_TRUE);
        if (PRMJ_FormatTime(tzbuf, sizeof tzbuf, "(%Z)", &split) != 0) {

            /* Decide whether to use the resulting timezone string.
             *
             * Reject it if it contains any non-ASCII, non-alphanumeric
             * characters.  It's then likely in some other character
             * encoding, and we probably won't display it correctly.
             */
            usetz = JS_TRUE;
            tzlen = strlen(tzbuf);
            if (tzlen > 100) {
                usetz = JS_FALSE;
            } else {
                for (i = 0; i < tzlen; i++) {
                    jschar c = tzbuf[i];
                    if (c > 127 ||
                        !(isalpha(c) || isdigit(c) ||
                          c == ' ' || c == '(' || c == ')')) {
                        usetz = JS_FALSE;
                    }
                }
            }

            /* Also reject it if it's not parenthesized or if it's '()'. */
            if (tzbuf[0] != '(' || tzbuf[1] == ')')
                usetz = JS_FALSE;
        } else
            usetz = JS_FALSE;

        switch (format) {
          case FORMATSPEC_FULL:
            /*
             * Avoid dependence on PRMJ_FormatTimeUSEnglish, because it
             * requires a PRMJTime... which only has 16-bit years.  Sub-ECMA.
             */
            /* Tue Oct 31 2000 09:41:40 GMT-0800 (PST) */
            JS_snprintf(buf, sizeof buf,
                        "%s %s %.2d %.4d %.2d:%.2d:%.2d GMT%+.4d%s%s",
                        days[WeekDay(local)],
                        months[MonthFromTime(local)],
                        DateFromTime(local),
                        YearFromTime(local),
                        HourFromTime(local),
                        MinFromTime(local),
                        SecFromTime(local),
                        offset,
                        usetz ? " " : "",
                        usetz ? tzbuf : "");
            break;
          case FORMATSPEC_DATE:
            /* Tue Oct 31 2000 */
            JS_snprintf(buf, sizeof buf,
                        "%s %s %.2d %.4d",
                        days[WeekDay(local)],
                        months[MonthFromTime(local)],
                        DateFromTime(local),
                        YearFromTime(local));
            break;
          case FORMATSPEC_TIME:
            /* 09:41:40 GMT-0800 (PST) */
            JS_snprintf(buf, sizeof buf,
                        "%.2d:%.2d:%.2d GMT%+.4d%s%s",
                        HourFromTime(local),
                        MinFromTime(local),
                        SecFromTime(local),
                        offset,
                        usetz ? " " : "",
                        usetz ? tzbuf : "");
            break;
        }
    }

    str = JS_NewStringCopyZ(cx, buf);
    if (!str)
        return JS_FALSE;
    *rval = STRING_TO_JSVAL(str);
    return JS_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static JSBool date_getDate ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
) [static]

Definition at line 1013 of file jsdate.c.

{
    jsdouble result;
    jsdouble *date = date_getProlog(cx, obj, argv);
    if (!date)
        return JS_FALSE;
    result = *date;

    if (!JSDOUBLE_IS_FINITE(result))
        return js_NewNumberValue(cx, result, rval);

    result = LocalTime(result);
    result = DateFromTime(result);
    return js_NewNumberValue(cx, result, rval);
}

Here is the call graph for this function:

static JSBool date_getDay ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
) [static]

Definition at line 1047 of file jsdate.c.

{
    jsdouble result;
    jsdouble *date = date_getProlog(cx, obj, argv);
    if (!date)
        return JS_FALSE;
    result = *date;

    if (!JSDOUBLE_IS_FINITE(result))
        return js_NewNumberValue(cx, result, rval);

    result = LocalTime(result);
    result = WeekDay(result);
    return js_NewNumberValue(cx, result, rval);
}

Here is the call graph for this function:

static JSBool date_getFullYear ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
) [static]

Definition at line 945 of file jsdate.c.

{
    jsdouble result;
    jsdouble *date = date_getProlog(cx, obj, argv);
    if (!date)
        return JS_FALSE;
    result = *date;

    if (!JSDOUBLE_IS_FINITE(result))
        return js_NewNumberValue(cx, result, rval);

    result = YearFromTime(LocalTime(result));
    return js_NewNumberValue(cx, result, rval);
}

Here is the call graph for this function:

static JSBool date_getHours ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
) [static]

Definition at line 1081 of file jsdate.c.

{
    jsdouble result;
    jsdouble *date = date_getProlog(cx, obj, argv);
    if (!date)
        return JS_FALSE;
    result = *date;

    if (!JSDOUBLE_IS_FINITE(result))
        return js_NewNumberValue(cx, result, rval);

    result = HourFromTime(LocalTime(result));
    return js_NewNumberValue(cx, result, rval);
}

Here is the call graph for this function:

static JSBool date_getMinutes ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
) [static]

Definition at line 1115 of file jsdate.c.

{
    jsdouble result;
    jsdouble *date = date_getProlog(cx, obj, argv);
    if (!date)
        return JS_FALSE;
    result = *date;

    if (!JSDOUBLE_IS_FINITE(result))
        return js_NewNumberValue(cx, result, rval);

    result = MinFromTime(LocalTime(result));
    return js_NewNumberValue(cx, result, rval);
}

Here is the call graph for this function:

static JSBool date_getMonth ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
) [static]

Definition at line 979 of file jsdate.c.

{
    jsdouble result;
    jsdouble *date = date_getProlog(cx, obj, argv);
    if (!date)
        return JS_FALSE;
    result = *date;

    if (!JSDOUBLE_IS_FINITE(result))
        return js_NewNumberValue(cx, result, rval);

    result = MonthFromTime(LocalTime(result));
    return js_NewNumberValue(cx, result, rval);
}

Here is the call graph for this function:

static jsdouble* date_getProlog ( JSContext cx,
JSObject obj,
jsval argv 
) [static]

Definition at line 903 of file jsdate.c.

{
    if (!JS_InstanceOf(cx, obj, &js_DateClass, argv))
        return NULL;
    return JSVAL_TO_DOUBLE(OBJ_GET_SLOT(cx, obj, JSSLOT_PRIVATE));
}

Here is the call graph for this function:

static JSBool date_getTime ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
) [static]

Definition at line 914 of file jsdate.c.

{
    jsdouble *date = date_getProlog(cx, obj, argv);
    if (!date)
        return JS_FALSE;

    return js_NewNumberValue(cx, *date, rval);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static JSBool date_getTimezoneOffset ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
) [static]

Definition at line 1187 of file jsdate.c.

{
    jsdouble result;
    jsdouble *date = date_getProlog(cx, obj, argv);
    if (!date)
        return JS_FALSE;
    result = *date;

    /*
     * Return the time zone offset in minutes for the current locale
     * that is appropriate for this time. This value would be a
     * constant except for daylight savings time.
     */
    result = (result - LocalTime(result)) / msPerMinute;
    return js_NewNumberValue(cx, result, rval);
}

Here is the call graph for this function:

static JSBool date_getUTCDate ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
) [static]

Definition at line 1030 of file jsdate.c.

{
    jsdouble result;
    jsdouble *date = date_getProlog(cx, obj, argv);
    if (!date)
        return JS_FALSE;
    result = *date;

    if (!JSDOUBLE_IS_FINITE(result))
        return js_NewNumberValue(cx, result, rval);

    result = DateFromTime(result);
    return js_NewNumberValue(cx, result, rval);
}

Here is the call graph for this function:

static JSBool date_getUTCDay ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
) [static]

Definition at line 1064 of file jsdate.c.

{
    jsdouble result;
    jsdouble *date = date_getProlog(cx, obj, argv);
    if (!date)
        return JS_FALSE;
    result = *date;

    if (!JSDOUBLE_IS_FINITE(result))
        return js_NewNumberValue(cx, result, rval);

    result = WeekDay(result);
    return js_NewNumberValue(cx, result, rval);
}

Here is the call graph for this function:

static JSBool date_getUTCFullYear ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
) [static]

Definition at line 962 of file jsdate.c.

{
    jsdouble result;
    jsdouble *date = date_getProlog(cx, obj, argv);
    if (!date)
        return JS_FALSE;
    result = *date;

    if (!JSDOUBLE_IS_FINITE(result))
        return js_NewNumberValue(cx, result, rval);

    result = YearFromTime(result);
    return js_NewNumberValue(cx, result, rval);
}

Here is the call graph for this function:

static JSBool date_getUTCHours ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
) [static]

Definition at line 1098 of file jsdate.c.

{
    jsdouble result;
    jsdouble *date = date_getProlog(cx, obj, argv);
    if (!date)
        return JS_FALSE;
    result = *date;

    if (!JSDOUBLE_IS_FINITE(result))
        return js_NewNumberValue(cx, result, rval);

    result = HourFromTime(result);
    return js_NewNumberValue(cx, result, rval);
}

Here is the call graph for this function:

static JSBool date_getUTCMilliseconds ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
) [static]

Definition at line 1170 of file jsdate.c.

{
    jsdouble result;
    jsdouble *date = date_getProlog(cx, obj, argv);
    if (!date)
        return JS_FALSE;
    result = *date;

    if (!JSDOUBLE_IS_FINITE(result))
        return js_NewNumberValue(cx, result, rval);

    result = msFromTime(result);
    return js_NewNumberValue(cx, result, rval);
}

Here is the call graph for this function:

static JSBool date_getUTCMinutes ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
) [static]

Definition at line 1132 of file jsdate.c.

{
    jsdouble result;
    jsdouble *date = date_getProlog(cx, obj, argv);
    if (!date)
        return JS_FALSE;
    result = *date;

    if (!JSDOUBLE_IS_FINITE(result))
        return js_NewNumberValue(cx, result, rval);

    result = MinFromTime(result);
    return js_NewNumberValue(cx, result, rval);
}

Here is the call graph for this function:

static JSBool date_getUTCMonth ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
) [static]

Definition at line 996 of file jsdate.c.

{
    jsdouble result;
    jsdouble *date = date_getProlog(cx, obj, argv);
    if (!date)
        return JS_FALSE;
    result = *date;

    if (!JSDOUBLE_IS_FINITE(result))
        return js_NewNumberValue(cx, result, rval);

    result = MonthFromTime(result);
    return js_NewNumberValue(cx, result, rval);
}

Here is the call graph for this function:

static JSBool date_getUTCSeconds ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
) [static]

Definition at line 1151 of file jsdate.c.

{
    jsdouble result;
    jsdouble *date = date_getProlog(cx, obj, argv);
    if (!date)
        return JS_FALSE;
    result = *date;

    if (!JSDOUBLE_IS_FINITE(result))
        return js_NewNumberValue(cx, result, rval);

    result = SecFromTime(result);
    return js_NewNumberValue(cx, result, rval);
}

Here is the call graph for this function:

static JSBool date_getYear ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
) [static]

Definition at line 924 of file jsdate.c.

{
    jsdouble *date;
    jsdouble result;

    date = date_getProlog(cx, obj, argv);
    if (!date)
        return JS_FALSE;

    result = *date;
    if (!JSDOUBLE_IS_FINITE(result))
        return js_NewNumberValue(cx, result, rval);

    result = YearFromTime(LocalTime(result));

    /* Follow ECMA-262 to the letter, contrary to IE JScript. */
    result -= 1900;
    return js_NewNumberValue(cx, result, rval);
}

Here is the call graph for this function:

static JSBool date_makeDate ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
uintN  maxargs,
JSBool  local,
jsval rval 
) [static]

Definition at line 1365 of file jsdate.c.

{
    uintN i;
    jsdouble lorutime; /* local or UTC version of *date */
    jsdouble args[3], *argp, *stop;
    jsdouble year, month, day;
    jsdouble result;

    jsdouble *date = date_getProlog(cx, obj, argv);
    if (!date)
        return JS_FALSE;

    result = *date;

    /* see complaint about ECMA in date_MakeTime */
    if (argc == 0)
        argc = 1;   /* should be safe, because length of all setters is 1 */
    else if (argc > maxargs)
        argc = maxargs;   /* clamp argc */

    for (i = 0; i < argc; i++) {
        if (!js_ValueToNumber(cx, argv[i], &args[i]))
            return JS_FALSE;
        if (!JSDOUBLE_IS_FINITE(args[i])) {
            *date = *cx->runtime->jsNaN;
            return js_NewNumberValue(cx, *date, rval);
        }
        args[i] = js_DoubleToInteger(args[i]);
    }

    /* return NaN if date is NaN and we're not setting the year,
     * If we are, use 0 as the time. */
    if (!(JSDOUBLE_IS_FINITE(result))) {
        if (maxargs < 3)
            return js_NewNumberValue(cx, result, rval);
        else
            lorutime = +0.;
    } else {
        if (local)
            lorutime = LocalTime(result);
        else
            lorutime = result;
    }

    argp = args;
    stop = argp + argc;
    if (maxargs >= 3 && argp < stop)
        year = *argp++;
    else
        year = YearFromTime(lorutime);

    if (maxargs >= 2 && argp < stop)
        month = *argp++;
    else
        month = MonthFromTime(lorutime);

    if (maxargs >= 1 && argp < stop)
        day = *argp++;
    else
        day = DateFromTime(lorutime);

    day = MakeDay(year, month, day); /* day within year */
    result = MakeDate(day, TimeWithinDay(lorutime));

    if (local)
        result = UTC(result);

    *date = TIMECLIP(result);
    return js_NewNumberValue(cx, *date, rval);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static JSBool date_makeTime ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
uintN  maxargs,
JSBool  local,
jsval rval 
) [static]

Definition at line 1223 of file jsdate.c.

{
    uintN i;
    jsdouble args[4], *argp, *stop;
    jsdouble hour, min, sec, msec;
    jsdouble lorutime; /* Local or UTC version of *date */

    jsdouble msec_time;
    jsdouble result;

    jsdouble *date = date_getProlog(cx, obj, argv);
    if (!date)
        return JS_FALSE;

    result = *date;

    /* just return NaN if the date is already NaN */
    if (!JSDOUBLE_IS_FINITE(result))
        return js_NewNumberValue(cx, result, rval);

    /* Satisfy the ECMA rule that if a function is called with
     * fewer arguments than the specified formal arguments, the
     * remaining arguments are set to undefined.  Seems like all
     * the Date.setWhatever functions in ECMA are only varargs
     * beyond the first argument; this should be set to undefined
     * if it's not given.  This means that "d = new Date();
     * d.setMilliseconds()" returns NaN.  Blech.
     */
    if (argc == 0)
        argc = 1;   /* should be safe, because length of all setters is 1 */
    else if (argc > maxargs)
        argc = maxargs;  /* clamp argc */

    for (i = 0; i < argc; i++) {
        if (!js_ValueToNumber(cx, argv[i], &args[i]))
            return JS_FALSE;
        if (!JSDOUBLE_IS_FINITE(args[i])) {
            *date = *cx->runtime->jsNaN;
            return js_NewNumberValue(cx, *date, rval);
        }
        args[i] = js_DoubleToInteger(args[i]);
    }

    if (local)
        lorutime = LocalTime(result);
    else
        lorutime = result;

    argp = args;
    stop = argp + argc;
    if (maxargs >= 4 && argp < stop)
        hour = *argp++;
    else
        hour = HourFromTime(lorutime);

    if (maxargs >= 3 && argp < stop)
        min = *argp++;
    else
        min = MinFromTime(lorutime);

    if (maxargs >= 2 && argp < stop)
        sec = *argp++;
    else
        sec = SecFromTime(lorutime);

    if (maxargs >= 1 && argp < stop)
        msec = *argp;
    else
        msec = msFromTime(lorutime);

    msec_time = MakeTime(hour, min, sec, msec);
    result = MakeDate(Day(lorutime), msec_time);

/*     fprintf(stderr, "%f\n", result); */

    if (local)
        result = UTC(result);

/*     fprintf(stderr, "%f\n", result); */

    *date = TIMECLIP(result);
    return js_NewNumberValue(cx, *date, rval);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static jsdouble date_msecFromDate ( jsdouble  year,
jsdouble  mon,
jsdouble  mday,
jsdouble  hour,
jsdouble  min,
jsdouble  sec,
jsdouble  msec 
) [static]

Definition at line 542 of file jsdate.c.

{
    jsdouble day;
    jsdouble msec_time;
    jsdouble result;

    day = MakeDay(year, mon, mday);
    msec_time = MakeTime(hour, min, sec, msec);
    result = MakeDate(day, msec_time);
    return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static JSBool date_now ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
) [static]

Definition at line 885 of file jsdate.c.

{
    int64 us, ms, us2ms;
    jsdouble msec_time;

    us = PRMJ_Now();
    JSLL_UI2L(us2ms, PRMJ_USEC_PER_MSEC);
    JSLL_DIV(ms, us, us2ms);
    JSLL_L2D(msec_time, ms);

    return js_NewDoubleValue(cx, msec_time, rval);
}

Here is the call graph for this function:

static JSBool date_parse ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
) [static]

Definition at line 867 of file jsdate.c.

{
    JSString *str;
    jsdouble result;

    str = js_ValueToString(cx, argv[0]);
    if (!str)
        return JS_FALSE;
    if (!date_parseString(str, &result)) {
        *rval = DOUBLE_TO_JSVAL(cx->runtime->jsNaN);
        return JS_TRUE;
    }

    result = TIMECLIP(result);
    return js_NewNumberValue(cx, result, rval);
}

Here is the call graph for this function:

static JSBool date_parseString ( JSString str,
jsdouble result 
) [static]

Definition at line 599 of file jsdate.c.

{
    jsdouble msec;

    const jschar *s = JSSTRING_CHARS(str);
    size_t limit = JSSTRING_LENGTH(str);
    size_t i = 0;
    int year = -1;
    int mon = -1;
    int mday = -1;
    int hour = -1;
    int min = -1;
    int sec = -1;
    int c = -1;
    int n = -1;
    jsdouble tzoffset = -1;  /* was an int, overflowed on win16!!! */
    int prevc = 0;
    JSBool seenplusminus = JS_FALSE;
    int temp;
    JSBool seenmonthname = JS_FALSE;

    if (limit == 0)
        goto syntax;
    while (i < limit) {
        c = s[i];
        i++;
        if (c <= ' ' || c == ',' || c == '-') {
            if (c == '-' && '0' <= s[i] && s[i] <= '9') {
              prevc = c;
            }
            continue;
        }
        if (c == '(') { /* comments) */
            int depth = 1;
            while (i < limit) {
                c = s[i];
                i++;
                if (c == '(') depth++;
                else if (c == ')')
                    if (--depth <= 0)
                        break;
            }
            continue;
        }
        if ('0' <= c && c <= '9') {
            n = c - '0';
            while (i < limit && '0' <= (c = s[i]) && c <= '9') {
                n = n * 10 + c - '0';
                i++;
            }

            /* allow TZA before the year, so
             * 'Wed Nov 05 21:49:11 GMT-0800 1997'
             * works */

            /* uses of seenplusminus allow : in TZA, so Java
             * no-timezone style of GMT+4:30 works
             */

            if ((prevc == '+' || prevc == '-')/*  && year>=0 */) {
                /* make ':' case below change tzoffset */
                seenplusminus = JS_TRUE;

                /* offset */
                if (n < 24)
                    n = n * 60; /* EG. "GMT-3" */
                else
                    n = n % 100 + n / 100 * 60; /* eg "GMT-0430" */
                if (prevc == '+')       /* plus means east of GMT */
                    n = -n;
                if (tzoffset != 0 && tzoffset != -1)
                    goto syntax;
                tzoffset = n;
            } else if (prevc == '/' && mon >= 0 && mday >= 0 && year < 0) {
                if (c <= ' ' || c == ',' || c == '/' || i >= limit)
                    year = n;
                else
                    goto syntax;
            } else if (c == ':') {
                if (hour < 0)
                    hour = /*byte*/ n;
                else if (min < 0)
                    min = /*byte*/ n;
                else
                    goto syntax;
            } else if (c == '/') {
                /* until it is determined that mon is the actual
                   month, keep it as 1-based rather than 0-based */
                if (mon < 0)
                    mon = /*byte*/ n;
                else if (mday < 0)
                    mday = /*byte*/ n;
                else
                    goto syntax;
            } else if (i < limit && c != ',' && c > ' ' && c != '-' && c != '(') {
                goto syntax;
            } else if (seenplusminus && n < 60) {  /* handle GMT-3:30 */
                if (tzoffset < 0)
                    tzoffset -= n;
                else
                    tzoffset += n;
            } else if (hour >= 0 && min < 0) {
                min = /*byte*/ n;
            } else if (prevc == ':' && min >= 0 && sec < 0) {
                sec = /*byte*/ n;
            } else if (mon < 0) {
                mon = /*byte*/n;
            } else if (mon >= 0 && mday < 0) {
                mday = /*byte*/ n;
            } else if (mon >= 0 && mday >= 0 && year < 0) {
                year = n;
            } else {
                goto syntax;
            }
            prevc = 0;
        } else if (c == '/' || c == ':' || c == '+' || c == '-') {
            prevc = c;
        } else {
            size_t st = i - 1;
            int k;
            while (i < limit) {
                c = s[i];
                if (!(('A' <= c && c <= 'Z') || ('a' <= c && c <= 'z')))
                    break;
                i++;
            }
            if (i <= st + 1)
                goto syntax;
            for (k = (sizeof(wtb)/sizeof(char*)); --k >= 0;)
                if (date_regionMatches(wtb[k], 0, s, st, i-st, 1)) {
                    int action = ttb[k];
                    if (action != 0) {
                        if (action < 0) {
                            /*
                             * AM/PM. Count 12:30 AM as 00:30, 12:30 PM as
                             * 12:30, instead of blindly adding 12 if PM.
                             */
                            JS_ASSERT(action == -1 || action == -2);
                            if (hour > 12 || hour < 0) {
                                goto syntax;
                            } else {
                                if (action == -1 && hour == 12) { /* am */
                                    hour = 0;
                                } else if (action == -2 && hour != 12) { /* pm */
                                    hour += 12;
                                }
                            }
                        } else if (action <= 13) { /* month! */
                            /* Adjust mon to be 1-based until the final values
                               for mon, mday and year are adjusted below */
                            if (seenmonthname) {
                                goto syntax;
                            }
                            seenmonthname = JS_TRUE;
                            temp = /*byte*/ (action - 2) + 1;

                            if (mon < 0) {
                                mon = temp;
                            } else if (mday < 0) {
                                mday = mon;
                                mon = temp;
                            } else if (year < 0) {
                                year = mon;
                                mon = temp;
                            } else {
                                goto syntax;
                            }
                        } else {
                            tzoffset = action - 10000;
                        }
                    }
                    break;
                }
            if (k < 0)
                goto syntax;
            prevc = 0;
        }
    }
    if (year < 0 || mon < 0 || mday < 0)
        goto syntax;
    /*
      Case 1. The input string contains an English month name.
              The form of the string can be month f l, or f month l, or
              f l month which each evaluate to the same date.
              If f and l are both greater than or equal to 70, or
              both less than 70, the date is invalid.
              The year is taken to be the greater of the values f, l.
              If the year is greater than or equal to 70 and less than 100,
              it is considered to be the number of years after 1900.
      Case 2. The input string is of the form "f/m/l" where f, m and l are
              integers, e.g. 7/16/45.
              Adjust the mon, mday and year values to achieve 100% MSIE
              compatibility.
              a. If 0 <= f < 70, f/m/l is interpreted as month/day/year.
                 i.  If year < 100, it is the number of years after 1900
                 ii. If year >= 100, it is the number of years after 0.
              b. If 70 <= f < 100
                 i.  If m < 70, f/m/l is interpreted as
                     year/month/day where year is the number of years after
                     1900.
                 ii. If m >= 70, the date is invalid.
              c. If f >= 100
                 i.  If m < 70, f/m/l is interpreted as
                     year/month/day where year is the number of years after 0.
                 ii. If m >= 70, the date is invalid.
    */
    if (seenmonthname) {
        if ((mday >= 70 && year >= 70) || (mday < 70 && year < 70)) {
            goto syntax;
        }
        if (mday > year) {
            temp = year;
            year = mday;
            mday = temp;
        }
        if (year >= 70 && year < 100) {
            year += 1900;
        }
    } else if (mon < 70) { /* (a) month/day/year */
        if (year < 100) {
            year += 1900;
        }
    } else if (mon < 100) { /* (b) year/month/day */
        if (mday < 70) {
            temp = year;
            year = mon + 1900;
            mon = mday;
            mday = temp;
        } else {
            goto syntax;
        }
    } else { /* (c) year/month/day */
        if (mday < 70) {
            temp = year;
            year = mon;
            mon = mday;
            mday = temp;
        } else {
            goto syntax;
        }
    }
    mon -= 1; /* convert month to 0-based */
    if (sec < 0)
        sec = 0;
    if (min < 0)
        min = 0;
    if (hour < 0)
        hour = 0;
    if (tzoffset == -1) { /* no time zone specified, have to use local */
        jsdouble msec_time;
        msec_time = date_msecFromDate(year, mon, mday, hour, min, sec, 0);

        *result = UTC(msec_time);
        return JS_TRUE;
    }

    msec = date_msecFromDate(year, mon, mday, hour, min, sec, 0);
    msec += tzoffset * msPerMinute;
    *result = msec;
    return JS_TRUE;

syntax:
    /* syntax error */
    *result = 0;
    return JS_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static JSBool date_regionMatches ( const char *  s1,
int  s1off,
const jschar s2,
int  s2off,
int  count,
int  ignoreCase 
) [static]

Definition at line 512 of file jsdate.c.

{
    JSBool result = JS_FALSE;
    /* return true if matches, otherwise, false */

    while (count > 0 && s1[s1off] && s2[s2off]) {
        if (ignoreCase) {
            if (JS_TOLOWER((jschar)s1[s1off]) != JS_TOLOWER(s2[s2off])) {
                break;
            }
        } else {
            if ((jschar)s1[s1off] != s2[s2off]) {
                break;
            }
        }
        s1off++;
        s2off++;
        count--;
    }

    if (count == 0) {
        result = JS_TRUE;
    }

    return result;
}

Here is the caller graph for this function:

static JSBool date_setDate ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
) [static]

Definition at line 1438 of file jsdate.c.

{
    return date_makeDate(cx, obj, argc, argv, 1, JS_TRUE, rval);
}

Here is the call graph for this function:

static JSBool date_setFullYear ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
) [static]

Definition at line 1466 of file jsdate.c.

{
    return date_makeDate(cx, obj, argc, argv, 3, JS_TRUE, rval);
}

Here is the call graph for this function:

static JSBool date_setHours ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
) [static]

Definition at line 1351 of file jsdate.c.

{
    return date_makeTime(cx, obj, argc, argv, 4, JS_TRUE, rval);
}

Here is the call graph for this function:

static JSBool date_setMilliseconds ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
) [static]

Definition at line 1309 of file jsdate.c.

{
    return date_makeTime(cx, obj, argc, argv, 1, JS_TRUE, rval);
}

Here is the call graph for this function:

static JSBool date_setMinutes ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
) [static]

Definition at line 1337 of file jsdate.c.

{
    return date_makeTime(cx, obj, argc, argv, 3, JS_TRUE, rval);
}

Here is the call graph for this function:

static JSBool date_setMonth ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
) [static]

Definition at line 1452 of file jsdate.c.

{
    return date_makeDate(cx, obj, argc, argv, 2, JS_TRUE, rval);
}

Here is the call graph for this function:

static JSBool date_setSeconds ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
) [static]

Definition at line 1323 of file jsdate.c.

{
    return date_makeTime(cx, obj, argc, argv, 2, JS_TRUE, rval);
}

Here is the call graph for this function:

static JSBool date_setTime ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
) [static]

Definition at line 1206 of file jsdate.c.

{
    jsdouble result;
    jsdouble *date = date_getProlog(cx, obj, argv);
    if (!date)
        return JS_FALSE;

    if (!js_ValueToNumber(cx, argv[0], &result))
        return JS_FALSE;

    result = TIMECLIP(result);

    *date = result;
    return js_NewNumberValue(cx, result, rval);
}

Here is the call graph for this function:

static JSBool date_setUTCDate ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
) [static]

Definition at line 1445 of file jsdate.c.

{
    return date_makeDate(cx, obj, argc, argv, 1, JS_FALSE, rval);
}

Here is the call graph for this function:

static JSBool date_setUTCFullYear ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
) [static]

Definition at line 1473 of file jsdate.c.

{
    return date_makeDate(cx, obj, argc, argv, 3, JS_FALSE, rval);
}

Here is the call graph for this function:

static JSBool date_setUTCHours ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
) [static]

Definition at line 1358 of file jsdate.c.

{
    return date_makeTime(cx, obj, argc, argv, 4, JS_FALSE, rval);
}

Here is the call graph for this function:

static JSBool date_setUTCMilliseconds ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
) [static]

Definition at line 1316 of file jsdate.c.

{
    return date_makeTime(cx, obj, argc, argv, 1, JS_FALSE, rval);
}

Here is the call graph for this function:

static JSBool date_setUTCMinutes ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
) [static]

Definition at line 1344 of file jsdate.c.

{
    return date_makeTime(cx, obj, argc, argv, 3, JS_FALSE, rval);
}

Here is the call graph for this function:

static JSBool date_setUTCMonth ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
) [static]

Definition at line 1459 of file jsdate.c.

{
    return date_makeDate(cx, obj, argc, argv, 2, JS_FALSE, rval);
}

Here is the call graph for this function:

static JSBool date_setUTCSeconds ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
) [static]

Definition at line 1330 of file jsdate.c.

{
    return date_makeTime(cx, obj, argc, argv, 2, JS_FALSE, rval);
}

Here is the call graph for this function:

static JSBool date_setYear ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
) [static]

Definition at line 1480 of file jsdate.c.

{
    jsdouble t;
    jsdouble year;
    jsdouble day;
    jsdouble result;

    jsdouble *date = date_getProlog(cx, obj, argv);
    if (!date)
        return JS_FALSE;

    result = *date;

    if (!js_ValueToNumber(cx, argv[0], &year))
        return JS_FALSE;
    if (!JSDOUBLE_IS_FINITE(year)) {
        *date = *cx->runtime->jsNaN;
        return js_NewNumberValue(cx, *date, rval);
    }

    year = js_DoubleToInteger(year);

    if (!JSDOUBLE_IS_FINITE(result)) {
        t = +0.0;
    } else {
        t = LocalTime(result);
    }

    if (year >= 0 && year <= 99)
        year += 1900;

    day = MakeDay(year, MonthFromTime(t), DateFromTime(t));
    result = MakeDate(day, TimeWithinDay(t));
    result = UTC(result);

    *date = TIMECLIP(result);
    return js_NewNumberValue(cx, *date, rval);
}

Here is the call graph for this function:

static JSBool date_toDateString ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
) [static]

Definition at line 1847 of file jsdate.c.

{
    jsdouble *date = date_getProlog(cx, obj, argv);
    if (!date)
        return JS_FALSE;
    return date_format(cx, *date, FORMATSPEC_DATE, rval);
}

Here is the call graph for this function:

static JSBool date_toGMTString ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
) [static]

Definition at line 1532 of file jsdate.c.

{
    char buf[100];
    JSString *str;
    jsdouble *date = date_getProlog(cx, obj, argv);
    if (!date)
        return JS_FALSE;

    if (!JSDOUBLE_IS_FINITE(*date)) {
        JS_snprintf(buf, sizeof buf, js_NaN_date_str);
    } else {
        jsdouble temp = *date;

        /* Avoid dependence on PRMJ_FormatTimeUSEnglish, because it
         * requires a PRMJTime... which only has 16-bit years.  Sub-ECMA.
         */
        JS_snprintf(buf, sizeof buf, "%s, %.2d %s %.4d %.2d:%.2d:%.2d GMT",
                    days[WeekDay(temp)],
                    DateFromTime(temp),
                    months[MonthFromTime(temp)],
                    YearFromTime(temp),
                    HourFromTime(temp),
                    MinFromTime(temp),
                    SecFromTime(temp));
    }
    str = JS_NewStringCopyZ(cx, buf);
    if (!str)
        return JS_FALSE;
    *rval = STRING_TO_JSVAL(str);
    return JS_TRUE;
}

Here is the call graph for this function:

static JSBool date_toLocaleDateString ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
) [static]

Definition at line 1796 of file jsdate.c.

{
    /* Use '%#x' for windows, because '%x' is
     * backward-compatible and non-y2k with msvc; '%#x' requests that a
     * full year be used in the result string.
     */
    return date_toLocaleHelper(cx, obj, argc, argv, rval,
#if defined(_WIN32) && !defined(__MWERKS__)
                                   "%#x"
#else
                                   "%x"
#endif
                                   );
}

Here is the call graph for this function:

static JSBool date_toLocaleFormat ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
) [static]

Definition at line 1820 of file jsdate.c.

{
    JSString *fmt;

    if (argc == 0)
        return date_toLocaleString(cx, obj, argc, argv, rval);

    fmt = JS_ValueToString(cx, argv[0]);
    if (!fmt)
        return JS_FALSE;

    return date_toLocaleHelper(cx, obj, argc, argv, rval,
                               JS_GetStringBytes(fmt));
}

Here is the call graph for this function:

static JSBool date_toLocaleHelper ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval,
char *  format 
) [static]

Definition at line 1729 of file jsdate.c.

{
    char buf[100];
    JSString *str;
    PRMJTime split;
    jsdouble *date = date_getProlog(cx, obj, argv);
    if (!date)
        return JS_FALSE;

    if (!JSDOUBLE_IS_FINITE(*date)) {
        JS_snprintf(buf, sizeof buf, js_NaN_date_str);
    } else {
        intN result_len;
        jsdouble local = LocalTime(*date);
        new_explode(local, &split, JS_FALSE);

        /* let PRMJTime format it.       */
        result_len = PRMJ_FormatTime(buf, sizeof buf, format, &split);

        /* If it failed, default to toString. */
        if (result_len == 0)
            return date_format(cx, *date, FORMATSPEC_FULL, rval);

        /* Hacked check against undesired 2-digit year 00/00/00 form. */
        if (strcmp(format, "%x") == 0 && result_len >= 6 &&
            /* Format %x means use OS settings, which may have 2-digit yr, so
               hack end of 3/11/22 or 11.03.22 or 11Mar22 to use 4-digit yr...*/
            !isdigit(buf[result_len - 3]) &&
            isdigit(buf[result_len - 2]) && isdigit(buf[result_len - 1]) &&
            /* ...but not if starts with 4-digit year, like 2022/3/11. */
            !(isdigit(buf[0]) && isdigit(buf[1]) &&
              isdigit(buf[2]) && isdigit(buf[3]))) {
            JS_snprintf(buf + (result_len - 2), (sizeof buf) - (result_len - 2),
                        "%d", js_DateGetYear(cx, obj));
        }

    }

    if (cx->localeCallbacks && cx->localeCallbacks->localeToUnicode)
        return cx->localeCallbacks->localeToUnicode(cx, buf, rval);

    str = JS_NewStringCopyZ(cx, buf);
    if (!str)
        return JS_FALSE;
    *rval = STRING_TO_JSVAL(str);
    return JS_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static JSBool date_toLocaleString ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
) [static]

Definition at line 1779 of file jsdate.c.

{
    /* Use '%#c' for windows, because '%c' is
     * backward-compatible and non-y2k with msvc; '%#c' requests that a
     * full year be used in the result string.
     */
    return date_toLocaleHelper(cx, obj, argc, argv, rval,
#if defined(_WIN32) && !defined(__MWERKS__)
                                   "%#c"
#else
                                   "%c"
#endif
                                   );
}

Here is the call graph for this function:

Here is the caller graph for this function:

static JSBool date_toLocaleTimeString ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
) [static]

Definition at line 1813 of file jsdate.c.

{
    return date_toLocaleHelper(cx, obj, argc, argv, rval, "%X");
}

Here is the call graph for this function:

static JSBool date_toSource ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
) [static]

Definition at line 1861 of file jsdate.c.

{
    jsdouble *date;
    char buf[DTOSTR_STANDARD_BUFFER_SIZE], *numStr, *bytes;
    JSString *str;

    date = date_getProlog(cx, obj, argv);
    if (!date)
        return JS_FALSE;

    numStr = JS_dtostr(buf, sizeof buf, DTOSTR_STANDARD, 0, *date);
    if (!numStr) {
        JS_ReportOutOfMemory(cx);
        return JS_FALSE;
    }

    bytes = JS_smprintf("(new %s(%s))", js_Date_str, numStr);
    if (!bytes) {
        JS_ReportOutOfMemory(cx);
        return JS_FALSE;
    }

    str = JS_NewString(cx, bytes, strlen(bytes));
    if (!str) {
        free(bytes);
        return JS_FALSE;
    }
    *rval = STRING_TO_JSVAL(str);
    return JS_TRUE;
}

Here is the call graph for this function:

static JSBool date_toString ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
) [static]

Definition at line 1895 of file jsdate.c.

{
    jsdouble *date = date_getProlog(cx, obj, argv);
    if (!date)
        return JS_FALSE;
    return date_format(cx, *date, FORMATSPEC_FULL, rval);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static JSBool date_toTimeString ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
) [static]

Definition at line 1837 of file jsdate.c.

{
    jsdouble *date = date_getProlog(cx, obj, argv);
    if (!date)
        return JS_FALSE;
    return date_format(cx, *date, FORMATSPEC_TIME, rval);
}

Here is the call graph for this function:

static JSBool date_UTC ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
) [static]

Definition at line 562 of file jsdate.c.

{
    jsdouble array[MAXARGS];
    uintN loop;
    jsdouble d;

    for (loop = 0; loop < MAXARGS; loop++) {
        if (loop < argc) {
            if (!js_ValueToNumber(cx, argv[loop], &d))
                return JS_FALSE;
            /* return NaN if any arg is NaN */
            if (!JSDOUBLE_IS_FINITE(d)) {
                return js_NewNumberValue(cx, d, rval);
            }
            array[loop] = floor(d);
        } else {
            array[loop] = 0;
        }
    }

    /* adjust 2-digit years into the 20th century */
    if (array[0] >= 0 && array[0] <= 99)
        array[0] += 1900;

    /* if we got a 0 for 'date' (which is out of range)
     * pretend it's a 1.  (So Date.UTC(1972, 5) works) */
    if (array[2] < 1)
        array[2] = 1;

    d = date_msecFromDate(array[0], array[1], array[2],
                              array[3], array[4], array[5], array[6]);
    d = TIMECLIP(d);

    return js_NewNumberValue(cx, d, rval);
}

Here is the call graph for this function:

static JSBool date_valueOf ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
) [static]

Definition at line 1905 of file jsdate.c.

{
    /* It is an error to call date_valueOf on a non-date object, but we don't
     * need to check for that explicitly here because every path calls
     * date_getProlog, which does the check.
     */

    /* If called directly with no arguments, convert to a time number. */
    if (argc == 0)
        return date_getTime(cx, obj, argc, argv, rval);

    /* Convert to number only if the hint was given, otherwise favor string. */
    if (argc == 1) {
        JSString *str, *str2;

        str = js_ValueToString(cx, argv[0]);
        if (!str)
            return JS_FALSE;
        str2 = ATOM_TO_STRING(cx->runtime->atomState.typeAtoms[JSTYPE_NUMBER]);
        if (js_EqualStrings(str, str2))
            return date_getTime(cx, obj, argc, argv, rval);
    }
    return date_toString(cx, obj, argc, argv, rval);
}

Here is the call graph for this function:

static intN DateFromTime ( jsdouble  t) [static]

Definition at line 260 of file jsdate.c.

{
    intN d, step, next;
    jsint year = YearFromTime(t);
    d = DayWithinYear(t, year);

    if (d <= (next = 30))
        return d + 1;
    step = next;
    next += (InLeapYear(t) ? 29 : 28);
    if (d <= next)
        return d - step;
    step = next;
    if (d <= (next += 31))
        return d - step;
    step = next;
    if (d <= (next += 30))
        return d - step;
    step = next;
    if (d <= (next += 31))
        return d - step;
    step = next;
    if (d <= (next += 30))
        return d - step;
    step = next;
    if (d <= (next += 31))
        return d - step;
    step = next;
    if (d <= (next += 31))
        return d - step;
    step = next;
    if (d <= (next += 30))
        return d - step;
    step = next;
    if (d <= (next += 31))
        return d - step;
    step = next;
    if (d <= (next += 30))
        return d - step;
    step = next;
    return d - step;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static jsdouble DaylightSavingTA ( jsdouble  t) [static]

Definition at line 381 of file jsdate.c.

{
    volatile int64 PR_t;
    int64 ms2us;
    int64 offset;
    jsdouble result;

    /* abort if NaN */
    if (JSDOUBLE_IS_NaN(t))
        return t;

    /*
     * If earlier than 1970 or after 2038, potentially beyond the ken of
     * many OSes, map it to an equivalent year before asking.
     */
    if (t < 0.0 || t > 2145916800000.0) {
        jsint year;
        jsdouble day;

        year = EquivalentYearForDST(YearFromTime(t));
        day = MakeDay(year, MonthFromTime(t), DateFromTime(t));
        t = MakeDate(day, TimeWithinDay(t));
    }

    /* put our t in an LL, and map it to usec for prtime */
    JSLL_D2L(PR_t, t);
    JSLL_I2L(ms2us, PRMJ_USEC_PER_MSEC);
    JSLL_MUL(PR_t, PR_t, ms2us);

    offset = PRMJ_DSTOffset(PR_t);

    JSLL_DIV(offset, offset, ms2us);
    JSLL_L2D(result, offset);
    return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static jsint EquivalentYearForDST ( jsint  year) [static]

Definition at line 362 of file jsdate.c.

{
    jsint day;
    JSBool isLeapYear;

    day = (jsint) DayFromYear(year) + 4;
    day = day % 7;
    if (day < 0)
        day += 7;

    isLeapYear = (DaysInYear(year) == 366);

    return yearStartingWith[isLeapYear][day];
}

Here is the caller graph for this function:

static intN HourFromTime ( jsdouble  t) [static]

Definition at line 429 of file jsdate.c.

{
    intN result = (intN) fmod(floor(t/msPerHour), HoursPerDay);
    if (result < 0)
        result += (intN)HoursPerDay;
    return result;
}

Here is the caller graph for this function:

js_DateGetDate ( JSContext cx,
JSObject obj 
)

Definition at line 2203 of file jsdate.c.

{
    jsdouble *date = date_getProlog(cx, obj, NULL);

    if (!date || JSDOUBLE_IS_NaN(*date))
        return 0;
    return (int) DateFromTime(LocalTime(*date));
}

Here is the call graph for this function:

js_DateGetHours ( JSContext cx,
JSObject obj 
)

Definition at line 2213 of file jsdate.c.

{
    jsdouble *date = date_getProlog(cx, obj, NULL);

    if (!date || JSDOUBLE_IS_NaN(*date))
        return 0;
    return (int) HourFromTime(LocalTime(*date));
}

Here is the call graph for this function:

js_DateGetMinutes ( JSContext cx,
JSObject obj 
)

Definition at line 2223 of file jsdate.c.

{
    jsdouble *date = date_getProlog(cx, obj, NULL);

    if (!date || JSDOUBLE_IS_NaN(*date))
        return 0;
    return (int) MinFromTime(LocalTime(*date));
}

Here is the call graph for this function:

js_DateGetMonth ( JSContext cx,
JSObject obj 
)

Definition at line 2193 of file jsdate.c.

{
    jsdouble *date = date_getProlog(cx, obj, NULL);

    if (!date || JSDOUBLE_IS_NaN(*date))
        return 0;
    return (int) MonthFromTime(LocalTime(*date));
}

Here is the call graph for this function:

Definition at line 2365 of file jsdate.c.

{
    jsdouble *date = date_getProlog(cx, obj, NULL);
    if (!date || JSDOUBLE_IS_NaN(*date))
        return 0;
    return (*date);
}

Here is the call graph for this function:

Here is the caller graph for this function:

js_DateGetSeconds ( JSContext cx,
JSObject obj 
)

Definition at line 2233 of file jsdate.c.

{
    jsdouble *date = date_getProlog(cx, obj, NULL);

    if (!date || JSDOUBLE_IS_NaN(*date))
        return 0;
    return (int) SecFromTime(*date);
}

Here is the call graph for this function:

js_DateGetYear ( JSContext cx,
JSObject obj 
)

Definition at line 2182 of file jsdate.c.

{
    jsdouble *date = date_getProlog(cx, obj, NULL);

    /* Preserve legacy API behavior of returning 0 for invalid dates. */
    if (!date || JSDOUBLE_IS_NaN(*date))
        return 0;
    return (int) YearFromTime(LocalTime(*date));
}

Here is the call graph for this function:

Here is the caller graph for this function:

js_DateIsValid ( JSContext cx,
JSObject obj 
)

Definition at line 2171 of file jsdate.c.

{
    jsdouble *date = date_getProlog(cx, obj, NULL);

    if (!date || JSDOUBLE_IS_NaN(*date))
        return JS_FALSE;
    else
        return JS_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

js_DateSetDate ( JSContext cx,
JSObject obj,
int  date 
)

Definition at line 2285 of file jsdate.c.

{
    jsdouble local;
    jsdouble *datep = date_getProlog(cx, obj, NULL);
    if (!datep)
        return;
    local = LocalTime(*datep);
    if (JSDOUBLE_IS_NaN(local))
        return;
    local = date_msecFromDate(YearFromTime(local),
                              MonthFromTime(local),
                              date,
                              HourFromTime(local),
                              MinFromTime(local),
                              SecFromTime(local),
                              msFromTime(local));
    *datep = UTC(local);
}

Here is the call graph for this function:

js_DateSetHours ( JSContext cx,
JSObject obj,
int  hours 
)

Definition at line 2305 of file jsdate.c.

{
    jsdouble local;
    jsdouble *date = date_getProlog(cx, obj, NULL);
    if (!date)
        return;
    local = LocalTime(*date);
    if (JSDOUBLE_IS_NaN(local))
        return;
    local = date_msecFromDate(YearFromTime(local),
                              MonthFromTime(local),
                              DateFromTime(local),
                              hours,
                              MinFromTime(local),
                              SecFromTime(local),
                              msFromTime(local));
    *date = UTC(local);
}

Here is the call graph for this function:

js_DateSetMinutes ( JSContext cx,
JSObject obj,
int  minutes 
)

Definition at line 2325 of file jsdate.c.

{
    jsdouble local;
    jsdouble *date = date_getProlog(cx, obj, NULL);
    if (!date)
        return;
    local = LocalTime(*date);
    if (JSDOUBLE_IS_NaN(local))
        return;
    local = date_msecFromDate(YearFromTime(local),
                              MonthFromTime(local),
                              DateFromTime(local),
                              HourFromTime(local),
                              minutes,
                              SecFromTime(local),
                              msFromTime(local));
    *date = UTC(local);
}

Here is the call graph for this function:

js_DateSetMonth ( JSContext cx,
JSObject obj,
int  month 
)

Definition at line 2264 of file jsdate.c.

{
    jsdouble local;
    jsdouble *date = date_getProlog(cx, obj, NULL);
    if (!date)
        return;
    local = LocalTime(*date);
    /* bail if date was NaN */
    if (JSDOUBLE_IS_NaN(local))
        return;
    local = date_msecFromDate(YearFromTime(local),
                              month,
                              DateFromTime(local),
                              HourFromTime(local),
                              MinFromTime(local),
                              SecFromTime(local),
                              msFromTime(local));
    *date = UTC(local);
}

Here is the call graph for this function:

js_DateSetSeconds ( JSContext cx,
JSObject obj,
int  seconds 
)

Definition at line 2345 of file jsdate.c.

{
    jsdouble local;
    jsdouble *date = date_getProlog(cx, obj, NULL);
    if (!date)
        return;
    local = LocalTime(*date);
    if (JSDOUBLE_IS_NaN(local))
        return;
    local = date_msecFromDate(YearFromTime(local),
                              MonthFromTime(local),
                              DateFromTime(local),
                              HourFromTime(local),
                              MinFromTime(local),
                              seconds,
                              msFromTime(local));
    *date = UTC(local);
}

Here is the call graph for this function:

js_DateSetYear ( JSContext cx,
JSObject obj,
int  year 
)

Definition at line 2243 of file jsdate.c.

{
    jsdouble local;
    jsdouble *date = date_getProlog(cx, obj, NULL);
    if (!date)
        return;
    local = LocalTime(*date);
    /* reset date if it was NaN */
    if (JSDOUBLE_IS_NaN(local))
        local = 0;
    local = date_msecFromDate(year,
                              MonthFromTime(local),
                              DateFromTime(local),
                              HourFromTime(local),
                              MinFromTime(local),
                              SecFromTime(local),
                              msFromTime(local));
    *date = UTC(local);
}

Here is the call graph for this function:

JSObject* js_InitDateClass ( JSContext cx,
JSObject obj 
)

Definition at line 2115 of file jsdate.c.

{
    JSObject *proto;
    jsdouble *proto_date;

    /* set static LocalTZA */
    LocalTZA = -(PRMJ_LocalGMTDifference() * msPerSecond);
    proto = JS_InitClass(cx, obj, NULL, &js_DateClass, Date, MAXARGS,
                         NULL, date_methods, NULL, date_static_methods);
    if (!proto)
        return NULL;

    /* Alias toUTCString with toGMTString.  (ECMA B.2.6) */
    if (!JS_AliasProperty(cx, proto, "toUTCString", "toGMTString"))
        return NULL;

    /* Set the value of the Date.prototype date to NaN */
    proto_date = date_constructor(cx, proto);
    if (!proto_date)
        return NULL;
    *proto_date = *cx->runtime->jsNaN;

    return proto;
}

Here is the call graph for this function:

Here is the caller graph for this function:

js_NewDateObject ( JSContext cx,
int  year,
int  mon,
int  mday,
int  hour,
int  min,
int  sec 
)

Definition at line 2159 of file jsdate.c.

{
    JSObject *obj;
    jsdouble msec_time;

    msec_time = date_msecFromDate(year, mon, mday, hour, min, sec, 0);
    obj = js_NewDateObjectMsec(cx, UTC(msec_time));
    return obj;
}

Here is the call graph for this function:

js_NewDateObjectMsec ( JSContext cx,
jsdouble  msec_time 
)

Definition at line 2141 of file jsdate.c.

{
    JSObject *obj;
    jsdouble *date;

    obj = js_NewObject(cx, &js_DateClass, NULL, NULL);
    if (!obj)
        return NULL;

    date = date_constructor(cx, obj);
    if (!date)
        return NULL;

    *date = msec_time;
    return obj;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static jsdouble MakeDay ( jsdouble  year,
jsdouble  month,
jsdouble  date 
) [static]

Definition at line 318 of file jsdate.c.

{
    JSBool leap;
    jsdouble yearday;
    jsdouble monthday;

    year += floor(month / 12);

    month = fmod(month, 12.0);
    if (month < 0)
        month += 12;

    leap = (DaysInYear((jsint) year) == 366);

    yearday = floor(TimeFromYear(year) / msPerDay);
    monthday = DayFromMonth(month, leap);

    return yearday + monthday + date - 1;
}

Here is the caller graph for this function:

static intN MinFromTime ( jsdouble  t) [static]

Definition at line 438 of file jsdate.c.

{
    intN result = (intN) fmod(floor(t / msPerMinute), MinutesPerHour);
    if (result < 0)
        result += (intN)MinutesPerHour;
    return result;
}

Here is the caller graph for this function:

static intN MonthFromTime ( jsdouble  t) [static]

Definition at line 227 of file jsdate.c.

{
    intN d, step;
    jsint year = YearFromTime(t);
    d = DayWithinYear(t, year);

    if (d < (step = 31))
        return 0;
    step += (InLeapYear(t) ? 29 : 28);
    if (d < step)
        return 1;
    if (d < (step += 31))
        return 2;
    if (d < (step += 30))
        return 3;
    if (d < (step += 31))
        return 4;
    if (d < (step += 30))
        return 5;
    if (d < (step += 31))
        return 6;
    if (d < (step += 31))
        return 7;
    if (d < (step += 30))
        return 8;
    if (d < (step += 31))
        return 9;
    if (d < (step += 30))
        return 10;
    return 11;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static intN msFromTime ( jsdouble  t) [static]

Definition at line 456 of file jsdate.c.

{
    intN result = (intN) fmod(t, msPerSecond);
    if (result < 0)
        result += (intN)msPerSecond;
    return result;
}

Here is the caller graph for this function:

static void new_explode ( jsdouble  timeval,
PRMJTime split,
JSBool  findEquivalent 
) [static]

Definition at line 1570 of file jsdate.c.

{
    jsint year = YearFromTime(timeval);
    int16 adjustedYear;

    /* If the year doesn't fit in a PRMJTime, find something to do about it. */
    if (year > 32767 || year < -32768) {
        if (findEquivalent) {
            /* We're really just trying to get a timezone string; map the year
             * to some equivalent year in the range 0 to 2800.  Borrowed from
             * A. D. Olsen.
             */
            jsint cycles;
#define CYCLE_YEARS 2800L
            cycles = (year >= 0) ? year / CYCLE_YEARS
                                 : -1 - (-1 - year) / CYCLE_YEARS;
            adjustedYear = (int16)(year - cycles * CYCLE_YEARS);
        } else {
            /* Clamp it to the nearest representable year. */
            adjustedYear = (int16)((year > 0) ? 32767 : - 32768);
        }
    } else {
        adjustedYear = (int16)year;
    }

    split->tm_usec = (int32) msFromTime(timeval) * 1000;
    split->tm_sec = (int8) SecFromTime(timeval);
    split->tm_min = (int8) MinFromTime(timeval);
    split->tm_hour = (int8) HourFromTime(timeval);
    split->tm_mday = (int8) DateFromTime(timeval);
    split->tm_mon = (int8) MonthFromTime(timeval);
    split->tm_wday = (int8) WeekDay(timeval);
    split->tm_year = (int16) adjustedYear;
    split->tm_yday = (int16) DayWithinYear(timeval, year);

    /* not sure how this affects things, but it doesn't seem
       to matter. */
    split->tm_isdst = (DaylightSavingTA(timeval) != 0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static intN SecFromTime ( jsdouble  t) [static]

Definition at line 447 of file jsdate.c.

{
    intN result = (intN) fmod(floor(t / msPerSecond), SecondsPerMinute);
    if (result < 0)
        result += (intN)SecondsPerMinute;
    return result;
}

Here is the caller graph for this function:

static jsdouble TimeWithinDay ( jsdouble  t) [static]

Definition at line 177 of file jsdate.c.

{
    jsdouble result;
    result = fmod(t, msPerDay);
    if (result < 0)
        result += msPerDay;
    return result;
}

Here is the caller graph for this function:

static jsdouble UTC ( jsdouble  t) [static]

Definition at line 423 of file jsdate.c.

{
    return t - AdjustTime(t - LocalTZA);
}

Here is the caller graph for this function:

static intN WeekDay ( jsdouble  t) [static]

Definition at line 304 of file jsdate.c.

{
    jsint result;
    result = (jsint) Day(t) + 4;
    result = result % 7;
    if (result < 0)
        result += 7;
    return (intN) result;
}

Here is the caller graph for this function:

static jsint YearFromTime ( jsdouble  t) [static]

Definition at line 197 of file jsdate.c.

{
    jsint y = (jsint) floor(t /(msPerDay*365.2425)) + 1970;
    jsdouble t2 = (jsdouble) TimeFromYear(y);

    if (t2 > t) {
        y--;
    } else {
        if (t2 + msPerDay * DaysInYear(y) <= t)
            y++;
    }
    return y;
}

Here is the caller graph for this function:


Variable Documentation

Definition at line 1943 of file jsdate.c.

Initial value:
 {
    {"UTC",               date_UTC,               MAXARGS,0,0 },
    {"parse",             date_parse,             1,0,0 },
    {"now",               date_now,               0,0,0 },
    {0,0,0,0,0}
}

Definition at line 1936 of file jsdate.c.

const char* days[] [static]
Initial value:
{
   "Sun","Mon","Tue","Wed","Thu","Fri","Sat"
}

Definition at line 1522 of file jsdate.c.

jsdouble firstDayOfMonth[2][12] [static]
Initial value:
 {
    {0.0, 31.0, 59.0, 90.0, 120.0, 151.0, 181.0, 212.0, 243.0, 273.0, 304.0, 334.0},
    {0.0, 31.0, 60.0, 91.0, 121.0, 152.0, 182.0, 213.0, 244.0, 274.0, 305.0, 335.0}
}

Definition at line 219 of file jsdate.c.

char js_NaN_date_str[] = "Invalid Date" [static]

Definition at line 1521 of file jsdate.c.

jsdouble LocalTZA [static]

Definition at line 378 of file jsdate.c.

const char* months[] [static]
Initial value:
{
   "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
}

Definition at line 1526 of file jsdate.c.

int ttb[] [static]
Initial value:
 {
    -1, -2, 0, 0, 0, 0, 0, 0, 0,       
    2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
    10000 + 0, 10000 + 0, 10000 + 0,   
    10000 + 5 * 60, 10000 + 4 * 60,    
    10000 + 6 * 60, 10000 + 5 * 60,    
    10000 + 7 * 60, 10000 + 6 * 60,    
    10000 + 8 * 60, 10000 + 7 * 60     
}

Definition at line 500 of file jsdate.c.

const char* wtb[] [static]
Initial value:
 {
    "am", "pm",
    "monday", "tuesday", "wednesday", "thursday", "friday",
    "saturday", "sunday",
    "january", "february", "march", "april", "may", "june",
    "july", "august", "september", "october", "november", "december",
    "gmt", "ut", "utc",
    "est", "edt",
    "cst", "cdt",
    "mst", "mdt",
    "pst", "pdt"
    
}

Definition at line 486 of file jsdate.c.

jsint yearStartingWith[2][7] [static]
Initial value:
 {
    {1978, 1973, 1974, 1975, 1981, 1971, 1977},
    {1984, 1996, 1980, 1992, 1976, 1988, 1972}
}

Definition at line 349 of file jsdate.c.