Package org.mozilla.javascript
Class NativeDate
- java.lang.Object
-
- org.mozilla.javascript.ScriptableObject
-
- org.mozilla.javascript.IdScriptableObject
-
- org.mozilla.javascript.NativeDate
-
- All Implemented Interfaces:
java.io.Serializable
,ConstProperties
,DebuggableObject
,IdFunctionCall
,Scriptable
,SymbolScriptable
final class NativeDate extends IdScriptableObject
This class implements the Date native object. See ECMA 15.9.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.mozilla.javascript.ScriptableObject
ScriptableObject.GetterSlot, ScriptableObject.KeyComparator, ScriptableObject.Slot, ScriptableObject.SlotAccess
-
-
Field Summary
Fields Modifier and Type Field Description private static int
ConstructorId_now
private static int
ConstructorId_parse
private static int
ConstructorId_UTC
private double
date
private static java.lang.Object
DATE_TAG
private static double
HalfTimeDomain
private static double
HoursPerDay
private static int
Id_constructor
private static int
Id_getDate
private static int
Id_getDay
private static int
Id_getFullYear
private static int
Id_getHours
private static int
Id_getMilliseconds
private static int
Id_getMinutes
private static int
Id_getMonth
private static int
Id_getSeconds
private static int
Id_getTime
private static int
Id_getTimezoneOffset
private static int
Id_getUTCDate
private static int
Id_getUTCDay
private static int
Id_getUTCFullYear
private static int
Id_getUTCHours
private static int
Id_getUTCMilliseconds
private static int
Id_getUTCMinutes
private static int
Id_getUTCMonth
private static int
Id_getUTCSeconds
private static int
Id_getYear
private static int
Id_setDate
private static int
Id_setFullYear
private static int
Id_setHours
private static int
Id_setMilliseconds
private static int
Id_setMinutes
private static int
Id_setMonth
private static int
Id_setSeconds
private static int
Id_setTime
private static int
Id_setUTCDate
private static int
Id_setUTCFullYear
private static int
Id_setUTCHours
private static int
Id_setUTCMilliseconds
private static int
Id_setUTCMinutes
private static int
Id_setUTCMonth
private static int
Id_setUTCSeconds
private static int
Id_setYear
private static int
Id_toDateString
private static int
Id_toGMTString
private static int
Id_toISOString
private static int
Id_toJSON
private static int
Id_toLocaleDateString
private static int
Id_toLocaleString
private static int
Id_toLocaleTimeString
private static int
Id_toSource
private static int
Id_toString
private static int
Id_toTimeString
private static int
Id_toUTCString
private static int
Id_valueOf
private static java.lang.String
js_NaN_date_str
private static java.text.DateFormat
localeDateFormatter
private static java.text.DateFormat
localeDateTimeFormatter
private static java.text.DateFormat
localeTimeFormatter
private static double
LocalTZA
private static int
MAX_PROTOTYPE_ID
private static int
MAXARGS
private static double
MinutesPerDay
private static double
MinutesPerHour
private static double
msPerDay
private static double
msPerHour
private static double
msPerMinute
private static double
msPerSecond
private static double
SecondsPerDay
private static double
SecondsPerHour
private static double
SecondsPerMinute
private static long
serialVersionUID
private static java.util.TimeZone
thisTimeZone
private static java.text.DateFormat
timeZoneFormatter
-
Fields inherited from class org.mozilla.javascript.ScriptableObject
CONST, DONTENUM, EMPTY, PERMANENT, READONLY, UNINITIALIZED_CONST
-
Fields inherited from interface org.mozilla.javascript.Scriptable
NOT_FOUND
-
-
Constructor Summary
Constructors Modifier Constructor Description private
NativeDate()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static void
append0PaddedUint(java.lang.StringBuilder sb, int i, int minWidth)
private static void
appendMonthName(java.lang.StringBuilder sb, int index)
private static void
appendWeekDayName(java.lang.StringBuilder sb, int index)
private static java.lang.String
date_format(double t, int methodId)
private static double
date_msecFromArgs(java.lang.Object[] args)
private static double
date_msecFromDate(double year, double mon, double mday, double hour, double min, double sec, double msec)
private static double
date_parseString(java.lang.String s)
private static int
DateFromTime(double t)
private static double
Day(double t)
private static double
DayFromMonth(int m, int year)
private static double
DayFromYear(double y)
private static double
DaylightSavingTA(double t)
private static int
DaysInMonth(int year, int month)
private static double
DaysInYear(double year)
private static int
EquivalentYear(int year)
java.lang.Object
execIdCall(IdFunctionObject f, Context cx, Scriptable scope, Scriptable thisObj, java.lang.Object[] args)
'thisObj' will be null if invoked as constructor, in which case instance of Scriptable should be returned.protected void
fillConstructorProperties(IdFunctionObject ctor)
protected int
findPrototypeId(java.lang.String s)
java.lang.String
getClassName()
Return the name of the class.java.lang.Object
getDefaultValue(java.lang.Class<?> typeHint)
Implements the [[DefaultValue]] internal method.(package private) double
getJSTimeValue()
private static int
HourFromTime(double t)
(package private) static void
init(Scriptable scope, boolean sealed)
protected void
initPrototypeId(int id)
private static double
internalUTC(double t)
private static boolean
IsLeapYear(int year)
private static java.lang.String
js_toISOString(double t)
private static java.lang.String
js_toUTCString(double date)
private static java.lang.Object
jsConstructor(java.lang.Object[] args)
private static double
jsStaticFunction_UTC(java.lang.Object[] args)
private static double
LocalTime(double t)
private static double
makeDate(double date, java.lang.Object[] args, int methodId)
private static double
MakeDate(double day, double time)
private static double
MakeDay(double year, double month, double date)
private static double
makeTime(double date, java.lang.Object[] args, int methodId)
private static double
MakeTime(double hour, double min, double sec, double ms)
private static int
MinFromTime(double t)
private static int
MonthFromTime(double t)
private static int
msFromTime(double t)
private static double
now()
private static double
parseISOString(java.lang.String s)
15.9.1.15 Date Time String Format
Parse input string according to simplified ISO-8601 Extended Format:YYYY-MM-DD'T'HH:mm:ss.sss'Z'
orYYYY-MM-DD'T'HH:mm:ss.sss[+-]hh:mm
private static int
SecFromTime(double t)
private static double
TimeClip(double d)
private static double
TimeFromYear(double y)
private static double
TimeWithinDay(double t)
private static java.lang.String
toLocale_helper(double t, int methodId)
private static int
WeekDay(double t)
private static int
YearFromTime(double t)
-
Methods inherited from class org.mozilla.javascript.IdScriptableObject
activatePrototypeMap, addIdFunctionProperty, defaultGet, defaultHas, defaultPut, defineOwnProperty, delete, delete, exportAsJSClass, findInstanceIdInfo, findInstanceIdInfo, findPrototypeId, get, get, getAttributes, getAttributes, getIds, getInstanceIdName, getInstanceIdValue, getMaxInstanceId, getOwnPropertyDescriptor, has, has, hasPrototypeMap, incompatibleCallError, initPrototypeConstructor, initPrototypeMethod, initPrototypeMethod, initPrototypeMethod, initPrototypeValue, initPrototypeValue, instanceIdInfo, put, put, setAttributes, setInstanceIdAttributes, setInstanceIdValue
-
Methods inherited from class org.mozilla.javascript.ScriptableObject
addLazilyInitializedValue, applyDescriptorToAttributeBitset, associateValue, avoidObjectDetection, buildClassCtor, buildDataDescriptor, callMethod, callMethod, checkPropertyChange, checkPropertyDefinition, checkValidAttributes, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineOwnProperties, defineOwnProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, delete, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, ensureSymbolScriptable, equivalentValues, get, get, getAllIds, getArrayPrototype, getAssociatedValue, getAttributes, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGeneratorFunctionPrototype, getGetterOrSetter, getIds, getObjectPrototype, getParentScope, getProperty, getProperty, getProperty, getPropertyIds, getPrototype, getSlot, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, has, hasInstance, hasProperty, hasProperty, hasProperty, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGetterOrSetter, isSealed, isTrue, preventExtensions, put, putConst, putConstProperty, putProperty, putProperty, putProperty, redefineProperty, sameValue, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setExternalArrayData, setGetterOrSetter, setParentScope, setPrototype, size
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
DATE_TAG
private static final java.lang.Object DATE_TAG
-
js_NaN_date_str
private static final java.lang.String js_NaN_date_str
- See Also:
- Constant Field Values
-
HalfTimeDomain
private static final double HalfTimeDomain
- See Also:
- Constant Field Values
-
HoursPerDay
private static final double HoursPerDay
- See Also:
- Constant Field Values
-
MinutesPerHour
private static final double MinutesPerHour
- See Also:
- Constant Field Values
-
SecondsPerMinute
private static final double SecondsPerMinute
- See Also:
- Constant Field Values
-
msPerSecond
private static final double msPerSecond
- See Also:
- Constant Field Values
-
MinutesPerDay
private static final double MinutesPerDay
- See Also:
- Constant Field Values
-
SecondsPerDay
private static final double SecondsPerDay
- See Also:
- Constant Field Values
-
SecondsPerHour
private static final double SecondsPerHour
- See Also:
- Constant Field Values
-
msPerDay
private static final double msPerDay
- See Also:
- Constant Field Values
-
msPerHour
private static final double msPerHour
- See Also:
- Constant Field Values
-
msPerMinute
private static final double msPerMinute
- See Also:
- Constant Field Values
-
MAXARGS
private static final int MAXARGS
- See Also:
- Constant Field Values
-
ConstructorId_now
private static final int ConstructorId_now
- See Also:
- Constant Field Values
-
ConstructorId_parse
private static final int ConstructorId_parse
- See Also:
- Constant Field Values
-
ConstructorId_UTC
private static final int ConstructorId_UTC
- See Also:
- Constant Field Values
-
Id_constructor
private static final int Id_constructor
- See Also:
- Constant Field Values
-
Id_toString
private static final int Id_toString
- See Also:
- Constant Field Values
-
Id_toTimeString
private static final int Id_toTimeString
- See Also:
- Constant Field Values
-
Id_toDateString
private static final int Id_toDateString
- See Also:
- Constant Field Values
-
Id_toLocaleString
private static final int Id_toLocaleString
- See Also:
- Constant Field Values
-
Id_toLocaleTimeString
private static final int Id_toLocaleTimeString
- See Also:
- Constant Field Values
-
Id_toLocaleDateString
private static final int Id_toLocaleDateString
- See Also:
- Constant Field Values
-
Id_toUTCString
private static final int Id_toUTCString
- See Also:
- Constant Field Values
-
Id_toSource
private static final int Id_toSource
- See Also:
- Constant Field Values
-
Id_valueOf
private static final int Id_valueOf
- See Also:
- Constant Field Values
-
Id_getTime
private static final int Id_getTime
- See Also:
- Constant Field Values
-
Id_getYear
private static final int Id_getYear
- See Also:
- Constant Field Values
-
Id_getFullYear
private static final int Id_getFullYear
- See Also:
- Constant Field Values
-
Id_getUTCFullYear
private static final int Id_getUTCFullYear
- See Also:
- Constant Field Values
-
Id_getMonth
private static final int Id_getMonth
- See Also:
- Constant Field Values
-
Id_getUTCMonth
private static final int Id_getUTCMonth
- See Also:
- Constant Field Values
-
Id_getDate
private static final int Id_getDate
- See Also:
- Constant Field Values
-
Id_getUTCDate
private static final int Id_getUTCDate
- See Also:
- Constant Field Values
-
Id_getDay
private static final int Id_getDay
- See Also:
- Constant Field Values
-
Id_getUTCDay
private static final int Id_getUTCDay
- See Also:
- Constant Field Values
-
Id_getHours
private static final int Id_getHours
- See Also:
- Constant Field Values
-
Id_getUTCHours
private static final int Id_getUTCHours
- See Also:
- Constant Field Values
-
Id_getMinutes
private static final int Id_getMinutes
- See Also:
- Constant Field Values
-
Id_getUTCMinutes
private static final int Id_getUTCMinutes
- See Also:
- Constant Field Values
-
Id_getSeconds
private static final int Id_getSeconds
- See Also:
- Constant Field Values
-
Id_getUTCSeconds
private static final int Id_getUTCSeconds
- See Also:
- Constant Field Values
-
Id_getMilliseconds
private static final int Id_getMilliseconds
- See Also:
- Constant Field Values
-
Id_getUTCMilliseconds
private static final int Id_getUTCMilliseconds
- See Also:
- Constant Field Values
-
Id_getTimezoneOffset
private static final int Id_getTimezoneOffset
- See Also:
- Constant Field Values
-
Id_setTime
private static final int Id_setTime
- See Also:
- Constant Field Values
-
Id_setMilliseconds
private static final int Id_setMilliseconds
- See Also:
- Constant Field Values
-
Id_setUTCMilliseconds
private static final int Id_setUTCMilliseconds
- See Also:
- Constant Field Values
-
Id_setSeconds
private static final int Id_setSeconds
- See Also:
- Constant Field Values
-
Id_setUTCSeconds
private static final int Id_setUTCSeconds
- See Also:
- Constant Field Values
-
Id_setMinutes
private static final int Id_setMinutes
- See Also:
- Constant Field Values
-
Id_setUTCMinutes
private static final int Id_setUTCMinutes
- See Also:
- Constant Field Values
-
Id_setHours
private static final int Id_setHours
- See Also:
- Constant Field Values
-
Id_setUTCHours
private static final int Id_setUTCHours
- See Also:
- Constant Field Values
-
Id_setDate
private static final int Id_setDate
- See Also:
- Constant Field Values
-
Id_setUTCDate
private static final int Id_setUTCDate
- See Also:
- Constant Field Values
-
Id_setMonth
private static final int Id_setMonth
- See Also:
- Constant Field Values
-
Id_setUTCMonth
private static final int Id_setUTCMonth
- See Also:
- Constant Field Values
-
Id_setFullYear
private static final int Id_setFullYear
- See Also:
- Constant Field Values
-
Id_setUTCFullYear
private static final int Id_setUTCFullYear
- See Also:
- Constant Field Values
-
Id_setYear
private static final int Id_setYear
- See Also:
- Constant Field Values
-
Id_toISOString
private static final int Id_toISOString
- See Also:
- Constant Field Values
-
Id_toJSON
private static final int Id_toJSON
- See Also:
- Constant Field Values
-
MAX_PROTOTYPE_ID
private static final int MAX_PROTOTYPE_ID
- See Also:
- Constant Field Values
-
Id_toGMTString
private static final int Id_toGMTString
- See Also:
- Constant Field Values
-
thisTimeZone
private static final java.util.TimeZone thisTimeZone
-
LocalTZA
private static final double LocalTZA
-
timeZoneFormatter
private static final java.text.DateFormat timeZoneFormatter
-
localeDateTimeFormatter
private static final java.text.DateFormat localeDateTimeFormatter
-
localeDateFormatter
private static final java.text.DateFormat localeDateFormatter
-
localeTimeFormatter
private static final java.text.DateFormat localeTimeFormatter
-
date
private double date
-
-
Method Detail
-
init
static void init(Scriptable scope, boolean sealed)
-
getClassName
public java.lang.String getClassName()
Description copied from class:ScriptableObject
Return the name of the class. This is typically the same name as the constructor. Classes extending ScriptableObject must implement this abstract method.- Specified by:
getClassName
in interfaceScriptable
- Specified by:
getClassName
in classScriptableObject
-
getDefaultValue
public java.lang.Object getDefaultValue(java.lang.Class<?> typeHint)
Description copied from class:ScriptableObject
Implements the [[DefaultValue]] internal method.Note that the toPrimitive conversion is a no-op for every type other than Object, for which [[DefaultValue]] is called. See ECMA 9.1.
A
hint
of null means "no hint".- Specified by:
getDefaultValue
in interfaceScriptable
- Overrides:
getDefaultValue
in classScriptableObject
- Parameters:
typeHint
- the type hint- Returns:
- the default value for the object See ECMA 8.6.2.6.
-
getJSTimeValue
double getJSTimeValue()
-
fillConstructorProperties
protected void fillConstructorProperties(IdFunctionObject ctor)
- Overrides:
fillConstructorProperties
in classIdScriptableObject
-
initPrototypeId
protected void initPrototypeId(int id)
- Overrides:
initPrototypeId
in classIdScriptableObject
-
execIdCall
public java.lang.Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope, Scriptable thisObj, java.lang.Object[] args)
Description copied from class:IdScriptableObject
'thisObj' will be null if invoked as constructor, in which case instance of Scriptable should be returned.- Specified by:
execIdCall
in interfaceIdFunctionCall
- Overrides:
execIdCall
in classIdScriptableObject
-
Day
private static double Day(double t)
-
TimeWithinDay
private static double TimeWithinDay(double t)
-
IsLeapYear
private static boolean IsLeapYear(int year)
-
DayFromYear
private static double DayFromYear(double y)
-
TimeFromYear
private static double TimeFromYear(double y)
-
YearFromTime
private static int YearFromTime(double t)
-
DayFromMonth
private static double DayFromMonth(int m, int year)
-
DaysInYear
private static double DaysInYear(double year)
-
DaysInMonth
private static int DaysInMonth(int year, int month)
-
MonthFromTime
private static int MonthFromTime(double t)
-
DateFromTime
private static int DateFromTime(double t)
-
WeekDay
private static int WeekDay(double t)
-
now
private static double now()
-
DaylightSavingTA
private static double DaylightSavingTA(double t)
-
EquivalentYear
private static int EquivalentYear(int year)
-
LocalTime
private static double LocalTime(double t)
-
internalUTC
private static double internalUTC(double t)
-
HourFromTime
private static int HourFromTime(double t)
-
MinFromTime
private static int MinFromTime(double t)
-
SecFromTime
private static int SecFromTime(double t)
-
msFromTime
private static int msFromTime(double t)
-
MakeTime
private static double MakeTime(double hour, double min, double sec, double ms)
-
MakeDay
private static double MakeDay(double year, double month, double date)
-
MakeDate
private static double MakeDate(double day, double time)
-
TimeClip
private static double TimeClip(double d)
-
date_msecFromDate
private static double date_msecFromDate(double year, double mon, double mday, double hour, double min, double sec, double msec)
-
date_msecFromArgs
private static double date_msecFromArgs(java.lang.Object[] args)
-
jsStaticFunction_UTC
private static double jsStaticFunction_UTC(java.lang.Object[] args)
-
parseISOString
private static double parseISOString(java.lang.String s)
15.9.1.15 Date Time String Format
Parse input string according to simplified ISO-8601 Extended Format:YYYY-MM-DD'T'HH:mm:ss.sss'Z'
- or
YYYY-MM-DD'T'HH:mm:ss.sss[+-]hh:mm
-
date_parseString
private static double date_parseString(java.lang.String s)
-
date_format
private static java.lang.String date_format(double t, int methodId)
-
jsConstructor
private static java.lang.Object jsConstructor(java.lang.Object[] args)
-
toLocale_helper
private static java.lang.String toLocale_helper(double t, int methodId)
-
js_toUTCString
private static java.lang.String js_toUTCString(double date)
-
js_toISOString
private static java.lang.String js_toISOString(double t)
-
append0PaddedUint
private static void append0PaddedUint(java.lang.StringBuilder sb, int i, int minWidth)
-
appendMonthName
private static void appendMonthName(java.lang.StringBuilder sb, int index)
-
appendWeekDayName
private static void appendWeekDayName(java.lang.StringBuilder sb, int index)
-
makeTime
private static double makeTime(double date, java.lang.Object[] args, int methodId)
-
makeDate
private static double makeDate(double date, java.lang.Object[] args, int methodId)
-
findPrototypeId
protected int findPrototypeId(java.lang.String s)
- Overrides:
findPrototypeId
in classIdScriptableObject
-
-