Multipage preference

21 Numbers and Dates

21.1 Number Objects

21.1.1 The Number Constructor

Number constructor는:

  • %Number%입니다.
  • global object"Number" property의 initial value입니다.
  • constructor로 called될 때 new Number object를 create하고 initialize합니다.
  • constructor가 아니라 function으로 called될 때 type conversion을 수행합니다.
  • class definition의 extends clause의 value로 사용될 수 있습니다. specified Number behaviour를 inherit하려는 subclass constructor[[NumberData]] internal slot을 가진 subclass instance를 create하고 initialize하기 위해 Number constructor에 대한 super call을 include해야 합니다.

21.1.1.1 Number ( value )

이 function은 called될 때 다음 step을 수행합니다:

  1. value가 present이면, 다음을 수행한다.
    1. primitive를 ? ToNumeric(value)로 둔다.
    2. primitive가 BigInt이면, n𝔽((primitive))로 둔다.
    3. 그렇지 않으면, nprimitive로 둔다.
  2. 그렇지 않으면,
    1. n+0𝔽로 둔다.
  3. NewTarget이 undefined이면, n을 반환한다.
  4. obj를 ? OrdinaryCreateFromConstructor(NewTarget, "%Number.prototype%", « [[NumberData]] »)로 둔다.
  5. obj.[[NumberData]]n으로 설정한다.
  6. obj를 반환한다.

21.1.2 Properties of the Number Constructor

Number constructor는:

  • value가 %Function.prototype%[[Prototype]] internal slot을 가집니다.
  • 다음 property를 가집니다:

21.1.2.1 Number.EPSILON

Number.EPSILON의 value는 Number value로 represent 가능한 1보다 큰 smallest value와 1 사이의 difference의 magnitude에 대한 Number value이며, 이는 approximately 2.2204460492503130808472633361816 × 10-16입니다.

이 property는 attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }를 가집니다.

21.1.2.2 Number.isFinite ( number )

이 function은 called될 때 다음 step을 수행합니다:

  1. number가 Number가 아니면, false를 반환한다.
  2. numberfinite가 아니면, false를 반환한다.
  3. true를 반환한다.

21.1.2.3 Number.isInteger ( number )

이 function은 called될 때 다음 step을 수행합니다:

  1. numberintegral Number이면, true를 반환한다.
  2. false를 반환한다.

21.1.2.4 Number.isNaN ( number )

이 function은 called될 때 다음 step을 수행합니다:

  1. number가 Number가 아니면, false를 반환한다.
  2. numberNaN이면, true를 반환한다.
  3. false를 반환한다.
Note

이 function은 argument가 NaN인지 determine하기 전에 Number로 convert하지 않는다는 점에서 global isNaN function(19.2.3)과 다릅니다.

21.1.2.5 Number.isSafeInteger ( number )

Note

integer nn에 대한 Number value가 any other integer에 대한 Number value가 아닌 경우에만 “safe integer”입니다.

이 function은 called될 때 다음 step을 수행합니다:

  1. numberintegral Number이면, 다음을 수행한다.
    1. abs((number)) ≤ 253 - 1이면, true를 반환한다.
  2. false를 반환한다.

21.1.2.6 Number.MAX_SAFE_INTEGER

Note

IEEE 754-2019의 precision limitation 때문에 necessary한 rounding behaviour로 인해, Number.MAX_SAFE_INTEGER보다 큰 every integer에 대한 Number value는 at least one other integer와 shared됩니다. 따라서 such large-magnitude integersafe하지 않으며, Number value로 exactly represent 가능하거나 서로 distinguish 가능하다고 guaranteed되지 않습니다. 예를 들어, 90071992547409929007199254740993 둘 다 Number value 9007199254740992𝔽로 evaluate됩니다.

Number.MAX_SAFE_INTEGER의 value는 9007199254740991𝔽 (𝔽(253 - 1))입니다.

이 property는 attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }를 가집니다.

21.1.2.7 Number.MAX_VALUE

Number.MAX_VALUE의 value는 Number type의 largest positive finite value이며, 이는 approximately 1.7976931348623157 × 10308입니다.

이 property는 attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }를 가집니다.

21.1.2.8 Number.MIN_SAFE_INTEGER

Note

IEEE 754-2019의 precision limitation 때문에 necessary한 rounding behaviour로 인해, Number.MIN_SAFE_INTEGER보다 작은 every integer에 대한 Number value는 at least one other integer와 shared됩니다. 따라서 such large-magnitude integersafe하지 않으며, Number value로 exactly represent 가능하거나 서로 distinguish 가능하다고 guaranteed되지 않습니다. 예를 들어, -9007199254740992-9007199254740993 둘 다 Number value -9007199254740992𝔽로 evaluate됩니다.

Number.MIN_SAFE_INTEGER의 value는 -9007199254740991𝔽 (𝔽(-(253 - 1)))입니다.

이 property는 attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }를 가집니다.

21.1.2.9 Number.MIN_VALUE

Number.MIN_VALUE의 value는 Number type의 smallest positive value이며, 이는 approximately 5 × 10-324입니다.

IEEE 754-2019 double precision binary representation에서, smallest possible value는 denormalized number입니다. implementation이 denormalized value를 support하지 않으면, Number.MIN_VALUE의 value는 implementation에 의해 actually represented될 수 있는 smallest non-zero positive value여야 합니다.

이 property는 attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }를 가집니다.

21.1.2.10 Number.NaN

Number.NaN의 value는 NaN입니다.

이 property는 attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }를 가집니다.

21.1.2.11 Number.NEGATIVE_INFINITY

Number.NEGATIVE_INFINITY의 value는 -∞𝔽입니다.

이 property는 attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }를 가집니다.

21.1.2.12 Number.parseFloat ( string )

"parseFloat" property의 initial value는 %parseFloat%입니다.

21.1.2.13 Number.parseInt ( string, radix )

"parseInt" property의 initial value는 %parseInt%입니다.

21.1.2.14 Number.POSITIVE_INFINITY

Number.POSITIVE_INFINITY의 value는 +∞𝔽입니다.

이 property는 attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }를 가집니다.

21.1.2.15 Number.prototype

Number.prototype의 initial value는 Number prototype object입니다.

이 property는 attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }를 가집니다.

21.1.3 Properties of the Number Prototype Object

Number prototype object는:

  • %Number.prototype%입니다.
  • ordinary object입니다.
  • itself가 Number object입니다; value가 +0𝔽[[NumberData]] internal slot을 가집니다.
  • value가 %Object.prototype%[[Prototype]] internal slot을 가집니다.

explicitly 달리 stated되지 않는 한, 아래에 defined된 Number prototype object의 method는 generic하지 않고, 이들에게 passed되는 this value는 Number value이거나 Number value로 initialized된 [[NumberData]] internal slot을 가진 object여야 합니다.

method specification 안의 phrase “this Number value”는 method invocation의 this value를 argument로 pass하여 abstract operation ThisNumberValue를 calling한 result를 refer합니다.

21.1.3.1 Number.prototype.constructor

Number.prototype.constructor의 initial value는 %Number%입니다.

21.1.3.2 Number.prototype.toExponential ( fractionDigits )

이 method는 significand의 decimal point 앞에 one digit, significand의 decimal point 뒤에 fractionDigits digits를 가진 decimal exponential notation으로 represented된 this Number value를 contain하는 String을 반환합니다. fractionDigitsundefined이면, Number를 uniquely specify하는 데 necessary한 만큼의 significand digit을 include합니다(ToString에서와 같지만, 이 경우 Number는 always exponential notation으로 output됩니다).

called될 때 다음 step을 수행합니다:

  1. number를 ? ThisNumberValue(this value)로 둔다.
  2. fractionCount를 ? ToIntegerOrInfinity(fractionDigits)로 둔다.
  3. Assert: fractionDigitsundefined이면, fractionCount는 0이다.
  4. numberfinite가 아니면, Number::toString(number, 10)을 반환한다.
  5. fractionCount < 0 또는 fractionCount > 100이면, RangeError exception을 throw한다.
  6. number(number)로 설정한다.
  7. sign을 empty String으로 둔다.
  8. number < 0이면, 다음을 수행한다.
    1. sign"-"로 설정한다.
    2. number를 -number로 설정한다.
  9. number = 0이면, 다음을 수행한다.
    1. significand를 code unit 0x0030 (DIGIT ZERO)가 fractionCount + 1번 occurrence하는 것으로 구성된 String value로 둔다.
    2. exponent를 0으로 둔다.
  10. 그렇지 않으면,
    1. fractionDigitsundefined가 아니면, 다음을 수행한다.
      1. exponentintSignificand를 10fractionCountintSignificand < 10fractionCount + 1이고 intSignificand × 10exponent - fractionCount - number가 가능한 한 zero에 close한 integers로 둔다. such exponentintSignificand의 set이 two이면, intSignificand × 10exponent - fractionCount가 larger인 exponentintSignificand를 pick한다.
    2. 그렇지 않으면,
      1. exponent, intSignificand, 및 ffff ≥ 0, 10ffintSignificand < 10ff + 1, 𝔽(intSignificand × 10exponent - ff) is 𝔽(number), 그리고 ff가 가능한 한 small인 integers로 둔다. intSignificand의 decimal representation은 ff + 1 digits를 가지고, intSignificand는 10으로 divisible하지 않으며, intSignificand의 least significant digit이 these criteria에 의해 necessarily uniquely determined되는 것은 아님에 note한다.
      2. fractionCountff로 설정한다.
    3. significandintSignificand의 decimal representation의 digits로 구성된 String value로 둔다(in order, with no leading zeroes).
  11. fractionCount ≠ 0이면, 다음을 수행한다.
    1. intPartsignificand의 first code unit으로 둔다.
    2. fractionalPartsignificand의 other fractionCount code unit으로 둔다.
    3. significandintPart, ".", 및 fractionalPartstring-concatenation으로 설정한다.
  12. exponent = 0이면, 다음을 수행한다.
    1. exponentSign"+"로 둔다.
    2. exponentDigits"0"으로 둔다.
  13. 그렇지 않으면,
    1. exponent > 0이면, 다음을 수행한다.
      1. exponentSign"+"로 둔다.
    2. 그렇지 않으면,
      1. Assert: exponent < 0이다.
      2. exponentSign"-"로 둔다.
      3. exponent를 -exponent로 설정한다.
    3. exponentDigitsexponent의 decimal representation의 digits로 구성된 String value로 둔다(in order, with no leading zeroes).
  14. significandsignificand, "e", exponentSign, 및 exponentDigitsstring-concatenation으로 설정한다.
  15. signsignificandstring-concatenation을 반환한다.
Note

above rules에 의해 required되는 것보다 more accurate conversion을 provide하는 implementation의 경우, step 10.b.i의 다음 alternative version을 guideline으로 사용할 것이 recommended됩니다:

  1. exponent, intSignificand, 및 ffff ≥ 0, 10ffintSignificand < 10ff + 1, 𝔽(intSignificand × 10exponent - ff) is 𝔽(number), 그리고 ff가 가능한 한 small인 integers로 둔다. intSignificand에 대해 multiple possibility가 있으면, 𝔽(intSignificand × 10exponent - ff)가 𝔽(number)에 closest한 intSignificand를 choose한다. such possible value of intSignificand가 two이면, even인 것을 choose한다.

21.1.3.3 Number.prototype.toFixed ( fractionDigits )

Note 1

이 method는 decimal point 뒤에 fractionDigits digits를 가진 decimal fixed-point notation으로 represented된 this Number value를 contain하는 String을 반환합니다. fractionDigitsundefined이면, 0이 assumed됩니다.

called될 때 다음 step을 수행합니다:

  1. number를 ? ThisNumberValue(this value)로 둔다.
  2. fractionCount를 ? ToIntegerOrInfinity(fractionDigits)로 둔다.
  3. Assert: fractionDigitsundefined이면, fractionCount는 0이다.
  4. fractionCountfinite가 아니면, RangeError exception을 throw한다.
  5. fractionCount < 0 또는 fractionCount > 100이면, RangeError exception을 throw한다.
  6. numberfinite가 아니면, Number::toString(number, 10)을 반환한다.
  7. number(number)로 설정한다.
  8. sign을 empty String으로 둔다.
  9. number < 0이면, 다음을 수행한다.
    1. sign"-"로 설정한다.
    2. number를 -number로 설정한다.
  10. number ≥ 1021이면, 다음을 수행한다.
    1. digitString을 ! ToString(𝔽(number))으로 둔다.
  11. 그렇지 않으면,
    1. intValueintValue / 10fractionCount - number가 가능한 한 zero에 close한 integer로 둔다. such intValue가 two이면, larger intValue를 pick한다.
    2. intValue = 0이면, digitString"0"으로 둔다; 그렇지 않으면 digitStringintValue의 decimal representation의 digits로 구성된 String value로 둔다(in order, with no leading zeroes).
    3. fractionCount ≠ 0이면, 다음을 수행한다.
      1. digitCountdigitString의 length로 둔다.
      2. digitCountfractionCount이면, 다음을 수행한다.
        1. zeroPad를 code unit 0x0030 (DIGIT ZERO)가 fractionCount + 1 - digitCount번 occurrence하는 것으로 구성된 String value로 둔다.
        2. digitStringzeroPaddigitStringstring-concatenation으로 설정한다.
        3. digitCountfractionCount + 1로 설정한다.
      3. intPartdigitString의 first digitCount - fractionCount code units로 둔다.
      4. fractionalPartdigitString의 other fractionCount code units로 둔다.
      5. digitStringintPart, ".", 및 fractionalPartstring-concatenation으로 설정한다.
  12. signdigitStringstring-concatenation을 반환한다.
Note 2

toString은 adjacent Number value와 number를 distinguish하기에 enough significant digits만 print하므로, some value에 대해 toFixed의 output은 toString보다 more precise할 수 있습니다. 예를 들어,

(1000000000000000128).toString()"1000000000000000100"을 반환하는 반면,
(1000000000000000128).toFixed(0)"1000000000000000128"을 반환합니다.

21.1.3.4 Number.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] )

ECMA-402 Internationalization API를 include하는 ECMAScript implementation은 ECMA-402 specification에 specified된 대로 이 method를 implement해야 합니다. ECMAScript implementation이 ECMA-402 API를 include하지 않으면 이 method의 다음 specification이 사용됩니다:

이 method는 host environment의 current locale의 convention에 따라 formatted된 this Number value를 represent하는 String value를 produce합니다. 이 method는 implementation-defined이며, toString과 same thing을 return하는 것이 permissible하지만 encouraged되지는 않습니다.

이 method의 optional parameter의 meaning은 ECMA-402 specification에 defined되어 있습니다; ECMA-402 support를 include하지 않는 implementation은 those parameter position을 anything else에 사용해서는 안 됩니다.

21.1.3.5 Number.prototype.toPrecision ( precision )

이 method는 significand의 decimal point 앞에 one digit, significand의 decimal point 뒤에 precision - 1 digits를 가진 decimal exponential notation 또는 precision significant digits를 가진 decimal fixed notation 중 하나로 represented된 this Number value를 contain하는 String을 반환합니다. precisionundefined이면, 대신 ToString을 call합니다.

called될 때 다음 step을 수행합니다:

  1. number를 ? ThisNumberValue(this value)로 둔다.
  2. precisionundefined이면, ! ToString(number)을 반환한다.
  3. precisionCount를 ? ToIntegerOrInfinity(precision)로 둔다.
  4. numberfinite가 아니면, Number::toString(number, 10)을 반환한다.
  5. precisionCount < 1 또는 precisionCount > 100이면, RangeError exception을 throw한다.
  6. number(number)로 설정한다.
  7. sign을 empty String으로 둔다.
  8. number < 0이면, 다음을 수행한다.
    1. sign을 code unit 0x002D (HYPHEN-MINUS)로 설정한다.
    2. number를 -number로 설정한다.
  9. number = 0이면, 다음을 수행한다.
    1. significand를 code unit 0x0030 (DIGIT ZERO)가 precisionCount번 occurrence하는 것으로 구성된 String value로 둔다.
    2. exponent를 0으로 둔다.
  10. 그렇지 않으면,
    1. exponentintSignificand를 10precisionCount - 1intSignificand < 10precisionCount이고 intSignificand × 10exponent - precisionCount + 1 - number가 가능한 한 zero에 close한 integers로 둔다. such exponentintSignificand의 set이 two이면, intSignificand × 10exponent - precisionCount + 1이 larger인 exponentintSignificand를 pick한다.
    2. significandintSignificand의 decimal representation의 digits로 구성된 String value로 둔다(in order, with no leading zeroes).
    3. exponent < -6 또는 exponentprecisionCount이면, 다음을 수행한다.
      1. Assert: exponent ≠ 0이다.
      2. precisionCount ≠ 1이면, 다음을 수행한다.
        1. intPartsignificand의 first code unit으로 둔다.
        2. fractionalPartsignificand의 other precisionCount - 1 code units로 둔다.
        3. significandintPart, ".", 및 fractionalPartstring-concatenation으로 설정한다.
      3. exponent > 0이면, 다음을 수행한다.
        1. exponentSign을 code unit 0x002B (PLUS SIGN)로 둔다.
      4. 그렇지 않으면,
        1. Assert: exponent < 0이다.
        2. exponentSign을 code unit 0x002D (HYPHEN-MINUS)로 둔다.
        3. exponent를 -exponent로 설정한다.
      5. exponentDigitsexponent의 decimal representation의 digits로 구성된 String value로 둔다(in order, with no leading zeroes).
      6. sign, significand, code unit 0x0065 (LATIN SMALL LETTER E), exponentSign, 및 exponentDigitsstring-concatenation을 반환한다.
  11. exponent = precisionCount - 1이면, signsignificandstring-concatenation을 반환한다.
  12. exponent ≥ 0이면, 다음을 수행한다.
    1. significandsignificand의 first exponent + 1 code units, code unit 0x002E (FULL STOP), 및 significand의 remaining precisionCount - (exponent + 1) code units의 string-concatenation으로 설정한다.
  13. 그렇지 않으면,
    1. significand를 code unit 0x0030 (DIGIT ZERO), code unit 0x002E (FULL STOP), code unit 0x0030 (DIGIT ZERO)의 -(exponent + 1) occurrences, 및 String significandstring-concatenation으로 설정한다.
  14. signsignificandstring-concatenation을 반환한다.

21.1.3.6 Number.prototype.toString ( [ radix ] )

Note

optional radix2𝔽부터 36𝔽까지의 inclusive interval 안에 있는 integral Number value여야 합니다. radixundefined이면 10𝔽radix의 value로 사용됩니다.

이 method는 called될 때 다음 step을 수행합니다:

  1. x를 ? ThisNumberValue(this 값)로 둔다.
  2. radixundefined이면 radixMV를 10으로 둔다.
  3. 그렇지 않으면 radixMV를 ? SnapToInteger(radix, truncate, 2, 36)로 둔다.
  4. Number::toString(x, radixMV)을 반환한다.

