Loading ...
Sorry, an error occurred while loading the content.

comparing dates Flash Lite 1.1

Expand Messages
  • Hayden Porter
    I need to find an efficient way to compare dates for a Flash Lite 1.1 project. Unless I am missing something obvious, since there is no date object in FL1.1 AS
    Message 1 of 3 , Nov 3, 2007
    View Source
    • 0 Attachment
      I need to find an efficient way to compare dates for a Flash Lite 1.1
      project.

      Unless I am missing something obvious, since there is no date object
      in FL1.1 AS it seems I will need to convert date and time from
      fscommand2() functions into a numeric value of seconds for comparison
      to another date.

      I searched Google for this but did not find anything and did not find
      anything in the Flash mobile book either.

      Anyone dealt with this problem before?

      Hayden
    • Darren Osadchuk
      Hi Hayden, Dealt with something similar recently, actually. It s a small app that counts the number of days since a defined start date and shows data based on
      Message 2 of 3 , Nov 3, 2007
      View Source
      • 0 Attachment
        Hi Hayden,

        Dealt with something similar recently, actually. It's a small app that
        counts the number of days since a defined start date and shows data
        based on that value. I'd share the code, but it wasn't for my own stuff,
        so I'm not in a position to do that; in any event, some comments:

        I'm not sure that you need to convert it down to seconds, unless you're
        looking at both date and time. If it's just strictly dates, then you
        could just compare days.

        The basic approach I took was to count the number of days that had
        elapsed from the start of the current year. You'll need a bit of extra
        code to account for the possibility of a leap year, and also the
        rollover from one year to the next. So I dumped the day, month, and year
        into vars. A switch statement based on the month set a value for
        totalDays. Then I added to that the day variable, then checked to see if
        the year var is a leap year and that the month is post-February; if it
        is, then add an extra day for the leap year.

        You can do this for two dates and compare them; the larger value for
        totalDays is the later date. Note that if the dates have different
        years, then you'll need to compensate for that. For the app I was
        working on, the possible date range was pretty small (essentially, from
        when the app was downloaded to about a week or so later), so I didn't
        need to do too much to account for year differences.

        What you'd probably want to do is set some arbitrary 'day zero', then
        count the days from that point. You'd have to determine what works best
        for your application and go with that.

        Hope this helps!
        Darren

        Hayden Porter wrote:
        >
        >
        > I need to find an efficient way to compare dates for a Flash Lite 1.1
        > project.
        >
        > Unless I am missing something obvious, since there is no date object
        > in FL1.1 AS it seems I will need to convert date and time from
        > fscommand2() functions into a numeric value of seconds for comparison
        > to another date.
        >
        > I searched Google for this but did not find anything and did not find
        > anything in the Flash mobile book either.
        >
        > Anyone dealt with this problem before?
        >
        > Hayden
      • Hayden Porter
        Hi Darren, thanks for your suggestion about counting days. Counting the days from a given year (accounting for leap year) is a simpler and more Flash Lite 1.1
        Message 3 of 3 , Nov 4, 2007
        View Source
        • 0 Attachment
          Hi Darren,

          thanks for your suggestion about counting days. Counting the days
          from a given year (accounting for leap year) is a simpler and more
          Flash Lite 1.1 idiomatic solution. (I am used to comparing dates
          through PHP timestamps with seconds since epoch)

          I set up some code to do this and may post it on my blog at some
          future point.

          Hayden

          > I'm not sure that you need to convert it down to seconds, unless you're
          > looking at both date and time. If it's just strictly dates, then you
          > could just compare days.
          >
          > The basic approach I took was to count the number of days that had
          > elapsed from the start of the current year. You'll need a bit of extra
          > code to account for the possibility of a leap year, and also the
          > rollover from one year to the next. So I dumped the day, month, and
          year
          > into vars. A switch statement based on the month set a value for
          > totalDays. Then I added to that the day variable, then checked to
          see if
          > the year var is a leap year and that the month is post-February;
          if it
          > is, then add an extra day for the leap year.
          >
          > You can do this for two dates and compare them; the larger value for
          > totalDays is the later date. Note that if the dates have different
          > years, then you'll need to compensate for that. For the app I was
          > working on, the possible date range was pretty small (essentially, from
          > when the app was downloaded to about a week or so later), so I didn't
          > need to do too much to account for year differences.
        Your message has been successfully submitted and would be delivered to recipients shortly.