‘bugs’ Archive

ColdFusion Leap Year Fun

9 March 2008 15:18

So just an update on this. I sent off some emails to folks at Adobe and have had acknowledgment but as yet no reply. I’ll you know if and when I get something back.

Filed: Technology // Tagged: , , // No Comments

Coldfusion possible Leap Year bug

28 February 2008 10:11

My colleague noticed that as of midnight GMT one of our applications at work broke. After some digging it looks like a CF leap year bug.

<cfset attributes.minage = 18>
<cfoutput>
#now()#<br />
#attributes.minage#<br />
#dateadd("yyyy", -(attributes.minage), now())#<br />
#datediff("yyyy", dateadd("yyyy", -(attributes.minage), now()), now())#<br />
#datediff("yyyy", dateadd("yyyy", -(attributes.minage), now()), DateAdd("d", 1, now()))#
</cfoutput>

The code was run on CF 7.0.1, 7.0.2 & 8.0.0 on Windows and Linux, all produce same results.

Not sure for definite it’s a bug, but, it’s always worked until today, in theory it might work again tomorrow as well. Last leap year of course was CF6 so may not have shown up.

Yay for dateDiff()… 😐

Update

A more detailed example. It only effects the 28/2. Other dates fine suggesting more that it’s leap year related.

<cfoutput>
	<cfset variables.datea = createDate(2008,02,3)>
	<cfloop from="2008" to="1990" step="-1" index="variables.y">
		<cfset variables.dateb = createDate(variables.y,02,3)>
		<cfset variables.diff = datediff("yyyy", variables.datea, variables.dateb)>
		#variables.datea# - #variables.dateb# = #variables.diff#<br />
	</cfloop>
</cfoutput>

And it’s output….

{ts '2008-02-28 00:00:00'} - {ts '2008-02-28 00:00:00'} = 0
{ts '2008-02-28 00:00:00'} - {ts '2007-02-28 00:00:00'} = 0
{ts '2008-02-28 00:00:00'} - {ts '2006-02-28 00:00:00'} = -1
{ts '2008-02-28 00:00:00'} - {ts '2005-02-28 00:00:00'} = -2
{ts '2008-02-28 00:00:00'} - {ts '2004-02-28 00:00:00'} = -4
{ts '2008-02-28 00:00:00'} - {ts '2003-02-28 00:00:00'} = -4
{ts '2008-02-28 00:00:00'} - {ts '2002-02-28 00:00:00'} = -5
{ts '2008-02-28 00:00:00'} - {ts '2001-02-28 00:00:00'} = -6
{ts '2008-02-28 00:00:00'} - {ts '2000-02-28 00:00:00'} = -8
{ts '2008-02-28 00:00:00'} - {ts '1999-02-28 00:00:00'} = -8
{ts '2008-02-28 00:00:00'} - {ts '1998-02-28 00:00:00'} = -9
{ts '2008-02-28 00:00:00'} - {ts '1997-02-28 00:00:00'} = -10
{ts '2008-02-28 00:00:00'} - {ts '1996-02-28 00:00:00'} = -12
{ts '2008-02-28 00:00:00'} - {ts '1995-02-28 00:00:00'} = -12
{ts '2008-02-28 00:00:00'} - {ts '1994-02-28 00:00:00'} = -13
{ts '2008-02-28 00:00:00'} - {ts '1993-02-28 00:00:00'} = -14
{ts '2008-02-28 00:00:00'} - {ts '1992-02-28 00:00:00'} = -16
{ts '2008-02-28 00:00:00'} - {ts '1991-02-28 00:00:00'} = -16
{ts '2008-02-28 00:00:00'} - {ts '1990-02-28 00:00:00'} = -17

Filed: Technology // Tagged: , , // 2 Comments

ColdFusion structure Bug

26 October 2006 9:44

Found a new bug today in Coldfusion 7. Basically if you create structure via arguments and try to use it later you’ll notice some funky behaviour and the meta information about the structure is incorrect. Code test case is included.

<cfscript>
function struct() { return arguments; } </cfscript>

<cfset s = struct(arg1=“blahblah”, arg2=“cont”, arg3=“act”)>

<cfoutput>
<h3>#s.getClass()#</h3>
length: #structcount(s)# (#structkeylist(s)#)<br>
<cfset structdelete(s, ‘arg1’)>
length: #structcount(s)# (#structkeylist(s)#)<br>
<cfset structdelete(s, ‘arg2’)>
length: #structcount(s)# (#structkeylist(s)#) </cfoutput>

<cfset s = structnew()>
<cfset s[‘arg1’] = “blahblah”>
<cfset s[‘arg2’] = “cont”>
<cfset s[‘arg3’] = “act”>

<cfoutput>
<h3>#s.getClass()#</h3>
length: #structcount(s)# (#structkeylist(s)#)<br>
<cfset structdelete(s, ‘arg1’)>
length: #structcount(s)# (#structkeylist(s)#)<br>
<cfset structdelete(s, ‘arg2’)>
length: #structcount(s)# (#structkeylist(s)#) </cfoutput>

Filed: Technology // Tagged: , , // No Comments

 
Twitter   •   About   •   Contact
©2017 Ian Winter. All Rights Reserved.   •   Powered by WordPress   •   Hosted at Memset