source: imaps-frontend/node_modules/es-abstract/2019/ToDateString.js@ d565449

main
Last change on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 514 bytes
Line 
1'use strict';
2
3var GetIntrinsic = require('get-intrinsic');
4
5var $TypeError = require('es-errors/type');
6var $Date = GetIntrinsic('%Date%');
7var $String = GetIntrinsic('%String%');
8
9var $isNaN = require('../helpers/isNaN');
10
11// https://262.ecma-international.org/6.0/#sec-todatestring
12
13module.exports = function ToDateString(tv) {
14 if (typeof tv !== 'number') {
15 throw new $TypeError('Assertion failed: `tv` must be a Number');
16 }
17 if ($isNaN(tv)) {
18 return 'Invalid Date';
19 }
20 return $String(new $Date(tv));
21};
Note: See TracBrowser for help on using the repository browser.