brOOper / gwt-cal

Automatically exported from code.google.com/p/gwt-cal
0 stars 0 forks source link

MonthView, multi-month appointment starts on wrong day in final month #66

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hey Carlos,

I was hoping you could please download the attached "LayoutTest.java" file and 
include in the gwt-cal-demo? Then in "Main.java" load the LayoutTest panel, 
like this:
RootPanel.get().add(new LayoutTest());

This LayoutTest class demonstrates an issue with the MonthView layout code 
where multi-day appointments that span 2 or more months render incorrectly.

The example has an appointment from 2010-06-03 to 2010-07-02. When you set the 
month to July (using next/previous month buttons), you will see that in July 
the appointment is rendered to start on July 20th.

If you want we can try to troubleshoot this one together. Just give me a call. 
Thanks! 

Original issue reported on code.google.com by Brad.Ryd...@gmail.com on 13 Jul 2010 at 1:50

Attachments:

GoogleCodeExporter commented 8 years ago
Hey Carlos, I tracked this one down. Here was the issue...

differenceInDays is used to calculate the week (row) the appointment will start 
and end. This method returns an absolute value. So when 6/27 is the start date, 
and the test date is 6/03, it returns 24 day difference, when in fact it should 
be -24.

As a result, the calculateWeekFor returns a value of 3 (24/7), when in fact the 
desired result would actually be 0.

So I added the following check at the start of calculateWeekFor, AND the 
dayInWeek method:
   if(testDate.before(calendarFirstDate)) {
     return 0;
   }

You can see the unit test for this here:
   appointmentFromPriorMonthInFirstWeekOfNextMonth_issue66()

Original comment by Brad.Ryd...@gmail.com on 19 Aug 2010 at 9:25