if I have an XML object like this:
<a>
<u date="2009-04-10" value="543"/>
<u date="2009-04-11" value="234"/>
<u date="2009-04-13" value="321"/>
<u date="2009-04-14" value="66"/>
<u date="2009-04-16" value="234"/>
<t date="2009-04-01" value="43"/>
<t date="2009-04-02" value="67"/>
<t date="2009-04-03" value="432"/>
<t date="2009-04-08" value="123"/>
<t date="2009-04-09" value="65"/>
<l date="2009-04-01" value="12"/>
<l date="2009-04-02" value="76"/>
<l date="2009-04-03" value="123"/>
<l date="2009-04-04" value="6543"/>
<l date="2009-04-05" value="123"/>
<l date="2009-04-06" value="65"/>
<l date="2009-04-15" value="234"/>
<l date="2009-04-16" value="65"/>
</a>
There is 3 XMLLists in this XML object. If you notice, the dates have gaps in them. Is there a way to add the missing dates to each XMLList? With a value of 0.
Also I do not want to add any dates before or after the first and last node in each XMLList…i just want to fill in the missing dates between each node.
How can I do that?
Thanks!!!
It isn’t that easy unfortunately. There is not timedelta class (like Python) in Actionscript. This makes finding the distance between dates a bit of a pain. It isn’t too bad if you can guarantee that the dates will always be within the same month (e.g. 1-31 within a given month). Then you can use something like:
This doesn’t do fancy stuff like pad “0” before months or dates that are less than 10. It also will not handle if your ranges cross month barriers. The first is really easy to fix so I leave it to you. The second is not very easy at all (especially if the dates cross year boundaries as well) and again I’ll leave it to you.