es.date.get-year.js 631 B

1234567891011121314151617181920
  1. 'use strict';
  2. var $ = require('../internals/export');
  3. var uncurryThis = require('../internals/function-uncurry-this');
  4. var fails = require('../internals/fails');
  5. // IE8- non-standard case
  6. var FORCED = fails(function () {
  7. // eslint-disable-next-line es/no-date-prototype-getyear-setyear -- detection
  8. return new Date(16e11).getYear() !== 120;
  9. });
  10. var getFullYear = uncurryThis(Date.prototype.getFullYear);
  11. // `Date.prototype.getYear` method
  12. // https://tc39.es/ecma262/#sec-date.prototype.getyear
  13. $({ target: 'Date', proto: true, forced: FORCED }, {
  14. getYear: function getYear() {
  15. return getFullYear(this) - 1900;
  16. }
  17. });