Old code, probably terribly inefficient:

        //YYYY-MM-DD
        static public const SIMPLE_INTL_DATE : RegExp =
/^(\d{4})[-\/](\d{2})[-\/](\d{2})$/;

        //YYYY-MM-DD - midday!
        static public function parseSimpleIntlDate(input : String) : Date {

            var parts : Array = input.match(SIMPLE_INTL_DATE);

            var d : Date = new Date();
            d.milliseconds = 0;
            d.seconds = 0;
            d.minutes = 0;
            d.hours = 12;
            d.date = Convert.stringToInt(parts[3]);
            d.month = Convert.stringToInt(parts[2]) - 1;
            d.fullYear = Convert.stringToInt(parts[1]); //Not really
necessary, since we're unlikely to have a year < 999, but you get that.
            return d;
        }

    public class Convert {

        private static const validButIgnoredCharactersInNumbers : RegExp =
/[,\$]/g;

        public static function stringToInt(input : String) : Number {

            return parseInt(cleanupNumberInput(input));
        }

        public static function stringToFloat(input : String) : Number {

            return parseFloat(cleanupNumberInput(input));
        }

        public static function cleanupNumberInput(input : String) : String {

            if (input == null) return null;

            //Strip any initial 0s - don't wanna parse as octal, do we?
            var output : String = input;
            while (output.charAt(0) == "0" && output.length > 1)
                output = output.substr(1);

            return output.replace(validButIgnoredCharactersInNumbers, "");
        }

    }

On Tue, Sep 16, 2008 at 3:32 PM, Andrew Jones <[EMAIL PROTECTED]> wrote:

> Hello -
> I am having an issue creating a valid Flex Date object from a value
> returned to my app in XML.  The returned value is 2008-09-14 (year-
> month-day), and no matter how I try, I can't create a valid date
> object from this.
>
> Has anyone ever had to do something similar, or have any ideas on what
> I might do?
>
> Andrew
>
>
> ------------------------------------
>
> --
> Flexcoders Mailing List
> FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> Alternative FAQ location:
> https://share.acrobat.com/adc/document.do?docid=942dbdc8-e469-446f-b4cf-1e62079f6847
> Search Archives:
> http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups
> Links
>
>
>
>


-- 
"Therefore, send not to know For whom the bell tolls. It tolls for thee."

http://flex.joshmcdonald.info/

:: Josh 'G-Funk' McDonald
:: 0437 221 380 :: [EMAIL PROTECTED]

Reply via email to