2 Replies Latest reply on Sep 1, 2009 1:32 AM by liorchaga

    LineChart and TimeZone problem

    liorchaga

      Hey,

       

      I have a flex project that reads data from a text file (containing dates and prices) and display a line chart.
      The dates are in the format of yyyy-MM-dd.
      When I run the application from a client with a GMT timezone and to the east (e.g. GMT +2:00), everything is ok.

       

      However, when I run it a timezone west from GMT, e.g. GMT -7:00, nothing is shown.

       

      I attached 2 screenshots and a sample project.

       

      Here is the code that parses the date string:

       

      private function parseDate(dateString:String):Date {
          if ( dateString == null ) {
              return null;
          }
                     
          if ( dateString.indexOf("0000-00-00") != -1 ) {
              return null;
          }
                     
          var results:Array  = dateString.substring(0, 10).split("-");
          var year:String = results[0];
          var month:String = results[1];
          var day:String = results[2];
          var d:Date = new Date(year, month, day);
      
          return d;
      }
      

       

      Any ideas?
      Thanks,
      Lior.

        • 1. Re: LineChart and TimeZone problem
          matthew horn Level 3

          This is just a guess, but is it possible that the way a date is created and stored in Flash Player is dependent on the time zone? For example, in the US, it's generally MM/dd/yyyy, but in Europe, it's dd/MM/yyyy. Like I said, just a guess, but I was able to reproduce your issue -- and could not figure out why it was happening.

           

          matt horn

          flex docs

          • 2. Re: LineChart and TimeZone problem
            liorchaga Level 1

            Thanks! You gave me a good lead (the obvious one, I might add to my disgrace).

            With all the changes that have gone through my project, I ended up with two functions that parse the dates, with different implementation - one in the mxml that read the data (that was the correct one) and one in the mxml that contains the LineChart, and the line chart had a parseFunction set to this (which ofcourse had a bug in it).

            I removed the parseFunction in the LineChart and it works perfect.

             

            Lior.