the-forest/client/node_modules/es-abstract/2023/TimeString.js

27 lines
818 B
JavaScript
Raw Normal View History

2024-09-17 20:35:18 -04:00
'use strict';
var $TypeError = require('es-errors/type');
var $isNaN = require('../helpers/isNaN');
var HourFromTime = require('./HourFromTime');
var MinFromTime = require('./MinFromTime');
var SecFromTime = require('./SecFromTime');
var ToZeroPaddedDecimalString = require('./ToZeroPaddedDecimalString');
// https://262.ecma-international.org/13.0/#sec-timestring
module.exports = function TimeString(tv) {
if (typeof tv !== 'number' || $isNaN(tv)) {
throw new $TypeError('Assertion failed: `tv` must be a non-NaN Number');
}
var hour = ToZeroPaddedDecimalString(HourFromTime(tv), 2); // step 1
var minute = ToZeroPaddedDecimalString(MinFromTime(tv), 2); // step 2
var second = ToZeroPaddedDecimalString(SecFromTime(tv), 2); // step 3
return hour + ':' + minute + ':' + second + ' GMT'; // step 4
};