Reply To: Different periods depending on the day of the week

Home Forums Quform WordPress Different periods depending on the day of the week Reply To: Different periods depending on the day of the week

#35364
brandworker
Participant
  jQuery(function ($) {
    var datepicker = $('.quform-field-1_4').data('kendoDatePicker'),
        timepicker = $('.quform-field-1_5').data('kendoTimePicker');

    if (window.kendo && datepicker && timepicker) {
        datepicker.setOptions({
            change: function () {
                var date = datepicker.value();

                if (date) {
                    var dayOfWeek = date.getDay(),
                        times = [];

                    if (dayOfWeek === 0) { // Sun
                         times = [
                            '10:00', '10:30', '11:00', '11:30', '12:00', '12:30', '13:00',
                            '13:30', '14:00', '14:30', '15:00', '15:30', '16:00', '16:30', 
                            '17:00', '17:30', '18:00', '18:30', '19:00', '19:30', '20:00',
                            '20:30', '21:00'
                        ];
                    } else if (dayOfWeek === 1) { // Mon
                        times = [
                            '17:00', '17:30', '18:00', '18:30', '19:00', '19:30', '20:00',
                            '20:30', '21:00', '21:30', '22:00'
                        ];
                    } else if (dayOfWeek === 2) { // Tue
                        times = [
                            '17:00', '17:30', '18:00', '18:30', '19:00', '19:30', '20:00',
                            '20:30', '21:00', '21:30', '22:00'
                        ];
                    } else if (dayOfWeek === 3) { // Wed
                        times = [
                            '17:00', '17:30', '18:00', '18:30', '19:00', '19:30', '20:00',
                            '20:30', '21:00', '21:30', '22:00'
                        ];
                    } else if (dayOfWeek === 4) { // Thu
                        times = [
                            '17:00', '17:30', '18:00', '18:30', '19:00', '19:30', '20:00',
                            '20:30', '21:00', '21:30', '22:00'
                        ];
                    } else if (dayOfWeek === 5) { // Fri
                        times = [
                            '16:00', '16:30', 
                            '17:00', '17:30', '18:00', '18:30', '19:00', '19:30', '20:00',
                            '20:30', '21:00', '21:30', '22:00', '22:30', '23:00', '23:30',
                            '00:00'
                        ];
                    } else if (dayOfWeek === 6) { // Sat
                         times = [
                            '12:00', '12:30', '13:00',
                            '13:30', '14:00', '14:30', '15:00', '15:30', '16:00', '16:30', 
                            '17:00', '17:30', '18:00', '18:30', '19:00', '19:30', '20:00',
                            '20:30', '21:00', '21:30', '22:00', '22:30', '23:00', '23:30',
                            '00:00'
                        ];
                    }

                    var dates = [],
                        i = 0,
                        length = times.length,
                        d;

                    for ( ; i < length; i++) {
                        d = kendo.parseDate(times[i]);

                        if (d instanceof Date) {
                            dates.push(d);
                        }
                    }

                    timepicker.setOptions({ dates: dates });
                }
            }
        });
    }
});   

We are in Germany (German) 24 Hour

Be inspired. © 2024 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy