Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
getMoment(timezone, locale) {
moment.locale(locale);
const now = moment().tz(timezone);
const tz = moment().tz(timezone).format('z');
// Day
const weekdays = moment.weekdays();
const dayName = weekdays[now.get('day')];
const day = now.get('date');
// Month
const months = moment.months();
const monthName = months[now.month()];
const month = now.get('month');
// Year
const year = now.get('year');
// Time
let hours = now.get('hour');
const meridiem = (hours < 12) ? 'AM' : 'PM';
hours = (this.props.config.meridiem && meridiem === 'PM') ? (hours - 12) : hours;
const minutes = now.get('minute');
: `on ${dayOfWeek.sort().map((day) => moment.weekdays(false, +day)).join(', ')}`;
}
};
return (
<div style="{{flex:">
<select style="{{width:" size="small" value="{schedule.dayOfWeek" mode="multiple" disabled="{removed}">
{
moment
.weekdays(false)
.map((day, id) => ({day}))
}
</select>
</div>
);
};
getSchedule() {
const root = cloneDeep(this.rootObject)
const frequency = root['service=scheduler;table=timetables;field=frequency;'] ? root['service=scheduler;table=timetables;field=frequency;'] : {}
const months = {}
moment.months().forEach((key) => { months[key.toLowerCase()] = false })
if (frequency && frequency.months) frequency.months.forEach((key) => { months[key] = true })
const days = {}
moment.weekdays().forEach((key) => { days[key.toLowerCase()] = false })
if (frequency && frequency.days) frequency.days.forEach((key) => { days[key] = true })
const freq = {
days,
months,
at: frequency.at ? frequency.at[0] : '00:00',
recur: frequency.recur || 'daily',
timezone: frequency.timezone || 'Europe/London',
}
const startsAt = root['service=scheduler;table=timetables;field=starts_at;']
const endsAt = root['service=scheduler;table=timetables;field=ends_at;']
const limit = {}
limit.startsAt = startsAt ? moment(startsAt, 'YYYY-MM-DD hh:mm:ss').format('YYYY-MM-DD hh:mm:ss') : ''
limit.endsAt = endsAt ? moment(endsAt, 'YYYY-MM-DD hh:mm:ss').format('YYYY-MM-DD hh:mm:ss') : ''
function setStartDayOfWeek(day) {
const dow = moment.weekdays().indexOf(day);
moment.updateLocale(moment.locale(), { week: { dow } });
}
getSchedule() {
const root = cloneDeep(this.rootObject)
const frequency = root['service=scheduler;table=timetables;field=frequency;'] ? root['service=scheduler;table=timetables;field=frequency;'] : {}
const months = {}
moment.months().forEach((key) => { months[key.toLowerCase()] = false })
if (frequency && frequency.months) frequency.months.forEach((key) => { months[key] = true })
const days = {}
moment.weekdays().forEach((key) => { days[key.toLowerCase()] = false })
if (frequency && frequency.days) frequency.days.forEach((key) => { days[key] = true })
const freq = {
days,
months,
at: frequency.at ? frequency.at[0] : '00:00',
recur: frequency.recur || 'daily',
timezone: frequency.timezone || 'Europe/London',
}
const startsAt = root['service=scheduler;table=timetables;field=starts_at;']
const endsAt = root['service=scheduler;table=timetables;field=ends_at;']
const limit = {}
limit.startsAt = startsAt ? moment(startsAt, 'YYYY-MM-DD hh:mm:ss').format('YYYY-MM-DD hh:mm:ss') : ''
limit.endsAt = endsAt ? moment(endsAt, 'YYYY-MM-DD hh:mm:ss').format('YYYY-MM-DD hh:mm:ss') : ''
this._sectionService.getSystemGeneral().then(function(systemGeneral) {
self.generalData = systemGeneral;
self._snapshotDataObjectsIfNecessary();
})
]).then(function() {
self.isLoading = false;
});
var today = new Date();
this.dateFormatShortOptions = this.generateDateFormatConvertedList(today, this.shortDateFormats);
this.dateFormatMediumOptions = this.generateDateFormatConvertedList(today, this.mediumDateFormats);
this.dateFormatLongOptions = this.generateDateFormatConvertedList(today, this.longDateFormats);
this.dateFormatFullOptions = this.generateDateFormatConvertedList(today, this.fullDateFormats);
this.timeFormatShortOptions = this.generateDateFormatConvertedList(today, this.shortTimeFormats);
this.timeFormatMediumOptions = this.generateDateFormatConvertedList(today, this.mediumTimeFormats);
this.timeFormatLongOptions = this.generateDateFormatConvertedList(today, this.longTimeFormats);
this.firstDayOfWeekOptions = _.map(moment.weekdays(), function(day, index) {
return {
label: day,
value: index
};
});
}
}
},