2020-08-25 23:57:08 +00:00
|
|
|
'use strict';
|
|
|
|
|
2021-02-26 03:58:33 +00:00
|
|
|
var modulo = require('./modulo');
|
2020-08-25 23:57:08 +00:00
|
|
|
|
|
|
|
// https://ecma-international.org/ecma-262/5.1/#sec-15.9.1.3
|
|
|
|
|
|
|
|
module.exports = function DaysInYear(y) {
|
2021-02-26 03:58:33 +00:00
|
|
|
if (modulo(y, 4) !== 0) {
|
2020-08-25 23:57:08 +00:00
|
|
|
return 365;
|
|
|
|
}
|
2021-02-26 03:58:33 +00:00
|
|
|
if (modulo(y, 100) !== 0) {
|
2020-08-25 23:57:08 +00:00
|
|
|
return 366;
|
|
|
|
}
|
2021-02-26 03:58:33 +00:00
|
|
|
if (modulo(y, 400) !== 0) {
|
2020-08-25 23:57:08 +00:00
|
|
|
return 365;
|
|
|
|
}
|
|
|
|
return 366;
|
|
|
|
};
|