이 method는 generic하지 않습니다; this value가 Number 또는 Number object가 아니면 TypeError exception을 throw합니다. 따라서 method로 사용하기 위해 다른 kind의 object로 transferred될 수 없습니다.

이 method의 "length" property는 1𝔽입니다.

21.1.3.7 Number.prototype.valueOf ( )

  1. ThisNumberValue(this value)를 반환한다.

21.1.3.7.1 ThisNumberValue ( arg )

The abstract operation ThisNumberValue takes argument arg (an ECMAScript language value) and returns either a normal completion containing a Number or a throw completion. It performs the following steps when called:

  1. arg가 Number이면, arg를 반환한다.
  2. arg가 Object이고 arg[[NumberData]] internal slot을 가지면, 다음을 수행한다.
    1. numberarg.[[NumberData]]로 둔다.
    2. Assert: number는 Number이다.
    3. number를 반환한다.
  3. TypeError exception을 throw한다.

21.1.4 Properties of Number Instances

Number instance는 Number prototype object에서 property를 inherit하는 ordinary object입니다. Number instance는 또한 [[NumberData]] internal slot을 가집니다. [[NumberData]] internal slot은 이 Number object가 represented하는 Number value입니다.

21.2 BigInt Objects

21.2.1 The BigInt Constructor

BigInt constructor는:

  • %BigInt%입니다.
  • global object"BigInt" property의 initial value입니다.
  • constructor가 아니라 function으로 called될 때 type conversion을 수행합니다.
  • new operator와 함께 사용되거나 subclassed되도록 intended되지 않습니다. class definition의 extends clause의 value로 사용될 수 있지만 BigInt constructor에 대한 super call은 exception을 cause합니다.

21.2.1.1 BigInt ( value )

이 function은 called될 때 다음 step을 수행합니다:

  1. NewTarget이 undefined가 아니면, TypeError exception을 throw한다.
  2. primitive를 ? ToPrimitive(value, number)로 둔다.
  3. primitive가 Number이면, ? NumberToBigInt(primitive)를 반환한다.
  4. ToBigInt(primitive)를 반환한다.

21.2.1.1.1 NumberToBigInt ( number )

The abstract operation NumberToBigInt takes argument number (a Number) and returns either a normal completion containing a BigInt or a throw completion. It performs the following steps when called:

  1. numberintegral Number가 아니면, RangeError exception을 throw한다.
  2. ((number))를 반환한다.

21.2.2 Properties of the BigInt Constructor

BigInt constructor는:

  • value가 %Function.prototype%[[Prototype]] internal slot을 가집니다.
  • 다음 property를 가집니다:

21.2.2.1 BigInt.asIntN ( bits, bigint )

이 function은 called될 때 다음 step을 수행합니다:

  1. bits를 ? ToIndex(bits)로 설정한다.
  2. bigint를 ? ToBigInt(bigint)로 설정한다.
  3. remainder(bigint) modulo 2bits라고 하자.
  4. remainder ≥ 2bits - 1이면, (remainder - 2bits)를 반환한다.
  5. (remainder)를 반환한다.

21.2.2.2 BigInt.asUintN ( bits, bigint )

이 function은 called될 때 다음 step을 수행합니다:

  1. bits를 ? ToIndex(bits)로 설정한다.
  2. bigint를 ? ToBigInt(bigint)로 설정한다.
  3. ((bigint) modulo 2bits)를 반환한다.

21.2.2.3 BigInt.prototype

BigInt.prototype의 initial value는 BigInt prototype object입니다.

이 property는 attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }를 가집니다.

21.2.3 Properties of the BigInt Prototype Object

BigInt prototype object는:

  • %BigInt.prototype%입니다.
  • ordinary object입니다.
  • BigInt object가 아닙니다; [[BigIntData]] internal slot을 가지지 않습니다.
  • value가 %Object.prototype%[[Prototype]] internal slot을 가집니다.

method specification 안의 phrase “this BigInt value”는 method invocation의 this value를 argument로 pass하여 abstract operation ThisBigIntValue를 calling한 result를 refer합니다.

21.2.3.1 BigInt.prototype.constructor

BigInt.prototype.constructor의 initial value는 %BigInt%입니다.

21.2.3.2 BigInt.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] )

ECMA-402 Internationalization API를 include하는 ECMAScript implementation은 ECMA-402 specification에 specified된 대로 이 method를 implement해야 합니다. ECMAScript implementation이 ECMA-402 API를 include하지 않으면 이 method의 다음 specification이 사용됩니다:

이 method는 host environment의 current locale의 convention에 따라 formatted된 this BigInt value를 represent하는 String value를 produce합니다. 이 method는 implementation-defined이며, toString과 same thing을 return하는 것이 permissible하지만 encouraged되지는 않습니다.

이 method의 optional parameter의 meaning은 ECMA-402 specification에 defined되어 있습니다; ECMA-402 support를 include하지 않는 implementation은 those parameter position을 anything else에 사용해서는 안 됩니다.

21.2.3.3 BigInt.prototype.toString ( [ radix ] )

Note

optional radix2𝔽부터 36𝔽까지의 inclusive interval 안에 있는 integral Number value여야 합니다. radixundefined이면 10𝔽radix의 value로 사용됩니다.

이 method는 called될 때 다음 step을 수행합니다:

  1. x를 ? ThisBigIntValue(this 값)로 둔다.
  2. radixundefined이면 radixMV를 10으로 둔다.
  3. 그렇지 않으면 radixMV를 ? SnapToInteger(radix, truncate, 2, 36)로 둔다.
  4. BigInt::toString(x, radixMV)을 반환한다.

이 method는 generic하지 않습니다; this value가 BigInt 또는 BigInt object가 아니면 TypeError exception을 throw합니다. 따라서 method로 사용하기 위해 다른 kind의 object로 transferred될 수 없습니다.

21.2.3.4 BigInt.prototype.valueOf ( )

  1. ThisBigIntValue(this value)를 반환한다.

21.2.3.4.1 ThisBigIntValue ( arg )

The abstract operation ThisBigIntValue takes argument arg (an ECMAScript language value) and returns either a normal completion containing a BigInt or a throw completion. It performs the following steps when called:

  1. arg가 BigInt이면, arg를 반환한다.
  2. arg가 Object이고 arg[[BigIntData]] internal slot을 가지면, 다음을 수행한다.
    1. Assert: arg.[[BigIntData]]는 BigInt이다.
    2. arg.[[BigIntData]]를 반환한다.
  3. TypeError exception을 throw한다.

21.2.3.5 BigInt.prototype [ %Symbol.toStringTag% ]

%Symbol.toStringTag% property의 initial value는 String value "BigInt"입니다.

이 property는 attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }를 가집니다.

21.2.4 Properties of BigInt Instances

BigInt instance는 BigInt prototype object에서 property를 inherit하는 ordinary object입니다. BigInt instance는 또한 [[BigIntData]] internal slot을 가집니다. [[BigIntData]] internal slot은 이 BigInt object가 represented하는 BigInt value입니다.

21.3 The Math Object

Math object는:

  • %Math%입니다.
  • global object"Math" property의 initial value입니다.
  • ordinary object입니다.
  • value가 %Object.prototype%[[Prototype]] internal slot을 가집니다.
  • function object가 아닙니다.
  • [[Construct]] internal method를 가지지 않습니다; new operator와 함께 constructor로 사용될 수 없습니다.
  • [[Call]] internal method를 가지지 않습니다; function으로 invoked될 수 없습니다.
Note

이 specification에서 phrase “the Number value for x”는 6.1.6.1에 defined된 technical meaning을 가집니다.

21.3.1 Value Properties of the Math Object

21.3.1.1 Math.E

natural logarithm의 base인 e에 대한 Number value이며, 이는 approximately 2.7182818284590452354입니다.

이 property는 attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }를 가집니다.

21.3.1.2 Math.LN10

10의 natural logarithm에 대한 Number value이며, 이는 approximately 2.302585092994046입니다.

이 property는 attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }를 가집니다.

21.3.1.3 Math.LN2

2의 natural logarithm에 대한 Number value이며, 이는 approximately 0.6931471805599453입니다.

이 property는 attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }를 가집니다.

21.3.1.4 Math.LOG10E

natural logarithm의 base인 e의 base-10 logarithm에 대한 Number value입니다; 이 value는 approximately 0.4342944819032518입니다.

이 property는 attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }를 가집니다.

Note

Math.LOG10E의 value는 Math.LN10의 value의 reciprocal에 approximate합니다.

21.3.1.5 Math.LOG2E

natural logarithm의 base인 e의 base-2 logarithm에 대한 Number value입니다; 이 value는 approximately 1.4426950408889634입니다.

이 property는 attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }를 가집니다.

Note

Math.LOG2E의 value는 Math.LN2의 value의 reciprocal에 approximate합니다.

21.3.1.6 Math.PI

circle의 circumference와 diameter의 ratio인 π에 대한 Number value이며, 이는 approximately 3.1415926535897932입니다.

이 property는 attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }를 가집니다.

21.3.1.7 Math.SQRT1_2

½의 square root에 대한 Number value이며, 이는 approximately 0.7071067811865476입니다.

이 property는 attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }를 가집니다.

Note

Math.SQRT1_2의 value는 Math.SQRT2의 value의 reciprocal에 approximate합니다.

21.3.1.8 Math.SQRT2

2의 square root에 대한 Number value이며, 이는 approximately 1.4142135623730951입니다.

이 property는 attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }를 가집니다.

21.3.1.9 Math [ %Symbol.toStringTag% ]

%Symbol.toStringTag% property의 initial value는 String value "Math"입니다.

이 property는 attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }를 가집니다.

21.3.2 Function Properties of the Math Object

Note

acos, acosh, asin, asinh, atan, atanh, atan2, cbrt, cos, cosh, exp, expm1, hypot, log, log1p, log2, log10, pow, random, sin, sinh, tan, 및 tanh function의 behaviour는 interest의 boundary case를 represent하는 certain argument value에 대해 specific result를 require하는 것 외에는 여기에서 precisely specified되지 않습니다. other argument value에 대해, these function은 familiar mathematical function의 result에 대한 approximation을 compute하도록 intended되지만, approximation algorithm 선택에는 some latitude가 allowed됩니다. general intent는 implementer가 given hardware platform에서 C programmer에게 available한 same mathematical library를 ECMAScript에 사용할 수 있게 하는 것입니다.

