Problem:
I am developing a Gant type chart for a web application that displays the
current time in some sort of scale (either by 24, 12, 8,4,2, or one hour)

I have already looked at cfchart, but dont know if it can be applied to this
case, so I am attempting to develop this myself.

http://www.active.aero/testing.cfm


In the code attached below, specifically line 170 I compare the following
dates:

Date           Purpose
display_this   This is the date held as the "time value" of the current cell
flown_started  This is the date/time that the flight began
flown_ended        This is the date/time that the flight ended

so if the first comparison is 1, then that means the flight had already
started
and if the second comparison is -1, then that means the flight is still
going on

<cfif datecompare(display_this,flown_started,"n") is 1 AND
datecompare(display_this,flown_ended,"n") is "-1">style="background-color:
red"</cfif>


What I dont understand is why the hell does the red background stop and then
start again. The only thing I can think of is that the datecompare only
actually compares the minutes and not the date itself.








SEE CODE BELOW
<cfparam name="scale" default="24">
<cfparam name="time_add_number" default="1">
<cfparam name="hours" default="9999">
<cfparam name="use_this_time" default="">
<cfparam name="minute_scale" default="0">
<cfparam name="post_twelve" default="false">
<cfparam name="date_in_question" default="">





<cfif isDefined('url.search_time')>
        <cfset use_this_time = url.search_time>
        <cfset date_in_question = DateFormat(now(),'mm/dd/yyyy')>
<cfelse>
        <cfset use_this_time = now()>
        <cfset date_in_question = DateFormat(now(),'mm/dd/yyyy')>
</cfif>

<cfif scale is "24">
        <cfset time_add_number = 1>
        <cfset middle = Evaluate("scale/2")>
        <cfset this_display_date =
DateFormat(DateAdd("h",-12,use_this_time),"m/d/yyyy")>
        <cfset this_display_time =  this_display_date &" "&
TimeFormat(DateAdd("h",-12,use_this_time),"hh:mm TT")>
<cfelseif scale is 12>
        <cfset time_add_number = 1>
        <cfset middle = Evaluate("scale/2")>
        <cfset this_display_date =
DateFormat(DateAdd("h",-6,use_this_time),"m/d/yyyy")>
        <cfset this_display_time =
TimeFormat(DateAdd("h",-6,use_this_time),"hh:mm TT")>
<cfelseif scale is 8>
        <cfset time_add_number = 1>
        <cfset middle = Evaluate("scale/2")>
        <cfset this_display_date =
DateFormat(DateAdd("h",-4,use_this_time),"m/d/yyyy")>
        <cfset this_display_time =
TimeFormat(DateAdd("h",-4,use_this_time),"hh:mm TT")>
<cfelseif scale is 4>
        <cfset time_add_number = 1>
        <cfset middle = Evaluate("scale/2")>
        <cfset this_display_date =
DateFormat(DateAdd("h",-2,use_this_time),"m/d/yyyy")>   
        <cfset this_display_time =
TimeFormat(DateAdd("h",-2,use_this_time),"hh:mm TT")>
<cfelseif scale is 2>
        <cfset time_add_number = 1>
        <cfset middle = Evaluate("scale/2")>
        <cfset this_display_date =
DateFormat(DateAdd("h",-1,use_this_time),"m/d/yyyy")>
        <cfset this_display_time =
TimeFormat(DateAdd("h",-1,use_this_time),"hh:mm TT")>
<cfelseif scale is 1>
        <cfset time_add_number = 1>
        <cfset middle = Evaluate("scale/2")>
        <cfset this_display_date = DateFormat(use_this_time,"m/d/yyyy")>
        <cfset this_display_time = TimeFormat(use_this_time,"hh:mm TT")>
</cfif>
<cfset cell_width = Round(Evaluate("100/scale"))>
<cfset display_current_time_at = "middle">

<cfset minute_scale = Round(Evaluate("100/60"))>


<cfoutput>
cell width = #cell_width#%<br>
use_this_time = #use_this_time#<br>
this_display_time = #this_display_time#<br>
minute_scale = #minute_scale#%<br>


