source: imaps-frontend/node_modules/es-abstract/2023/MakeDay.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: 1007 bytes
Line 
1'use strict';
2
3var GetIntrinsic = require('get-intrinsic');
4
5var $DateUTC = GetIntrinsic('%Date.UTC%');
6
7var $isFinite = require('../helpers/isFinite');
8
9var DateFromTime = require('./DateFromTime');
10var Day = require('./Day');
11var floor = require('./floor');
12var modulo = require('./modulo');
13var MonthFromTime = require('./MonthFromTime');
14var ToIntegerOrInfinity = require('./ToIntegerOrInfinity');
15var YearFromTime = require('./YearFromTime');
16
17// https://262.ecma-international.org/5.1/#sec-15.9.1.12
18
19module.exports = function MakeDay(year, month, date) {
20 if (!$isFinite(year) || !$isFinite(month) || !$isFinite(date)) {
21 return NaN;
22 }
23 var y = ToIntegerOrInfinity(year);
24 var m = ToIntegerOrInfinity(month);
25 var dt = ToIntegerOrInfinity(date);
26 var ym = y + floor(m / 12);
27 if (!$isFinite(ym)) {
28 return NaN;
29 }
30 var mn = modulo(m, 12);
31 var t = $DateUTC(ym, mn, 1);
32 if (YearFromTime(t) !== ym || MonthFromTime(t) !== mn || DateFromTime(t) !== 1) {
33 return NaN;
34 }
35 return Day(t) + dt - 1;
36};
Note: See TracBrowser for help on using the repository browser.