MH42 / gwt-cal

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

appts in MonthView are rendered in cells one day after the appt's start date #28

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. create a new calendar instance 
2. set the view to the month view
3. add an appointment for any date visible in the current month

What is the expected output? What do you see instead?

expect The appointment be rendered within the cell for the appointment's start 
date
actual The appointment is rendered in the appointment's start date (+ one day) 
cell

What version of the product are you using? On what operating system?

branches/version-0.9 os x leopard

Please provide any additional information below.

This was not an issue in earlier deployments.

My guess is that there is an err in the logic within 
MonthView#layOnWeekDaysAppointments 
 -> which calls MonthView#layOnAppointment(appointment, dayOfWeek, dayOfWeek,...
   -> which calls MonthView#placeItemInGrid(panel, colStart, colEnd, ...

Original issue reported on code.google.com by d.tang...@gmail.com on 11 Feb 2010 at 11:16

GoogleCodeExporter commented 9 years ago
I'm looking into this. 

Original comment by carlos.m...@gmail.com on 13 Feb 2010 at 7:04

GoogleCodeExporter commented 9 years ago
Hello d.tangren,

I spent some time doing both manual and automatic tests. I was not able to 
reproduce
the issue you are describing. Can you please confirm that you tested with
version-0.9, revision 249?

To conduce my investigation, I tried with the following code:

{{{

        int testYear = 2010 - 1900;
        int month = 5;

        calendar.setDate(new Date(testYear, month, 1));
        calendar.setView(CalendarViews.MONTH);
        calendar.suspendLayout();

        for(int day = 1; day < 29; day++)
        {
            Date testDay = new Date(testYear, month, day);

            Appointment apppointment = new Appointment();
            apppointment.setTitle(testDay.toString());
            apppointment.setStart(testDay);
            apppointment.setEnd(testDay);

            calendar.addAppointment(apppointment);

            Appointment multiDayAppointment = new Appointment();            
            multiDayAppointment.setStart(new Date(testDay.getYear(),
testDay.getMonth(), testDay.getDate(),0, 0, 0));
            multiDayAppointment.setTitle(multiDayAppointment.getStart().toString());
            multiDayAppointment.setEnd(new Date(testDay.getYear(),
testDay.getMonth(), testDay.getDate() + 1));
            multiDayAppointment.setStyle(Appointment.RED);
            calendar.addAppointment(multiDayAppointment);
        }

      calendar.resumeLayout();

}}}

It configures a simple appointment and a multi-day appointment for each day of 
the
month starting on the 1st. and the last being the 28th. I put the 28 limit in 
the for
loop to prevent any issues with February. To make things more obvious, I set the
title of all the appointments to be the START date of the same appointment.

To generate configurations for all months, I changed the 'int month = 5;' line 
to be
0, 1, etc.

Please let me know if getting the latest revision code solves this issue for 
you. If
you have issues after that, I will take another look.

Thank you,

Carlos

Original comment by carlos.m...@gmail.com on 14 Feb 2010 at 3:37

GoogleCodeExporter commented 9 years ago
Hello d.tangren, 

I finally figured out the problem. Just by setting one of the appointment's 
start
time to be after 00:00:00 makes the problem obvious.

The algorithm to calculate the difference in days between to days was broken
(DateUtils.differenceInDays). Its limited logic could only deal with 
Appointments
whose dates represented the FIRST INSTANT of the corresponding day (i.e., 0 
hours, 0
minutes, 0 seconds, etc.)

The solution did not have to do with rounding up or down (as I had originally 
tried)
but with an 'offset' that has to do with the Daylight saving time and crazy
subtleties related to the way we keep track of time across the world.

Anyway, I hope refreshing your copy of the library to revision 250 will solve 
the issue.

After you verify, could you please let me know so I can consider this issue 
done?

Best,

Carlos

Original comment by carlos.m...@gmail.com on 14 Feb 2010 at 8:38

GoogleCodeExporter commented 9 years ago

Original comment by Brad.Ryd...@gmail.com on 12 May 2010 at 7:12