<cfset flown_started = "03/19/03 21:30">
<cfset flown_ended = "03/21/03 00:30">
Joe bob flew from #flown_started# - #flown_ended#<br>
<cfset minutes_flown = DateDiff("n",flown_started,flown_ended)>
minutes flown = #minutes_flown#<br>
</cfoutput>
flown started ||||| display this ||||| flown ended<br>
<br>
<br>
<cfoutput>
        <table width=100% border=0 cellpadding=0 cellspacing=0>
                <tr>
                        <td>
                                <table width=100% border=0 cellpadding=0
cellspacing=0>
                                        <tr height=10px>
                                                <td>&nbsp;</td>
                                                <cfloop
index="time_display_counter" from=1 to="#scale#">
                                                        <th >
                                                                <cfif
time_display_counter is middle + 1 OR scale is 1>
                                                                        <li
style=disc></li>
                                                                </cfif>
                                                        </th>
                                                </cfloop>
                                        </tr>
                                        <tr>
                                                <th width=5%>Crew</td>
                                                <cfloop
index="time_display_counter" from=1 to="#scale#">
                                                        <td
width="#cell_width#%" >
                                                                <cfif
datepart("h",this_display_time) lt 12>
        
<cfif hours is "00">
        
<cfset minutes = DatePart("n",this_display_time)>
        
<cfif len(minutes) is 1>
        
<cfset minutes = "0" & minutes>
        
</cfif>
        
<cfset this_display_time = hours & ":" & minutes>
        
<cfset this_display_date = DateAdd("d",1,this_display_date)>
        
<cfset display_this = DateFormat(this_display_date,'m/d/yyyy') & #chr(13)# &
this_display_time>
        
<cfset hours = 9999>
        
<cfelse>
        
<cfset display_this = DateFormat(this_display_date,'m/d/yyyy')  & #chr(13)#
& TimeFormat(this_display_time, "hh:mm")>
        
</cfif>
        
<cfset post_twelve="false">
        
<cfelse>
        
<cfset hours = DatePart("h",this_display_time)>
        
<cfset minutes = DatePart("n",this_display_time)>
        
<cfif len(minutes) is 1>
        
<cfset minutes = "0" & minutes>
        
</cfif>
        
<cfif hours is 23>
        
<cfset this_display_time = hours & ":" & minutes>
        
<cfset display_this = DateFormat(this_display_date,'m/d/yyyy') & #chr(13)#
& this_display_time>
        
<cfset hours = "00">
        
<cfelse>
        
<cfset this_display_time = hours & ":" & minutes>
        
<cfset display_this = DateFormat(this_display_date,'m/d/yyyy') & #chr(13)#
& this_display_time>
        
</cfif>
        
<cfset post_twelve="true">
        
</cfif>
                                                                <div
title="#display_this#" onMouseOver="this.style.backgroundColor='BCDAF8';"
onMouseOut="this.style.backgroundColor='white'">
                                                                <font
size=-2>
        
<cfif post_twelve>
        
#this_display_time#
        
<cfelse>
        
#TimeFormat(this_display_time, "hh:mm")#
        
</cfif>
                                                                </font>
                                                                </div>
                                                                <cfset
this_display_time = DateAdd("h",time_add_number,this_display_time)>
                                                        </td>
                                                </cfloop>
                                        </tr>
                                        <tr height=30px
onMouseOver="this.style.backgroundColor='silver';"
onMouseOut="this.style.backgroundColor='white'">
                                                <td>Joe Bob</td>
                                                <cfloop
index="time_display_counter" from=1 to="#scale#">
                                                        <td
width="#cell_width#%" >
                                                                <cfif
datepart("h",this_display_time) lt 12>
        
<cfif hours is "00">
        
<cfset minutes = DatePart("n",this_display_time)>
        
<cfif len(minutes) is 1>
        
<cfset minutes = "0" & minutes>
        
</cfif>
        
<cfset this_display_time = hours & ":" & minutes>
        
<cfset this_display_date = DateAdd("d",1,this_display_date)>
        
<cfset display_this = DateFormat(this_display_date,'m/d/yyyy') & #chr(13)# &
this_display_time>
        
<cfset hours = 9999>
        
<cfelse>
        
