1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
|
/*
This is the Hebcal daf yomi calculator,
adapted by Aaron Peromsik from Bob Newell's public domain daf.el.
more info: https://groups.google.com/forum/#!topic/comp.emacs/Gr-rijg2kgM
*/
#include <stdio.h>
#include <string.h>
#include "hebcal.h"
#include "dafyomi.h"
#include "config.h"
#include "translations.h"
#define _(String) lookup_translation(String)
#define NM_LEN 60
struct mesechta {
char *sname;
int blatt;
};
static struct mesechta shas[] = {
{ "Berachot", 64 },
{ "Shabbat", 157 },
{ "Eruvin", 105 },
{ "Pesachim", 121 },
{ "Shekalim", 22 },
{ "Yoma", 88 },
{ "Sukkah", 56 },
{ "Beitzah", 40 },
{ "Rosh Hashana", 35 },
{ "Taanit", 31 },
{ "Megillah", 32 },
{ "Moed Katan", 29 },
{ "Chagigah", 27 },
{ "Yevamot", 122 },
{ "Ketubot", 112 },
{ "Nedarim", 91 },
{ "Nazir", 66 },
{ "Sotah", 49 },
{ "Gitin", 90 },
{ "Kiddushin", 82 },
{ "Baba Kamma", 119 },
{ "Baba Metzia", 119 },
{ "Baba Batra", 176 },
{ "Sanhedrin", 113 },
{ "Makkot", 24 },
{ "Shevuot", 49 },
{ "Avodah Zarah", 76 },
{ "Horayot", 14 },
{ "Zevachim", 120 },
{ "Menachot", 110 },
{ "Chullin", 142 },
{ "Bechorot", 61 },
{ "Arachin", 34 },
{ "Temurah", 34 },
{ "Keritot", 28 },
{ "Meilah", 22 },
{ "Kinnim", 4 },
{ "Tamid", 9 },
{ "Midot", 5 },
{ "Niddah", 73 }
};
void hebcal_dafyomi( date_t *greg_day )
{
int dafcnt = 40;
int cno, dno, osday, nsday, total, count, j, cday, blatt;
date_t tmp_date;
char buffer[NM_LEN];
tmp_date.mm = 9;
tmp_date.dd = 11;
tmp_date.yy = 1923;
osday = greg2abs(tmp_date);
tmp_date.mm = 6;
tmp_date.dd = 24;
tmp_date.yy = 1975;
nsday = greg2abs(tmp_date);
cday = greg2abs(*greg_day);
/* No cycle, new cycle, old cycle */
if (cday < osday)
return; /* daf yomi hadn't started yet */
if (cday >= nsday)
{
cno = 8 + ( (cday - nsday) / 2711 );
dno = (cday - nsday) % 2711;
}
else
{
cno = 1 + ( (cday - osday) / 2702 );
dno = (cday - osday) % 2702;
}
/* Find the daf taking note that the cycle changed slightly after cycle 7. */
total = blatt = 0;
count = -1;
/* Fix Shekalim for old cycles */
if (cno <= 7)
shas[4].blatt = 13;
else
shas[4].blatt = 22;
/* Find the daf */
j = 0;
while (j < dafcnt)
{
count++;
total = total + shas[j].blatt - 1;
if (dno < total)
{
blatt = (shas[j].blatt + 1) - (total - dno);
/* fiddle with the weird ones near the end */
switch(count)
{
case 36:
blatt = blatt + 21;
break;
case 37:
blatt = blatt + 24;
break;
case 38:
blatt = blatt + 32;
break;
default:
break;
}
/* Bailout */
j = 1 + dafcnt;
}
j ++;
}
sprintf(buffer,
_("Daf Yomi: %s %d"),
_(shas[count].sname),
blatt );
PrintGregDate(*greg_day);
printf("%s\n", buffer);
}
|