algorithm 선택은 implementation에 left되지만, implementation은 Sun Microsystems의 freely distributable mathematical library인 fdlibm(http://www.netlib.org/fdlibm)에 contained된 IEEE 754-2019 arithmetic을 위한 approximation algorithm을 사용할 것이 recommended됩니다(이 standard에 의해 specified되지는 않음).

21.3.2.1 Math.abs ( x )

이 function은 x의 absolute value를 반환합니다; result는 x와 same magnitude를 가지지만 positive sign을 가집니다.

called될 때 다음 step을 수행합니다:

  1. n을 ? ToNumber(x)로 둔다.
  2. nNaN이면, NaN을 반환한다.
  3. n-0𝔽이면, +0𝔽를 반환한다.
  4. n-∞𝔽이면, +∞𝔽를 반환한다.
  5. n < -0𝔽이면, -n을 반환한다.
  6. n을 반환한다.

21.3.2.2 Math.acos ( x )

이 function은 x의 inverse cosine을 반환합니다. result는 radians로 expressed되며 +0𝔽부터 𝔽(π)까지의 inclusive interval 안에 있습니다.

called될 때 다음 step을 수행합니다:

  1. n을 ? ToNumber(x)로 둔다.
  2. nNaN이거나, n > 1𝔽이거나, n < -1𝔽이면, NaN을 반환한다.
  3. n1𝔽이면, +0𝔽를 반환한다.
  4. (n)의 inverse cosine을 represent하는 implementation-approximated Number value를 반환한다.

21.3.2.3 Math.acosh ( x )

이 function은 x의 inverse hyperbolic cosine을 반환합니다.

called될 때 다음 step을 수행합니다:

  1. n을 ? ToNumber(x)로 둔다.
  2. nNaN 또는 +∞𝔽 중 하나이면, n을 반환한다.
  3. n1𝔽이면, +0𝔽를 반환한다.
  4. n < 1𝔽이면, NaN을 반환한다.
  5. (n)의 inverse hyperbolic cosine을 represent하는 implementation-approximated Number value를 반환한다.

21.3.2.4 Math.asin ( x )

이 function은 x의 inverse sine을 반환합니다. result는 radians로 expressed되며 𝔽(-π / 2)부터 𝔽(π / 2)까지의 inclusive interval 안에 있습니다.

called될 때 다음 step을 수행합니다:

  1. n을 ? ToNumber(x)로 둔다.
  2. nNaN, +0𝔽, 또는 -0𝔽 중 하나이면, n을 반환한다.
  3. n > 1𝔽 또는 n < -1𝔽이면, NaN을 반환한다.
  4. (n)의 inverse sine을 represent하는 implementation-approximated Number value를 반환한다.

21.3.2.5 Math.asinh ( x )

이 function은 x의 inverse hyperbolic sine을 반환합니다.

called될 때 다음 step을 수행합니다:

  1. n을 ? ToNumber(x)로 둔다.
  2. nfinite가 아니거나 n+0𝔽 또는 -0𝔽 중 하나이면, n을 반환한다.
  3. (n)의 inverse hyperbolic sine을 represent하는 implementation-approximated Number value를 반환한다.

21.3.2.6 Math.atan ( x )

이 function은 x의 inverse tangent를 반환합니다. result는 radians로 expressed되며 𝔽(-π / 2)부터 𝔽(π / 2)까지의 inclusive interval 안에 있습니다.

called될 때 다음 step을 수행합니다:

  1. n을 ? ToNumber(x)로 둔다.
  2. nNaN, +0𝔽, 또는 -0𝔽 중 하나이면, n을 반환한다.
  3. n+∞𝔽이면, π / 2를 represent하는 implementation-approximated Number value를 반환한다.
  4. n-∞𝔽이면, -π / 2를 represent하는 implementation-approximated Number value를 반환한다.
  5. (n)의 inverse tangent를 represent하는 implementation-approximated Number value를 반환한다.

21.3.2.7 Math.atanh ( x )

이 function은 x의 inverse hyperbolic tangent를 반환합니다.

called될 때 다음 step을 수행합니다:

  1. n을 ? ToNumber(x)로 둔다.
  2. nNaN, +0𝔽, 또는 -0𝔽 중 하나이면, n을 반환한다.
  3. n > 1𝔽 또는 n < -1𝔽이면, NaN을 반환한다.
  4. n1𝔽이면, +∞𝔽를 반환한다.
  5. n-1𝔽이면, -∞𝔽를 반환한다.
  6. (n)의 inverse hyperbolic tangent를 represent하는 implementation-approximated Number value를 반환한다.

21.3.2.8 Math.atan2 ( y, x )

이 function은 arguments yx의 quotient y / x의 inverse tangent를 반환하며, yx의 sign은 result의 quadrant를 determine하는 데 사용됩니다. two-argument inverse tangent function에서 y라는 argument가 first이고 x라는 argument가 second인 것은 intentional이며 traditional임에 note하십시오. result는 radians로 expressed되며 -π부터 +π까지의 inclusive interval 안에 있습니다.

called될 때 다음 step을 수행합니다:

  1. ny를 ? ToNumber(y)로 둔다.
  2. nx를 ? ToNumber(x)로 둔다.
  3. nyNaN이거나 nxNaN이면, NaN을 반환한다.
  4. ny+∞𝔽이면, 다음을 수행한다.
    1. nx+∞𝔽이면, π / 4를 represent하는 implementation-approximated Number value를 반환한다.
    2. nx-∞𝔽이면, 3π / 4를 represent하는 implementation-approximated Number value를 반환한다.
    3. π / 2를 represent하는 implementation-approximated Number value를 반환한다.
  5. ny-∞𝔽이면, 다음을 수행한다.
    1. nx+∞𝔽이면, -π / 4를 represent하는 implementation-approximated Number value를 반환한다.
    2. nx-∞𝔽이면, -3π / 4를 represent하는 implementation-approximated Number value를 반환한다.
    3. -π / 2를 represent하는 implementation-approximated Number value를 반환한다.
  6. ny+0𝔽이면, 다음을 수행한다.
    1. nx > +0𝔽이거나 nx+0𝔽이면, +0𝔽를 반환한다.
    2. π를 represent하는 implementation-approximated Number value를 반환한다.
  7. ny-0𝔽이면, 다음을 수행한다.
    1. nx > +0𝔽이거나 nx+0𝔽이면, -0𝔽를 반환한다.
    2. -π를 represent하는 implementation-approximated Number value를 반환한다.
  8. Assert: nyfinite이고 +0𝔽-0𝔽도 아니다.
  9. ny > +0𝔽이면, 다음을 수행한다.
    1. nx+∞𝔽이면, +0𝔽를 반환한다.
    2. nx-∞𝔽이면, π를 represent하는 implementation-approximated Number value를 반환한다.
    3. nx+0𝔽 또는 -0𝔽 중 하나이면, π / 2를 represent하는 implementation-approximated Number value를 반환한다.
  10. ny < -0𝔽이면, 다음을 수행한다.
    1. nx+∞𝔽이면, -0𝔽를 반환한다.
    2. nx-∞𝔽이면, -π를 represent하는 implementation-approximated Number value를 반환한다.
    3. nx+0𝔽 또는 -0𝔽 중 하나이면, -π / 2를 represent하는 implementation-approximated Number value를 반환한다.
  11. Assert: nxfinite이고 +0𝔽-0𝔽도 아니다.
  12. resultabs((ny) / (nx))의 inverse tangent로 둔다.
  13. nx < -0𝔽이면, 다음을 수행한다.
    1. ny > +0𝔽이면, result를 π - result로 설정한다.
    2. 그렇지 않으면, result를 -π + result로 설정한다.
  14. 그렇지 않으면,
    1. ny < -0𝔽이면, result를 -result로 설정한다.
  15. result를 represent하는 implementation-approximated Number value를 반환한다.

21.3.2.9 Math.cbrt ( x )

이 function은 x의 cube root를 반환합니다.

called될 때 다음 step을 수행합니다:

  1. n을 ? ToNumber(x)로 둔다.
  2. nfinite가 아니거나 n+0𝔽 또는 -0𝔽 중 하나이면, n을 반환한다.
  3. (n)의 cube root를 represent하는 implementation-approximated Number value를 반환한다.

21.3.2.10 Math.ceil ( x )

이 function은 x보다 less하지 않은 smallest(closest to -∞) integral Number value를 반환합니다. x가 already integral Number이면, result는 x입니다.

called될 때 다음 step을 수행합니다:

  1. n을 ? ToNumber(x)로 둔다.
  2. nfinite가 아니거나 n+0𝔽 또는 -0𝔽 중 하나이면, n을 반환한다.
  3. n < -0𝔽이고 n > -1𝔽이면, -0𝔽를 반환한다.
  4. nintegral Number이면, n을 반환한다.
  5. n보다 less하지 않은 smallest(closest to -∞) integral Number value를 반환한다.
Note

Math.ceil(x)의 value는 -Math.floor(-x)의 value와 same입니다.

21.3.2.11 Math.clz32 ( x )

이 function은 called될 때 다음 step을 수행합니다:

  1. n을 ? ToUint32(x)로 둔다.
  2. pn의 unsigned 32-bit binary representation 안의 leading zero bit 수로 둔다.
  3. 𝔽(p)를 반환한다.
Note

n+0𝔽 또는 -0𝔽 중 하나이면, 이 method는 32𝔽를 반환합니다. n의 32-bit binary encoding의 most significant bit가 1이면, 이 method는 +0𝔽를 반환합니다.

21.3.2.12 Math.cos ( x )

이 function은 x의 cosine을 반환합니다. argument는 radians로 expressed됩니다.

called될 때 다음 step을 수행합니다:

  1. n을 ? ToNumber(x)로 둔다.
  2. nfinite가 아니면, NaN을 반환한다.
  3. n+0𝔽 또는 -0𝔽 중 하나이면, 1𝔽를 반환한다.
  4. (n)의 cosine을 represent하는 implementation-approximated Number value를 반환한다.

21.3.2.13 Math.cosh ( x )

이 function은 x의 hyperbolic cosine을 반환합니다.

called될 때 다음 step을 수행합니다:

  1. n을 ? ToNumber(x)로 둔다.
  2. nNaN이면, NaN을 반환한다.
  3. n+∞𝔽 또는 -∞𝔽 중 하나이면, +∞𝔽를 반환한다.
  4. n+0𝔽 또는 -0𝔽 중 하나이면, 1𝔽를 반환한다.
  5. (n)의 hyperbolic cosine을 represent하는 implementation-approximated Number value를 반환한다.
Note

Math.cosh(x)의 value는 (Math.exp(x) + Math.exp(-x)) / 2의 value와 same입니다.

21.3.2.14 Math.exp ( x )

이 function은 x의 exponential function(e raised to the power of x, 여기서 e는 natural logarithm의 base)을 반환합니다.

called될 때 다음 step을 수행합니다:

  1. n을 ? ToNumber(x)로 둔다.
  2. nNaN 또는 +∞𝔽 중 하나이면, n을 반환한다.
  3. n+0𝔽 또는 -0𝔽 중 하나이면, 1𝔽를 반환한다.
  4. n-∞𝔽이면, +0𝔽를 반환한다.
  5. (n)의 exponential function을 represent하는 implementation-approximated Number value를 반환한다.

21.3.2.15 Math.expm1 ( x )

이 function은 x의 exponential function(e raised to the power of x, 여기서 e는 natural logarithm의 base)에서 1을 subtract한 result를 반환합니다. result는 x의 value가 0에 close한 경우에도 accurate한 way로 computed됩니다.

called될 때 다음 step을 수행합니다:

  1. n을 ? ToNumber(x)로 둔다.
  2. nNaN, +0𝔽, -0𝔽, 또는 +∞𝔽 중 하나이면, n을 반환한다.
  3. n-∞𝔽이면, -1𝔽를 반환한다.
  4. exp(n)의 exponential function으로 둔다.
  5. exp - 1을 represent하는 implementation-approximated Number value를 반환한다.

21.3.2.16 Math.floor ( x )

이 function은 x보다 greater하지 않은 greatest(closest to +∞) integral Number value를 반환합니다. x가 already integral Number이면, result는 x입니다.

called될 때 다음 step을 수행합니다:

  1. n을 ? ToNumber(x)로 둔다.
  2. nfinite가 아니거나 n+0𝔽 또는 -0𝔽 중 하나이면, n을 반환한다.
  3. n < 1𝔽이고 n > +0𝔽이면, +0𝔽를 반환한다.
  4. nintegral Number이면, n을 반환한다.
  5. n보다 greater하지 않은 greatest(closest to +∞) integral Number value를 반환한다.
Note

Math.floor(x)의 value는 -Math.ceil(-x)의 value와 same입니다.

21.3.2.17 Math.fround ( x )

이 function은 called될 때 다음 step을 수행합니다:

  1. n을 ? ToNumber(x)로 둔다.
  2. nNaN이면, NaN을 반환한다.
  3. n+0𝔽, -0𝔽, +∞𝔽, 또는 -∞𝔽 중 하나이면, n을 반환한다.
  4. n32를 roundTiesToEven mode를 사용하여 nIEEE 754-2019 binary32 format으로 converting한 result로 둔다.
  5. n64n32IEEE 754-2019 binary64 format으로 converting한 result로 둔다.
  6. n64에 corresponding하는 ECMAScript Number value를 반환한다.

21.3.2.18 Math.f16round ( x )

이 function은 called될 때 다음 step을 수행합니다:

  1. n을 ? ToNumber(x)로 둔다.
  2. nNaN이면, NaN을 반환한다.
  3. n+0𝔽, -0𝔽, +∞𝔽, 또는 -∞𝔽 중 하나이면, n을 반환한다.
  4. n16을 roundTiesToEven mode를 사용하여 nIEEE 754-2019 binary16 format으로 converting한 result로 둔다.
  5. n64n16IEEE 754-2019 binary64 format으로 converting한 result로 둔다.
  6. n64에 corresponding하는 ECMAScript Number value를 반환한다.
Note

이 operation은 double-rounding 가능성 때문에 binary32로 cast한 다음 binary16으로 cast하는 것과 same하지 않습니다: 예를 들어 number k = 1.00048828125000022204𝔽를 consider하면, Math.f16round(k)는 1.0009765625𝔽이지만, Math.f16round(Math.fround(k))는 1𝔽입니다.

모든 platform이 binary64에서 binary16으로 casting하는 native support를 provide하는 것은 아닙니다. 이를 provide할 수 있는 다양한 library가 있으며, 여기에는 MIT-licensed half library가 include됩니다. Alternatively, roundTiesToEven 하에서 binary64에서 binary32로 first cast한 다음 result가 incorrect double-rounding으로 이어질 수 있는지 check할 수 있습니다. such case는 binary32 value의 mantissa를 initial cast를 roundTiesToOdd 하에서 수행했을 때 produced될 value가 되도록 adjusting함으로써 explicitly handled될 수 있습니다. adjusted value를 roundTiesToEven 하에서 binary16으로 casting하면 correct value가 produced됩니다.

21.3.2.19 Math.hypot ( ...args )

zero or more arguments가 given되면, 이 function은 그 arguments의 squares의 sum의 square root를 반환합니다.

called될 때 다음 step을 수행합니다:

  1. coerced를 새 empty List로 둔다.
  2. args의 각 element arg에 대해, 다음을 수행한다.
    1. n을 ? ToNumber(arg)로 둔다.
    2. ncoerced에 append한다.
  3. coerced의 각 element number에 대해, 다음을 수행한다.
    1. number+∞𝔽 또는 -∞𝔽 중 하나이면, +∞𝔽를 반환한다.
  4. onlyZerotrue로 둔다.
  5. coerced의 각 element number에 대해, 다음을 수행한다.
    1. numberNaN이면, NaN을 반환한다.
    2. number+0𝔽-0𝔽도 아니면, onlyZerofalse로 설정한다.
  6. onlyZerotrue이면, +0𝔽를 반환한다.
  7. coerced의 element의 mathematical value의 squares의 sum의 square root를 represent하는 implementation-approximated Number value를 반환한다.

이 function의 "length" property는 2𝔽입니다.

Note

implementation은 이 function이 two or more arguments와 함께 called될 때 naive implementation에서 발생하기 쉬운 overflow 및 underflow로 인한 precision loss를 avoid하도록 care해야 합니다.

21.3.2.20 Math.imul ( x, y )

이 function은 called될 때 다음 step을 수행합니다:

  1. a(? ToUint32(x))로 둔다.
  2. b(? ToUint32(y))로 둔다.
  3. product를 (a × b) modulo 232로 둔다.
  4. product ≥ 231이면, 𝔽(product - 232)를 반환한다.
  5. 𝔽(product)를 반환한다.

21.3.2.21 Math.log ( x )

이 function은 x의 natural logarithm을 반환합니다.

called될 때 다음 step을 수행합니다:

  1. n을 ? ToNumber(x)로 둔다.
  2. nNaN 또는 +∞𝔽 중 하나이면, n을 반환한다.
  3. n1𝔽이면, +0𝔽를 반환한다.
  4. n+0𝔽 또는 -0𝔽 중 하나이면, -∞𝔽를 반환한다.
  5. n < -0𝔽이면, NaN을 반환한다.
  6. ln((n))을 represent하는 implementation-approximated Number value를 반환한다.

21.3.2.22 Math.log1p ( x )

이 function은 1 + x의 natural logarithm을 반환합니다. result는 x의 value가 zero에 close한 경우에도 accurate한 way로 computed됩니다.

called될 때 다음 step을 수행합니다:

  1. n을 ? ToNumber(x)로 둔다.
  2. nNaN, +0𝔽, -0𝔽, 또는 +∞𝔽 중 하나이면, n을 반환한다.
  3. n-1𝔽이면, -∞𝔽를 반환한다.
  4. n < -1𝔽이면, NaN을 반환한다.
  5. ln(1 + (n))을 represent하는 implementation-approximated Number value를 반환한다.

21.3.2.23 Math.log10 ( x )

이 function은 x의 base 10 logarithm을 반환합니다.

called될 때 다음 step을 수행합니다:

  1. n을 ? ToNumber(x)로 둔다.
  2. nNaN 또는 +∞𝔽 중 하나이면, n을 반환한다.
  3. n1𝔽이면, +0𝔽를 반환한다.
  4. n+0𝔽 또는 -0𝔽 중 하나이면, -∞𝔽를 반환한다.
  5. n < -0𝔽이면, NaN을 반환한다.
  6. log10((n))을 represent하는 implementation-approximated Number value를 반환한다.

21.3.2.24 Math.log2 ( x )

이 function은 x의 base 2 logarithm을 반환합니다.

called될 때 다음 step을 수행합니다:

  1. n을 ? ToNumber(x)로 둔다.
  2. nNaN 또는 +∞𝔽 중 하나이면, n을 반환한다.
  3. n1𝔽이면, +0𝔽를 반환한다.
  4. n+0𝔽 또는 -0𝔽 중 하나이면, -∞𝔽를 반환한다.
  5. n < -0𝔽이면, NaN을 반환한다.
  6. log2((n))를 represent하는 implementation-approximated Number value를 반환한다.

21.3.2.25 Math.max ( ...args )

zero or more arguments가 given되면, 이 function은 각 argument에 ToNumber를 call하고 resulting value 중 largest를 반환합니다.

called될 때 다음 step을 수행합니다:

  1. coerced를 새 empty List로 둔다.
  2. args의 각 element arg에 대해, 다음을 수행한다.
    1. n을 ? ToNumber(arg)로 둔다.
    2. ncoerced에 append한다.
  3. highest-∞𝔽로 둔다.
  4. coerced의 각 element number에 대해, 다음을 수행한다.
    1. numberNaN이면, NaN을 반환한다.
    2. number+0𝔽이고 highest-0𝔽이면, highest+0𝔽로 설정한다.
    3. number > highest이면, highestnumber로 설정한다.
  5. highest를 반환한다.
Note

largest value를 determine하기 위한 value comparison은 +0𝔽-0𝔽보다 larger로 considered된다는 점을 제외하고 IsLessThan algorithm을 사용하여 수행됩니다.

이 function의 "length" property는 2𝔽입니다.

21.3.2.26 Math.min ( ...args )

zero or more arguments가 given되면, 이 function은 각 argument에 ToNumber를 call하고 resulting value 중 smallest를 반환합니다.

called될 때 다음 step을 수행합니다:

  1. coerced를 새 empty List로 둔다.
  2. args의 각 element arg에 대해, 다음을 수행한다.
    1. n을 ? ToNumber(arg)로 둔다.
    2. ncoerced에 append한다.
  3. lowest+∞𝔽로 둔다.
  4. coerced의 각 element number에 대해, 다음을 수행한다.
    1. numberNaN이면, NaN을 반환한다.
    2. number-0𝔽이고 lowest+0𝔽이면, lowest-0𝔽로 설정한다.
    3. number < lowest이면, lowestnumber로 설정한다.
  5. lowest를 반환한다.
Note

smallest value를 determine하기 위한 value comparison은 +0𝔽-0𝔽보다 larger로 considered된다는 점을 제외하고 IsLessThan algorithm을 사용하여 수행됩니다.

이 function의 "length" property는 2𝔽입니다.

21.3.2.27 Math.pow ( base, exponent )

이 function은 called될 때 다음 step을 수행합니다:

  1. base를 ? ToNumber(base)로 설정한다.
  2. exponent를 ? ToNumber(exponent)로 설정한다.
  3. Number::exponentiate(base, exponent)를 반환한다.

21.3.2.28 Math.random ( )

이 function은 positive sign을 가지고, +0𝔽보다 크거나 같지만 1𝔽보다 strictly less한 Number value를 반환하며, 이는 implementation-defined algorithm 또는 strategy를 사용하여 해당 range에서 approximately uniform distribution으로 randomly 또는 pseudo randomly chosen됩니다.

distinct realm을 위해 created된 각 Math.random function은 successive call에서 distinct sequence of values를 produce해야 합니다.

21.3.2.29 Math.round ( x )

이 function은 x에 closest하고 integral인 Number value를 반환합니다. two integral Numbersx에 equally close하면, result는 +∞에 closer한 Number value입니다. x가 already integral이면, result는 x입니다.

called될 때 다음 step을 수행합니다:

  1. n을 ? ToNumber(x)로 둔다.
  2. nfinite가 아니거나 nintegral Number이면, n을 반환한다.
  3. n < 0.5𝔽이고 n > +0𝔽이면, +0𝔽를 반환한다.
  4. n < -0𝔽이고 n-0.5𝔽이면, -0𝔽를 반환한다.
  5. tie의 경우 +∞에 closer한 Number를 preferring하여, n에 closest한 integral Number를 반환한다.
Note 1

Math.round(3.5)는 4를 반환하지만, Math.round(-3.5)는 -3을 반환합니다.

Note 2

Math.round(x)의 value는 always Math.floor(x + 0.5)의 value와 same하지 않습니다. x-0𝔽이거나 x-0𝔽보다 less하지만 -0.5𝔽보다 greater than or equal to인 경우, Math.round(x)-0𝔽를 반환하지만, Math.floor(x + 0.5)+0𝔽를 반환합니다. Math.round(x)x + 0.5를 computing할 때 internal rounding 때문에 Math.floor(x + 0.5)의 value와 differ할 수도 있습니다.

21.3.2.30 Math.sign ( x )

이 function은 x의 sign을 반환하여, x가 positive, negative, 또는 zero인지를 indicate합니다.

called될 때 다음 step을 수행합니다:

  1. n을 ? ToNumber(x)로 둔다.
  2. nNaN, +0𝔽, 또는 -0𝔽 중 하나이면, n을 반환한다.
  3. n < -0𝔽이면, -1𝔽를 반환한다.
  4. 1𝔽를 반환한다.

21.3.2.31 Math.sin ( x )

이 function은 x의 sine을 반환합니다. argument는 radians로 expressed됩니다.

called될 때 다음 step을 수행합니다:

  1. n을 ? ToNumber(x)로 둔다.
  2. nNaN, +0𝔽, 또는 -0𝔽 중 하나이면, n을 반환한다.
  3. n+∞𝔽 또는 -∞𝔽 중 하나이면, NaN을 반환한다.
  4. (n)의 sine을 represent하는 implementation-approximated Number value를 반환한다.

21.3.2.32 Math.sinh ( x )

이 function은 x의 hyperbolic sine을 반환합니다.

called될 때 다음 step을 수행합니다:

  1. n을 ? ToNumber(x)로 둔다.
  2. nfinite가 아니거나 n+0𝔽 또는 -0𝔽 중 하나이면, n을 반환한다.
  3. (n)의 hyperbolic sine을 represent하는 implementation-approximated Number value를 반환한다.
Note

Math.sinh(x)의 value는 (Math.exp(x) - Math.exp(-x)) / 2의 value와 same입니다.

21.3.2.33 Math.sqrt ( x )

이 function은 x의 square root를 반환합니다.

called될 때 다음 step을 수행합니다:

  1. n을 ? ToNumber(x)로 둔다.
  2. nNaN, +0𝔽, -0𝔽, 또는 +∞𝔽 중 하나이면, n을 반환한다.
  3. n < -0𝔽이면, NaN을 반환한다.
  4. 𝔽((n)의 square root)를 반환한다.

21.3.2.34 Math.sumPrecise ( items )

Numbers의 iterable이 given되면, 이 function은 iterable 안의 각 value를 sum하고 그 sum을 반환합니다. any value가 Number가 아니면 TypeError exception을 throw합니다.

called될 때 다음 step을 수행합니다:

  1. RequireObjectCoercible(items)를 수행한다.
  2. iteratorRecord를 ? GetIterator(items, sync)로 둔다.
  3. stateminus-zero로 둔다.
  4. sum을 0으로 둔다.
  5. count를 0으로 둔다.
  6. nextnot-started로 둔다.
  7. Repeat, nextdone이 아닌 동안,
    1. next를 ? IteratorStepValue(iteratorRecord)로 설정한다.
    2. nextdone이 아니면, 다음을 수행한다.
      1. count ≥ 253 - 1이면, 다음을 수행한다.
        1. NOTE: 이 step은 practice에서 reached될 것으로 expected되지 않으며, implementation이 이 specification을 violating하지 않고 input이 “reasonably sized”라고 rely할 수 있도록 하기 위해서만 included된다.
        2. errorThrowCompletion(newly created RangeError object)로 둔다.
        3. IteratorClose(iteratorRecord, error)를 반환한다.
      2. next가 Number가 아니면, 다음을 수행한다.
        1. errorThrowCompletion(newly created TypeError object)로 둔다.
        2. IteratorClose(iteratorRecord, error)를 반환한다.
      3. nnext로 둔다.
      4. statenot-a-number가 아니면, 다음을 수행한다.
        1. nNaN이면, 다음을 수행한다.
          1. statenot-a-number로 설정한다.
        2. 그렇지 않고 n+∞𝔽이면, 다음을 수행한다.
          1. stateminus-infinity이면, statenot-a-number로 설정한다.
          2. 그렇지 않으면, stateplus-infinity로 설정한다.
        3. 그렇지 않고 n-∞𝔽이면, 다음을 수행한다.
          1. stateplus-infinity이면, statenot-a-number로 설정한다.
          2. 그렇지 않으면, stateminus-infinity로 설정한다.
        4. 그렇지 않고 n-0𝔽가 아니며 stateminus-zero 또는 finite 중 하나이면, 다음을 수행한다.
          1. statefinite로 설정한다.
          2. sumsum + (n)으로 설정한다.
      5. countcount + 1로 설정한다.
  8. statenot-a-number이면, NaN을 반환한다.
  9. stateplus-infinity이면, +∞𝔽를 반환한다.
  10. stateminus-infinity이면, -∞𝔽를 반환한다.
  11. stateminus-zero이면, -0𝔽를 반환한다.
  12. 𝔽(sum)을 반환한다.
Note

sum의 value는 다양한 algorithm을 통해 arbitrary-precision arithmetic 없이 computed될 수 있습니다. 그중 하나는 Jonathan Richard Shewchuk의 Adaptive Precision Floating-Point Arithmetic and Fast Robust Geometric Predicates에 given된 “Grow-Expansion” algorithm입니다. 더 recent한 algorithm은 “Fast exact summation using small and large superaccumulators”에 given되어 있으며, 그 code는 https://gitlab.com/radfordneal/xsum에서 available합니다.

21.3.2.35 Math.tan ( x )

이 function은 x의 tangent를 반환합니다. argument는 radians로 expressed됩니다.

called될 때 다음 step을 수행합니다:

  1. n을 ? ToNumber(x)로 둔다.
  2. nNaN, +0𝔽, 또는 -0𝔽 중 하나이면, n을 반환한다.
  3. n+∞𝔽 또는 -∞𝔽 중 하나이면, NaN을 반환한다.
  4. (n)의 tangent를 represent하는 implementation-approximated Number value를 반환한다.

21.3.2.36 Math.tanh ( x )

이 function은 x의 hyperbolic tangent를 반환합니다.

called될 때 다음 step을 수행합니다:

  1. n을 ? ToNumber(x)로 둔다.
  2. nNaN, +0𝔽, 또는 -0𝔽 중 하나이면, n을 반환한다.
  3. n+∞𝔽이면, 1𝔽를 반환한다.
  4. n-∞𝔽이면, -1𝔽를 반환한다.
  5. (n)의 hyperbolic tangent를 represent하는 implementation-approximated Number value를 반환한다.
Note

Math.tanh(x)의 value는 (Math.exp(x) - Math.exp(-x)) / (Math.exp(x) + Math.exp(-x))의 value와 same입니다.

21.3.2.37 Math.trunc ( x )

이 function은 fractional digit을 제거하여 number x의 integral part를 반환합니다. x가 already integral이면, result는 x입니다.

called될 때 다음 step을 수행합니다:

  1. n을 ? ToNumber(x)로 둔다.
  2. nfinite가 아니거나 n+0𝔽 또는 -0𝔽 중 하나이면, n을 반환한다.
  3. n < 1𝔽이고 n > +0𝔽이면, +0𝔽를 반환한다.
  4. n < -0𝔽이고 n > -1𝔽이면, -0𝔽를 반환한다.
  5. +0𝔽의 direction으로 n에 nearest한 integral Number를 반환한다.

21.4 Date Objects

21.4.1 Date 객체 개요 및 추상 연산 정의

다음 추상 연산은 시간 값(21.4.1.1에서 정의됨)을 대상으로 작동한다. 모든 경우에 이러한 함수 중 하나에 전달된 인수가 NaN이면 결과도 NaN이라는 점에 유의한다.

21.4.1.1 시간 값과 시간 범위

ECMAScript의 시간 측정은 POSIX의 시간 측정과 유사하며, 특히 역산 그레고리력, 1970년 1월 1일 UTC가 시작되는 자정의 에포크, 그리고 매일을 정확히 86,400초(각각의 길이는 1000밀리초)로 구성된 것으로 계산하는 정의를 공유한다.

ECMAScript 시간 값은 Number이며, 밀리초 정밀도로 특정 시점을 나타내는 유한한 정수 Number이거나 특정 시점을 나타내지 않는 NaN이다. msPerDay의 정수 배수인 시간 값(즉, 어떤 정수 d에 대해 msPerDay × d인 값)은 에포크로부터 d개의 완전한 UTC 일이 지난 뒤 시작되는 UTC 일의 시작 시점(음수 d의 경우 에포크 이전)을 나타낸다. 그 밖의 모든 유한한 시간 값 tv는 그러한 배수인 값 중 가장 가까운 이전 시간 값 s를 기준으로 정의되며, s와 같은 UTC 일에 속하면서 그보다 (tv - s)밀리초 뒤에 발생하는 시점을 나타낸다.

시간 값은 UTC 윤초를 고려하지 않는다. 즉, 양의 윤초 안의 시점을 나타내는 시간 값은 없으며, 음의 윤초에 의해 UTC 타임라인에서 제거된 시점을 나타내는 시간 값은 존재한다. 하지만 시간 값의 정의는 윤초 경계에서만 불연속적이고 윤초 밖에서는 차이가 없는 방식으로 UTC와 구간별 정렬을 이룬다.

Number는 -9,007,199,254,740,992부터 9,007,199,254,740,992까지의 모든 정수를 정확하게 나타낼 수 있다(21.1.2.821.1.2.6). 시간 값은 이보다 약간 작은 -8,640,000,000,000,000밀리초부터 8,640,000,000,000,000밀리초까지의 범위를 지원한다. 이에 따라 1970년 1월 1일 UTC가 시작되는 자정을 기준으로 정확히 -100,000,000일부터 100,000,000일까지의 시간 값 범위가 지원된다.

1970년 1월 1일 UTC가 시작되는 자정의 정확한 순간은 시간 값 +0𝔽으로 나타낸다.

Note

역산 그레고리력에서 윤년은 정확히 4로 나누어지고 400으로 나누어지거나 100으로 나누어지지 않는 해이다.

역산 그레고리력의 400년 주기에는 97개의 윤년이 포함된다. 이에 따라 1년의 평균은 365.2425일, 즉 31,556,952,000밀리초가 된다. 따라서 Number가 밀리초 정밀도로 정확하게 나타낼 수 있는 최대 범위는 1970년을 기준으로 약 -285,426년부터 285,426년까지이다. 이 절에서 명시한 시간 값이 지원하는 더 작은 범위는 1970년을 기준으로 약 -273,790년부터 273,790년까지이다.

21.4.1.2 시간 관련 상수

다음 절의 알고리즘은 이러한 상수를 참조한다.

HoursPerDay = 24
MinutesPerHour = 60
SecondsPerMinute = 60
msPerSecond = 1000
msPerMinute = 60000 = msPerSecond × SecondsPerMinute
msPerHour = 3600000 = msPerMinute × MinutesPerHour
msPerDay = 86400000 = msPerHour × HoursPerDay
NanosecondsPerDay = 106 × msPerDay = 8.64 × 1013
nsPerSecond = 106 × msPerSecond = 109
nsPerMillisecond = 106
nsPerMicrosecond = 103
MaxEpochNanoseconds = 108 × NanosecondsPerDay = 8.64 × 1021
MinEpochNanoseconds = -MaxEpochNanoseconds = -8.64 × 1021

21.4.1.3 Day ( tv )

The abstract operation Day takes argument tv (유한한 시간 값) and returns 정수. tv가 속하는 날의 일 번호를 반환한다. It performs the following steps when called:

  1. floor((tv) / msPerDay)를 반환한다.

21.4.1.4 TimeWithinDay ( tv )

The abstract operation TimeWithinDay takes argument tv (유한한 시간 값) and returns 0(포함)부터 msPerDay(제외)까지의 구간에 있는 정수. tv가 속하는 날의 시작 이후 경과한 밀리초 수를 반환한다. It performs the following steps when called:

  1. (tv) modulo msPerDay를 반환한다.

21.4.1.5 DayFromYear ( y )

The abstract operation DayFromYear takes argument y (정수) and returns 정수. 연도 y의 첫째 날의 일 번호를 반환한다. It performs the following steps when called:

  1. 참고: 다음 단계에서 numberYears1, numberYears4, numberYears100, numberYears400은 각각 epoch와 연도 y의 시작 사이에 나타나는 1, 4, 100, 400으로 나누어떨어지는 연도의 수를 나타낸다. y가 epoch보다 이전이면 이 수는 음수이다.
  2. numberYears1을 (y - 1970)으로 둔다.
  3. numberYears4floor((y - 1969) / 4)로 둔다.
  4. numberYears100floor((y - 1901) / 100)으로 둔다.
  5. numberYears400floor((y - 1601) / 400)으로 둔다.
  6. 365 × numberYears1 + numberYears4 - numberYears100 + numberYears400을 반환한다.

21.4.1.6 TimeFromYear ( y )

The abstract operation TimeFromYear takes argument y (정수) and returns 시간 값. 연도 y의 시작에 해당하는 시간 값을 반환한다. It performs the following steps when called:

  1. 𝔽(msPerDay × DayFromYear(y))를 반환한다.

21.4.1.7 YearFromTime ( tv )

The abstract operation YearFromTime takes argument tv (유한한 시간 값) and returns 정수. tv가 속하는 연도를 반환한다. It performs the following steps when called:

  1. TimeFromYear(y) ≤ tv를 만족하는 가장 큰 정수 y(+∞에 가장 가까운 값)를 반환한다.

21.4.1.8 DayWithinYear ( tv )

The abstract operation DayWithinYear takes argument tv (유한한 시간 값) and returns 0부터 365까지의 폐구간에 있는 정수. It performs the following steps when called:

  1. Day(tv) - DayFromYear(YearFromTime(tv))를 반환한다.

21.4.1.9 InLeapYear ( tv )

The abstract operation InLeapYear takes argument tv (유한한 시간 값) and returns 0 또는 1. tv가 윤년에 속하면 1을, 그렇지 않으면 0을 반환한다. It performs the following steps when called:

  1. yYearFromTime(tv)으로 둔다.
  2. (y modulo 400) = 0이면 1을 반환한다.
  3. (y modulo 100) = 0이면 0을 반환한다.
  4. (y modulo 4) = 0이면 1을 반환한다.
  5. 0을 반환한다.

21.4.1.10 MonthFromTime ( tv )

The abstract operation MonthFromTime takes argument tv (유한한 시간 값) and returns 0부터 11까지의 폐구간에 있는 정수. tv가 속하는 월을 식별하는 정수를 반환한다. 월 값 0은 1월을 지정하고, 1은 2월을, 2는 3월을, 3은 4월을, 4는 5월을, 5는 6월을, 6은 7월을, 7은 8월을, 8은 9월을, 9는 10월을, 10은 11월을, 11은 12월을 지정한다. MonthFromTime(+0𝔽) = 0이며, 이는 1970년 1월 1일 목요일에 해당한다. It performs the following steps when called:

  1. inLeapYearInLeapYear(tv)로 둔다.
  2. dayWithinYearDayWithinYear(tv)로 둔다.
  3. dayWithinYear < 31이면 0을 반환한다.
  4. dayWithinYear < 59 + inLeapYear이면 1을 반환한다.
  5. dayWithinYear < 90 + inLeapYear이면 2를 반환한다.
  6. dayWithinYear < 120 + inLeapYear이면 3을 반환한다.
  7. dayWithinYear < 151 + inLeapYear이면 4를 반환한다.
  8. dayWithinYear < 181 + inLeapYear이면 5를 반환한다.
  9. dayWithinYear < 212 + inLeapYear이면 6을 반환한다.
  10. dayWithinYear < 243 + inLeapYear이면 7을 반환한다.
  11. dayWithinYear < 273 + inLeapYear이면 8을 반환한다.
  12. dayWithinYear < 304 + inLeapYear이면 9를 반환한다.
  13. dayWithinYear < 334 + inLeapYear이면 10을 반환한다.
  14. 단언: dayWithinYear < 365 + inLeapYear.
  15. 11을 반환한다.

21.4.1.11 DateFromTime ( tv )

The abstract operation DateFromTime takes argument tv (유한한 시간 값) and returns 1부터 31까지의 폐구간에 있는 정수. tv가 속하는 월의 날짜를 반환한다. It performs the following steps when called:

  1. inLeapYearInLeapYear(tv)로 둔다.
  2. dayWithinYearDayWithinYear(tv)로 둔다.
  3. monthMonthFromTime(tv)으로 둔다.
  4. month = 0이면 dayWithinYear + 1을 반환한다.
  5. month = 1이면 dayWithinYear - 30을 반환한다.
  6. month = 2이면 dayWithinYear - 58 - inLeapYear를 반환한다.
  7. month = 3이면 dayWithinYear - 89 - inLeapYear를 반환한다.
  8. month = 4이면 dayWithinYear - 119 - inLeapYear를 반환한다.
  9. month = 5이면 dayWithinYear - 150 - inLeapYear를 반환한다.
  10. month = 6이면 dayWithinYear - 180 - inLeapYear를 반환한다.
  11. month = 7이면 dayWithinYear - 211 - inLeapYear를 반환한다.
  12. month = 8이면 dayWithinYear - 242 - inLeapYear를 반환한다.
  13. month = 9이면 dayWithinYear - 272 - inLeapYear를 반환한다.
  14. month = 10이면 dayWithinYear - 303 - inLeapYear를 반환한다.
  15. 단언: month = 11.
  16. dayWithinYear - 333 - inLeapYear를 반환한다.

21.4.1.12 WeekDay ( tv )

The abstract operation WeekDay takes argument tv (유한한 시간 값) and returns 0부터 6까지의 폐구간에 있는 정수. tv가 속하는 요일을 식별하는 정수를 반환한다. 요일 값 0은 일요일을 지정하고, 1은 월요일을, 2는 화요일을, 3은 수요일을, 4는 목요일을, 5는 금요일을, 6은 토요일을 지정한다. WeekDay(+0𝔽) = 4이며, 이는 1970년 1월 1일 목요일에 해당한다. It performs the following steps when called:

  1. (Day(tv) + 4) modulo 7을 반환한다.

21.4.1.13 HourFromTime ( tv )

The abstract operation HourFromTime takes argument tv (유한한 시간 값) and returns 0부터 23까지의 폐구간에 있는 정수. tv가 속하는 날의 시를 반환한다. It performs the following steps when called:

  1. floor((tv) / msPerHour) modulo HoursPerDay를 반환한다.

21.4.1.14 MinFromTime ( tv )

The abstract operation MinFromTime takes argument tv (유한한 시간 값) and returns 0부터 59까지의 폐구간에 있는 정수. tv가 속하는 시의 분을 반환한다. It performs the following steps when called:

  1. floor((tv) / msPerMinute) modulo MinutesPerHour를 반환한다.

21.4.1.15 SecFromTime ( tv )

The abstract operation SecFromTime takes argument tv (유한한 시간 값) and returns 0부터 59까지의 폐구간에 있는 정수. tv가 속하는 분의 초를 반환한다. It performs the following steps when called:

  1. floor((tv) / msPerSecond) modulo SecondsPerMinute를 반환한다.

21.4.1.16 MillisecFromTime ( tv )

The abstract operation MillisecFromTime takes argument tv (유한한 시간 값) and returns 0부터 999까지의 폐구간에 있는 정수. tv가 속하는 초의 밀리초를 반환한다. It performs the following steps when called:

  1. (tv) modulo msPerSecond를 반환한다.

21.4.1.17 에포크 나노초와 범위

에포크 나노초 수는 나노초 정밀도로 특정 시점을 나타내는 정수이다. 이는 시간 값과 동일한 범위를 지원하지만 나노초 단위로 표현되며, 그 범위는 MinEpochNanoseconds부터 MaxEpochNanoseconds까지이다. 시간 값 NaN에 해당하는 나노초 값은 없으며, 특정 시점이 없음을 나타내는 표현도 없다.

UTC 기준 1970년 1월 1일이 시작되는 정확한 자정은 값 0으로 표현된다. 최댓값은 MaxEpochNanoseconds이고 최솟값은 MinEpochNanoseconds이다.

21.4.1.18 GetUTCEpochNanoseconds ( year, month, day, hour, minute, second, millisecond, microsecond, nanosecond )

The abstract operation GetUTCEpochNanoseconds takes arguments year (정수), month (1 이상 12 이하인 정수), day (1 이상 31 이하인 정수), hour (0 이상 23 이하인 정수), minute (0 이상 59 이하인 정수), second (0 이상 59 이하인 정수), millisecond (0 이상 999 이하인 정수), microsecond (0 이상 999 이하인 정수), and nanosecond (0 이상 999 이하인 정수) and returns 에포크 나노초 수. 반환되는 값은 UTC 기준으로 주어진 ISO 8601 달력 날짜와 벽시계 시각에 해당하는 에포크 나노초 수이다. It performs the following steps when called:

  1. dateMakeDay(𝔽(year), 𝔽(month - 1), 𝔽(day))로 둔다.
  2. timeMakeTime(𝔽(hour), 𝔽(minute), 𝔽(second), 𝔽(millisecond))으로 둔다.
  3. msMakeDate(date, time)로 둔다.
  4. 검증: ms는 정수인 Number이다.
  5. (ms) × nsPerMillisecond + microsecond × nsPerMicrosecond + nanosecond를 반환한다.

21.4.1.19 시간대 식별자

ECMAScript의 시간대는 0x0000부터 0x007F까지의 닫힌구간에 있는 코드 단위로만 구성된 String인 시간대 식별자로 나타낸다. ECMAScript 구현이 지원하는 시간대는 AvailableNamedTimeZoneIdentifiers가 반환한 Time Zone Identifier Record[[Identifier]] 필드로 나타내는 사용 가능한 명명된 시간대이거나, IsTimeZoneOffsetStringtrue를 반환하는 String으로 나타내는 오프셋 시간대일 수 있다.

기본 시간대 식별자는 사용 가능한 명명된 시간대에서 선호되는 식별자이다. 비기본 시간대 식별자는 기본 시간대 식별자가 아닌 사용 가능한 명명된 시간대의 식별자이다. 사용 가능한 명명된 시간대 식별자는 기본 시간대 식별자 또는 비기본 시간대 식별자이다. 각각의 사용 가능한 명명된 시간대 식별자는 정확히 하나의 사용 가능한 명명된 시간대와 연결된다. 각각의 사용 가능한 명명된 시간대는 정확히 하나의 기본 시간대 식별자 및 0개 이상의 비기본 시간대 식별자와 연결된다.

ECMAScript 구현은 식별자가 "UTC"인 사용 가능한 명명된 시간대를 지원해야 하며, 이 식별자는 UTC 시간대의 기본 시간대 식별자여야 한다. 또한 구현은 임의의 수만큼 다른 사용 가능한 명명된 시간대를 지원할 수 있다.

ECMA-402 국제화 API 사양에 설명된 시간대 요구 사항을 준수하는 구현을 시간대 인식이라고 한다. 시간대 인식 구현은 IANA 시간대 데이터베이스의 “Zone” 및 “Link” 이름에 대응하는 사용 가능한 명명된 시간대를 지원해야 하며, 그러한 이름만 지원해야 한다. 시간대 인식 구현에서 기본 시간대 식별자와 비기본 시간대 식별자는 ECMA-402 사양에 규정된 AvailableNamedTimeZoneIdentifiers에 의해 명시적으로 재정의되는 경우를 제외하고 각각 IANA 시간대 데이터베이스의 “Zone” 이름과 “Link” 이름이다. 전체 IANA 시간대 데이터베이스를 지원하지 않는 구현도 시간대를 나타내는 식별자로 IANA 시간대 데이터베이스 이름을 사용하도록 권장된다.

21.4.1.20 GetNamedTimeZoneEpochNanoseconds ( timeZoneIdentifier, year, month, day, hour, minute, second, millisecond, microsecond, nanosecond )

The implementation-defined abstract operation GetNamedTimeZoneEpochNanoseconds takes arguments timeZoneIdentifier (String), year (정수), month (1 이상 12 이하인 정수), day (1 이상 31 이하인 정수), hour (0 이상 23 이하인 정수), minute (0 이상 59 이하인 정수), second (0 이상 59 이하인 정수), millisecond (0 이상 999 이하인 정수), microsecond (0 이상 999 이하인 정수), and nanosecond (0 이상 999 이하인 정수) and returns 에포크 나노초 수로 이루어진 List. 반환되는 List의 각 값은 timeZoneIdentifier로 식별되는 명명된 시간대에서 주어진 ISO 8601 달력 날짜와 벽시계 시각에 해당하는 에포크 나노초 수를 나타낸다.

입력이 음의 시간대 전이로 인해 두 번 이상 발생하는 현지 시각을 나타내는 경우(예: 일광 절약 시간이 종료되거나 시간대 규칙 변경으로 인해 시간대 오프셋이 감소하는 경우), 반환되는 List에는 둘 이상의 요소가 있으며 수치의 오름차순으로 정렬된다. 입력이 양의 시간대 전이로 인해 존재하지 않게 된 현지 시각을 나타내는 경우(예: 일광 절약 시간이 시작되거나 시간대 규칙 변경으로 인해 시간대 오프셋이 증가하는 경우), 반환되는 List는 비어 있다. 그 밖의 경우 반환되는 List에는 하나의 요소가 있다.

어느 시간대에 대해서도 현지의 정치적 규칙을 포함하지 않는 ECMAScript 구현에서 사용하는 GetNamedTimeZoneEpochNanoseconds의 기본 구현은 호출될 때 다음 단계를 수행한다:

  1. 검증: timeZoneIdentifier"UTC"이다.
  2. epochNanosecondsGetUTCEpochNanoseconds(year, month, day, hour, minute, second, millisecond, microsecond, nanosecond)로 둔다.
  3. « epochNanoseconds »를 반환한다.
Note

시간대 인식 구현은 IANA 시간대 데이터베이스의 시간대 정보를 사용해야 하며, 그 밖의 모든 구현에도 이를 사용할 것을 권장한다.

America/New_York에서 2017년 11월 5일 오전 1시 30분은 두 번 반복되므로, GetNamedTimeZoneEpochNanoseconds("America/New_York", 2017, 11, 5, 1, 30, 0, 0, 0, 0)는 길이가 2인 List를 반환하며, 첫 번째 요소는 05:30 UTC(UTC 오프셋 -04:00에서 미국 동부 일광 절약 시간 01:30에 해당)를 나타내고 두 번째 요소는 06:30 UTC(UTC 오프셋 -05:00에서 미국 동부 표준시 01:30에 해당)를 나타낸다.

America/New_York에서 2017년 3월 12일 오전 2시 30분은 존재하지 않으므로, GetNamedTimeZoneEpochNanoseconds("America/New_York", 2017, 3, 12, 2, 30, 0, 0, 0, 0)는 빈 List를 반환한다.

21.4.1.21 GetNamedTimeZoneOffsetNanoseconds ( timeZoneIdentifier, epochNanoseconds )

The implementation-defined abstract operation GetNamedTimeZoneOffsetNanoseconds takes arguments timeZoneIdentifier (String) and epochNanoseconds (에포크 나노초 수) and returns 정수.

반환되는 정수는 에포크 나노초 수 epochNanoseconds에 해당하는 순간에 timeZoneIdentifier로 식별되는 명명된 시간대의 UTC 기준 오프셋을 나노초 단위로 나타낸다.

어느 시간대에 대해서도 현지의 정치적 규칙을 포함하지 않는 ECMAScript 구현에서 사용하는 GetNamedTimeZoneOffsetNanoseconds의 기본 구현은 호출될 때 다음 단계를 수행한다:

  1. 검증: timeZoneIdentifier"UTC"이다.
  2. 0을 반환한다.
Note

시간대 오프셋 값은 양수이거나 음수일 수 있다.

21.4.1.22 Time Zone Identifier Record

Time Zone Identifier Record사용 가능한 명명된 시간대 식별자와 이에 대응하는 기본 시간대 식별자를 설명하는 데 사용하는 Record이다.

Time Zone Identifier Record에는 Table 60에 나열된 필드가 있다.

Table 60: Time Zone Identifier Record Fields
필드 이름 의미
[[Identifier]] String 구현이 지원하는 사용 가능한 명명된 시간대 식별자.
[[PrimaryIdentifier]] String [[Identifier]]가 해석되는 기본 시간대 식별자.
Note

[[Identifier]]기본 시간대 식별자이면 [[Identifier]][[PrimaryIdentifier]]이다.

21.4.1.23 AvailableNamedTimeZoneIdentifiers ( )

The implementation-defined abstract operation AvailableNamedTimeZoneIdentifiers takes no arguments and returns Time Zone Identifier RecordList. 결과는 이 구현에서 사용 가능한 모든 명명된 시간대 식별자와 각각의 사용 가능한 명명된 시간대 식별자에 대응하는 기본 시간대 식별자를 설명한다. List는 각 Time Zone Identifier Record[[Identifier]] 필드에 따라 정렬된다.

ECMA-402 국제화 API를 구현하는 모든 구현을 포함한 시간대 인식 구현은 ECMA-402 명세에 규정된 대로 AvailableNamedTimeZoneIdentifiers 추상 연산을 구현해야 한다. 시간대를 인식하지 않는 구현의 경우 AvailableNamedTimeZoneIdentifiers는 호출될 때 다음 단계를 수행한다.

  1. 구현이 어떤 시간대의 현지 정치적 규칙도 포함하지 않으면,
    1. « Time Zone Identifier Record { [[Identifier]]: "UTC", [[PrimaryIdentifier]]: "UTC" } »를 반환한다.
  2. identifiers사전식 코드 단위 순서로 정렬된 고유한 사용 가능한 명명된 시간대 식별자List로 설정한다.
  3. result를 새로운 빈 List로 설정한다.
  4. identifiers의 각 요소 identifier에 대해, 다음을 수행한다.
    1. primaryidentifier로 설정한다.
    2. identifier가 이 구현의 비기본 시간대 식별자이고 identifier"UTC"가 아니면,
      1. primaryidentifier와 연결된 기본 시간대 식별자로 설정한다.
      2. 참고: 구현은 기본 시간대 식별자를 얻기 위해 identifier를 반복적으로 해석해야 할 수 있다.
    3. recordTime Zone Identifier Record { [[Identifier]]: identifier, [[PrimaryIdentifier]]: primary }로 설정한다.
    4. recordresult에 추가한다.
  5. 단언: result에는 record.[[Identifier]]"UTC"이고 record.[[PrimaryIdentifier]]"UTC"Time Zone Identifier Record record가 포함되어 있다.
  6. result를 반환한다.

21.4.1.24 SystemTimeZoneIdentifier ( )

The implementation-defined abstract operation SystemTimeZoneIdentifier takes no arguments and returns String. 호스트 환경의 현재 시간대를 나타내는 String을 반환한다. 이 String은 IsTimeZoneOffsetStringtrue를 반환하는 UTC 오프셋을 나타내는 String이거나 기본 시간대 식별자이다. It performs the following steps when called:

  1. 구현이 UTC 시간대만 지원하면, "UTC"를 반환한다.
  2. systemTimeZoneString을 호스트 환경의 현재 시간대를 나타내는 String, 즉 기본 시간대 식별자 또는 오프셋 시간대 식별자로 설정한다.
  3. systemTimeZoneString을 반환한다.
Note

구현이 Date 객체의 메서드에서 일반적으로 제공하는 수준의 기능을 보장하기 위해, 호스트 환경의 시간대 설정에 대응하는 IANA 시간대 이름이 존재한다면 SystemTimeZoneIdentifier가 그 이름을 반환할 것을 권장한다. 해당 시간대에 표준시 및 서머 타임에 관한 현지 정치적 규칙이 존재한다면 GetNamedTimeZoneEpochNanosecondsGetNamedTimeZoneOffsetNanoseconds는 이를 반영해야 한다.

예를 들어 호스트 환경이 사용자가 자신의 시간대로 미국 동부 시간을 선택한 시스템의 브라우저이면 SystemTimeZoneIdentifier는 "America/New_York"를 반환한다.

21.4.1.25 LocalTime ( tv )

The abstract operation LocalTime takes argument tv (유한한 시간 값) and returns 정수 Number. tv를 UTC에서 현지 시각으로 변환한다. tv에서 유효한 표준시 및 서머 타임에 관한 현지 정치적 규칙을 사용하여 이 절에 명시된 방식으로 결과를 결정해야 한다. It performs the following steps when called:

  1. systemTimeZoneIdentifierSystemTimeZoneIdentifier()로 둔다.
  2. IsTimeZoneOffsetString(systemTimeZoneIdentifier)가 true이면,
    1. offsetNsParseTimeZoneOffsetString(systemTimeZoneIdentifier)로 둔다.
  3. 그렇지 않으면,
    1. offsetNsGetNamedTimeZoneOffsetNanoseconds(systemTimeZoneIdentifier, (tv) × nsPerMillisecond)로 둔다.
  4. offsetMstruncate(offsetNs / nsPerMillisecond)로 둔다.
  5. tv + 𝔽(offsetMs)를 반환한다.
Note 1

구현에서 현지 시각 tv에 관한 정치적 규칙을 사용할 수 없으면 SystemTimeZoneIdentifier"UTC"를 반환하고 GetNamedTimeZoneOffsetNanoseconds가 0을 반환하므로 결과는 tv이다.

Note 2

시간대 인식 구현은 IANA Time Zone Database https://www.iana.org/time-zones/의 시간대 정보를 사용해야 하며, 그 밖의 모든 구현에도 이를 사용할 것을 권장한다.

Note 3

반복되는 시각이 있는 음의 시간대 전환(예: 서머 타임이 끝나거나 시간대 조정이 감소하는 경우)에서는 서로 다른 두 입력 시간 값 tvUTC가 동일한 현지 시각 tlocal로 변환된다.

LocalTime(UTC(tvlocal))은 반드시 항상 tvlocal과 같지는 않다. 마찬가지로 UTC(LocalTime(tvUTC))도 반드시 항상 tvUTC와 같지는 않다.

21.4.1.26 UTC ( t )

The abstract operation UTC takes argument t (Number) and returns 시간 값. t를 현지 시간에서 UTC 시간 값으로 변환한다. 결과를 결정할 때는 이 절에 명시된 방식에 따라 t에서 유효한 표준시 및 일광 절약 시간에 관한 현지의 정치적 규칙을 사용해야 한다. It performs the following steps when called:

  1. t가 유한하지 않으면 NaN을 반환한다.
  2. systemTimeZoneIdentifierSystemTimeZoneIdentifier()로 둔다.
  3. IsTimeZoneOffsetString(systemTimeZoneIdentifier)가 true이면,
    1. offsetNsParseTimeZoneOffsetString(systemTimeZoneIdentifier)로 둔다.
  4. 그렇지 않으면,
    1. possibleInstantsGetNamedTimeZoneEpochNanoseconds(systemTimeZoneIdentifier, YearFromTime(t), MonthFromTime(t) + 1, DateFromTime(t), HourFromTime(t), MinFromTime(t), SecFromTime(t), MillisecFromTime(t), 0, 0)로 둔다.
    2. 참고: 다음 단계는 t가 음의 시간대 전환 시 여러 번 반복되는 현지 시간(예: 일광 절약 시간이 종료되거나 시간대 규칙 변경으로 인해 시간대 오프셋이 감소하는 경우) 또는 양의 시간대 전환 시 건너뛴 현지 시간(예: 일광 절약 시간이 시작되거나 시간대 규칙 변경으로 인해 시간대 오프셋이 증가하는 경우)을 나타낼 때, t가 전환 이전의 시간대 오프셋을 사용하여 해석되도록 한다.
    3. possibleInstants가 비어 있지 않으면,
      1. disambiguatedInstantpossibleInstants[0]으로 둔다.
    4. 그렇지 않으면,
      1. 참고: t는 양의 시간대 전환 시 건너뛴 현지 시간을 나타낸다(예: 일광 절약 시간이 시작되거나 시간대 규칙 변경으로 UTC 오프셋이 증가하는 경우).
      2. possibleInstantsBeforeGetNamedTimeZoneEpochNanoseconds(systemTimeZoneIdentifier, YearFromTime(tBefore), MonthFromTime(tBefore) + 1, DateFromTime(tBefore), HourFromTime(tBefore), MinFromTime(tBefore), SecFromTime(tBefore), MillisecFromTime(tBefore), 0, 0)로 둔다. 여기서 tBeforepossibleInstantsBefore가 비어 있지 않은 t보다 작은 가장 큰 정수 Number이다(즉, tBefore는 전환 이전의 마지막 현지 시간을 나타낸다).
      3. disambiguatedInstantpossibleInstantsBefore의 마지막 요소로 둔다.
    5. offsetNsGetNamedTimeZoneOffsetNanoseconds(systemTimeZoneIdentifier, disambiguatedInstant)로 둔다.
  5. offsetMstruncate(offsetNs / nsPerMillisecond)로 둔다.
  6. t - 𝔽(offsetMs)를 반환한다.

입력 t는 명목상 시간 값이지만 임의의 Number 값일 수 있다. 현지 UTC 오프셋에 관계없이 시간 값 범위의 경계에 해당하는 입력을 지원할 수 있도록 알고리즘은 t시간 값 범위로 제한해서는 안 된다. 예를 들어 최대 시간 값은 8.64 × 1015이며, "+275760-09-13T00:00:00Z"에 해당한다. 해당 순간에 현지 시간대 오프셋이 UTC보다 1시간 빠른 환경에서는 8.64 × 1015 + 3.6 × 106이라는 더 큰 입력으로 표현되며, 이는 "+275760-09-13T01:00:00+01:00"에 해당한다.

구현에서 현지 시간 t에 대한 정치적 규칙을 사용할 수 없는 경우, SystemTimeZoneIdentifier"UTC"를 반환하고 GetNamedTimeZoneOffsetNanoseconds가 0을 반환하므로 결과는 t이다.

Note 1

시간대 인식 구현은 IANA 시간대 데이터베이스의 시간대 정보를 사용해야 하며, 그 밖의 모든 구현에도 이를 사용할 것을 권장한다.

America/New_York에서 2017년 11월 5일 오전 1:30은 두 번 반복되지만(시계를 뒤로 돌림), 오전 1:30 UTC-05가 아니라 오전 1:30 UTC-04로 해석해야 한다. UTC(TimeClip(MakeDate(MakeDay(2017, 10, 5), MakeTime(1, 30, 0, 0))))에서 offsetMs의 값은 -4 × msPerHour이다.

America/New_York에서 2017년 3월 12일 오전 2:30은 존재하지 않지만, 오전 2:30 UTC-05(오전 3:30 UTC-04와 동일)로 해석해야 한다. UTC(TimeClip(MakeDate(MakeDay(2017, 2, 12), MakeTime(2, 30, 0, 0))))에서 offsetMs의 값은 -5 × msPerHour이다.

Note 2

UTC(LocalTime(tUTC))가 반드시 항상 tUTC와 같은 것은 아니다. 마찬가지로 LocalTime(UTC(tlocal))도 반드시 항상 tlocal과 같은 것은 아니다.

21.4.1.27 MakeTime ( hour, min, sec, ms )

The abstract operation MakeTime takes arguments hour (Number), min (Number), sec (Number), and ms (Number) and returns Number. 밀리초 수를 계산한다. It performs the following steps when called:

  1. hour가 유한하지 않거나, min이 유한하지 않거나, sec가 유한하지 않거나, ms가 유한하지 않으면 NaN을 반환한다.
  2. h를 ! ToIntegerOrInfinity(hour)로 둔다.
  3. m을 ! ToIntegerOrInfinity(min)로 둔다.
  4. s를 ! ToIntegerOrInfinity(sec)로 둔다.
  5. milli를 ! ToIntegerOrInfinity(ms)로 둔다.
  6. ((𝔽(h) × 𝔽(msPerHour) + 𝔽(m) × 𝔽(msPerMinute)) + 𝔽(s) × 𝔽(msPerSecond)) + 𝔽(milli)를 반환한다.
Note

MakeTime의 산술 연산은 부동소수점 산술이며 결합법칙이 성립하지 않으므로, 연산은 올바른 순서로 수행해야 한다.

21.4.1.28 MakeDay ( year, month, date )

The abstract operation MakeDay takes arguments year (Number), month (Number), and date (Number) and returns 유한한 Number 또는 NaN. 일 수를 계산한다. It performs the following steps when called:

  1. year가 유한하지 않거나, month가 유한하지 않거나, date가 유한하지 않으면 NaN을 반환한다.
  2. y를 ! ToIntegerOrInfinity(year)로 둔다.
  3. m을 ! ToIntegerOrInfinity(month)로 둔다.
  4. dt를 ! ToIntegerOrInfinity(date)로 둔다.
  5. ym𝔽(y) + 𝔽(floor(m / 12))로 둔다.
  6. ym이 유한하지 않으면 NaN을 반환한다.
  7. mnm modulo 12로 둔다.
  8. YearFromTime(tv) = (ym), MonthFromTime(tv) = mn, DateFromTime(tv) = 1을 만족하는 유한한 시간 값 tv를 찾는다. 단, 이것이 가능하지 않으면(일부 인수가 범위를 벗어났기 때문에) NaN을 반환한다.
  9. 𝔽(Day(tv)) + 𝔽(dt) - 1𝔽을 반환한다.

21.4.1.29 MakeDate ( day, time )

The abstract operation MakeDate takes arguments day (Number) and time (Number) and returns 유한한 Number 또는 NaN. 밀리초 수를 계산한다. It performs the following steps when called:

  1. day가 유한하지 않거나 time이 유한하지 않으면 NaN을 반환한다.
  2. tvday × 𝔽(msPerDay) + time으로 둔다.
  3. tv가 유한하지 않으면 NaN을 반환한다.
  4. tv를 반환한다.

21.4.1.30 MakeFullYear ( year )

The abstract operation MakeFullYear takes argument year (Number) and returns 정수 Number 또는 NaN. year의 정수 부분과 연결된 전체 연도를 반환하며, 0부터 99까지의 닫힌구간에 있는 값은 1900년 시작 이후의 연수로 해석한다. 역산 그레고리력과 일치시키기 위해 “전체 연도”는 연도 0(기원전 1년)의 시작 이후 완료된 연도의 부호 있는 개수로 정의한다. It performs the following steps when called:

  1. yearNaN, +∞𝔽 또는 -∞𝔽 중 하나이면, NaN을 반환한다.
  2. truncated를 ! ToIntegerOrInfinity(year)로 설정한다.
  3. truncated가 0부터 99까지의 닫힌구간에 있으면, 1900𝔽 + 𝔽(truncated)를 반환한다.
  4. 𝔽(truncated)를 반환한다.

21.4.1.31 TimeClip ( time )

The abstract operation TimeClip takes argument time (Number) and returns 시간 값. 밀리초 수를 계산한다. It performs the following steps when called:

  1. time이 유한하지 않으면, NaN을 반환한다.
  2. abs((time)) > 8.64 × 1015이면, NaN을 반환한다.
  3. 𝔽(! ToIntegerOrInfinity(time))를 반환한다.

21.4.1.32 날짜 시간 문자열 형식

ECMAScript는 ISO 8601 역일 날짜 확장 형식을 단순화한 날짜-시간 문자열 교환 형식을 정의한다. 형식은 다음과 같다. YYYY-MM-DDTHH:mm:ss.sssZ

각 요소는 다음과 같다.

YYYY 역산 그레고리력의 연도를 0000부터 9999까지의 네 자리 십진 숫자로 나타내거나, "+" 또는 "-" 뒤에 여섯 자리 십진 숫자가 오는 확장 연도로 나타낸다.
- "-" (하이픈)이 문자열에 문자 그대로 두 번 나타난다.
MM 연중 월을 01(1월)부터 12(12월)까지의 두 자리 십진 숫자로 나타낸다.
DD 월중 일을 01부터 31까지의 두 자리 십진 숫자로 나타낸다.
T 시간 요소의 시작을 나타내기 위해 "T"가 문자열에 문자 그대로 나타난다.
HH 자정 이후 경과한 완전한 시간의 수를 00부터 24까지의 두 자리 십진 숫자로 나타낸다.
: ":" (콜론)이 문자열에 문자 그대로 두 번 나타난다.
mm 해당 시간이 시작된 이후 경과한 완전한 분의 수를 00부터 59까지의 두 자리 십진 숫자로 나타낸다.
ss 해당 분이 시작된 이후 경과한 완전한 초의 수를 00부터 59까지의 두 자리 십진 숫자로 나타낸다.
. "." (마침표)이 문자열에 문자 그대로 나타난다.
sss 해당 초가 시작된 이후 경과한 완전한 밀리초의 수를 세 자리 십진 숫자로 나타낸다.
Z UTC 오프셋 표현이며, "Z"(오프셋이 없는 UTC) 또는 "+""-" 뒤에 시간 표현 HH:mm이 오는 형식으로 지정한다(각각 UTC보다 앞서거나 뒤처진 현지 시각을 나타내는 시간대 오프셋 문자열 형식의 하위 집합)

이 형식에는 다음과 같은 날짜 전용 형식이 포함된다.

YYYY
YYYY-MM
YYYY-MM-DD
        

또한 위의 날짜 전용 형식 중 하나 바로 뒤에 다음 시간 형식 중 하나가 오고 선택적으로 UTC 오프셋 표현이 추가되는 “날짜-시간” 형식도 포함된다.

THH:mm
THH:mm:ss
THH:mm:ss.sss
        

범위를 벗어나거나 규격을 준수하지 않는 요소가 포함된 문자열은 이 형식의 유효한 인스턴스가 아니다.

Note 1

모든 날은 자정에 시작하고 자정에 끝나므로 한 날짜와 연결될 수 있는 두 자정을 구별하기 위해 00:0024:00이라는 두 표기법을 사용할 수 있다. 이는 1995-02-04T24:001995-02-05T00:00이라는 두 표기법이 정확히 같은 시점을 가리킨다는 의미이다.

Note 2

이 형식은 RFC 9557에 정의된 시간대 이름이 포함된 주석을 지원하지 않으며, 시간대 오프셋의 숫자 표현만 지원한다.

21.4.1.32.1 확장 연도

1970년 1월 1일을 기준으로 앞뒤 약 273,790년에 이르는 전체 시간 값 범위(21.4.1.1)를 포괄하려면 0년 이전 또는 9999년 이후의 연도를 나타내야 한다. ISO 8601은 연도 표현의 확장을 허용하지만 정보 교환 당사자 간의 상호 합의가 있는 경우에만 허용한다. 단순화된 ECMAScript 형식에서 이러한 확장 연도 표현은 6자리여야 하며 항상 + 또는 - 부호가 접두사로 붙는다. 연도 0은 양수로 간주하며 + 부호를 접두사로 붙여야 한다. 연도 0을 -000000으로 나타내는 것은 유효하지 않다. 확장 연도가 시간 값의 범위를 벗어난 시점을 나타내면서 날짜 시간 문자열 형식과 일치하는 문자열은 Date.parse에서 인식할 수 없는 것으로 처리하며, 해당 함수는 구현별 동작이나 휴리스틱으로 대체하지 않고 NaN을 반환한다.

Note

확장 연도를 사용하는 날짜-시간 값의 예:

-271821-04-20T00:00:00Z 기원전 271822년
-000001-01-01T00:00:00Z 기원전 2년
+000000-01-01T00:00:00Z 기원전 1년
+000001-01-01T00:00:00Z 서기 1년
+001970-01-01T00:00:00Z 서기 1970년
+002009-12-15T00:00:00Z 서기 2009년
+275760-09-13T00:00:00Z 서기 275760년

21.4.1.33 시간대 오프셋 문자열 형식

ECMAScript는 ISO 8601에서 파생된 UTC 오프셋 문자열 교환 형식을 정의한다. 형식은 다음 문법으로 설명한다.

구문

UTCOffset ::: ASCIISign Hour ASCIISign Hour HourSubcomponents[+Extended] ASCIISign Hour HourSubcomponents[~Extended] ASCIISign ::: one of + - Hour ::: 0 DecimalDigit 1 DecimalDigit 20 21 22 23 HourSubcomponents[Extended] ::: TimeSeparator[?Extended] MinuteSecond TimeSeparator[?Extended] MinuteSecond TimeSeparator[?Extended] MinuteSecond TemporalDecimalFractionopt TimeSeparator[Extended] ::: [+Extended] : [~Extended] [empty] MinuteSecond ::: 0 DecimalDigit 1 DecimalDigit 2 DecimalDigit 3 DecimalDigit 4 DecimalDigit 5 DecimalDigit TemporalDecimalFraction ::: TemporalDecimalSeparator DecimalDigit TemporalDecimalSeparator DecimalDigit DecimalDigit TemporalDecimalSeparator DecimalDigit DecimalDigit DecimalDigit TemporalDecimalSeparator DecimalDigit DecimalDigit DecimalDigit DecimalDigit TemporalDecimalSeparator DecimalDigit DecimalDigit DecimalDigit DecimalDigit DecimalDigit TemporalDecimalSeparator DecimalDigit DecimalDigit DecimalDigit DecimalDigit DecimalDigit DecimalDigit TemporalDecimalSeparator DecimalDigit DecimalDigit DecimalDigit DecimalDigit DecimalDigit DecimalDigit DecimalDigit TemporalDecimalSeparator DecimalDigit DecimalDigit DecimalDigit DecimalDigit DecimalDigit DecimalDigit DecimalDigit DecimalDigit TemporalDecimalSeparator DecimalDigit DecimalDigit DecimalDigit DecimalDigit DecimalDigit DecimalDigit DecimalDigit DecimalDigit DecimalDigit TemporalDecimalSeparator ::: one of . ,

21.4.1.33.1 IsTimeZoneOffsetString ( offsetString )

The abstract operation IsTimeZoneOffsetString takes argument offsetString (String) and returns Boolean. 반환 값은 offsetStringUTCOffset으로 주어진 문법을 준수하는지를 나타낸다. It performs the following steps when called:

  1. parseResultParseText(offsetString, UTCOffset)로 설정한다.
  2. parseResult가 오류의 List이면, false를 반환한다.
  3. true를 반환한다.

21.4.1.33.2 ParseTimeZoneOffsetString ( offsetString )

The abstract operation ParseTimeZoneOffsetString takes argument offsetString (String) and returns 정수. 반환 값은 String offsetString에 대응하는 나노초 단위의 UTC 오프셋이다. It performs the following steps when called:

  1. parseResultParseText(offsetString, UTCOffset)로 설정한다.
  2. 단언: parseResult는 오류의 List가 아니다.
  3. 단언: parseResult에는 ASCIISign Parse Node가 포함되어 있다.
  4. parsedSignparseResult 안에 포함된 ASCIISign Parse Node가 일치시킨 소스 텍스트로 설정한다.
  5. parsedSign이 단일 코드 포인트 U+002D (HYPHEN-MINUS)이면,
    1. sign을 -1로 설정한다.
  6. 그렇지 않으면,
    1. sign을 1로 설정한다.
  7. 참고: 파싱된 각 값은 충분히 짧은 십진 숫자 문자열임이 보장되므로 아래의 StringToNumber 적용에서는 정밀도가 손실되지 않는다.
  8. 단언: parseResult에는 Hour Parse Node가 포함되어 있다.
  9. parsedHoursparseResult 안에 포함된 Hour Parse Node가 일치시킨 소스 텍스트로 설정한다.
  10. hours(StringToNumber(CodePointsToString(parsedHours)))로 설정한다.
  11. parseResultMinuteSecond Parse Node가 포함되어 있지 않으면,
    1. minutes를 0으로 설정한다.
  12. 그렇지 않으면,
    1. parsedMinutesparseResult 안에 포함된 첫 번째 MinuteSecond Parse Node가 일치시킨 소스 텍스트로 설정한다.
    2. minutes(StringToNumber(CodePointsToString(parsedMinutes)))로 설정한다.
  13. parseResult에 두 개의 MinuteSecond Parse Node가 포함되어 있지 않으면,
    1. seconds를 0으로 설정한다.
  14. 그렇지 않으면,
    1. parsedSecondsparseResult 안에 포함된 두 번째 MinuteSecond Parse Node가 일치시킨 소스 텍스트로 설정한다.
    2. seconds(StringToNumber(CodePointsToString(parsedSeconds)))로 설정한다.
  15. parseResultTemporalDecimalFraction Parse Node가 포함되어 있지 않으면,
    1. nanoseconds를 0으로 설정한다.
  16. 그렇지 않으면,
    1. parsedFractionparseResult 안에 포함된 TemporalDecimalFraction Parse Node가 일치시킨 소스 텍스트로 설정한다.
    2. fractionCodePointsToString(parsedFraction)과 "000000000"을 문자열 연결한 결과로 설정한다.
    3. nanosecondsStringfraction의 1부터 10까지의 부분 문자열로 설정한다.
    4. nanoseconds(StringToNumber(nanosecondsString))로 설정한다.
  17. sign × (((hours × MinutesPerHour + minutes) × SecondsPerMinute + seconds) × nsPerSecond + nanoseconds)를 반환한다.

21.4.2 The Date Constructor

Date constructor는:

  • %Date%입니다.
  • global object"Date" property의 initial value입니다.
  • constructor로 called될 때 new Date를 create하고 initialize합니다.
  • constructor가 아니라 function으로 called될 때 current time(UTC)을 represent하는 String을 반환합니다.
  • argument의 number 및 type에 따라 behaviour가 differ하는 function입니다.
  • class definition의 extends clause의 value로 사용될 수 있습니다. specified Date behaviour를 inherit하려는 subclass constructor[[DateValue]] internal slot을 가진 subclass instance를 create하고 initialize하기 위해 Date constructor에 대한 super call을 include해야 합니다.

21.4.2.1 Date ( ...values )

이 function은 called될 때 following steps를 수행합니다:

  1. NewTarget이 undefined이면, 다음을 수행한다.
    1. now를 current time을 identifying하는 time value (UTC)로 둔다.
    2. ToDateString(now)를 반환한다.
  2. numberOfArgsvalues 안의 elements 수로 둔다.
  3. numberOfArgs = 0이면, 다음을 수행한다.
    1. dv를 current time을 identifying하는 time value (UTC)로 둔다.
  4. 그렇지 않고 numberOfArgs = 1이면, 다음을 수행한다.
    1. valuevalues[0]으로 둔다.
    2. value가 Object이고 value[[DateValue]] internal slot을 가지면, 다음을 수행한다.
      1. tvvalue.[[DateValue]]로 둔다.
    3. 그렇지 않으면,
      1. v를 ? ToPrimitive(value)로 둔다.
      2. v가 String이면, 다음을 수행한다.
        1. Assert: next step은 v가 String이므로 abrupt completion을 never return한다.
        2. tvparse method(21.4.3.2)에서와 exactly same manner로 v를 date로 parsing한 result로 둔다.
      3. 그렇지 않으면,
        1. tv를 ? ToNumber(v)로 둔다.
    4. dvTimeClip(tv)로 둔다.
  5. 그렇지 않으면,
    1. Assert: numberOfArgs ≥ 2이다.
    2. y를 ? ToNumber(values[0])로 둔다.
    3. m을 ? ToNumber(values[1])로 둔다.
    4. numberOfArgs > 2이면 dt를 ? ToNumber(values[2])로 둔다; 그렇지 않으면 dt1𝔽로 둔다.
    5. numberOfArgs > 3이면 h를 ? ToNumber(values[3])로 둔다; 그렇지 않으면 h+0𝔽로 둔다.
    6. numberOfArgs > 4이면 min을 ? ToNumber(values[4])로 둔다; 그렇지 않으면 min+0𝔽로 둔다.
    7. numberOfArgs > 5이면 s를 ? ToNumber(values[5])로 둔다; 그렇지 않으면 s+0𝔽로 둔다.
    8. numberOfArgs > 6이면 milli를 ? ToNumber(values[6])로 둔다; 그렇지 않으면 milli+0𝔽로 둔다.
    9. yrMakeFullYear(y)로 둔다.
    10. finalDateMakeDate(MakeDay(yr, m, dt), MakeTime(h, min, s, milli))로 둔다.
    11. dvTimeClip(UTC(finalDate))로 둔다.
  6. obj를 ? OrdinaryCreateFromConstructor(NewTarget, "%Date.prototype%", « [[DateValue]] »)로 둔다.
  7. obj.[[DateValue]]dv로 설정한다.
  8. obj를 반환한다.

21.4.3 Properties of the Date Constructor

Date constructor는:

  • value가 %Function.prototype%[[Prototype]] internal slot을 가집니다.
  • value가 7𝔽"length" property를 가집니다.
  • 다음 property를 가집니다:

21.4.3.1 Date.now ( )

이 function은 call이 occur한 UTC date 및 time을 designating하는 time value를 반환합니다.

21.4.3.2 Date.parse ( string )

이 function은 argument에 ToString operator를 apply합니다. ToStringabrupt completion을 result하면 Completion Record가 immediately returned됩니다. Otherwise, 이 function은 resulting String을 date 및 time으로 interpret합니다; date 및 time에 corresponding하는 UTC time value인 Number를 반환합니다. String은 contents에 따라 local time, UTC time, 또는 어떤 other time zone의 time으로 interpreted될 수 있습니다. function은 first로 expanded years를 포함하여 Date Time String Format(21.4.1.32)에 described된 format에 따라 String을 parse하려고 attempt합니다. String이 that format에 conform하지 않으면 function은 any implementation-specific heuristics 또는 implementation-specific date format으로 fallback할 수 있습니다. unrecognizable하거나 out-of-bounds format element value를 contain하는 String은 이 function이 NaN을 return하게 해야 합니다.

String이 Date Time String Format에 conform하면, absent format element 대신 substitute value가 take됩니다. MM 또는 DD elements가 absent이면, "01"이 사용됩니다. HH, mm, 또는 ss elements가 absent이면, "00"이 사용됩니다. sss element가 absent이면, "000"이 사용됩니다. UTC offset representation이 absent이면, date-only form은 UTC time으로 interpreted되고 date-time form은 local time으로 interpreted됩니다.

x가 ECMAScript의 particular implementation 안에서 milliseconds amount가 zero인 any Date이면, all referenced properties가 their initial values를 가진다면, following expressions는 that implementation에서 same numeric value를 produce해야 합니다:

x.valueOf()
Date.parse(x.toString())
Date.parse(x.toUTCString())
Date.parse(x.toISOString())

However, expression

Date.parse(x.toLocaleString())

은 preceding three expressions와 same Number value를 produce할 필요가 없으며, general하게 이 function에 Date Time String Format(21.4.1.32)에 conform하지 않고 that implementation에서 toString 또는 toUTCString method에 의해 produced될 수 없는 any String value가 given될 때 produced되는 value는 implementation-defined입니다.

21.4.3.3 Date.prototype

Date.prototype의 initial value는 Date prototype object입니다.

이 property는 attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }를 가집니다.

