source: imaps-frontend/node_modules/es-abstract/2024/TimeString.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: 818 bytes
RevLine 
[d565449]1'use strict';
2
3var $TypeError = require('es-errors/type');
4
5var $isNaN = require('../helpers/isNaN');
6
7var HourFromTime = require('./HourFromTime');
8var MinFromTime = require('./MinFromTime');
9var SecFromTime = require('./SecFromTime');
10var ToZeroPaddedDecimalString = require('./ToZeroPaddedDecimalString');
11
12// https://262.ecma-international.org/13.0/#sec-timestring
13
14module.exports = function TimeString(tv) {
15 if (typeof tv !== 'number' || $isNaN(tv)) {
16 throw new $TypeError('Assertion failed: `tv` must be a non-NaN Number');
17 }
18
19 var hour = ToZeroPaddedDecimalString(HourFromTime(tv), 2); // step 1
20
21 var minute = ToZeroPaddedDecimalString(MinFromTime(tv), 2); // step 2
22
23 var second = ToZeroPaddedDecimalString(SecFromTime(tv), 2); // step 3
24
25 return hour + ':' + minute + ':' + second + ' GMT'; // step 4
26};
Note: See TracBrowser for help on using the repository browser.