Projekt

Obecné

Profil

Stáhnout (936 Bajtů) Statistiky
| Větev: | Revize:
1 3a515b92 cagy
'use strict';
2
3
var GetIntrinsic = require('../GetIntrinsic');
4
5
var $floor = GetIntrinsic('%Math.floor%');
6
var $DateUTC = GetIntrinsic('%Date.UTC%');
7
8
var mod = require('../helpers/mod');
9
var $isFinite = require('../helpers/isFinite');
10
11
var DateFromTime = require('./DateFromTime');
12
var Day = require('./Day');
13
var MonthFromTime = require('./MonthFromTime');
14
var ToInteger = require('./ToInteger');
15
var YearFromTime = require('./YearFromTime');
16
17
// https://ecma-international.org/ecma-262/5.1/#sec-15.9.1.12
18
19
module.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 = mod(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
};