Permalink
Cannot retrieve contributors at this time
30 lines (23 sloc)
1.03 KB
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
codeql-action/node_modules/es-abstract/2023/DateString.js
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var GetIntrinsic = require('get-intrinsic'); | |
var $TypeError = GetIntrinsic('%TypeError%'); | |
var weekdays = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']; | |
var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; | |
var $isNaN = require('../helpers/isNaN'); | |
var padTimeComponent = require('../helpers/padTimeComponent'); | |
var Type = require('./Type'); | |
var WeekDay = require('./WeekDay'); | |
var MonthFromTime = require('./MonthFromTime'); | |
var YearFromTime = require('./YearFromTime'); | |
var DateFromTime = require('./DateFromTime'); | |
// https://262.ecma-international.org/9.0/#sec-datestring | |
module.exports = function DateString(tv) { | |
if (Type(tv) !== 'Number' || $isNaN(tv)) { | |
throw new $TypeError('Assertion failed: `tv` must be a non-NaN Number'); | |
} | |
var weekday = weekdays[WeekDay(tv)]; | |
var month = months[MonthFromTime(tv)]; | |
var day = padTimeComponent(DateFromTime(tv)); | |
var year = padTimeComponent(YearFromTime(tv), 4); | |
return weekday + '\x20' + month + '\x20' + day + '\x20' + year; | |
}; |