Scott, Deborah wrote:
> I have a txt data file that has several fields. Two of the fields are
> start time and end time (listed in epoch time).
> 
> I need to write a perl program that finds (and prints) events that
> occur between midnight "last night" and "midnight tonight."
> 
> First problem:
> The date for midnight "last night" and "tonight" will change each
> day, so this needs to be some kind of automatic date finder.

The time() function gives you epoch seconds for "right now". You can pass
that to localtime to break it into year/month/day/hour/minute/second
components. You can then use the Time::Local module or POSIX mktime() to
find epoch seconds for midnight. The next midnight is simply that time +
86400 seconds.

> 
> Second problem:
> How do I find (and then list) only those events that occur TODAY.
> These events might start or stop at any time during the month.
> 
> The events that I would list would include ANYTHING that includes
> "today." Some might start today and end today and last only an hour.
> Some might start two days ago and end next week. This txt file will
> also list events that have already started and stopped last month or
> will start in the future, so I have to make sure that these are NOT
> included in "today's" report. 

The basic idea is:

   if event_start_time <= end_of_today,
   and event_end_time >= start_of_today

Then some portion of the event occurred today. (assumption is that 
event_start_time <= event_end_time). With all those values in epoch
seconds, the comparison is simple.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to