You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

InLeapYear.js 517B

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