Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    How to disable DST in Timeline.

    Is it possible to disable DST for a timeline. I have tried DateUtil.setAdjustForDST(false) but that didn't do anything.

    My timeline has an eventSnapGap of 1 day (1440 minutes) so I am not interested in DST in my case.

    The problem is that for event dates after October 24th, 1 hour is subtracted from the dates sent to and from the server which leads to some problems.
    I'm saving the dates as DATE in the database so when I send for example 26/10/2015 00:00 it is changed to 25/10/2015 23:00 which is then saved in the database as 25/10/2015, so 1 day earlier than intended.

    The Timeline also shows the start and end dates differently after October 24th.
    After October 24th the event dates are shown 1 day to the right compared to events before October 24th.
    In this picture you can see that the top event ending on the 26th fills the day of the 26th in the timeline, but the other event that ends on the 24th does not fill the day of the 24th.
    Click image for larger version

Name:	Strange_DST_Behavior.png
Views:	103
Size:	21.1 KB
ID:	231966

    The timeline works great when there is no DST so if I can just disable DST i think it would solve my problems.

    Let me know if you need more info.

    #2
    FYI, I also noticed a bug in the Timeline Resolution example in the showcase.

    If you open the Timeline Resolution example and press the "Hours (1 day)" button, then some of the events stretch way outside of the timeline creating a very long horizontal scroll-bar.

    This was with Chrome Version 45.0.2454.101 m

    Comment


      #3
      Sorry for the delay, your account wasn't correctly flagged as having support.

      Can you show the settings you have on your timeline? We'll take a look at both issues and update here when we have more information.

      Comment


        #4
        Here are my timeline settings, let me know if anything needs explaining or if you need any additional info.

        Code:
        timeline = new Timeline();
        timeline.setWidth100();
        timeline.setEventSnapGap(1440); // 60 * 24
        timeline.setDisableWeekends(false);
        timeline.setShowWeekends(false);
        timeline.setShowEventDescriptions(false);
        timeline.setCanCreateEvents(false);
        timeline.setEventLaneFieldTitle("Person");
        timeline.setShowControlsBar(false);
        timeline.setShowQuickEventDialog(false);
        timeline.setCanRemoveEvents(false);
        timeline.setLaneEventPadding(3);
        timeline.setOverlapSortSpecifiers(new SortSpecifier("sortOrder", SortDirection.ASCENDING));
        timeline.setLaneFields(new ListGridField("title", "People", 210));
        timeline.setLanes(lanes);
        timeline.setDataSource(ds);
        timeline.setAutoFetchData(true);
        timeline.setCanAcceptDrop(true);
        timeline.setShowZones(true);
        timeline.setZones(holidays.toArray(new CalendarEvent[holidays.size()]));
        timeline.setUseEventCanvasRolloverControls(false);
        Canvas properties = new Canvas();
        properties.setHoverWidth(500);
        timeline.setAutoChildProperties("eventCanvas", properties);
        timeline.setShowLaneRollOver(true);
        timeline.setEventHeaderHTMLCustomizer(new EventHeaderHTMLCustomizer() {
            
            @Override
            public String getEventHeaderHTML(CalendarEvent calendarEvent, CalendarView calendarView) {
                if(calendarEvent.getStyleName().equals("eventWindowHeader-project") || calendarEvent.getStyleName().equals("eventWindowHeader-absence"))
                {
                    boolean isBelowThreshold = calendarEvent.getAttribute("brightness") != null && calendarEvent.getAttributeAsDouble("brightness") < brightnessThreshold;
                    String imgUrl = isBelowThreshold ? "[SKIN]/actions/edit_resource.png" : "[SKIN]/actions/edit_resource_black.png";
                    String img = Canvas.imgHTML(imgUrl, 17, 18);
                    String changedImg = img.substring(0, img.length()-1) + "style='cursor: pointer;'>";
                    if (calendarEvent.getStyleName().equals("eventWindowHeader-project")) {
                        String color = isBelowThreshold ? "#ffffff" : "#5a5a5a";
                        return "<table width='100%' height='100%' cellspacing='0' cellpadding='0' style='background-color: " + calendarEvent.getAttributeAsString("background-color") + "; color:" + color + ";'><tbody><tr><td valign='middle' align='middle' >" + calendarEvent.getName() + "&nbsp;&nbsp;" + changedImg + "</div></td></tr></tbody></table>";
                    }
                    return "<table width='100%' height='100%' cellspacing='0' cellpadding='0'><tbody><tr><td valign='middle' align='middle' >" + calendarEvent.getName() + "&nbsp;&nbsp;" + changedImg + "</div></td></tr></tbody></table>";
                }
                else
                    return "<table width='100%' height='100%' cellspacing='0' cellpadding='0'><tbody><tr><td valign='middle' align='middle' >" + calendarEvent.getName() + "</td></tr></tbody></table>";
            }
        });
        timeline.addEventClickHandler(new EventClickHandler() {
            @Override
            public void onEventClick(CalendarEventClick calendarEventClick) {
                if(calendarEventClick.getEvent().getAttributeAsBoolean("canEdit"))
                {
                    openEventEditModal(calendarEventClick.getEvent());
                }
                calendarEventClick.cancel();
            }
        });
        
        timeline.setEventCanvasHoverHTMLCustomizer(new EventCanvasHoverHTMLCustomizer() {
            @Override
            public String getHoverHTML(CalendarEvent calendarEvent, EventCanvas eventWindow) {
                DateTimeFormat dtf = DateTimeFormat.getFormat("d/M, yyyy");
                Date editedEndDate = (Date) calendarEvent.getEndDate().clone();
                CalendarUtil.addDaysToDate(editedEndDate, -1);
                String hoverHtml = DateUtil.formatAsShortDate(calendarEvent.getStartDate()) + " - " + DateUtil.formatAsShortDate(editedEndDate) + "<br>";
                hoverHtml += calendarEvent.getName() + "<br>";
                hoverHtml += calendarEvent.getDescription();
                return hoverHtml;
            }
        });
        timeline.addDropHandler(getTimelineDrophandler());
        timeline.setHeaderLevels(TimelineUtils.getDayViewHeaderLevels(sessionManager));
        timeline.setDefaultTimelineColumnSpan(28);
        
        Date startDate = DateUtil.getAbsoluteDate(RelativeDate.TODAY);
        // if you don't call this, you'll get defaultTimelineColumnSpan columns (20)
        timeline.setStartDate(startDate);
        Date endDate = DateUtil.getAbsoluteDate(RelativeDate.TODAY);
        CalendarUtil.addDaysToDate(endDate, 28);
        timeline.setEndDate(endDate);
        // ShowLaneCustomizer works with the filter to exclude lanes
        timeline.setShowLaneCustomizer(new ShowLaneCustomizer() {  
            @Override  
            public boolean shouldShowLane(Lane lane, CalendarView calendarView) {
                if(lane != null)
                {
                    // Employee Name
                    String employeeName = filterEmployeeValue;  
                    if (employeeName != null && employeeName != "") {  
                        String laneName = lane.getAttribute("employee");
                        if (laneName.toLowerCase().contains(employeeName.toLowerCase()) == false) {  
                            return false;  
                        }
                    }
                    // Role
                    if (filterRoleValue != null && filterRoleValue.length > 0) {
                        Integer laneRole = lane.getAttributeAsInt("roleId");
                        boolean found = false;
                        for (String roleId : filterRoleValue) {
                            if (laneRole.equals(Integer.parseInt(roleId))) {
                                found = true;
                                break;
                            }
                        }
                        if(!found)
                            return false;
                    }
                    // Team
                    if(filterTeamValue != null && filterTeamValue.length > 0)
                    {
                        int[] laneTeams = lane.getAttributeAsIntArray("teams");
                        if(laneTeams == null)
                            return false;
                        boolean found = false;
                        
                        for (String teamName : filterTeamValue) {
                            int filterTeamId = Integer.parseInt(teamName);
                            for (int teamId : laneTeams) {
                                if (filterTeamId == teamId) {
                                    found = true;
                                    break;
                                }
                            }
                            if(found)
                                break;
                        }
                        if(!found)
                            return false;
                    }
                    // Project
                    String projectName = (String)filterProjectValue;
                    if (projectName != null && projectName != "") {
                        for (CalendarEvent event : timeline.getLaneEvents(lane)) {
                            if(event.getAttributeAsBoolean("isClientEvent"))
                                continue;
                            if(event.getName().toLowerCase().contains(projectName.toLowerCase()))
                                return executeDefault(lane, calendarView);
                        }
                        return false;
                    }
                }
                return executeDefault(lane, calendarView);
            }
        });

        Comment


          #5
          And here is the ds:

          Code:
          <DataSource  
              ID="project_resource_overview"
              serverConstructor="it.forecast.server.servlets.resourceOverview.ResourceOverviewServlet">
              <operationBindings>
              
                  <binding operationType="custom" operationId="getLanes">
                      <serverObject  
                           className="it.forecast.server.servlets.resourceOverview.ResourceOverviewServlet"
                           methodName="execute" 
                      />
                  </binding>
                  
              </operationBindings>
              <fields>  
                  <field name="eventId"    type="sequence"    primaryKey="true"    />
                  <field name="name"                                            />
                  <field name="description"                                    />
                  <field name="startDate"        type="datetime"                    />
                  <field name="endDate"        type="datetime"                    />
                  <field name="lane"            type="text"                        />
                  <field name="project"        type="integer"                    />
                  <field name="pic"            type="binary" />
              </fields>
          </DataSource>

          Comment


            #6
            Have you been able to reproduce any of my problems?

            Comment


              #7
              Hi Niels, yes, we can see the problem. This one is going to take a while to fix, as DST and timezones are really tricky and it's not easy to figure out the best behavior here for arbitrary granularity timezones. Please be patient.

              Comment


                #8
                Hi,

                Any update on this?

                Comment


                  #9
                  We have a spec for changes that address the problem and we expect the changes to hit nightly builds in the comoing days, most likely this week.

                  Comment


                    #10
                    That is great to hear, Thanks.

                    Comment

                    Working...
                    X