InLeapYear.js 462 B

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