source: imaps-frontend/node_modules/es-abstract/2017/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: 917 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 ToInteger = require('./ToInteger');
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 = ToInteger(year);
24 var m = ToInteger(month);
25 var dt = ToInteger(date);
26 var ym = y + floor(m / 12);
27 var mn = modulo(m, 12);
28 var t = $DateUTC(ym, mn, 1);
29 if (YearFromTime(t) !== ym || MonthFromTime(t) !== mn || DateFromTime(t) !== 1) {
30 return NaN;
31 }
32 return Day(t) + dt - 1;
33};
Note: See TracBrowser for help on using the repository browser.