PDA

View Full Version : Advanced calendar question


duhuskermeg
08-27-2001, 11:42 PM
Hi!!

I have some problems with a function...
The functions purpose is to check for free time in a given period.

function freetime(FromDate, ToDate, FromTime, ToTime) : true/false

The question is: how do I make the best routine for checking this? There might be more the one appointments each day, so the check has to check for all appointments, and also consider that the appointment might run over days.

I thought about registering all appointments thats already registeres in a table, but what is the best way to do this?



//
// Example:
//
// Defintions

Number_Appointments = 0;
AppointmentTable = new Array();
function appointmet(FromDate, ToDate, FromTime, ToTime)
{
this.FromDate = FromDate;
this.ToDate = ToDate;
this.FromTime = FromTime;
this.ToTime = ToTime;
}
execute_function_read_registered_appointments_to_t able;

//
// use of table
//

if (freetime(FromDate, ToDate, FromTime, ToTime))
{
AppointmentTable[Number_Appointments + 1] = new appointment(FromDate, ToDate, FromTime, ToTime);
} else {
goto busy;
}

//


PS: Last I have to say that I dont think this will contain as much data as it may seem at first. The calendar will contain appointments for 1-6 months, and for some it may be 5 appointments and for others it may be much more, but anyway, It's not as bad as it may seem, in my oppinion.

PPS: If you can solve this, I also need a function similiar to the other one. The return value of the other function must be starting hour for appointments a given date AND the length (hours) for the appointment. Is this possible somehow?


TranceMore

Jesse
08-28-2001, 06:58 AM
ok I'm no OO guru but you might want to consider having one object for each day.
then you can do stuff like:

with (day21) {
appt1 = New Appointment();
appt1.startTime =
// ...
apptX = New Appointment();
apptX.startTime =
}
then you can make a routine which loops through all apptX in a given day and returns if a set time is free or not... just brainstorming here.

duhuskermeg
08-29-2001, 12:48 AM
Yeah.. its a start, but when the appointments are assigned to the days.. its maybe a bit hart when appointments run over more than one day...

I figured out it maybe easier to convert time to minutes when running the check. (time = hour * 60) + minutes

But I'm still not satisfyed with the date storage for searcing...



TranceMore