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

7194Re: comparing dates Flash Lite 1.1

Expand Messages
  • Hayden Porter
    Nov 4, 2007
    • 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.
    • Show all 3 messages in this topic