imrahil / asx3m

Automatically exported from code.google.com/p/asx3m
0 stars 0 forks source link

Empty date XML does not return null date #2

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. A <date/> does not return a null date.

What is the expected output? What do you see instead?
DateConverter should return null date, instead of a negative date.

What version of the product are you using? On what operating system?
0.91

Please provide any additional information below.

Original issue reported on code.google.com by yukel...@gmail.com on 30 Mar 2009 at 12:57

GoogleCodeExporter commented 9 years ago
I believe DateConverter should be changed to something like the following to 
handle nulls or bad string 
parsing

        override public function toString(obj:Object):String
        {
            var date:Date = obj as Date;

            if (date && !isNaN(date.time))
            {
                return (String(date.fullYear+"-"+addLeadingZero((date.month+1))+"-
"+addLeadingZero(date.date)+" 
"+addLeadingZero(date.hours)+":"+addLeadingZero(date.minutes)+":"+addLeadingZero
(date.seconds)+"."+da
te.milliseconds));
            }
            else 
            {
                return null;
            }
        }
        public override function fromString(value:String):Object{
            var date:Date = null;

            if (value && value.length > 0)
            {
                date.setFullYear(Number(value.substr(0,4)), Number(value.substr(5,2))-
1,Number(value.substr(8,2)))
                date.setHours(Number(value.substr(11,2)), Number(value.substr(14,2)), 
Number(value.substr(17,2)), Number(value.substr(20,3)));

                if (isNaN(date.time))
                {
                    date = null;
                }
            }

            return date;
        }

Original comment by mderi...@gmail.com on 15 Dec 2009 at 3:40