Support » Plugin: Event post » Time not displayed

  • Resolved Arnd030

    (@arnd030)


    Thanks for Event Post.

    I found this bug:

    Event time is not displayed, only the date.

    For example, I have:

    2017-06-15 17:00:00 as event_begin

    2017-06-17 08:00:00 as event_end

    But I only get:

    <div class="event_date" data-start="Donnerstag 15 Juni 2017" data-end="Samstag 17 Juni 2017">
    <span class="linking_word linking_word-from">von</span>
    <time class="date date-start" itemprop="dtstart" datetime="2017-06-15T17:00:00+00:00">15. Juni 2017</time>
    <span class="linking_word linking_word-to">bis</span>
    <time class="date date-end" itemprop="dtend" datetime="2017-06-17T08:00:00+00:00">17. Juni 2017</time>
    </div><!-- .event_date -->

    What is the problem here?

    Thanks!

    Arnd

Viewing 6 replies - 1 through 6 (of 6 total)
  • I think I found it.

    It is deliberate. In function delta_date in eventpost.php, you check if the event is over several days, and only display the time of day for events on a single day.

    It would be better to display the time also on events over several days. For example, people want to know at what time to arrive on Friday evening for a weekend event.

    I tried to patch the script like this:

    /**
         *
         * @param timestamp $time_start
         * @param timestamp $time_end
         * @return string
         */
        public function delta_date($time_start, $time_end){
            if(!$time_start || !$time_end){
                return;
            }
    
            //Display dates
            $dates="\t\t\t\t".'<div class="event_date" data-start="' . $this->human_date($time_start) . '" data-end="' . $this->human_date($time_end) . '">';
            if (date('d/m/Y', $time_start) == date('d/m/Y', $time_end)) { // same day
                $dates.= "\n\t\t\t\t\t\t\t".'<time itemprop="dtstart" datetime="' . date_i18n('c', $time_start) . '">'
                        . '<span class="date date-single">' . $this->human_date($time_end, $this->settings['dateformat']) . "</span>";
                if (date('H:i', $time_start) != date('H:i', $time_end) && date('H:i', $time_start) != '00:00' && date('H:i', $time_end) != '00:00') {
                    $dates.='   <span class="linking_word linking_word-from">' . __('from', 'event-post') . '</span>
                                <span class="time time-start">' . date_i18n($this->settings['timeformat'], $time_start) . '</span>
                                <span class="linking_word linking_word-t">' . __('to', 'event-post') . '</span>
                                <span class="time time-end">' . date_i18n($this->settings['timeformat'], $time_end) . '</span>';
                }
                elseif (date('H:i', $time_start) != '00:00') {
                    $dates.='   <span class="linking_word">' . __('at', 'event-post') . '</span>
                                <time class="time time-single" itemprop="dtstart" datetime="' . date_i18n('c', $time_start) . '">' . date_i18n($this->settings['timeformat'], $time_start) . '</time>';
                }
                $dates.="\n\t\t\t\t\t\t\t".'</time>';
            } else { // not same day
                $dates.= '
                    <span class="linking_word linking_word-from">' . __('from', 'event-post') . '</span>
                    <time class="date date-start" itemprop="dtstart" datetime="' . date('c', $time_start) . '">' . $this->human_date($time_start, $this->settings['dateformat']);
                    
    
                     if (date('H:i', $time_start) != date('H:i', $time_end) && date('H:i', $time_start) != '00:00' && date('H:i', $time_end) != '00:00') 
                      $dates.= ', ' . date_i18n($this->settings['timeformat'], $time_start);
                    
                    $dates.='</time>
                    
                    <span class="linking_word linking_word-to">' . __('to', 'event-post') . '</span>
                    <time class="date date-end" itemprop="dtend" datetime="' . date('c', $time_end) . '">' . $this->human_date($time_end, $this->settings['dateformat']);
                    
                    if (date('H:i', $time_start) != date('H:i', $time_end) && date('H:i', $time_start) != '00:00' && date('H:i', $time_end) != '00:00') {
                      $dates.=  ', ' . date_i18n($this->settings['timeformat'], $time_end);
                }
                $dates.='</time>';
            }
            $dates.="\n\t\t\t\t\t\t".'</div><!-- .event_date -->';
            return $dates;
        }

    I changed the part after line 609, the else-part for events over several days.

    Could you be so kind to look into this and check for mistakes? I am not sure if I understand your code correctly.

    Thank you very much

    Arnd

    • This reply was modified 3 months, 1 week ago by  Arnd030.

    I think I found it.

    It is deliberate. In function delta_date in eventpost.php, you check if the event is over several days, and only display the time of day for events on a single day.

    It would be better to display the time also on events over several days. For example, people want to know at what time to arrive on Friday evening for a weekend event.

    I tried to patch the script like this:

    /**
         *
         * @param timestamp $time_start
         * @param timestamp $time_end
         * @return string
         */
        public function delta_date($time_start, $time_end){
            if(!$time_start || !$time_end){
                return;
            }
    
            //Display dates
            $dates="\t\t\t\t".'<div class="event_date" data-start="' . $this->human_date($time_start) . '" data-end="' . $this->human_date($time_end) . '">';
            if (date('d/m/Y', $time_start) == date('d/m/Y', $time_end)) { // same day
                $dates.= "\n\t\t\t\t\t\t\t".'<time itemprop="dtstart" datetime="' . date_i18n('c', $time_start) . '">'
                        . '<span class="date date-single">' . $this->human_date($time_end, $this->settings['dateformat']) . "</span>";
                if (date('H:i', $time_start) != date('H:i', $time_end) && date('H:i', $time_start) != '00:00' && date('H:i', $time_end) != '00:00') {
                    $dates.='   <span class="linking_word linking_word-from">' . __('from', 'event-post') . '</span>
                                <span class="time time-start">' . date_i18n($this->settings['timeformat'], $time_start) . '</span>
                                <span class="linking_word linking_word-t">' . __('to', 'event-post') . '</span>
                                <span class="time time-end">' . date_i18n($this->settings['timeformat'], $time_end) . '</span>';
                }
                elseif (date('H:i', $time_start) != '00:00') {
                    $dates.='   <span class="linking_word">' . __('at', 'event-post') . '</span>
                                <time class="time time-single" itemprop="dtstart" datetime="' . date_i18n('c', $time_start) . '">' . date_i18n($this->settings['timeformat'], $time_start) . '</time>';
                }
                $dates.="\n\t\t\t\t\t\t\t".'</time>';
            } else { // not same day
                $dates.= '
                    <span class="linking_word linking_word-from">' . __('from', 'event-post') . '</span>
                    <time class="date date-start" itemprop="dtstart" datetime="' . date('c', $time_start) . '">' . $this->human_date($time_start, $this->settings['dateformat']);
                    
    
                     if (date('H:i', $time_start) != date('H:i', $time_end) && date('H:i', $time_start) != '00:00' && date('H:i', $time_end) != '00:00') 
                      $dates.= ', ' . date_i18n($this->settings['timeformat'], $time_start);
                    
                    $dates.='</time>
                    
                    <span class="linking_word linking_word-to">' . __('to', 'event-post') . '</span>
                    <time class="date date-end" itemprop="dtend" datetime="' . date('c', $time_end) . '">' . $this->human_date($time_end, $this->settings['dateformat']);
                    
                    if (date('H:i', $time_start) != date('H:i', $time_end) && date('H:i', $time_start) != '00:00' && date('H:i', $time_end) != '00:00') {
                      $dates.=  ', ' . date_i18n($this->settings['timeformat'], $time_end);
                }
                $dates.='</time>';
            }
            $dates.="\n\t\t\t\t\t\t".'</div><!-- .event_date -->';
            return $dates;
        }

    I changed the part after line 609, the else-part for events over several days.

    Could you be so kind to look into this and check for mistakes? I am not sure if I understand your code correctly.

    Thank you very much

    Arnd

    PS: There is a problem with this forum, my reply disappeared after a small edit, and after re-posting I get “Duplicate reply detected” though the reply is not there.

    Plugin Author Bastien Ho

    (@bastho)

    Hi,

    Thank you for your contribution.
    actually, time is not displayed when set to the very midnight (00:00:00). It could be improved by saving “all day” event with no time, and consider midnight as an assumed time.

    But this evolution implicates a lot of code correction in time parsing and UI.

    Since the current version has some bugs to be fixed, we plan to work on fixing them in a minor release while the next major release will focus on this kind of questions.

    By the way, displaying time in multi-days events is a good idea. We’ll try to intregrate it the next minor release.

    • This reply was modified 3 months ago by  Bastien Ho.
    Plugin Author Bastien Ho

    (@bastho)

    I’ve implemented tile displaying in version 4.5.2

    thank you for your help.

    Plugin Author Bastien Ho

    (@bastho)

    I’ve implemented time displaying in version 4.5.2

    thank you for your help.

    Thank you very much!

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.