Subject: Re: Chron & Shabbat (was: FAQ)
From: [email-masked] (Daniel P. Faigin)
Date: 8 May 93 07:00:45
Newsgroups: soc.culture.jewish

On Fri, 7 May 1993 11:28:15 MST, "D. C. Sessions" <[email-masked]> said:

>   OK, I'll bite: assuming that you aren't posting it MANUALLY (please
>   tell us you're not!) does anyone have a halachic objection to having
>   an automated process run on a monthly basis, Shabbat or no?

Actually, to clarify (and this is true of m.l-j also). Cron runs the program
*daily*, not monthly. Before the program does anything, it checks to see if it
Shabbat (although I'll post personal stuff on Shabbat, I don't post the FAQ
portions since they represent the group, and and me). If is it Shabbat,
measured from 1/2 hr before sunset on Friday to 1/2 hr after sunset on
Saturday, the program exits. It program also checks the appropriate holidays
in the same fashion, and doesn't run. The relevant perl code is below. When I
put this in the program, I was told that it was OK to have something run on a
daily basis automatically -- after all, we don't power off our computers and
they run all sorts of cron scripts on our behalf.

The script below uses the hebcal and rise programs available from nysernet.

sub checkday {
    local(@no_work_days);
    local($sec);
    local($min);
    local($hour);
    local($mday);
    local($mon);
    local($year);
    local($wday);
    local($yday);
    local($isdst);
    local(@tempno_work_days);
    local($thisday);
    local($tmptime);
    local($sethrs);
    local($setmin);
    local($settime);
    local($tsttime);

    @no_work_days = ( "Rosh Hashana I"
		     ,"Rosh Hashana II"
		     ,"Yom Kippur"
		     ,"Pesach I"
		     ,"Pesach II"
		     ,"Pesach VII"
		     ,"Pesach VIII"
		     ,"Shavuot I"
		     ,"Shavuot II"
		     ,"Sukkot I"
		     ,"Sukkot II"
		     ,"Shmini Atzeret"
		     ,"Simchat Torah"
		     ,"Tish'a B'Av"
		     );

    open(RISE, "$rise_pgm |");
    while (<RISE>) {
	if (/Sunset\s+(\d\d):(\d\d).*/) {
	    $sethrs = $1;
	    $setmin = $2;
	}
    }
    close(RISE);

    $settime = $sethrs + ($setmin/60);

    ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =
	localtime(time);
    $mon++;
    $mon = 1 if ($mon == 13);
    $tsttime = $hour + ($min/60);

    if ((($wday == 5) && ($tsttime >= ($settime - 0.50))) ||
	(($wday == 6) && ($tsttime < ($settime + 0.50)))) {
	$no_work_date = 1;
	$no_work_reason = "Shabbat";
    } else {
	$no_work_date = 0;
	$no_work_reason = "";
    }
    if ($tsttime < ($settime + 0.50)) {
	open(HEBCAL, "$hebcal_pgm -t |");
	while (($_ = <HEBCAL>) && (!$no_work_date)) {
	    @tmpno_work_days = @no_work_days;
	    while (($thisday = shift @tmpno_work_days) && !$no_work_date) {
		$no_work_date = $_ =~ /\d\s($thisday)$/;
		$no_work_reason = $thisday;
	    }
	} 
	close(HEBCAL);
    } 
    if (($tsttime >= ($settime - 0.50)) && !$no_work_date) {
	$tmptime = time + (60*60*12);