123456789101112131415161718192021222324252627282930313233343536 |
- "use strict";
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = lastDayOfDecade;
- var _index = _interopRequireDefault(require("../toDate/index.js"));
- var _index2 = _interopRequireDefault(require("../_lib/requiredArgs/index.js"));
- /**
- * @name lastDayOfDecade
- * @category Decade Helpers
- * @summary Return the last day of a decade for the given date.
- *
- * @description
- * Return the last day of a decade for the given date.
- *
- * @param {Date|Number} date - the original date
- * @returns {Date} the last day of a decade
- * @throws {TypeError} 1 argument required
- *
- * @example
- * // The last day of a decade for 21 December 2012 21:12:00:
- * const result = lastDayOfDecade(new Date(2012, 11, 21, 21, 12, 00))
- * //=> Wed Dec 31 2019 00:00:00
- */
- function lastDayOfDecade(dirtyDate) {
- (0, _index2.default)(1, arguments);
- var date = (0, _index.default)(dirtyDate);
- var year = date.getFullYear();
- var decade = 9 + Math.floor(year / 10) * 10;
- date.setFullYear(decade + 1, 0, 0);
- date.setHours(0, 0, 0, 0);
- return date;
- }
- module.exports = exports.default;
|