<commit_before>import React, { useMemo, useState, useEffect, useReducer, useCallback, useRef } from 'react';
import PropTypes from 'prop-types';
import {
    useCalendarUserSettings,
    useCalendarBootstrap,
    useAddresses,
    useActiveBreakpoint,
    useModals
} from 'react-components';
import {
    convertUTCDateTimeToZone,
    convertZonedDateTimeToUTC,
    fromUTCDate,
    toUTCDate,
    getTimezone,
    formatTimezoneOffset,
    getTimezoneOffset
} from 'proton-shared/lib/date/timezone';
import { isSameDay, MILLISECONDS_IN_MINUTE } from 'proton-shared/lib/date-fns-utc';
import { VIEWS, SETTINGS_VIEW } from '../../constants';
import useCalendarsEvents from './useCalendarsEvents';
import { getDateRange } from './helper';
import CalendarContainerView from './CalendarContainerView';
import InteractiveCalendarView from './InteractiveCalendarView';
import AlarmContainer from '../alarms/AlarmContainer';
import AskUpdateTimezoneModal from '../settings/AskUpdateTimezoneModal';
import { canAskTimezoneSuggestion, saveLastTimezoneSuggestion } from '../../helpers/timezoneSuggestion';
import { getTitleDateString } from './formatHelper';

const { DAY, WEEK, MONTH } = VIEWS;

const URL_PARAMS_VIEWS_CONVERSION = {
    //'year': YEAR,
    month: MONTH,
    week: WEEK,
    day: DAY
};
const VIEW_URL_PARAMS_VIEWS_CONVERSION = {
    //'year': YEAR,
    [MONTH]: 'month',
    [WEEK]: 'week',
    [DAY]: 'day'
};

const SETTINGS_VIEW_CONVERSION = {
    //[SETTINGS_VIEW.YEAR]: YEAR,
    [SETTINGS_VIEW.MONTH]: MONTH,
    [SETTINGS_VIEW.WEEK]: WEEK,
    [SETTINGS_VIEW.DAY]: DAY
};

const SUPPORTED_VIEWS = [MONTH, WEEK, DAY];

const getDefaultView = ({ ViewPreference } = {}) => {
    return SETTINGS_VIEW_CONVERSION[ViewPreference] || WEEK;
};

const getUrlView = (urlView) => {
    if (urlView && URL_PARAMS_VIEWS_CONVERSION[urlView]) {
        return URL_PARAMS_VIEWS_CONVERSION[urlView];
    }
};

const getUrlDate = (urlYear, urlMonth, urlDay) => {
    const year = parseInt(urlYear, 10);
    const month = parseInt(urlMonth, 10);
    const day = parseInt(urlDay, 10);
    if (year >= 0 && year < 9999 && month >= 1 && month <= 12 && day >= 1 && day <= 31) {
        return new Date(Date.UTC(year, month - 1, day));
    }
};

const getRange = (view, range) => {
    if (!range) {
        return;
    }
    const max = Math.max(Math.min(range, 6), 1);
    if (view === WEEK) {
        return max;
    }
    return Math.min(max, 4);
};

const getWeekStartsOn = ({ WeekStart = 0 } = {}) => {
    // Sunday should be 0, not 7
    return WeekStart % 7;
};

const getAutoDetectPrimaryTimezone = ({ AutoDetectPrimaryTimezone = false } = {}) => {
    return !!AutoDetectPrimaryTimezone;
};

const getDisplaySecondaryTimezone = ({ DisplaySecondaryTimezone } = {}) => {
    return !!DisplaySecondaryTimezone;
};

const getSecondaryTimezone = ({ SecondaryTimezone } = {}) => {
    return SecondaryTimezone;<commit_msg>Allow selecting 6 weeks custom range<commit_after>import React, { useMemo, useState, useEffect, useReducer, useCallback, useRef } from 'react';
import PropTypes from 'prop-types';
import {
    useCalendarUserSettings,
    useCalendarBootstrap,
    useAddresses,
    useActiveBreakpoint,
    useModals
} from 'react-components';
import {
    convertUTCDateTimeToZone,
    convertZonedDateTimeToUTC,
    fromUTCDate,
    toUTCDate,
    getTimezone,
    formatTimezoneOffset,
    getTimezoneOffset
} from 'proton-shared/lib/date/timezone';
import { isSameDay, MILLISECONDS_IN_MINUTE } from 'proton-shared/lib/date-fns-utc';
import { VIEWS, SETTINGS_VIEW } from '../../constants';
import useCalendarsEvents from './useCalendarsEvents';
import { getDateRange } from './helper';
import CalendarContainerView from './CalendarContainerView';
import InteractiveCalendarView from './InteractiveCalendarView';
import AlarmContainer from '../alarms/AlarmContainer';
import AskUpdateTimezoneModal from '../settings/AskUpdateTimezoneModal';
import { canAskTimezoneSuggestion, saveLastTimezoneSuggestion } from '../../helpers/timezoneSuggestion';
import { getTitleDateString } from './formatHelper';

const { DAY, WEEK, MONTH } = VIEWS;

const URL_PARAMS_VIEWS_CONVERSION = {
    //'year': YEAR,
    month: MONTH,
    week: WEEK,
    day: DAY
};
const VIEW_URL_PARAMS_VIEWS_CONVERSION = {
    //'year': YEAR,
    [MONTH]: 'month',
    [WEEK]: 'week',
    [DAY]: 'day'
};

const SETTINGS_VIEW_CONVERSION = {
    //[SETTINGS_VIEW.YEAR]: YEAR,
    [SETTINGS_VIEW.MONTH]: MONTH,
    [SETTINGS_VIEW.WEEK]: WEEK,
    [SETTINGS_VIEW.DAY]: DAY
};

const SUPPORTED_VIEWS = [MONTH, WEEK, DAY];

const getDefaultView = ({ ViewPreference } = {}) => {
    return SETTINGS_VIEW_CONVERSION[ViewPreference] || WEEK;
};

const getUrlView = (urlView) => {
    if (urlView && URL_PARAMS_VIEWS_CONVERSION[urlView]) {
        return URL_PARAMS_VIEWS_CONVERSION[urlView];
    }
};

const getUrlDate = (urlYear, urlMonth, urlDay) => {
    const year = parseInt(urlYear, 10);
    const month = parseInt(urlMonth, 10);
    const day = parseInt(urlDay, 10);
    if (year >= 0 && year < 9999 && month >= 1 && month <= 12 && day >= 1 && day <= 31) {
        return new Date(Date.UTC(year, month - 1, day));
    }
};

const getRange = (view, range) => {
    if (!range) {
        return;
    }
    const max = Math.max(Math.min(range, 6), 1);
    if (view === WEEK) {
        return max;
    }
    return Math.min(max, 5);
};

const getWeekStartsOn = ({ WeekStart = 0 } = {}) => {
    // Sunday should be 0, not 7
    return WeekStart % 7;
};

const getAutoDetectPrimaryTimezone = ({ AutoDetectPrimaryTimezone = false } = {}) => {
    return !!AutoDetectPrimaryTimezone;
};

const getDisplaySecondaryTimezone = ({ DisplaySecondaryTimezone } = {}) => {
    return !!DisplaySecondaryTimezone;
};

const getSecondaryTimezone = ({ SecondaryTimezone } = {}) => {
    return SecondaryTimezone;
{'fraction_non_alphanumeric': 0.13610779464438, 'fraction_numerical': 0.008698618454716017, 'mean_word_length': 3.870431893687708, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 25, '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': '1220038', 'n_tokens_mistral': 2001, 'n_tokens_neox': 1934, 'n_words': 432}