Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor(props) {
super(props);
const {
firstDayOfWeek,
locale,
location,
timeZone,
} = this.props;
moment.tz.setDefault(timeZone);
moment.updateLocale(locale || 'en',
{
week: {
dow: firstDayOfWeek, // First day of week (got from UserStatus).
doy: 1, // First day of year (not yet supported).
},
});
const { defaultDate, defaultView } = props;
this.state = {
calendar: '',
date: defaultDate,
end: undefined,
events: undefined,
loading: false,
// eslint doesn't recognize the usage in the new 'static getDerivedStateFromProps'
'March',
'April',
'May',
'June',
'July',
'Aug.',
'Sept.',
'Oct.',
'Nov.',
'Dec.',
],
};
// Called at startup so that the formatting applied under updateLocale occur site-wide.
moment.updateLocale('en', options);
momentTimezone.updateLocale('en', options);
function setStartDayOfWeek(day) {
const dow = moment.weekdays().indexOf(day);
moment.updateLocale(moment.locale(), { week: { dow } });
}
calendarDate: function(date) {
moment.updateLocale('en', {
calendar: {
sameDay: '[Today at] LT',
lastDay: '[Yesterday at] LT',
nextDay: '[Tomorrow at] LT',
lastWeek: '[Last] ddd [at] LT',
nextWeek: 'ddd [at] LT',
sameElse: 'L'
}
});
return moment.utc(date).tz(global.timezone).calendar();
},
componentWillUnmount() {
const { modifiedLanguageCode } = this.state
moment.updateLocale(modifiedLanguageCode, null)
}
const setStartDayOfWeek = (day: string) => {
const dow = moment.weekdays().indexOf(day);
moment.updateLocale(moment.locale(), { week: { dow } } as any);
};
function setStartDayOfWeek(day) {
const dow = moment.weekdays().indexOf(day);
moment.updateLocale(moment.locale(), { week: { dow } });
}
constructor (weekIndex) {
moment.updateLocale('sv', {
ordinal: (number) => {
const b = number % 10
const output = (~~(number % 100 / 10) === 1) ? 'e'
: (b === 1) ? 'a'
: (b === 2) ? 'a'
: (b === 3) ? 'e' : 'e'
return number + ':' + output
}
})
moment.locale('sv')
this.index = weekIndex || 0
this.current = moment.tz(TIME_ZONE).add(this.index, 'weeks')
this.startDayOfWeek = this.current.clone().startOf('isoweek')
this.endDayOfWeek = this.current.clone().endOf('isoweek')
}
static fromNow (timezone, date) {
if (isUndefined(date)) {
return 'Never'
}
moment.updateLocale('en', {
relativeTime: {
future: 'in %s',
past: '%s ago',
s: 'a few seconds',
m: '1m',
mm: '%dm',
h: '1h',
hh: '%dh',
d: '1d',
dd: '%dd',
M: '1mo',
MM: '%dmos',
y: '1y',
yy: '%dyrs'
}
})