index.js 951 B

12345678910111213141516171819202122232425262728
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = getUTCDayOfYear;
  6. var _index = _interopRequireDefault(require("../../toDate/index.js"));
  7. var _index2 = _interopRequireDefault(require("../requiredArgs/index.js"));
  8. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9. var MILLISECONDS_IN_DAY = 86400000; // This function will be a part of public API when UTC function will be implemented.
  10. // See issue: https://github.com/date-fns/date-fns/issues/376
  11. function getUTCDayOfYear(dirtyDate) {
  12. (0, _index2.default)(1, arguments);
  13. var date = (0, _index.default)(dirtyDate);
  14. var timestamp = date.getTime();
  15. date.setUTCMonth(0, 1);
  16. date.setUTCHours(0, 0, 0, 0);
  17. var startOfYearTimestamp = date.getTime();
  18. var difference = timestamp - startOfYearTimestamp;
  19. return Math.floor(difference / MILLISECONDS_IN_DAY) + 1;
  20. }
  21. module.exports = exports.default;