21.4.3.4 Date.UTC ( year [ , month [ , date [ , hours [ , minutes [ , seconds [ , ms ] ] ] ] ] ] )

이 function은 called될 때 following steps를 수행합니다:

  1. y를 ? ToNumber(year)로 둔다.
  2. month가 present하면, m을 ? ToNumber(month)로 둔다; 그렇지 않으면 m+0𝔽로 둔다.
  3. date가 present하면, dt를 ? ToNumber(date)로 둔다; 그렇지 않으면 dt1𝔽로 둔다.
  4. hours가 present하면, h를 ? ToNumber(hours)로 둔다; 그렇지 않으면 h+0𝔽로 둔다.
  5. minutes가 present하면, min을 ? ToNumber(minutes)로 둔다; 그렇지 않으면 min+0𝔽로 둔다.
  6. seconds가 present하면, s를 ? ToNumber(seconds)로 둔다; 그렇지 않으면 s+0𝔽로 둔다.
  7. ms가 present하면, milli를 ? ToNumber(ms)로 둔다; 그렇지 않으면 milli+0𝔽로 둔다.
  8. yrMakeFullYear(y)로 둔다.
  9. TimeClip(MakeDate(MakeDay(yr, m, dt), MakeTime(h, min, s, milli)))를 반환한다.

