4 Replies Latest reply on Jun 6, 2009 8:18 PM by crumsberry

    What is the exact format that this code generates?

    crumsberry Level 1

      What si the exact format this code generates? I cant tell. I need to know so that I can put my own set of dates into an array and have it accept that from a database.

       

      <mx:Script>

      <![CDATA[

      import mx.formatters.DateFormatter;

      import mx.core.mx_internal;

       

      [Bindable]

      private var input:Array = [];

       

      private function generateDates():void

      {

      var today:Date = new Date();

      var monthSeconds:Number = 30*24*60*60*1000;

       

      //let us generate random special dates for previous 2 months from today

      for (var i:int = 0; i < 10; ++i)

      {

      input.push(new Date(today.time - Math.random()*monthSeconds*2))

      }

       

      //let us generate random special dates for next 2 months from today

      for (var i:int = 0; i < 10; ++i)

      {

      input.push(new Date(today.time + Math.random()*monthSeconds*2))

      }

      dch.specialDates = input;

      }

       

      ]]>

      </mx:Script>

        • 1. Re: What is the exact format that this code generates?
          crumsberry Level 1

          Sorry, what I meant to say is: what is the exact format that input:Array is in once it is populated?

          • 2. Re: What is the exact format that this code generates?
            GordonSmith Level 4

            Your code makes input:Array contain 20 Date objects. A Date object does not really have a "format"; it internally just stores the number of milliseconds since 1/1/1970 but has properties for the year, month, day, hour, etc. If you need to construct a Date object for a particular date like June 6, 2009 you can do "new Date(2009, 5, 6)".

             

            Gordon Smith

            Adobe Flex SDK Team

            1 person found this helpful
            • 3. Re: What is the exact format that this code generates?
              crumsberry Level 1

              Wouldn't this do the trick then?????

              It gets its mysql data from: www.chugachexpress.com/php/filldates.php

               

              import mx.formatters.DateFormatter;

              import mx.core.mx_internal;

               

                [Bindable]

                private var tmp_string:String = "";

                    [Bindable]

              public var input:Array = [];

               

                    public function fdresultHandler(event:ResultEvent):void

                      {

                        tmp_string = event.result as String;

                        var input:Array = tmp_string.split(",");

                       for (var i:int = 0; i < input.length; i++)               

                         {

                           input[i] = new Date(DateField.stringToDate(input[i], "EEE MMM D HH:NN:SS GMT-0800 YYYY"));

                         }

               

                          input.pop();

                           datechooserM.specialDates = input;

                      }

              • 4. Re: What is the exact format that this code generates?
                crumsberry Level 1

                Used this code to get specific dates: Thanks

                 

                public function fdresultHandlerG(event:ResultEvent):void

                        {

                          tmp2_string = event.result as String;

                          var datesArrayTemp:Array = tmp2_string.split("&");

                         for each(var value:* in datesArrayTemp)               

                           {

                             datesArray.push(new Date(DateField.stringToDate(value, "YYYY, MM, DD")));

                           }

                             datechooserG.specialDates = datesArray;

                        }