brOOper / gwt-cal

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

MonthView incorrectly displaying appointments for wrong month #60

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.Create a full day appointment in June
2.set calendar to may
3.see the appointment as a multi-day appointment stretching on days of 
June visible at a May view

Here is how I fixed it (with unit test!):
MonthLayoutDescription.overlapsWithMonth(Appointment appointment, Date 
calendarFirstDate, Date calendarLastDate) {     
 return !(appointment.getStart().before(calendarFirstDate)
    && appointment.getEnd().before(calendarFirstDate) 
  ||appointment.getStart().after(calendarLastDate) 
    && appointment.getEnd().after(calendarLastDate));
}

MonthLayoutDescription.placeAppointments
for (Appointment appointment : appointments) {
            if(overlapsWithMonth(appointment, calendarFirstDay, 
calendarLastDay)) {
...

MonthLayoutDescriptionTest.testAppointments:

@Test
public void nextMonthAppointmentIncluded_issue60() throws ParseException{
    Appointment app = new Appointment();
    app.setAllDay(true);
    app.setStart(new Date(2010,05,11));
    app.setEnd(new Date(2010, 05, 11));

    ArrayList<Appointment> appointments = new ArrayList<Appointment>();
    appointments.add(app);

    MonthLayoutDescription monthDescription =
     new MonthLayoutDescription(dateFormatter.parse("04/25/2010"),6,
                                         appointments);

    weekDescriptions = monthDescription.getWeekDescriptions();
    assertNull("5th week should have no appointments", weekDescriptions
[5]);

   }

Original issue reported on code.google.com by doom777 on 3 Jun 2010 at 7:20

GoogleCodeExporter commented 8 years ago
Hey Carlos, can you please have a look? I'd like to push out a 0.9.1 release 
and would like to include fixes for any layout bugs. Thanks!

Original comment by Brad.Ryd...@gmail.com on 20 Jun 2010 at 6:07

GoogleCodeExporter commented 8 years ago
I'll take a look tonight. Thanks for the feedback.

Carlos

Original comment by carlos.m...@gmail.com on 21 Jun 2010 at 12:15

GoogleCodeExporter commented 8 years ago
Hello Doom777,

I tried to reproduce the issue without success. Please take a look at the 
attached document. Can you confirm that you are using the project main trunk? 

Thanks,

Carlos

Original comment by carlos.m...@gmail.com on 22 Jun 2010 at 7:50

Attachments:

GoogleCodeExporter commented 8 years ago
create the appointment in the middle of june, then move to may. I am using 
trunk. 

Original comment by doom777 on 22 Jun 2010 at 10:15

GoogleCodeExporter commented 8 years ago
Hello Doom777,

I have made your fix part of the code base (revision 324.) I improved the test 
case code a little bit to make it more thorough. 

Please let us know if you find any other glitches. I thank you in advance.

Best,

Carlos

P.S. I just want to mention a couple of things about the test case code you 
provided: 

a) The year parameter of the date constructor accepts a number minus 1900, a 
parameter of 2010 will actually result in a date in year 3910

b) A leading zero in an integer literal makes the number an octal number, it 
doesn't really matter in the context, just an FYI ;)

Original comment by carlos.m...@gmail.com on 24 Jun 2010 at 5:36