1 |
3a515b92
|
cagy
|
'use strict';
|
2 |
|
|
|
3 |
|
|
var GetIntrinsic = require('../GetIntrinsic');
|
4 |
|
|
|
5 |
|
|
var $EvalError = GetIntrinsic('%EvalError%');
|
6 |
|
|
|
7 |
|
|
var DaysInYear = require('./DaysInYear');
|
8 |
|
|
var YearFromTime = require('./YearFromTime');
|
9 |
|
|
|
10 |
|
|
// https://ecma-international.org/ecma-262/5.1/#sec-15.9.1.3
|
11 |
|
|
|
12 |
|
|
module.exports = function InLeapYear(t) {
|
13 |
|
|
var days = DaysInYear(YearFromTime(t));
|
14 |
|
|
if (days === 365) {
|
15 |
|
|
return 0;
|
16 |
|
|
}
|
17 |
|
|
if (days === 366) {
|
18 |
|
|
return 1;
|
19 |
|
|
}
|
20 |
|
|
throw new $EvalError('Assertion failed: there are not 365 or 366 days in a year, got: ' + days);
|
21 |
|
|
};
|