Screenshot of the new look
Hi Tung and folks,

   I have prepared a rather large patch for the OpenWebMail Calendar.
   This patch contains code to accomplish the following:

- Complete re-write of the dayview routine. Events of the day are now displayed in a matrix
  instead of line by line. This places events in an easy to read format. It is now easy to
  see at a glance when you have conflicts in your day.

- Update the formatting of military time to be displayed as HH:MM instead of H:MM, which is incorrect. 

- Addition of several interesting useful subroutines:
    sub floor()       - C style floor implementation without POSIX.pm 
    sub rgb2hsv()     - An rgb2hsv conversion algorithm
    sub hsv2rgb()     - An hsv2rgb conversion algorithm
    sub bordercolor() - Calculates a complimentary border color for any hex color

- Initial code cleanup for readability. I would like to cleanup more in the future.


   During this large undertaking I also uncovered several bugs in the calendaring implementation:

- Calendar events can be created with no start and end time. This might be considered a feature, and
  it is supported in the new code above. However, it is not good practice in my opinion.

- Calendar events can have a start time and no end time. This is not supported at all. These events
  are not removable from the system if they are accidentally created. They do not appear in the new
  dayview and they cannot be modified from the month or week views. I recommend events like this be disallowed.

- Calendar events can be created that have an end time earlier than the start time. This may be considered
  a feature if one considers these events to overlap into the next day. However, it should be supported by
  the recurrance options, or the user should be forced to enter two events in my opinion.

- Calendar events started at :05 revert to :00 when you go back to edit them.


   As with any new code, there are also some bugs in my implementation. I feel that these bugs will rarely
  be encountered in actual usage and that this code is ready for at least a -current release. I also feel
  that the code is at the stage where having more eyeballs looking at it would be helpful. Actually, I have
  found only one bug that occurs when you have a certain combination of events in a day. A sample
  combination to illustrate this bug is:

     Add 2 events that run from 8 am - 9 am
     Add 3 events that run from 9 am - 10 am

  You can now see a display error in the dayview. It would be helpful if testers can submit more
  combinations to me that break the dayview.

Installation:
Download the patch here.
Look at it online here.

   Extract with tar -xvzf cal-newdayview.patch.tgz

   To install this patch:

   - cd to the directory on your system where openwebmail-cal.pl is located.
   - copy the patch to that directory
   - type: patch openwebmail-cal.pl cal-newdayview.patch
   - copy cal-link.gif and cal-delete.gif to every iconset folder in /data/images/iconsets

 I did not update the Text.English iconset file. I leave that to the maintainer of that file.

 The patch contains a screenshot of what the new dayview looks like. You can also see a screenshot before
 you download the patch at http://www.acatysmoof.com/posting/openwebmail-patches/030212/screenshot.png

 It is important to note that this patch does not change the data structure of the OpenWebMail Calendar
 file format in any way. It simply displays the data in a nicer format.


Future:

   I would like to implement the same sort of routine into the weekview.

   I already have good ideas on how to get the bugs out of the dayview, but I need some more test combinations.

   I would like to add a user preference to allow user specified view periods. For example, instead of every
   half hour they could see every five minutes.


Credit:

   A big part of the concept and code for this patch was obtained from the Horde Kronolith project
    and translated from the PGP code by Charles Hagenbuch - specifically the 48 half-hour
   matrix idea. The html writing code and implementation, and the integration to the openwebmail data
   structures was done by me.
   The rgb and hsv code was translated from the open source C code routines at
   http://www.cs.rit.edu/~ncs/color/t_convert.html by Nan C. Schaller

Thanks,
Alex

P.S.- email addresses of the people above are available in the README file in the download for the patch.