1 Reply Latest reply on Mar 10, 2012 1:43 PM by jfb00

    Hour array

    jfb00 Level 3

      Hi,

      It is a way to create half hours array with specific format like:

      00:00

      01:00

      01:30

      02:00

      02:30

       

      Thanks!

        • 1. Re: Hour array
          jfb00 Level 3

          This is what i come up with

           

          private function getHoursArray():void{

                          var tempObj:Object = new Object;

                          var acHours:ArrayCollection = new ArrayCollection;

                          var df:spark.formatters.DateTimeFormatter = new spark.formatters.DateTimeFormatter();

                          df.dateTimePattern= "HH:mm";

                          var formattedDate:String = "";

                          var minutes:Number = 0;

                         

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

                              tempObj = new Object();

                              formattedDate = df.format(new Date(0,0,0,0,minutes));

                              tempObj.id = i;

                              tempObj.label = formattedDate;

                              //trace(formattedDate);

                              acHours.addItem(tempObj);

                              minutes = minutes + 30;

                          }

                      }

           

          Anyone has a better way?

          Best,