[ruby-talk:02362] Re: crontab

From: "David Douthitt" <DDouthitt@...>
Date: 2000-04-05 14:50:59 UTC
List: ruby-talk #2362
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

>>> Hugh Sasse Staff Elec Eng <hgs@dmu.ac.uk> 04/05/00 09:24AM >>>
I want to have a program that may be run between certain times.
It seems silly to invent a format to specify the start and end times
when I can use that from crontab.  So, has anyone already produced
code that will tell if "now" matches a crontab entry, using Ruby?
	Thank you,
	Hugh
	hgs@dmu.ac.uk 



In This Thread

Prev Next