Son CV dans un terminal web en Javascript!
https://terminal-cv.gregandev.fr
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1012 B
37 lines
1012 B
1 year ago
|
'use strict';
|
||
|
|
||
|
var GetIntrinsic = require('get-intrinsic');
|
||
|
|
||
|
var $DateUTC = GetIntrinsic('%Date.UTC%');
|
||
|
|
||
|
var $isFinite = require('../helpers/isFinite');
|
||
|
|
||
|
var DateFromTime = require('./DateFromTime');
|
||
|
var Day = require('./Day');
|
||
|
var floor = require('./floor');
|
||
|
var modulo = require('./modulo');
|
||
|
var MonthFromTime = require('./MonthFromTime');
|
||
|
var ToIntegerOrInfinity = require('./ToIntegerOrInfinity');
|
||
|
var YearFromTime = require('./YearFromTime');
|
||
|
|
||
|
// https://ecma-international.org/ecma-262/5.1/#sec-15.9.1.12
|
||
|
|
||
|
module.exports = function MakeDay(year, month, date) {
|
||
|
if (!$isFinite(year) || !$isFinite(month) || !$isFinite(date)) {
|
||
|
return NaN;
|
||
|
}
|
||
|
var y = ToIntegerOrInfinity(year);
|
||
|
var m = ToIntegerOrInfinity(month);
|
||
|
var dt = ToIntegerOrInfinity(date);
|
||
|
var ym = y + floor(m / 12);
|
||
|
if (!$isFinite(ym)) {
|
||
|
return NaN;
|
||
|
}
|
||
|
var mn = modulo(m, 12);
|
||
|
var t = $DateUTC(ym, mn, 1);
|
||
|
if (YearFromTime(t) !== ym || MonthFromTime(t) !== mn || DateFromTime(t) !== 1) {
|
||
|
return NaN;
|
||
|
}
|
||
|
return Day(t) + dt - 1;
|
||
|
};
|