Actually I thought I would add the code.
Because I have users populating the calendar from multiple time zones, it was easier for me to write code based on the time the apt was set for. For apt that start at 11:00pm CST I know those are the next day apts for EST. The same with PST entries. This explains the time conversion code.
The basic objective is to return the start date, but if the apt is recurring or longer than a day, and today is within that range, return today as the start date. This way, for as long as the apt is active it will appear with todays date.
I would welcome any suggestions on a better way to do this.
DateTimeVar StartDate;
DateTimeVar EndDate;
// Start here, are we dealing with a recurring apt? If we are then....
If {Calendar.Recurring} = True Then
(
StartDate := {Calendar.Recurrence Range Start Time};
EndDate := {Calendar.Recurrence Range End Time};
//convert recurring start date for CST.
//Because I have users from multiple zones this was the easiest method.
if Time(StartDate) > time(22,59,00) or Time(StartDate) = time(02,00,00) Then
StartDate := Date(StartDate) +1;
//convert recurring end date for CST
if Time(EndDate) > time(22,59,00) or Time(StartDate) = time(02,00,00) Then
EndDate := Date(EndDate) +1;
//if the recurring apt has an end date that is more than the start date
//and today is somewhere in the middle - print the record
If Date(EndDate)>= CurrentDate and Date(StartDate)<= CurrentDate Then
StartDate := CurrentDate;
Date(StartDate)
)
Else //non recurring apt
(
StartDate := {Calendar.Start Time};
EndDate := {Calendar.End Time};
//convert recurring start date for CST
if Time(StartDate) > time(22,59,00) or Time(StartDate) = time(02,00,00) Then
StartDate := Date(StartDate) +1;
//convert recurring end date for CST
if Time(EndDate) > time(22,59,00) or Time(StartDate) = time(02,00,00) Then
EndDate := Date(EndDate) +1;
// non recurring but an apt that is long enough to span multiple days
// and today is somewhere in the middle - print the record
If Date({Calendar.End Time}) > Date(StartDate) and Date({Calendar.End Time}) >= CurrentDate and Date(StartDate)<= CurrentDate Then
StartDate := CurrentDate;
Date(StartDate)
)