이 function의 "length" property는 7𝔽입니다.

Note

이 function은 Date constructor와 two ways에서 differ합니다: Date를 creating하는 대신 time value를 Number로 반환하고, arguments를 local time이 아니라 UTC로 interpret합니다.

21.4.4 Properties of the Date Prototype Object

Date prototype object는:

  • %Date.prototype%입니다.
  • itself가 ordinary object입니다.
  • Date instance가 아니며 [[DateValue]] internal slot을 가지지 않습니다.
  • value가 %Object.prototype%[[Prototype]] internal slot을 가집니다.

explicitly 달리 defined되지 않는 한, 아래에 defined된 Date prototype object의 methods는 generic하지 않으며, 이들에게 passed되는 this value는 time value로 initialized된 [[DateValue]] internal slot을 가진 object여야 합니다.

21.4.4.1 Date.prototype.constructor

Date.prototype.constructor의 initial value는 %Date%입니다.

21.4.4.2 Date.prototype.getDate ( )

이 메서드는 호출될 때 다음 단계를 수행한다:

  1. dateObjthis 값으로 둔다.
  2. RequireInternalSlot(dateObj, [[DateValue]])을 수행한다.
  3. tvdateObj.[[DateValue]]로 둔다.
  4. tvNaN이면 NaN을 반환한다.
  5. 𝔽(DateFromTime(LocalTime(tv)))을 반환한다.