<cfset display_this = DateFormat(this_display_date,'m/d/yyyy')  & #chr(13)#
& TimeFormat(this_display_time, "hh:mm")>
        
</cfif>
        
<cfset post_twelve="false">
                                                                <cfelse>
        
<cfset hours = DatePart("h",this_display_time)>
        
<cfset minutes = DatePart("n",this_display_time)>
        
<cfif len(minutes) is 1>
        
<cfset minutes = "0" & minutes>
        
</cfif>
        
<cfif hours is 23>
        
<cfset this_display_time = hours & ":" & minutes>
        
<cfset display_this = DateFormat(this_display_date,'m/d/yyyy') & #chr(13)#
& this_display_time>
        
<cfset hours = "00">
        
<cfelse>
        
<cfset this_display_time = hours & ":" & minutes>
        
<cfset display_this = DateFormat(this_display_date,'m/d/yyyy') & #chr(13)#
& this_display_time>
        
</cfif>
        
<cfset post_twelve="true">
                                                                </cfif>
                                                                <div <cfif
datecompare(display_this,flown_started,"n") is 1 AND
datecompare(display_this,flown_ended,"n") is "-1">style="background-color:
red"</cfif>>
        
&nbsp;
                                                                </div>
                                                                </td>
                                                                <cfset
this_display_time = DateAdd("h",time_add_number,this_display_time)>
                                                </cfloop>
                                        </tr>
                                </table>
                        </td>
                </tr>
        </table>
</cfoutput>
<br>
<br>
<table width=15% cellpadding=0 cellspacing=0>
        <tr style="height: 15px;">
                <td width=50%><font size="-2">Flight Time</font></td>
                <td style="background-color: red;">&nbsp;</td>
        </tr>
        <tr style="height: 15px;">
                <td width=50%><font size="-2">Service Time</font></td>
                <td style="background-color: blue;">&nbsp;</td>
        </tr>
        <tr style="height: 15px;">
                <td width=50%><font size="-2">Clock Time</font></td>
                <td style="background-color: yellow;">&nbsp;</td>
        </tr>
</table>

<form action="testing.cfm" name="lookup_times">
<table>
        <tr>
                <th>Scale (hours)</th>
                <td>24 <input type="radio" name="scale" value="24" <cfif
scale is 24>checked</cfif> onClick="document.location='testing.cfm?scale=' +
this.value + '&search_time=' + lookup_times.search_time.value"></td>
                <td>12 <input type="radio" name="scale" value="12" <cfif
scale is 12>checked</cfif> onClick="document.location='testing.cfm?scale=' +
this.value + '&search_time=' + lookup_times.search_time.value"></td>
                <td>8 <input type="radio" name="scale" value="8" <cfif scale
is 8>checked</cfif> onClick="document.location='testing.cfm?scale=' +
this.value + '&search_time=' + lookup_times.search_time.value"></td>    
                <td>4<input type="radio" name="scale" value="4" <cfif scale
is 4>checked</cfif> onClick="document.location='testing.cfm?scale=' +
this.value + '&search_time=' + lookup_times.search_time.value"></td>    
                <td>2<input type="radio" name="scale" value="2" <cfif scale
is 2>checked</cfif> onClick="document.location='testing.cfm?scale=' +
this.value + '&search_time=' + lookup_times.search_time.value"></td>    
                <td>1<input type="radio" name="scale" value="1" <cfif scale
is 1>checked</cfif> onClick="document.location='testing.cfm?scale=' +
this.value + '&search_time=' + lookup_times.search_time.value"></td>
        </tr>
</table>

<cfoutput>
        <table>
                <tr>
                        <th>Search by Time:</th>
                        <td><input type="text" name="search_time"
value="#DateFormat(use_this_time,'mm/dd/yyyy')# #TimeFormat(use_this_time,
'hh:mm TT')#"></td>
                        <td><input type="submit" value="Search"></td>
                        <td><input type="button" value="Restore Now"
onClick="document.location='crew_sel.cfm'"></td>
                </tr>
        </table>
</cfoutput>
</form>



John Stanley
Web Application Developer
www.activeaero.com
734-547-7277

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

                                Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
                                

Reply via email to