Export (0) Print
Expand All
Expand Minimize

2.1.43 [ECMA-262/5] Section 15.9.5.5, Date.prototype.toLocaleString ()

C0004:

The specification states:

This function returns a String value. The contents of the String are implementation-dependent, but are intended to represent the Date in the current time zone in a convenient, human-readable form that corresponds to the conventions of the host environment’s current locale.

IE9 Mode, IE10 Mode, and IE11 Mode (All Versions)

The returned String value is determined from the following steps:

  1. Using the system locale settings, get the local time value that corresponds to the date value. Apply any appropriate civil time adjustments.

  2. If the year of Result(1) is less than or equal 1600 or is greater than or equal to 10000, return the result of calling the standard built-in Date.prototype.toString method with Result(1) as its this object.

  3. Use the GetDateFormat Microsoft Windows system function (http://msdn.microsoft.com/en-us/library/dd318086(VS.85).aspx), to format the date and time that correspond to Result(1). Pass the default value of DATE_LONGDATE for format flags. However, if the current locale’s language is Arabic or Hebrew, pass the value DATE_LONGDATE | Date_RTLREADING for format flags.

  4. If the call in step 3 fails and the current locale language is Hebrew, throw a RangeError exception.

  5. Use the GetTimeFormat Windows system function (http://msdn.microsoft.com/en-us/library/dd318130(VS.85).aspx) to format the date and time that correspond to Result(1). Pass the default value of zero for format flags.

  6. If the calls in steps 3 or 5 fail, return the result of calling the standard built-in Date.prototype.toString method with Result(1) as its this object.

  7. Return the string value that is the result of concatenating Result(3), a space character, and Result(5).

Show:
© 2014 Microsoft