21.4.4.3 Date.prototype.getDay ( )

이 메서드는 호출될 때 다음 단계를 수행한다:

  1. dateObjthis 값으로 둔다.
  2. RequireInternalSlot(dateObj, [[DateValue]])을 수행한다.
  3. tvdateObj.[[DateValue]]로 둔다.
  4. tvNaN이면 NaN을 반환한다.
  5. 𝔽(WeekDay(LocalTime(tv)))를 반환한다.

21.4.4.4 Date.prototype.getFullYear ( )

이 메서드는 호출될 때 다음 단계를 수행한다:

  1. dateObjthis 값으로 둔다.
  2. RequireInternalSlot(dateObj, [[DateValue]])을 수행한다.
  3. tvdateObj.[[DateValue]]로 둔다.
  4. tvNaN이면 NaN을 반환한다.
  5. 𝔽(YearFromTime(LocalTime(tv)))을 반환한다.

21.4.4.5 Date.prototype.getHours ( )

이 메서드는 호출될 때 다음 단계를 수행한다:

  1. dateObjthis 값으로 둔다.
  2. RequireInternalSlot(dateObj, [[DateValue]])을 수행한다.
  3. tvdateObj.[[DateValue]]로 둔다.
  4. tvNaN이면 NaN을 반환한다.
  5. 𝔽(HourFromTime(LocalTime(tv)))을 반환한다.

