UNPKG

@orange_digital/chakra-datepicker

Version:
22 lines (21 loc) 912 B
"use strict"; var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { if (ar || !(i in from)) { if (!ar) ar = Array.prototype.slice.call(from, 0, i); ar[i] = from[i]; } } return to.concat(ar || Array.prototype.slice.call(from)); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.getNearbyYears = void 0; function getNearbyYears(date, n) { if (n === void 0) { n = 18; } // n=18 is 3 rows of 6 var currentYear = date.getFullYear(); var offset = Math.floor((currentYear - 2000) / n); var startValue = 2000 + offset * n; return __spreadArray([], new Array(n), true).map(function (_, idx) { return new Date(startValue + idx, date.getMonth(), date.getDate()); }); } exports.getNearbyYears = getNearbyYears;