lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Diego - Red Baires wrote:
table_campaigns have this definitions

record 1
  this_campaign_applies_from_date = may/6/2008
  this_campaign_applies_up_to_date = jun/20/2009

  this_campaign_applies_on_this_time = 1pm
  this_campaign_applies_up_to_this_time = 2pm

record [n] ...

function tell_me_if_a_campaign_must_be_executed() must
loop into the table, read it records and analize field decribed above.

so, first it compares if today is between the date-ranges of the record,
if so, then it must compare if this clock-time is between the time-range of the record

For completeness, a few more details.

You need"*t") to get elements of the current date/time. It's in table form and you get the parts as table fields. Then create a midnight os.time() for the current date and compare against your valid dates' similar midnight times. If it is within range, then use the current date and plug in the time range, so that you have a range that you can check with the current os.time(). Basically, you compose time points which are all in the same format (epoch seconds) which you can then compare easily. Of course, it's just one way to skin the cat, poor cat.

Kein-Hong Man (esq.)
Kuala Lumpur, Malaysia