7193Re: [FlashLite] comparing dates Flash Lite 1.1
- Nov 3, 2007Hi 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!
Hayden Porter wrote:
> I need to find an efficient way to compare dates for a Flash Lite 1.1
> 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?
- << Previous post in topic Next post in topic >>