2015-03-20 19 views
5

nadal działa z FullCalendar. Próbuję dowiedzieć się, dlaczego po uruchomieniu zdarzenia dayClick, parametr dateTime jest wciąż w GMT, gdy próbowałem ustawić go na lokalny i UTC. To w zasadzie cały dzień za sobą. Kliknij, aby powiedzieć, 19 marca, a dataTime będzie 18 marca.Strefa czasowa nie działa poprawnie dla FullCalendar

Oto mój config kalendarz i moi wydarzenia dayClick:

 vm.uiConfig = { 
     calendar: { 
      height: 350, 

      editable: false, 
      draggable: false, 
      selectable: true, 
      selectHelper: true, 
      unselectAuto: false, 
      disableResizing: false, 
      droppable: false, 
      handleWindowResize: true, 
      timezone: "local", 
      ignoreTimezone: false, 
      header: { 
       left: "title", 
       center: "", 
       right: "today prev,next" 
      }, 

      dayClick: vm.dayClick 
     } 
    }; 

    vm.dayClick = function(dateTime, jsEvent, view) 
    { 
     // change the day's background color just for fun 
     if (vm.previousCell) 
      vm.previousCell.css("background-color", vm.previousCellCSS); 

     vm.previousCell = $(this); 
     vm.previousCellCSS = vm.previousCell.css("background-color"); 
     vm.previousCell.css("background-color", "lightgrey"); 

     vm.selectedDate = { 
      date: new Date(dateTime) 
     }; 
    }; 

Próbowałem regulacji "czasową", "UTC" i "ignoreTimezone" właściwości, jak również, nie iść. Widziałem, jak niektórzy ludzie mówią, że to problem z zegarem systemu operacyjnego, skoro właśnie nadszedł czas, ale nie sądzę, żeby tak było w tym przypadku. Jakieś pomysły? Osiągnąłem szczyt i nie miałem szczęścia. Z góry dziękuję!

Odpowiedz

3

Miałem ten sam problem przy użyciu wersji FullCalendar V2.3.1, JQuery V1.11.2, Moment V2.10.2 i strefy czasowej V0.3.1 z bazą danych MySQL.

Problemem był typ danych dat rozpoczęcia i zakończenia wydarzenia. Przechowywałam je jako dateTime. Kiedy zmieniłem je na przechowywanie jako TimeStamps, zaczęło działać. Poniżej znajduje się fragment ważnych elementów mojego kodu. Mam nadzieję, że to ci pomoże.

$('#calendar').fullCalendar({ 
     events: function(start, end, timezone, callback) { 
      $.ajax({ 
       url: '/s/calendar_eventdata.php', 
       method: 'POST', 
       dataType: 'json', 
       data: 'uid=' + uidArray + '&start=' + start + '&end=' + end, 
       success: function(userData) { 
        var user_count = userData.length; 
        var eventData = []; 
        // Assemble the event objects 
        for (var i = 0; i < user_count; i++) 
        { 
         var uid = userData[i].uid; 
         var source = '/s/calendar_eventdata.php?e=' + userData[i].uid; 

         // Determine if the event is all day 
         var all_day = false; 
         if(userData[i].allDay === 1) 
         { 
          all_day = true; 
         } 

         // Add each source to a JSON feed object 
         eventData.push({ 
          source: source, 
          id: userData[i].eid, 
          eid: userData[i].eid, 
          p_eid: userData[i].p_eid, 
          uid: userData[i].uid, 
          p_uid: userData[i].p_uid, 
          etid: userData[i].etid, 
          typeIcon: userData[i].icon, 
          title: userData[i].title, 
          location: userData[i].location, 
          description: userData[i].description, 
          allDay: all_day, 
          start: moment.tz(userData[i].start_date, userData[i].saveTimezone).tz(deviceTimeZone), 
          end: moment.tz(userData[i].end_date, userData[i].saveTimezone).tz(deviceTimeZone), 
          saveTimezone: userData[i].saveTimezone, 
          duration: userData[i].duration, // todo: display as days, minutes, hours instead of only minutes 
          pharmaPropName: userData[i].pharmaPropName, 
          pharmaForm: userData[i].pharmaForm, 
          pharmaQuantity: userData[i].pharmaQuantity, 
          pharmaNotes: userData[i].pharmaNotes, 
          pharmaEntry: userData[i].pharmaEntry, 
          editable: true, 
          durationEditable: true, 
          backgroundColor: userData[i].cal_color, 
          borderColor: '#ffffff', 
          textColor: userData[i].txt_color 
          //error: function() { alert('There was an error loading calendar data.');} 
         }); 
        } 
        callback(eventData); 
       } 
      }); 
     }, 
     editable: true, 
     draggable: true, 
     resizeable: true, 
     theme: false, 
     selectable: true, 
     selectHelper: true, 
     unselectAuto: true, 
     eventStartEditable: true, 
     eventDurationEditable: true, 
     eventLimit: true, 
     defaultView: 'agendaWeek', 
     allDayDefault: false, 
     slotMinutes: 15, 
     snapMinutes: 15, 
     defaultEventMinutes: 30, 
     firstHour: 8, 
     timezone: deviceTimeZone, 
     year: moment.tz(deviceTimeZone).format("YYYY"), 
     month: moment.tz(deviceTimeZone).format("M"), 
     date: moment.tz(deviceTimeZone).format("DD"), 
     header: { 
      left: 'prev,next today', 
      center: 'title', 
      right: 'month,agendaWeek,agendaDay' 
     }, 
     buttonText: { 
      month: 'Month', 
      agendaWeek: 'Week', 
      agendaDay: 'Day' 
     }); 
Powiązane problemy