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
|
Rev | Line | |
---|
[d565449] | 1 | 'use strict';
|
---|
| 2 |
|
---|
| 3 | var $TypeError = require('es-errors/type');
|
---|
| 4 |
|
---|
| 5 | var $isNaN = require('../helpers/isNaN');
|
---|
| 6 |
|
---|
| 7 | var HourFromTime = require('./HourFromTime');
|
---|
| 8 | var MinFromTime = require('./MinFromTime');
|
---|
| 9 | var SecFromTime = require('./SecFromTime');
|
---|
| 10 | var ToZeroPaddedDecimalString = require('./ToZeroPaddedDecimalString');
|
---|
| 11 |
|
---|
| 12 | // https://262.ecma-international.org/13.0/#sec-timestring
|
---|
| 13 |
|
---|
| 14 | module.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.