main
Last change
on this file since d565449 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
|
Rev | Line | |
---|
[d565449] | 1 | 'use strict';
|
---|
| 2 |
|
---|
| 3 | var GetIntrinsic = require('get-intrinsic');
|
---|
| 4 |
|
---|
| 5 | var $DateUTC = GetIntrinsic('%Date.UTC%');
|
---|
| 6 |
|
---|
| 7 | var $isFinite = require('../helpers/isFinite');
|
---|
| 8 |
|
---|
| 9 | var DateFromTime = require('./DateFromTime');
|
---|
| 10 | var Day = require('./Day');
|
---|
| 11 | var floor = require('./floor');
|
---|
| 12 | var modulo = require('./modulo');
|
---|
| 13 | var MonthFromTime = require('./MonthFromTime');
|
---|
| 14 | var ToInteger = require('./ToInteger');
|
---|
| 15 | var YearFromTime = require('./YearFromTime');
|
---|
| 16 |
|
---|
| 17 | // https://262.ecma-international.org/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 = 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.