1
|
'use strict';
|
2
|
|
3
|
var GetIntrinsic = require('../GetIntrinsic');
|
4
|
|
5
|
var $TypeError = GetIntrinsic('%TypeError%');
|
6
|
var $Date = GetIntrinsic('%Date%');
|
7
|
|
8
|
var $isNaN = require('../helpers/isNaN');
|
9
|
|
10
|
var Type = require('./Type');
|
11
|
|
12
|
// https://ecma-international.org/ecma-262/6.0/#sec-todatestring
|
13
|
|
14
|
module.exports = function ToDateString(tv) {
|
15
|
if (Type(tv) !== 'Number') {
|
16
|
throw new $TypeError('Assertion failed: `tv` must be a Number');
|
17
|
}
|
18
|
if ($isNaN(tv)) {
|
19
|
return 'Invalid Date';
|
20
|
}
|
21
|
return $Date(tv);
|
22
|
};
|