21.4.4.6 Date.prototype.getMilliseconds ( )

이 메서드는 호출될 때 다음 단계를 수행한다:

  1. dateObjthis 값으로 둔다.
  2. RequireInternalSlot(dateObj, [[DateValue]])을 수행한다.
  3. tvdateObj.[[DateValue]]로 둔다.
  4. tvNaN이면 NaN을 반환한다.
  5. 𝔽(MillisecFromTime(LocalTime(tv)))을 반환한다.

21.4.4.7 Date.prototype.getMinutes ( )

이 메서드는 호출될 때 다음 단계를 수행한다:

  1. dateObjthis 값으로 둔다.
  2. RequireInternalSlot(dateObj, [[DateValue]])을 수행한다.
  3. tvdateObj.[[DateValue]]로 둔다.
  4. tvNaN이면 NaN을 반환한다.
  5. 𝔽(MinFromTime(LocalTime(tv)))을 반환한다.

21.4.4.8 Date.prototype.getMonth ( )

이 메서드는 호출될 때 다음 단계를 수행한다:

  1. dateObjthis 값으로 둔다.
  2. RequireInternalSlot(dateObj, [[DateValue]])을 수행한다.
  3. tvdateObj.[[DateValue]]로 둔다.
  4. tvNaN이면 NaN을 반환한다.
  5. 𝔽(MonthFromTime(LocalTime(tv)))을 반환한다.

21.4.4.9 Date.prototype.getSeconds ( )

이 메서드는 호출될 때 다음 단계를 수행한다:

  1. dateObjthis 값으로 둔다.
  2. RequireInternalSlot(dateObj, [[DateValue]])을 수행한다.
  3. tvdateObj.[[DateValue]]로 둔다.
  4. tvNaN이면 NaN을 반환한다.
  5. 𝔽(SecFromTime(LocalTime(tv)))을 반환한다.

21.4.4.10 Date.prototype.getTime ( )

이 메서드는 호출될 때 다음 단계를 수행한다:

  1. dateObjthis 값으로 둔다.
  2. RequireInternalSlot(dateObj, [[DateValue]])을 수행한다.
  3. dateObj.[[DateValue]]를 반환한다.

21.4.4.11 Date.prototype.getTimezoneOffset ( )

이 메서드는 호출될 때 다음 단계를 수행한다:

  1. dateObjthis 값으로 둔다.
  2. RequireInternalSlot(dateObj, [[DateValue]])을 수행한다.
  3. tvdateObj.[[DateValue]]로 둔다.
  4. tvNaN이면 NaN을 반환한다.
  5. (tv - LocalTime(tv)) / 𝔽(msPerMinute)를 반환한다.

21.4.4.12 Date.prototype.getUTCDate ( )

이 메서드는 호출될 때 다음 단계를 수행한다:

  1. dateObjthis 값으로 둔다.
  2. RequireInternalSlot(dateObj, [[DateValue]])을 수행한다.
  3. tvdateObj.[[DateValue]]로 둔다.
  4. tvNaN이면 NaN을 반환한다.
  5. 𝔽(DateFromTime(tv))를 반환한다.

21.4.4.13 Date.prototype.getUTCDay ( )

이 메서드는 호출될 때 다음 단계를 수행한다:

  1. dateObjthis 값으로 둔다.
  2. RequireInternalSlot(dateObj, [[DateValue]])을 수행한다.
  3. tvdateObj.[[DateValue]]로 둔다.
  4. tvNaN이면 NaN을 반환한다.
  5. 𝔽(WeekDay(tv))를 반환한다.

21.4.4.14 Date.prototype.getUTCFullYear ( )

이 메서드는 호출될 때 다음 단계를 수행한다:

  1. dateObjthis 값으로 둔다.
  2. RequireInternalSlot(dateObj, [[DateValue]])을 수행한다.
  3. tvdateObj.[[DateValue]]로 둔다.
  4. tvNaN이면 NaN을 반환한다.
  5. 𝔽(YearFromTime(tv))을 반환한다.

21.4.4.15 Date.prototype.getUTCHours ( )

이 메서드는 호출될 때 다음 단계를 수행한다:

  1. dateObjthis 값으로 둔다.
  2. RequireInternalSlot(dateObj, [[DateValue]])을 수행한다.
  3. tvdateObj.[[DateValue]]로 둔다.
  4. tvNaN이면 NaN을 반환한다.
  5. 𝔽(HourFromTime(tv))을 반환한다.

21.4.4.16 Date.prototype.getUTCMilliseconds ( )

이 메서드는 호출될 때 다음 단계를 수행한다:

  1. dateObjthis 값으로 둔다.
  2. RequireInternalSlot(dateObj, [[DateValue]])을 수행한다.
  3. tvdateObj.[[DateValue]]로 둔다.
  4. tvNaN이면 NaN을 반환한다.
  5. 𝔽(MillisecFromTime(tv))을 반환한다.

21.4.4.17 Date.prototype.getUTCMinutes ( )

이 메서드는 호출될 때 다음 단계를 수행한다:

  1. dateObjthis 값으로 둔다.
  2. RequireInternalSlot(dateObj, [[DateValue]])을 수행한다.
  3. tvdateObj.[[DateValue]]로 둔다.
  4. tvNaN이면 NaN을 반환한다.
  5. 𝔽(MinFromTime(tv))을 반환한다.

21.4.4.18 Date.prototype.getUTCMonth ( )

이 메서드는 호출될 때 다음 단계를 수행한다:

  1. dateObjthis 값으로 둔다.
  2. RequireInternalSlot(dateObj, [[DateValue]])을 수행한다.
  3. tvdateObj.[[DateValue]]로 둔다.
  4. tvNaN이면 NaN을 반환한다.
  5. 𝔽(MonthFromTime(tv))을 반환한다.

21.4.4.19 Date.prototype.getUTCSeconds ( )

이 메서드는 호출될 때 다음 단계를 수행한다:

  1. dateObjthis 값으로 둔다.
  2. RequireInternalSlot(dateObj, [[DateValue]])을 수행한다.
  3. tvdateObj.[[DateValue]]로 둔다.
  4. tvNaN이면 NaN을 반환한다.
  5. 𝔽(SecFromTime(tv))을 반환한다.

21.4.4.20 Date.prototype.setDate ( date )

이 메서드는 호출될 때 다음 단계를 수행한다:

  1. dateObjthis 값으로 둔다.
  2. RequireInternalSlot(dateObj, [[DateValue]])을 수행한다.
  3. tvdateObj.[[DateValue]]로 둔다.
  4. dt를 ? ToNumber(date)로 둔다.
  5. tvNaN이면 NaN을 반환한다.
  6. tvLocalTime(tv)으로 설정한다.
  7. newDateMakeDate(MakeDay(𝔽(YearFromTime(tv)), 𝔽(MonthFromTime(tv)), dt), 𝔽(TimeWithinDay(tv)))로 둔다.
  8. uTimeClip(UTC(newDate))로 둔다.
  9. dateObj.[[DateValue]]u로 설정한다.
  10. u를 반환한다.

21.4.4.21 Date.prototype.setFullYear ( year [ , month [ , date ] ] )

이 메서드는 호출될 때 다음 단계를 수행한다:

  1. dateObjthis 값으로 둔다.
  2. RequireInternalSlot(dateObj, [[DateValue]])을 수행한다.
  3. tvdateObj.[[DateValue]]로 둔다.
  4. y를 ? ToNumber(year)로 둔다.
  5. tvNaN이면 tv+0𝔽으로 설정하고, 그렇지 않으면 tvLocalTime(tv)으로 설정한다.
  6. month가 존재하면 m을 ? ToNumber(month)로 두고, 그렇지 않으면 m𝔽(MonthFromTime(tv))로 둔다.
  7. date가 존재하면 dt를 ? ToNumber(date)로 두고, 그렇지 않으면 dt𝔽(DateFromTime(tv))로 둔다.
  8. newDateMakeDate(MakeDay(y, m, dt), 𝔽(TimeWithinDay(tv)))로 둔다.
  9. uTimeClip(UTC(newDate))로 둔다.
  10. dateObj.[[DateValue]]u로 설정한다.
  11. u를 반환한다.

이 메서드의 "length" 속성은 3𝔽이다.

Note

month가 존재하지 않으면 이 메서드는 monthgetMonth() 값으로 존재하는 것처럼 동작한다. date가 존재하지 않으면 dategetDate() 값으로 존재하는 것처럼 동작한다.

21.4.4.22 Date.prototype.setHours ( hour [ , min [ , sec [ , ms ] ] ] )

이 메서드는 호출될 때 다음 단계를 수행한다:

  1. dateObjthis 값으로 둔다.
  2. RequireInternalSlot(dateObj, [[DateValue]])을 수행한다.
  3. tvdateObj.[[DateValue]]로 둔다.
  4. h를 ? ToNumber(hour)로 둔다.
  5. min이 존재하면 m을 ? ToNumber(min)로 둔다.
  6. sec가 존재하면 s를 ? ToNumber(sec)로 둔다.
  7. ms가 존재하면 milli를 ? ToNumber(ms)로 둔다.
  8. tvNaN이면 NaN을 반환한다.
  9. tvLocalTime(tv)으로 설정한다.
  10. min이 존재하지 않으면 m𝔽(MinFromTime(tv))로 둔다.
  11. sec가 존재하지 않으면 s𝔽(SecFromTime(tv))로 둔다.
  12. ms가 존재하지 않으면 milli𝔽(MillisecFromTime(tv))로 둔다.
  13. dateMakeDate(𝔽(Day(tv)), MakeTime(h, m, s, milli))로 둔다.
  14. uTimeClip(UTC(date))로 둔다.
  15. dateObj.[[DateValue]]u로 설정한다.
  16. u를 반환한다.

이 메서드의 "length" 속성은 4𝔽이다.

Note

min이 존재하지 않으면 이 메서드는 mingetMinutes() 값으로 존재하는 것처럼 동작한다. sec가 존재하지 않으면 secgetSeconds() 값으로 존재하는 것처럼 동작한다. ms가 존재하지 않으면 msgetMilliseconds() 값으로 존재하는 것처럼 동작한다.

21.4.4.23 Date.prototype.setMilliseconds ( ms )

이 메서드는 호출될 때 다음 단계를 수행한다:

  1. dateObjthis 값으로 둔다.
  2. RequireInternalSlot(dateObj, [[DateValue]])을 수행한다.
  3. tvdateObj.[[DateValue]]로 둔다.
  4. ms를 ? ToNumber(ms)로 설정한다.
  5. tvNaN이면 NaN을 반환한다.
  6. tvLocalTime(tv)으로 설정한다.
  7. timeMakeTime(𝔽(HourFromTime(tv)), 𝔽(MinFromTime(tv)), 𝔽(SecFromTime(tv)), ms)로 둔다.
  8. uTimeClip(UTC(MakeDate(𝔽(Day(tv)), time)))로 둔다.
  9. dateObj.[[DateValue]]u로 설정한다.
  10. u를 반환한다.

21.4.4.24 Date.prototype.setMinutes ( min [ , sec [ , ms ] ] )

이 메서드는 호출될 때 다음 단계를 수행한다:

  1. dateObjthis 값으로 둔다.
  2. RequireInternalSlot(dateObj, [[DateValue]])을 수행한다.
  3. tvdateObj.[[DateValue]]로 둔다.
  4. m을 ? ToNumber(min)로 둔다.
  5. sec가 존재하면 s를 ? ToNumber(sec)로 둔다.
  6. ms가 존재하면 milli를 ? ToNumber(ms)로 둔다.
  7. tvNaN이면 NaN을 반환한다.
  8. tvLocalTime(tv)으로 설정한다.
  9. sec가 존재하지 않으면 s𝔽(SecFromTime(tv))로 둔다.
  10. ms가 존재하지 않으면 milli𝔽(MillisecFromTime(tv))로 둔다.
  11. dateMakeDate(𝔽(Day(tv)), MakeTime(𝔽(HourFromTime(tv)), m, s, milli))로 둔다.
  12. uTimeClip(UTC(date))로 둔다.
  13. dateObj.[[DateValue]]u로 설정한다.
  14. u를 반환한다.

이 메서드의 "length" 속성은 3𝔽이다.

Note

sec가 존재하지 않으면 이 메서드는 secgetSeconds() 값으로 존재하는 것처럼 동작한다. ms가 존재하지 않으면 msgetMilliseconds() 값으로 존재하는 것처럼 동작한다.

21.4.4.25 Date.prototype.setMonth ( month [ , date ] )

이 메서드는 호출될 때 다음 단계를 수행한다:

  1. dateObjthis 값으로 둔다.
  2. RequireInternalSlot(dateObj, [[DateValue]])을 수행한다.
  3. tvdateObj.[[DateValue]]로 둔다.
  4. m을 ? ToNumber(month)로 둔다.
  5. date가 존재하면 dt를 ? ToNumber(date)로 둔다.
  6. tvNaN이면 NaN을 반환한다.
  7. tvLocalTime(tv)으로 설정한다.
  8. date가 존재하지 않으면 dt𝔽(DateFromTime(tv))로 둔다.
  9. newDateMakeDate(MakeDay(𝔽(YearFromTime(tv)), m, dt), 𝔽(TimeWithinDay(tv)))로 둔다.
  10. uTimeClip(UTC(newDate))로 둔다.
  11. dateObj.[[DateValue]]u로 설정한다.
  12. u를 반환한다.

이 메서드의 "length" 속성은 2𝔽이다.

Note

date가 존재하지 않으면 이 메서드는 dategetDate() 값으로 존재하는 것처럼 동작한다.

21.4.4.26 Date.prototype.setSeconds ( sec [ , ms ] )

이 메서드는 호출될 때 다음 단계를 수행한다:

  1. dateObjthis 값으로 둔다.
  2. RequireInternalSlot(dateObj, [[DateValue]])을 수행한다.
  3. tvdateObj.[[DateValue]]로 둔다.
  4. s를 ? ToNumber(sec)로 둔다.
  5. ms가 존재하면 milli를 ? ToNumber(ms)로 둔다.
  6. tvNaN이면 NaN을 반환한다.
  7. tvLocalTime(tv)으로 설정한다.
  8. ms가 존재하지 않으면 milli𝔽(MillisecFromTime(tv))로 둔다.
  9. dateMakeDate(𝔽(Day(tv)), MakeTime(𝔽(HourFromTime(tv)), 𝔽(MinFromTime(tv)), s, milli))로 둔다.
  10. uTimeClip(UTC(date))로 둔다.
  11. dateObj.[[DateValue]]u로 설정한다.
  12. u를 반환한다.

이 메서드의 "length" 속성은 2𝔽이다.

Note

ms가 존재하지 않으면 이 메서드는 msgetMilliseconds() 값으로 존재하는 것처럼 동작한다.

21.4.4.27 Date.prototype.setTime ( time )

이 메서드는 호출될 때 다음 단계를 수행한다:

  1. dateObjthis 값으로 둔다.
  2. RequireInternalSlot(dateObj, [[DateValue]])을 수행한다.
  3. t를 ? ToNumber(time)로 둔다.
  4. vTimeClip(t)로 둔다.
  5. dateObj.[[DateValue]]v로 설정한다.
  6. v를 반환한다.

21.4.4.28 Date.prototype.setUTCDate ( date )

이 메서드는 호출될 때 다음 단계를 수행한다:

  1. dateObjthis 값으로 둔다.
  2. RequireInternalSlot(dateObj, [[DateValue]])을 수행한다.
  3. tvdateObj.[[DateValue]]로 둔다.
  4. dt를 ? ToNumber(date)로 둔다.
  5. tvNaN이면 NaN을 반환한다.
  6. newDateMakeDate(MakeDay(𝔽(YearFromTime(tv)), 𝔽(MonthFromTime(tv)), dt), 𝔽(TimeWithinDay(tv)))로 둔다.
  7. vTimeClip(newDate)로 둔다.
  8. dateObj.[[DateValue]]v로 설정한다.
  9. v를 반환한다.

21.4.4.29 Date.prototype.setUTCFullYear ( year [ , month [ , date ] ] )

이 메서드는 호출될 때 다음 단계를 수행한다:

  1. dateObjthis 값으로 둔다.
  2. RequireInternalSlot(dateObj, [[DateValue]])을 수행한다.
  3. tvdateObj.[[DateValue]]로 둔다.
  4. tvNaN이면 tv+0𝔽으로 설정한다.
  5. y를 ? ToNumber(year)로 둔다.
  6. month가 존재하면 m을 ? ToNumber(month)로 두고, 그렇지 않으면 m𝔽(MonthFromTime(tv))로 둔다.
  7. date가 존재하면 dt를 ? ToNumber(date)로 두고, 그렇지 않으면 dt𝔽(DateFromTime(tv))로 둔다.
  8. newDateMakeDate(MakeDay(y, m, dt), 𝔽(TimeWithinDay(tv)))로 둔다.
  9. vTimeClip(newDate)로 둔다.
  10. dateObj.[[DateValue]]v로 설정한다.
  11. v를 반환한다.

이 메서드의 "length" 속성은 3𝔽이다.

Note

month가 존재하지 않으면 이 메서드는 monthgetUTCMonth() 값으로 존재하는 것처럼 동작한다. date가 존재하지 않으면 dategetUTCDate() 값으로 존재하는 것처럼 동작한다.

21.4.4.30 Date.prototype.setUTCHours ( hour [ , min [ , sec [ , ms ] ] ] )

