YearFromTime.js 407 B

12345678910111213141516
  1. 'use strict';
  2. var GetIntrinsic = require('get-intrinsic');
  3. var $Date = GetIntrinsic('%Date%');
  4. var callBound = require('call-bind/callBound');
  5. var $getUTCFullYear = callBound('Date.prototype.getUTCFullYear');
  6. // https://262.ecma-international.org/5.1/#sec-15.9.1.3
  7. module.exports = function YearFromTime(t) {
  8. // largest y such that this.TimeFromYear(y) <= t
  9. return $getUTCFullYear(new $Date(t));
  10. };