[ruby-talk:02363] Re: crontab

From: Hugh Sasse Staff Elec Eng <hgs@...>
Date: 2000-04-05 15:10:54 UTC
List: ruby-talk #2363
Thank you.  I can build on that to do similar things for the other
fields, which can be had with split.
	Hugh

On Wed, 5 Apr 2000, David Douthitt wrote:

> I wrote a really SIMPLE version which matches MonTueWedThuFriSatSunNoneAllWeekdayWeekend
> 
> although it doesn't account for conflicting entries (MonTueFriNone -or- AllWeekday, etc.)
> 
> class Time
>    def Time.datein (str)
>       dayx = Time.now.wday
>       wdays = %w(Sun Mon Tue Wed Thu Fri Sat)
>       weekday = (dayx > 0 && dayx < 6)
>       weekend = ! weekday
> 
>       (  ((str =~ /(#{wdays[dayx]}|^All$|^ *$)/) != nil)   ||
>         (((str =~ "^Weekday$") !=nil) && weekday)          ||
>         (((str =~ "^Weekend$") !=nil) && weekend) )
>    end
> end
> 

In This Thread

Prev Next