Announcement

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

    timeline events are missing at the end of the day

    given the example below, the timeline doesn't display calendar events that start in the last hour
    and when a calendar event ends in the last hour, it is drawn as if it ends at the end of the day

    we use smartgwt version 13.0p-20230509

    what could be the problem?

    Thanks in advance


    Click image for larger version  Name:	2023-09-27 11_58_53-Clipboard.png Views:	0 Size:	11.4 KB ID:	271007



    Code:
    private static final DateTimeFormat df = DateTimeFormat.getFormat("dd-MM-yyyy HH:mm:ss");
    
    static int id;
    
    
    
    final int startHour = 9; // start the timeline at 9:00
    
    
    
    // demo shows date September 22nd 2023
    
    Date periodStart = createDate(2023, 9, 22, startHour, 0, 0);
    
    Date periodEnd = createDate(2023, 9, 22, 23, 59, 59);
    
    
    
    @Override
    
    public void onModuleLoad() {
    
    
    
    VLayout body = new VLayout(10);
    
    body.setWidth100();
    
    body.setHeight100();
    
    
    
    Timeline timeline = createTimeline(periodStart, periodEnd);
    
    
    
    timeline.setResolution(new HeaderLevel[] { new HeaderLevel(TimeUnit.MINUTE) }, TimeUnit.MINUTE, (24 - startHour) * 60, 60);
    
    
    
    // Please note: if the line above is changed into the line below it doesn't seem to make any difference
    
    // timeline.setResolution(new HeaderLevel[] { new HeaderLevel(TimeUnit.MINUTE) }, TimeUnit.HOUR, (24 - startHour), 60);
    
    
    
    timeline.setLanes(new Lane("Lane 1", "Lane 1"));
    
    timeline.setData(getRecords());
    
    
    
    // why does this print wrong dates?
    
    GWT.log("start=" + timeline.getStartDate() + " end=" + timeline.getEndDate());
    
    
    
    body.setMembers(timeline);
    
    body.draw();
    
    }
    
    
    
    private static Timeline createTimeline(Date startDate, Date endDate) {
    
    Timeline timeline = new Timeline();
    
    timeline.setWidth100();
    
    timeline.setHeight100();
    
    timeline.setCanEditLane(false);
    
    timeline.setCanEditEvents(false);
    
    timeline.setCanAddFormulaFields(false);
    
    timeline.setCanCreateEvents(false);
    
    timeline.setCanRemoveEvents(false);
    
    timeline.setCanResizeEvents(false);
    
    timeline.setShowEventDescriptions(false);
    
    
    
    timeline.setShowAddEventButton(false);
    
    timeline.setShowDatePickerButton(false);
    
    timeline.setShowDateChooser(false);
    
    timeline.setShowDateCustomizer(new ShowDateCustomizer() {
    
    
    
    @Override
    
    public boolean shouldShowDate(Date date, CalendarView calendarView) {
    
    return date.equals(startDate) || date.equals(endDate) || (date.after(startDate) && date.before(endDate));
    
    }
    
    });
    
    timeline.setShowControlsBar(false);
    
    
    
    timeline.setShowLaneRollOver(true); // please note: doesn't work
    
    timeline.setShowTimelineView(true);
    
    timeline.setAlternateLaneStyles(true);
    
    
    
    timeline.setEventSnapGap(0);
    
    timeline.setColumnsPerPage(24);
    
    timeline.setSizeEventsToGrid(false);
    
    
    
    timeline.setSnapVDirection("nearest");
    
    
    
    // zone settings
    
    timeline.setShowZones(true);
    
    // indicator settings
    
    timeline.setShowIndicators(true);
    
    
    
    timeline.setLaneFields(new ListGridField("title", "Demo lanes", 200));
    
    timeline.setStartDate(startDate);
    
    timeline.setEndDate(endDate);
    
    
    
    return timeline;
    
    }
    
    
    
    private CalendarEvent[] getRecords() {
    
    return new CalendarEvent[] {
    
    buildEvent("Lane 1", "22-09-2023 09:10:00", "22-09-2023 10:11:07"),
    
    buildEvent("Lane 1", "22-09-2023 10:21:07", "22-09-2023 11:34:17"),
    
    buildEvent("Lane 1", "22-09-2023 11:44:17", "22-09-2023 12:54:40"),
    
    buildEvent("Lane 1", "22-09-2023 12:54:40", "22-09-2023 13:04:40"),
    
    buildEvent("Lane 1", "22-09-2023 13:04:40", "22-09-2023 13:40:46"),
    
    buildEvent("Lane 1", "22-09-2023 13:50:46", "22-09-2023 14:28:40"),
    
    buildEvent("Lane 1", "22-09-2023 14:28:40", "22-09-2023 14:38:40"),
    
    buildEvent("Lane 1", "22-09-2023 14:38:40", "22-09-2023 15:10:46"),
    
    buildEvent("Lane 1", "22-09-2023 15:10:46", "22-09-2023 15:20:46"),
    
    buildEvent("Lane 1", "22-09-2023 15:20:46", "22-09-2023 16:20:45"),
    
    buildEvent("Lane 1", "22-09-2023 18:01:03", "22-09-2023 22:28:40"),
    
    buildEvent("Lane 1", "22-09-2023 22:28:40", "22-09-2023 22:38:40"),
    
    buildEvent("Lane 1", "22-09-2023 22:38:40", "22-09-2023 22:48:46"),
    
    buildEvent("Lane 1", "22-09-2023 22:48:46", "22-09-2023 22:58:46"),
    
    buildEvent("Lane 1", "22-09-2023 22:58:46", "22-09-2023 23:10:45"), // incorrectly shown
    
    buildEvent("Lane 1", "22-09-2023 23:10:45", "22-09-2023 23:20:45"), // doesn't show
    
    buildEvent("Lane 1", "22-09-2023 23:20:45", "22-09-2023 23:27:56"), // doesn't show
    
    buildEvent("Lane 1", "22-09-2023 23:27:56", "22-09-2023 23:37:56"), // doesn't show
    
    buildEvent("Lane 1", "22-09-2023 23:37:56", "22-09-2023 23:47:03"), // doesn't show
    
    buildEvent("Lane 1", "22-09-2023 23:47:03", "22-09-2023 23:52:03") // doesn't show
    
    };
    
    }
    
    
    
    static Date createDate(int year, int month, int day, int hour, int minute, int second) {
    
    return new Date(year - 1900, month - 1, day, hour, minute, second);
    
    }
    
    
    
    static CalendarEvent buildEvent(String lane, String start, String end) {
    
    return new CalendarEvent(id++, "" + id, null, loseSeconds(df.parse(start)), loseSeconds(df.parse(end)), lane);
    
    }
    
    
    
    static Date loseSeconds(Date date) {
    
    date.setSeconds(0);
    
    return date;
    
    }

    #2
    Thanks for the report. We've made a change to fix these issues - please retest with a build dated October 1 or later.

    Comment


      #3
      Thanks a lot, we have tested the build of October 1st and this issue is solved now.

      Comment

      Working...
      X