nhn / tui.calendar

🍞📅A JavaScript calendar that has everything you need.
http://ui.toast.com/tui-calendar
MIT License
12.03k stars 1.3k forks source link

Issue with Daylight Saving Time (DTS) when i have to display some meetings #882

Open terrenzio93 opened 3 years ago

terrenzio93 commented 3 years ago

Problem

Hi everyone! I have this kind of problem. Some meetings have correct start date and end date but, when the DTS comes or expires, they would get the wrong hour. I will show you some examples:

immagine

As you can see, this appointment starts at 10.30 and ends at 11.30 as it should be because it was saved with that particular start date/hour and end date/hour. But if I take another meeting in November, that is what is happening:

immagine

Even if in the DB we got the meeting starting at 6.00 and ending at 7.00, the calendar displays the wrong hour. I think that happen because of the DTS.

FelixBrgm commented 3 years ago

This has already been touched on here: https://github.com/nhn/tui.calendar/issues/423 Just log what offset u have and what time it should be and adjust the if-statement and the hours added or removed accordingly. var today=new Date(); if(today.getTimezoneOffset()===-60 && event.start._date.getTimezoneOffset()===0) { //We need to hack the time setting. We may need to still do this after end of BST as well. event.start.setHours(event.start.getHours()-2); event.end.setHours(event.end.getHours()-2); } ....rest of my event handler.... } Regards

adhrinae commented 3 years ago

Yes, It's a known issue as @FelixBrgn mentioned. It won't be easy to fix the issue. I hope to fix this issue with the release of the next major version. But there's no scheduled timeline for the release yet even we're working on it though.

terrenzio93 commented 3 years ago

Hi everybody. Thank you all for your time and your responses.

Here the solution I figured out thanked to your messages.

Solution

function getTimeTemplate(schedule, isAllDay) {
        var html = [];
        //console.log(schedule.start._date);
        //Bugfix ora legale ora solare, sia nel grid del calendario che nel primo popup informativo
        if(schedule.start._date.getTimezoneOffset()==-60){
            schedule.start._date.setHours(schedule.start.getHours()+1);     
            schedule.end._date.setHours(schedule.end.getHours()+1);         
        }

        if (!isAllDay) {
          html.push('<strong>' + moment(schedule.start.getTime()).format('HH:mm') + '</strong> ');
        }
        if (schedule.isPrivate) {
          html.push('<span class="calendar-font-icon ic-lock-b"></span>');
          html.push(' Private');
        } else {
          if (schedule.isReadOnly) {
            html.push('<span class="calendar-font-icon ic-readonly-b"></span>');
          } else if (schedule.recurrenceRule) {
            html.push('<span class="calendar-font-icon ic-repeat-b"></span>');
          } else if (schedule.attendees.length) {
            html.push('<span class="calendar-font-icon ic-user-b"></span>');
          } else if (schedule.location) {
            html.push('<span class="calendar-font-icon ic-location-b"></span>');
          }
          html.push(' ' + schedule.title);
        }

        return html.join('');
      }