이 메서드는 호출될 때 다음 단계를 수행한다:

  1. dateObjthis 값으로 둔다.
  2. RequireInternalSlot(dateObj, [[DateValue]])을 수행한다.
  3. tvdateObj.[[DateValue]]로 둔다.
  4. h를 ? ToNumber(hour)로 둔다.
  5. min이 존재하면 m을 ? ToNumber(min)로 둔다.
  6. sec가 존재하면 s를 ? ToNumber(sec)로 둔다.
  7. ms가 존재하면 milli를 ? ToNumber(ms)로 둔다.
  8. tvNaN이면 NaN을 반환한다.
  9. min이 존재하지 않으면 m𝔽(MinFromTime(tv))로 둔다.
  10. sec가 존재하지 않으면 s𝔽(SecFromTime(tv))로 둔다.
  11. ms가 존재하지 않으면 milli𝔽(MillisecFromTime(tv))로 둔다.
  12. dateMakeDate(𝔽(Day(tv)), MakeTime(h, m, s, milli))로 둔다.
  13. vTimeClip(date)로 둔다.
  14. dateObj.[[DateValue]]v로 설정한다.
  15. v를 반환한다.

이 메서드의 "length" 속성은 4𝔽이다.

Note

min이 존재하지 않으면 이 메서드는 mingetUTCMinutes() 값으로 존재하는 것처럼 동작한다. sec가 존재하지 않으면 secgetUTCSeconds() 값으로 존재하는 것처럼 동작한다. ms가 존재하지 않으면 msgetUTCMilliseconds() 값으로 존재하는 것처럼 동작한다.

21.4.4.31 Date.prototype.setUTCMilliseconds ( ms )

이 메서드는 호출될 때 다음 단계를 수행한다:

  1. dateObjthis 값으로 둔다.
  2. RequireInternalSlot(dateObj, [[DateValue]])을 수행한다.
  3. tvdateObj.[[DateValue]]로 둔다.
  4. ms를 ? ToNumber(ms)로 설정한다.
  5. tvNaN이면 NaN을 반환한다.
  6. timeMakeTime(𝔽(HourFromTime(tv)), 𝔽(MinFromTime(tv)), 𝔽(SecFromTime(tv)), ms)로 둔다.
  7. vTimeClip(MakeDate(𝔽(Day(tv)), time))로 둔다.
  8. dateObj.[[DateValue]]v로 설정한다.
  9. v를 반환한다.

21.4.4.32 Date.prototype.setUTCMinutes ( min [ , sec [ , ms ] ] )

이 메서드는 호출될 때 다음 단계를 수행한다:

  1. dateObjthis 값으로 둔다.
  2. RequireInternalSlot(dateObj, [[DateValue]])을 수행한다.
  3. tvdateObj.[[DateValue]]로 둔다.
  4. m을 ? ToNumber(min)로 둔다.
  5. sec가 존재하면 s를 ? ToNumber(sec)로 둔다.
  6. ms가 존재하면 milli를 ? ToNumber(ms)로 둔다.
  7. tvNaN이면 NaN을 반환한다.
  8. sec가 존재하지 않으면 s𝔽(SecFromTime(tv))로 둔다.
  9. ms가 존재하지 않으면 milli𝔽(MillisecFromTime(tv))로 둔다.
  10. dateMakeDate(𝔽(Day(tv)), MakeTime(𝔽(HourFromTime(tv)), m, s, milli))로 둔다.
  11. vTimeClip(date)로 둔다.
  12. dateObj.[[DateValue]]v로 설정한다.
  13. v를 반환한다.

이 메서드의 "length" 속성은 3𝔽이다.

Note

sec가 존재하지 않으면 이 메서드는 secgetUTCSeconds() 값으로 존재하는 것처럼 동작한다. ms가 존재하지 않으면 msgetUTCMilliseconds()에서 반환된 값으로 존재하는 것처럼 동작한다.

21.4.4.33 Date.prototype.setUTCMonth ( month [ , date ] )

이 메서드는 호출될 때 다음 단계를 수행한다:

  1. dateObjthis 값으로 둔다.
  2. RequireInternalSlot(dateObj, [[DateValue]])을 수행한다.
  3. tvdateObj.[[DateValue]]로 둔다.
  4. m을 ? ToNumber(month)로 둔다.
  5. date가 존재하면 dt를 ? ToNumber(date)로 둔다.
  6. tvNaN이면 NaN을 반환한다.
  7. date가 존재하지 않으면 dt𝔽(DateFromTime(tv))로 둔다.
  8. newDateMakeDate(MakeDay(𝔽(YearFromTime(tv)), m, dt), 𝔽(TimeWithinDay(tv)))로 둔다.
  9. vTimeClip(newDate)로 둔다.
  10. dateObj.[[DateValue]]v로 설정한다.
  11. v를 반환한다.

이 메서드의 "length" 속성은 2𝔽이다.

Note

date가 존재하지 않으면 이 메서드는 dategetUTCDate() 값으로 존재하는 것처럼 동작한다.

21.4.4.34 Date.prototype.setUTCSeconds ( sec [ , ms ] )

이 메서드는 호출될 때 다음 단계를 수행한다:

  1. dateObjthis 값으로 둔다.
  2. RequireInternalSlot(dateObj, [[DateValue]])을 수행한다.
  3. tvdateObj.[[DateValue]]로 둔다.
  4. s를 ? ToNumber(sec)로 둔다.
  5. ms가 존재하면 milli를 ? ToNumber(ms)로 둔다.
  6. tvNaN이면 NaN을 반환한다.
  7. ms가 존재하지 않으면 milli𝔽(MillisecFromTime(tv))로 둔다.
  8. dateMakeDate(𝔽(Day(tv)), MakeTime(𝔽(HourFromTime(tv)), 𝔽(MinFromTime(tv)), s, milli))로 둔다.
  9. vTimeClip(date)로 둔다.
  10. dateObj.[[DateValue]]v로 설정한다.
  11. v를 반환한다.

이 메서드의 "length" 속성은 2𝔽이다.

Note

ms가 존재하지 않으면 이 메서드는 msgetUTCMilliseconds() 값으로 존재하는 것처럼 동작한다.

21.4.4.35 Date.prototype.toDateString ( )

이 method는 called될 때 following steps를 수행합니다:

  1. dateObjthis value로 둔다.
  2. RequireInternalSlot(dateObj, [[DateValue]])를 수행한다.
  3. tvdateObj.[[DateValue]]로 둔다.
  4. tvNaN이면, "Invalid Date"를 반환한다.
  5. tLocalTime(tv)로 둔다.
  6. DateString(t)를 반환한다.

21.4.4.36 Date.prototype.toISOString ( )

이 method는 called될 때 following steps를 수행합니다:

  1. dateObjthis value로 둔다.
  2. RequireInternalSlot(dateObj, [[DateValue]])를 수행한다.
  3. tvdateObj.[[DateValue]]로 둔다.
  4. tvNaN이면, RangeError exception을 throw한다.
  5. Assert: tvintegral Number이다.
  6. tvDate Time String Format으로 represent될 수 없는 year와 corresponding하면, RangeError exception을 throw한다.
  7. all format elements 및 UTC offset representation "Z"를 포함하여 UTC time scale 상에서 Date Time String Format으로 된 tv의 String representation을 반환한다.

21.4.4.37 Date.prototype.toJSON ( key )

이 method는 JSON.stringify(25.5.4)가 사용할 Date의 String representation을 제공합니다.

called될 때 following steps를 수행합니다:

  1. obj를 ? ToObject(this value)로 둔다.
  2. tv를 ? ToPrimitive(obj, number)로 둔다.
  3. tv가 Number이고 tvfinite가 아니면, null을 반환한다.
  4. Invoke(obj, "toISOString")를 반환한다.
Note 1

argument는 ignored됩니다.

Note 2

이 method는 intentionally generic입니다; this value가 Date일 것을 require하지 않습니다. 따라서 method로 사용하기 위해 other kinds of objects에 transferred될 수 있습니다. However, any such object가 toISOString method를 가질 것을 require합니다.

21.4.4.38 Date.prototype.toLocaleDateString ( [ reserved1 [ , reserved2 ] ] )

ECMA-402 Internationalization API를 include하는 ECMAScript implementation은 ECMA-402 specification에 specified된 대로 이 method를 implement해야 합니다. ECMAScript implementation이 ECMA-402 API를 include하지 않으면 이 method의 following specification이 사용됩니다:

이 method는 String value를 반환합니다. String의 contents는 implementation-defined이지만, host environment의 current locale의 convention에 corresponding하는 convenient, human-readable form으로 current time zone에서 Date의 “date” portion을 represent하도록 intended됩니다.

이 method에 대한 optional parameter의 meaning은 ECMA-402 specification에 defined되어 있습니다; ECMA-402 support를 include하지 않는 implementation은 those parameter position을 anything else에 사용해서는 안 됩니다.

21.4.4.39 Date.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] )

ECMA-402 Internationalization API를 include하는 ECMAScript implementation은 ECMA-402 specification에 specified된 대로 이 method를 implement해야 합니다. ECMAScript implementation이 ECMA-402 API를 include하지 않으면 이 method의 following specification이 사용됩니다:

이 method는 String value를 반환합니다. String의 contents는 implementation-defined이지만, host environment의 current locale의 convention에 corresponding하는 convenient, human-readable form으로 current time zone에서 Date를 represent하도록 intended됩니다.

이 method에 대한 optional parameter의 meaning은 ECMA-402 specification에 defined되어 있습니다; ECMA-402 support를 include하지 않는 implementation은 those parameter position을 anything else에 사용해서는 안 됩니다.

21.4.4.40 Date.prototype.toLocaleTimeString ( [ reserved1 [ , reserved2 ] ] )

ECMA-402 Internationalization API를 include하는 ECMAScript implementation은 ECMA-402 specification에 specified된 대로 이 method를 implement해야 합니다. ECMAScript implementation이 ECMA-402 API를 include하지 않으면 이 method의 following specification이 사용됩니다:

이 method는 String value를 반환합니다. String의 contents는 implementation-defined이지만, host environment의 current locale의 convention에 corresponding하는 convenient, human-readable form으로 current time zone에서 Date의 “time” portion을 represent하도록 intended됩니다.

이 method에 대한 optional parameter의 meaning은 ECMA-402 specification에 defined되어 있습니다; ECMA-402 support를 include하지 않는 implementation은 those parameter position을 anything else에 사용해서는 안 됩니다.

21.4.4.41 Date.prototype.toString ( )

이 method는 called될 때 following steps를 수행합니다:

  1. dateObjthis value로 둔다.
  2. RequireInternalSlot(dateObj, [[DateValue]])를 수행한다.
  3. tvdateObj.[[DateValue]]로 둔다.
  4. ToDateString(tv)를 반환한다.
Note 1

d.[[DateValue]]가 1000으로 evenly divisible한 any Date d에 대해, Date.parse(d.toString())의 result는 d.valueOf()와 =입니다. 21.4.3.2를 참조하십시오.

Note 2

이 method는 generic하지 않습니다; this value가 Date가 아니면 TypeError exception을 throw합니다. 따라서 method로 사용하기 위해 other kinds of objects에 transferred될 수 없습니다.

21.4.4.41.1 TimeString ( tv )

The abstract operation TimeString takes argument tv (Number이지만 NaN은 아님) and returns String. It performs the following steps when called:

  1. hourToZeroPaddedDecimalString(HourFromTime(tv), 2)로 둔다.
  2. minuteToZeroPaddedDecimalString(MinFromTime(tv), 2)로 둔다.
  3. secondToZeroPaddedDecimalString(SecFromTime(tv), 2)로 둔다.
  4. hour, ":", minute, ":", second, 코드 단위 0x0020 (SPACE), "GMT"를 문자열로 연결한 결과를 반환한다.

21.4.4.41.2 DateString ( tv )

The abstract operation DateString takes argument tv (Number이지만 NaN은 아님) and returns String. It performs the following steps when called:

  1. weekdayTable 61에서 WeekDay Index = WeekDay(tv)인 항목의 Name으로 둔다.
  2. monthTable 62에서 Month Index = MonthFromTime(tv)인 항목의 Name으로 둔다.
  3. dayToZeroPaddedDecimalString(DateFromTime(tv), 2)로 둔다.
  4. yvYearFromTime(tv)으로 둔다.
  5. yv ≥ 0이면 yearSign을 빈 String으로 두고, 그렇지 않으면 yearSign"-"로 둔다.
  6. paddedYearToZeroPaddedDecimalString(abs(yv), 4)로 둔다.
  7. weekday, 코드 단위 0x0020 (SPACE), month, 코드 단위 0x0020 (SPACE), day, 코드 단위 0x0020 (SPACE), yearSign, paddedYear를 문자열로 연결한 결과를 반환한다.
Table 61: 요일 이름
WeekDay 인덱스 이름
0 "Sun"
1 "Mon"
2 "Tue"
3 "Wed"
4 "Thu"
5 "Fri"
6 "Sat"
Table 62: 연중 월 이름
Month 인덱스 이름
0 "Jan"
1 "Feb"
2 "Mar"
3 "Apr"
4 "May"
5 "Jun"
6 "Jul"
7 "Aug"
8 "Sep"
9 "Oct"
10 "Nov"
11 "Dec"

21.4.4.41.3 TimeZoneString ( tv )

The abstract operation TimeZoneString takes argument tv (정수인 Number) and returns String. It performs the following steps when called:

  1. systemTimeZoneIdentifierSystemTimeZoneIdentifier()로 둔다.
  2. IsTimeZoneOffsetString(systemTimeZoneIdentifier)가 true이면,
    1. offsetNsParseTimeZoneOffsetString(systemTimeZoneIdentifier)로 둔다.
  3. 그렇지 않으면,
    1. offsetNsGetNamedTimeZoneOffsetNanoseconds(systemTimeZoneIdentifier, (tv) × nsPerMillisecond)로 둔다.
  4. offsettruncate(offsetNs / nsPerMillisecond)로 둔다.
  5. offset ≥ 0이면,
    1. offsetSign"+"로 둔다.
    2. absOffsetoffset으로 둔다.
  6. 그렇지 않으면,
    1. offsetSign"-"로 둔다.
    2. absOffset을 -offset으로 둔다.
  7. offsetMinToZeroPaddedDecimalString(MinFromTime(𝔽(absOffset)), 2)로 둔다.
  8. offsetHourToZeroPaddedDecimalString(HourFromTime(𝔽(absOffset)), 2)로 둔다.
  9. tzName을 빈 String이거나 코드 단위 0x0020 (SPACE), 코드 단위 0x0028 (LEFT PARENTHESIS), 구현 정의 시간대 이름, 코드 단위 0x0029 (RIGHT PARENTHESIS)를 문자열로 연결한 구현 정의 문자열로 둔다.
  10. offsetSign, offsetHour, offsetMin, tzName을 문자열로 연결한 결과를 반환한다.

21.4.4.41.4 ToDateString ( tv )

The abstract operation ToDateString takes argument tv (정수인 Number 또는 NaN) and returns String. It performs the following steps when called:

  1. tvNaN이면 "Invalid Date"를 반환한다.
  2. localTimeLocalTime(tv)으로 둔다.
  3. DateString(localTime), 코드 단위 0x0020 (SPACE), TimeString(localTime), TimeZoneString(tv)를 문자열로 연결한 결과를 반환한다.

21.4.4.42 Date.prototype.toTimeString ( )

이 method는 called될 때 following steps를 수행합니다:

  1. dateObjthis value로 둔다.
  2. RequireInternalSlot(dateObj, [[DateValue]])를 수행한다.
  3. tvdateObj.[[DateValue]]로 둔다.
  4. tvNaN이면, "Invalid Date"를 반환한다.
  5. localTimeLocalTime(tv)로 둔다.
  6. TimeString(localTime)과 TimeZoneString(tv)의 string-concatenation을 반환한다.

21.4.4.43 Date.prototype.toUTCString ( )

이 method는 this value에 corresponding하는 instant in time을 represent하는 String value를 반환합니다. String의 format은 RFC 7231의 HTTP-date를 기반으로 하며, ECMAScript Dates가 support하는 full range of times를 support하도록 generalized됩니다.

called될 때 following steps를 수행합니다:

  1. dateObjthis 값으로 둔다.
  2. RequireInternalSlot(dateObj, [[DateValue]])을 수행한다.
  3. tvdateObj.[[DateValue]]로 둔다.
  4. tvNaN이면 "Invalid Date"를 반환한다.
  5. weekdayTable 61에서 WeekDay 인덱스 = WeekDay(tv)인 항목의 이름으로 둔다.
  6. monthTable 62에서 Month 인덱스 = MonthFromTime(tv)인 항목의 이름으로 둔다.
  7. dayToZeroPaddedDecimalString(DateFromTime(tv), 2)로 둔다.
  8. yvYearFromTime(tv)으로 둔다.
  9. yv ≥ 0이면 yearSign을 빈 String으로 두고, 그렇지 않으면 yearSign"-"로 둔다.
  10. paddedYearToZeroPaddedDecimalString(abs(yv), 4)로 둔다.
  11. weekday, ",", 코드 단위 0x0020 (SPACE), day, 코드 단위 0x0020 (SPACE), month, 코드 단위 0x0020 (SPACE), yearSign, paddedYear, 코드 단위 0x0020 (SPACE), TimeString(tv)을 문자열로 연결한 결과를 반환한다.

21.4.4.44 Date.prototype.valueOf ( )

이 method는 called될 때 following steps를 수행합니다:

  1. dateObjthis value로 둔다.
  2. RequireInternalSlot(dateObj, [[DateValue]])를 수행한다.
  3. dateObj.[[DateValue]]를 반환한다.

21.4.4.45 Date.prototype [ %Symbol.toPrimitive% ] ( hint )

이 method는 ECMAScript language operator가 Date를 primitive value로 convert하기 위해 called합니다. hint에 allowed되는 values는 "default", "number", 및 "string"입니다. Date는 "default""string"과 equivalent하게 treat한다는 점에서 built-in ECMAScript object 중 unique합니다. all other built-in ECMAScript objects는 "default""number"와 equivalent하게 treat합니다.

called될 때 following steps를 수행합니다:

  1. objthis value로 둔다.
  2. obj가 Object가 아니면, TypeError exception을 throw한다.
  3. hint"string" 또는 "default" 중 하나이면, 다음을 수행한다.
    1. tryFirststring으로 둔다.
  4. 그렇지 않고 hint"number"이면, 다음을 수행한다.
    1. tryFirstnumber로 둔다.
  5. 그렇지 않으면,
    1. TypeError exception을 throw한다.
  6. OrdinaryToPrimitive(obj, tryFirst)를 반환한다.

이 property는 attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }를 가집니다.

이 method의 "name" property의 value는 "[Symbol.toPrimitive]"입니다.

21.4.5 Properties of Date Instances

Date instance는 Date prototype object에서 property를 inherit하는 ordinary object입니다. Date instance는 또한 [[DateValue]] internal slot을 가집니다. [[DateValue]] internal slot은 이 Date가 represented하는 time value입니다.