<commit_before>'use strict';

import locales from './Locales.js';
import moment from 'moment';

const daysInMonthCount = (month, year)  => moment([year, month]).endOf('month').date();

const getArrayByBoundary = (start, end) => {
  const arr = Array.apply(null, Array(end - start));
  return arr.map((x, i)  => (i + start));
};

const getVisibleDays = (month, year, location) => {
  const offset = moment([year, month]).locale(location).startOf('month').weekday();
  const previousMonthLength = daysInMonthCount(month - 1, year) + 1; //We need the last number too
  const currentMonthLength = daysInMonthCount(month, year) + 1;

  const previous = getArrayByBoundary(previousMonthLength - offset, previousMonthLength);
  const current = getArrayByBoundary(1, currentMonthLength);
  const following = getArrayByBoundary(1, 43 - previous.length - current.length);
  return {
    startCurrent: previous.length,
    endCurrent: previous.length + current.length - 1,
    days: previous.concat(current).concat(following)
  };
};

const getVisibleYears = (year) => {
  const startDecadeYear = parseInt(year / 10, 10) * 10;
  const endDecadeYear = startDecadeYear + 9;
  const previous = [startDecadeYear - 1];
  const current = getArrayByBoundary(startDecadeYear, endDecadeYear + 1);
  const following = [endDecadeYear + 1];
  return {
    startCurrent: previous.length,
    endCurrent: previous.length + current.length - 1,
    years: previous.concat(current).concat(following)
  };
};

export default {
  daysInMonthCount,
  getVisibleDays,
  getVisibleYears,<commit_msg>fixed wrong offset in weekdays min (daypicker top)<commit_after>'use strict';

import locales from './Locales.js';
import moment from 'moment';
import _ from 'lodash';

const daysInMonthCount = (month, year)  => moment([year, month]).endOf('month').date();

const getArrayByBoundary = (start, end) => {
  const arr = Array.apply(null, Array(end - start));
  return arr.map((x, i)  => (i + start));
};

const getWeekdaysMin = () => {
  const offset = moment().localeData().firstDayOfWeek();
  const weekdaysMin = moment.weekdaysMin();

  _.range(offset).forEach((x) => {
    const firstDay = weekdaysMin.shift();
    weekdaysMin.push(firstDay);
  });
  return weekdaysMin;
};

const getVisibleDays = (month, year, locale) => {
  const offset = moment([year, month]).locale(locale).startOf('month').weekday();
  const previousMonthLength = daysInMonthCount(month - 1, year) + 1; //We need the last number too
  const currentMonthLength = daysInMonthCount(month, year) + 1;

  const previous = getArrayByBoundary(previousMonthLength - offset, previousMonthLength);
  const current = getArrayByBoundary(1, currentMonthLength);
  const following = getArrayByBoundary(1, 43 - previous.length - current.length);
  return {
    startCurrent: previous.length,
    endCurrent: previous.length + current.length - 1,
    days: previous.concat(current).concat(following)
  };
};

const getVisibleYears = (year) => {
  const startDecadeYear = parseInt(year / 10, 10) * 10;
  const endDecadeYear = startDecadeYear + 9;
  const previous = [startDecadeYear - 1];
  const current = getArrayByBoundary(startDecadeYear, endDecadeYear + 1);
  const following = [endDecadeYear + 1];
  return {
    startCurrent: previous.length,
    endCurrent: previous.length + current.length - 1,
    years: previous.concat(current).concat(following)
  };
};

export default {
  daysInMonthCount,
  getVisibleDays,
  getVisibleYears,
  getWeekdaysMin,
{'fraction_non_alphanumeric': 0.13214593507612754, 'fraction_numerical': 0.010916403332375754, 'mean_word_length': 4.634304207119741, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2935039', 'n_tokens_mistral': 1106, 'n_tokens_neox': 1060, 'n_words': 265}