From: Hugh Sasse Staff Elec Eng Date: 2000-04-05T16:10:54+01:00 Subject: [ruby-talk:02363] Re: crontab 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 >