source: imaps-frontend/node_modules/es-abstract/2020/DateString.js

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

Update repo after prototype presentation

  • Property mode set to 100644
File size: 978 bytes
Line 
1'use strict';
2
3var $TypeError = require('es-errors/type');
4
5var weekdays = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
6var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
7
8var $isNaN = require('../helpers/isNaN');
9var padTimeComponent = require('../helpers/padTimeComponent');
10
11var DateFromTime = require('./DateFromTime');
12var MonthFromTime = require('./MonthFromTime');
13var WeekDay = require('./WeekDay');
14var YearFromTime = require('./YearFromTime');
15
16// https://262.ecma-international.org/9.0/#sec-datestring
17
18module.exports = function DateString(tv) {
19 if (typeof tv !== 'number' || $isNaN(tv)) {
20 throw new $TypeError('Assertion failed: `tv` must be a non-NaN Number');
21 }
22 var weekday = weekdays[WeekDay(tv)];
23 var month = months[MonthFromTime(tv)];
24 var day = padTimeComponent(DateFromTime(tv));
25 var year = padTimeComponent(YearFromTime(tv), 4);
26 return weekday + '\x20' + month + '\x20' + day + '\x20' + year;
27};
Note: See TracBrowser for help on using the repository browser.