From: Daniel Berger Date: 2007-01-03T02:20:06+09:00 Subject: Re: Detecting holidays Kieran Tully wrote: > On 1/2/07, Daniel Berger wrote: > > > Them: Why did the report fail for Jan. 1st? > > Me: National holiday. There was no data to grab. Ignore the failure. > > Them: Oh, right. > [snip] > > Ideally, I'd like to be able to do something like: > > > > if Date.today.is_national_holiday? > > exit # Don't run report on this day > > end > > Nice, but won't this just change the problem to: > > Them: Why is there no report for Jan. 1st? > > > What currently happens when the report 'fails'? Could you generate an > empty report that says > > 'No data available for today. Was it a holiday?' True, I may end up doing that in practice. > That might solve your actual problem, without introducing a 'holidays' > module. Though if your reports often fail for other reasons, perhaps > you do need to detect holidays to distinguish them rom real error > conditions. Yes, sometimes they fail for other reasons, such as the network or database flaking out briefly. So, in practice I see myself doing something like: begin # main report body rescue ReportException if Date.today.is_national_holiday? # note in log that it was a holiday, in case anyone asks. else raise end end It might be a little trickier than that in practice, but that's the general idea. Regards, Dan