Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import React from 'react';
import PropTypes from 'prop-types';
import moment from 'moment';
import { translateUsingPseudoLocale } from '../../../src/services/string/pseudo_locale_translator';
// For testing/demoing EuiDatePicker, process moment's `en` locale config into a babelfished version
const enConfig = moment.localeData('en')._config;
moment.defineLocale('en-xa', {
...enConfig,
months: enConfig.months.map(translateUsingPseudoLocale),
monthsShort: enConfig.monthsShort.map(translateUsingPseudoLocale),
weekdays: enConfig.weekdays.map(translateUsingPseudoLocale),
weekdaysMin: enConfig.weekdaysMin.map(translateUsingPseudoLocale),
weekdaysShort: enConfig.weekdaysShort.map(translateUsingPseudoLocale),
});
// Reset default moment locale after using `defineLocale`
moment.locale('en');
import { EuiSwitch, EuiFormRow } from '../../../../src/components';
export const GuideLocaleSelector = ({ selectedLocale, onToggleLocale }) => {
return (
getLocalizedDateFormat(localizedFormat: any): string {
return moment.localeData().longDateFormat(localizedFormat);
}
value() {
return (
(Nuxeo.UI && Nuxeo.UI.config && parseInt(Nuxeo.UI.config.firstDayOfWeek, 10)) ||
moment.localeData().firstDayOfWeek() ||
0
);
},
observer: '_firstDayOfWeekChanged',
export function getLocaleDataForLocale (locale) {
return moment.localeData(locale)
}
{ getFirstDayOfWeek: () => moment.localeData().firstDayOfWeek() },
);
firstOfWeek: function firstOfWeek(culture: string) {
return (moment.localeData(culture) as any).firstDayOfWeek();
},
i18n: function() {
return moment.localeData(this.props.locale) ||
moment.localeData(defaultProps.locale);
},
isLastDayOfWeek(day) {
const { firstDayOfWeek } = this.props;
return day.day() === ((firstDayOfWeek || moment.localeData().firstDayOfWeek()) + 6) % 7;
}
displayFormat: () => moment.localeData().longDateFormat('L'),
public render() {
const { current, locale } = this.props;
const dayMatrix = getDayMatrix(current.year(), current.month());
const weekdays = moment.localeData(locale).weekdaysShort();
return (
(
)}
/>