blob: bfe0c451f4e79b74150e5bf26fae8b507eaff216 [file] [log] [blame]
Leo Repp58b9f112021-11-22 11:57:47 +01001'use strict';
2
3var GetIntrinsic = require('get-intrinsic');
4
5var $EvalError = GetIntrinsic('%EvalError%');
6
7var DaysInYear = require('./DaysInYear');
8var YearFromTime = require('./YearFromTime');
9
10// https://262.ecma-international.org/5.1/#sec-15.9.1.3
11
12module.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};