Projekt

Obecné

Profil

Stáhnout (1.04 KB) Statistiky
| Větev: | Revize:
1
'use strict';
2

    
3
var GetIntrinsic = require('../GetIntrinsic');
4

    
5
var $TypeError = GetIntrinsic('%TypeError%');
6

    
7
var weekdays = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
8
var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
9

    
10
var $isNaN = require('../helpers/isNaN');
11
var padTimeComponent = require('../helpers/padTimeComponent');
12

    
13
var Type = require('./Type');
14
var WeekDay = require('./WeekDay');
15
var MonthFromTime = require('./MonthFromTime');
16
var YearFromTime = require('./YearFromTime');
17
var DateFromTime = require('./DateFromTime');
18

    
19
// https://www.ecma-international.org/ecma-262/9.0/#sec-datestring
20

    
21
module.exports = function DateString(tv) {
22
	if (Type(tv) !== 'Number' || $isNaN(tv)) {
23
		throw new $TypeError('Assertion failed: `tv` must be a non-NaN Number');
24
	}
25
	var weekday = weekdays[WeekDay(tv)];
26
	var month = months[MonthFromTime(tv)];
27
	var day = padTimeComponent(DateFromTime(tv));
28
	var year = padTimeComponent(YearFromTime(tv), 4);
29
	return weekday + '\x20' + month + '\x20' + day + '\x20' + year;
30
};
(15-15/117)