tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

value-to-primitive-result-string.js (1444B)


      1 // Copyright (C) 2016 the V8 project authors. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 /*---
      4 esid: sec-date-value
      5 description: Exotic `Symbol.toPrimitive` method returns a String value
      6 info: |
      7  3. If NewTarget is not undefined, then
      8     a. If Type(value) is Object and value has a [[DateValue]] internal slot, then
      9        i. Let tv be thisTimeValue(value).
     10     b. Else,
     11        i. Let v be ? ToPrimitive(value).
     12        ii. If Type(v) is String, then
     13            1. Let tv be the result of parsing v as a date, in exactly the same
     14               manner as for the parse method (20.3.3.2). If the parse resulted
     15               in an abrupt completion, tv is the Completion Record.
     16 
     17  ToPrimitive ( input [ , PreferredType ] )
     18 
     19  1. If PreferredType was not passed, let hint be "default".
     20  2. Else if PreferredType is hint String, let hint be "string".
     21  3. Else PreferredType is hint Number, let hint be "number".
     22  4. Let exoticToPrim be ? GetMethod(input, @@toPrimitive).
     23  5. If exoticToPrim is not undefined, then
     24     a. Let result be ? Call(exoticToPrim, input, « hint »).
     25     b. If Type(result) is not Object, return result.
     26 features: [Symbol.toPrimitive]
     27 ---*/
     28 
     29 var stringToPrimitive = {};
     30 stringToPrimitive[Symbol.toPrimitive] = function() {
     31  return '2016-06-05T18:40:00.000Z';
     32 };
     33 
     34 assert.sameValue(new Date(stringToPrimitive).getTime(), 1465152000000);
     35 
     36 reportCompare(0, 0);