示例#1
0
        /// <summary>
        /// Gets the DafYomi for the given day
        /// </summary>
        /// <param name="absoluteDate"></param>
        /// <returns></returns>
        private static Daf GetSingleDaf(int absoluteDate)
        {
            int dafcnt = 40;
            int cno, dno, osday, nsday, total, count, j, blatt;

            osday = JewishDateCalculations.GetAbsoluteFromGregorianDate(1923, 9, 11);
            nsday = JewishDateCalculations.GetAbsoluteFromGregorianDate(1975, 6, 24);

            /*  No cycle, new cycle, old cycle */
            if (absoluteDate < osday)
            {
                return(null); /* daf yomi hadn't started yet */
            }

            if (absoluteDate >= nsday)
            {
                cno = 8 + ((absoluteDate - nsday) / 2711);
                dno = (absoluteDate - nsday) % 2711;
            }
            else
            {
                cno = 1 + ((absoluteDate - osday) / 2702);
                dno = (absoluteDate - 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)
            {
                masechtaList[4].Dappim = 13;
            }
            else
            {
                masechtaList[4].Dappim = 22;
            }

            /* Find the daf */
            j = 0;
            while (j < dafcnt)
            {
                count++;
                total = total + masechtaList[j].Dappim - 1;
                if (dno < total)
                {
                    blatt = (masechtaList[j].Dappim + 1) - (total - dno);
                    /* fiddle with the weird ones near the end */
                    switch (count)
                    {
                    case 36:
                        blatt += 21;
                        break;

                    case 37:
                        blatt += 24;
                        break;

                    case 38:
                        blatt += 33;
                        break;

                    default:
                        break;
                    }
                    /* Bailout */
                    j = 1 + dafcnt;
                }
                j++;
            }

            return(new Daf(masechtaList[count], blatt));
        }