Timeline view: problem with rounding event position

Hi!

Im working on a timeline view that shows 21 days on the x-axis, covering the previous week, current week and next week. I have set round_position to true and I’d like every event to be presented by a bar covering the particular date. I noticed that if the end time is before 18:00, the bar doesn’t round up to the full day but shows as a tiny bar on the left side of the cell. I’d like to ask for advice as to how to fix this.

I have noticed that if I comment out the function I define for scheduler.date.timeline_start to start the timeline view at previous week’s monday, the events are all rounded up correctly.

Below is my scheduler configs, createTimelineView() and the scheduler.date.timeline_start function. Suggestions? Am I defining timeline_start correctly, or doing something really stupid?

scheduler.locale.labels.timeline_tab = "Aikajana";
            scheduler.locale.labels.section_inspector="Tarkastaja";
            scheduler.locale.labels.section_state="Tila";
            scheduler.config.first_hour = 8;
            scheduler.config.last_hour = 20;
            scheduler.config.details_on_create=true;
            scheduler.config.details_on_dblclick=true;
            scheduler.xy.bar_height = 60;
            scheduler.config.xml_date="%Y-%m-%d %H:%i";
            scheduler.config.default_date = "%D, %j %F";
            scheduler.config.day_date = "%D, %j %F";
scheduler.createTimelineView({
                        
                    	name:	"timeline",
	                	x_unit: "day", // unit which should be used for second scale
	                    x_date: "%D %d.%m", // date format which should be used for second scale, "July 01"

                        x_size: 21,
                        x_start: 0,
                        x_length: 21,
                        y_unit:	sections,
                        y_property:	"userIdForEvent",
                        render:"bar",
                        round_position:true,
                        section_autoheight: false
                    });
                    scheduler.date.timeline_start = function(date) {
                    	
                    	if (date.toDateString() == (new Date().toDateString())) {
	                    	
	                    	var distanceFromLastWeekMonday = date.getDay() + 6;
	                    	date.setTime( date.getTime() - distanceFromLastWeekMonday * 86400000 );
	                    	
                    	}
                    	return date;
                    }

Found it. I was doing something extremely stupid. The if-statement in the timeline_start function was comparing dates with seconds and all which is obviously wrong. The thing is I didnt see problems until I added sections to y-axis and events. I don’t really know why it worked with some times and not with others, which made it so weird, and I don’t really care :smiley:.

Here is the fixed code in case anyone who needs anything like it stumbles upon the thread:

                    scheduler.date.timeline_start = function(date) {
                    	
                    	if (scheduler.date.day_start(date).toString() == scheduler.date.day_start(new Date()).toString()) {
	                    	
	                    	var distanceFromLastWeekMonday = date.getDay() + 6;
	                    	date.setTime(date.getTime() - distanceFromLastWeekMonday * 86400000 );
	                    	
                    	}
                    	return date;
                    }