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');
const seconds = now.get('second');
// return time object
return {
day,
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;']
torqueLayer.on( "change:time", changes => {
if ( this.props.interval === "weekly" ) {
$( ".date", domNode ).text(
moment( ).day( "Monday" ).week( changes.step ).format( "MMM DD" ) );
} else {
$( ".date", domNode ).text( moment.months( changes.step ) );
}
} );
torqueLayer.addTo( map );
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;']