%%
%% This is file `babel-ca-hebrew.tex',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% babel.dtx  (with options: `ca-hebrew')
%% 
%%
%% Copyright (C) 2012-2024 Javier Bezos and Johannes L. Braams.
%% Copyright (C) 1989-2012 Johannes L. Braams and
%%           any individual authors listed elsewhere in this file.
%% All rights reserved.
%%
%%
%% This file is part of the Babel system.
%% --------------------------------------
%%
%% It may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%%   http://www.latex-project.org/lppl.txt
%% and version 1.3 or later is part of all distributions of LaTeX
%% version 2003/12/01 or later.
%%
%% This work has the LPPL maintenance status "maintained".
%%
%% The Current Maintainer of this work is Javier Bezos.
%%
%% The list of derived (unpacked) files belonging to the distribution
%% and covered by LPPL is defined by the unpacking scripts (with
%% extension |.ins|) which are part of the distribution.
%%
\newcount\bbl@cntcommon
\def\bbl@remainder#1#2#3{%
  #3=#1\relax
  \divide #3 by #2\relax
  \multiply #3 by -#2\relax
  \advance #3 by #1\relax}%
\newif\ifbbl@divisible
\def\bbl@checkifdivisible#1#2{%
  {\countdef\tmp=0
   \bbl@remainder{#1}{#2}{\tmp}%
   \ifnum \tmp=0
       \global\bbl@divisibletrue
   \else
       \global\bbl@divisiblefalse
   \fi}}
\newif\ifbbl@gregleap
\def\bbl@ifgregleap#1{%
  \bbl@checkifdivisible{#1}{4}%
  \ifbbl@divisible
      \bbl@checkifdivisible{#1}{100}%
      \ifbbl@divisible
          \bbl@checkifdivisible{#1}{400}%
          \ifbbl@divisible
              \bbl@gregleaptrue
          \else
              \bbl@gregleapfalse
          \fi
      \else
          \bbl@gregleaptrue
      \fi
  \else
      \bbl@gregleapfalse
  \fi
  \ifbbl@gregleap}
\def\bbl@gregdayspriormonths#1#2#3{%
    {#3=\ifcase #1 0 \or 0 \or 31 \or 59 \or 90 \or 120 \or 151 \or
          181 \or 212 \or 243 \or 273 \or 304 \or 334 \fi
     \bbl@ifgregleap{#2}%
         \ifnum #1 > 2
             \advance #3 by 1
         \fi
     \fi
     \global\bbl@cntcommon=#3}%
    #3=\bbl@cntcommon}
\def\bbl@gregdaysprioryears#1#2{%
  {\countdef\tmpc=4
   \countdef\tmpb=2
   \tmpb=#1\relax
   \advance \tmpb by -1
   \tmpc=\tmpb
   \multiply \tmpc by 365
   #2=\tmpc
   \tmpc=\tmpb
   \divide \tmpc by 4
   \advance #2 by \tmpc
   \tmpc=\tmpb
   \divide \tmpc by 100
   \advance #2 by -\tmpc
   \tmpc=\tmpb
   \divide \tmpc by 400
   \advance #2 by \tmpc
   \global\bbl@cntcommon=#2\relax}%
  #2=\bbl@cntcommon}
\def\bbl@absfromgreg#1#2#3#4{%
  {\countdef\tmpd=0
   #4=#1\relax
   \bbl@gregdayspriormonths{#2}{#3}{\tmpd}%
   \advance #4 by \tmpd
   \bbl@gregdaysprioryears{#3}{\tmpd}%
   \advance #4 by \tmpd
   \global\bbl@cntcommon=#4\relax}%
  #4=\bbl@cntcommon}
\newif\ifbbl@hebrleap
\def\bbl@checkleaphebryear#1{%
  {\countdef\tmpa=0
   \countdef\tmpb=1
   \tmpa=#1\relax
   \multiply \tmpa by 7
   \advance \tmpa by 1
   \bbl@remainder{\tmpa}{19}{\tmpb}%
   \ifnum \tmpb < 7
       \global\bbl@hebrleaptrue
   \else
       \global\bbl@hebrleapfalse
   \fi}}
\def\bbl@hebrelapsedmonths#1#2{%
  {\countdef\tmpa=0
   \countdef\tmpb=1
   \countdef\tmpc=2
   \tmpa=#1\relax
   \advance \tmpa by -1
   #2=\tmpa
   \divide #2 by 19
   \multiply #2 by 235
   \bbl@remainder{\tmpa}{19}{\tmpb}% \tmpa=years%19-years this cycle
   \tmpc=\tmpb
   \multiply \tmpb by 12
   \advance #2 by \tmpb
   \multiply \tmpc by 7
   \advance \tmpc by 1
   \divide \tmpc by 19
   \advance #2 by \tmpc
   \global\bbl@cntcommon=#2}%
  #2=\bbl@cntcommon}
\def\bbl@hebrelapseddays#1#2{%
  {\countdef\tmpa=0
   \countdef\tmpb=1
   \countdef\tmpc=2
   \bbl@hebrelapsedmonths{#1}{#2}%
   \tmpa=#2\relax
   \multiply \tmpa by 13753
   \advance \tmpa by 5604
   \bbl@remainder{\tmpa}{25920}{\tmpc}% \tmpc == ConjunctionParts
   \divide \tmpa by 25920
   \multiply #2 by 29
   \advance #2 by 1
   \advance #2 by \tmpa
   \bbl@remainder{#2}{7}{\tmpa}%
   \ifnum \tmpc < 19440
       \ifnum \tmpc < 9924
       \else
           \ifnum \tmpa=2
               \bbl@checkleaphebryear{#1}% of a common year
               \ifbbl@hebrleap
               \else
                   \advance #2 by 1
               \fi
           \fi
       \fi
       \ifnum \tmpc < 16789
       \else
           \ifnum \tmpa=1
               \advance #1 by -1
               \bbl@checkleaphebryear{#1}% at the end of leap year
               \ifbbl@hebrleap
                   \advance #2 by 1
               \fi
           \fi
       \fi
   \else
       \advance #2 by 1
   \fi
   \bbl@remainder{#2}{7}{\tmpa}%
   \ifnum \tmpa=0
       \advance #2 by 1
   \else
       \ifnum \tmpa=3
           \advance #2 by 1
       \else
           \ifnum \tmpa=5
                \advance #2 by 1
           \fi
       \fi
   \fi
   \global\bbl@cntcommon=#2\relax}%
  #2=\bbl@cntcommon}
\def\bbl@daysinhebryear#1#2{%
  {\countdef\tmpe=12
   \bbl@hebrelapseddays{#1}{\tmpe}%
   \advance #1 by 1
   \bbl@hebrelapseddays{#1}{#2}%
   \advance #2 by -\tmpe
   \global\bbl@cntcommon=#2}%
  #2=\bbl@cntcommon}
\def\bbl@hebrdayspriormonths#1#2#3{%
  {\countdef\tmpf= 14
   #3=\ifcase #1\relax
          0 \or
          0 \or
         30 \or
         59 \or
         89 \or
        118 \or
        148 \or
        148 \or
        177 \or
        207 \or
        236 \or
        266 \or
        295 \or
        325 \or
        400
   \fi
   \bbl@checkleaphebryear{#2}%
   \ifbbl@hebrleap
       \ifnum #1 > 6
           \advance #3 by 30
       \fi
   \fi
   \bbl@daysinhebryear{#2}{\tmpf}%
   \ifnum #1 > 3
       \ifnum \tmpf=353
           \advance #3 by -1
       \fi
       \ifnum \tmpf=383
           \advance #3 by -1
       \fi
   \fi
   \ifnum #1 > 2
       \ifnum \tmpf=355
           \advance #3 by 1
       \fi
       \ifnum \tmpf=385
           \advance #3 by 1
       \fi
   \fi
   \global\bbl@cntcommon=#3\relax}%
  #3=\bbl@cntcommon}
\def\bbl@absfromhebr#1#2#3#4{%
  {#4=#1\relax
   \bbl@hebrdayspriormonths{#2}{#3}{#1}%
   \advance #4 by #1\relax
   \bbl@hebrelapseddays{#3}{#1}%
   \advance #4 by #1\relax
   \advance #4 by -1373429
   \global\bbl@cntcommon=#4\relax}%
  #4=\bbl@cntcommon}
\def\bbl@hebrfromgreg#1#2#3#4#5#6{%
  {\countdef\tmpx= 17
   \countdef\tmpy= 18
   \countdef\tmpz= 19
   #6=#3\relax
   \global\advance #6 by 3761
   \bbl@absfromgreg{#1}{#2}{#3}{#4}%
   \tmpz=1  \tmpy=1
   \bbl@absfromhebr{\tmpz}{\tmpy}{#6}{\tmpx}%
   \ifnum \tmpx > #4\relax
       \global\advance #6 by -1
       \bbl@absfromhebr{\tmpz}{\tmpy}{#6}{\tmpx}%
   \fi
   \advance #4 by -\tmpx
   \advance #4 by 1
   #5=#4\relax
   \divide #5 by 30
   \loop
       \bbl@hebrdayspriormonths{#5}{#6}{\tmpx}%
       \ifnum \tmpx < #4\relax
           \advance #5 by 1
           \tmpy=\tmpx
   \repeat
   \global\advance #5 by -1
   \global\advance #4 by -\tmpy}}
\newcount\bbl@hebrday \newcount\bbl@hebrmonth \newcount\bbl@hebryear
\newcount\bbl@gregday \newcount\bbl@gregmonth \newcount\bbl@gregyear
\def\bbl@ca@hebrew#1-#2-#3\@@#4#5#6{%
  \bbl@gregday=#3\relax \bbl@gregmonth=#2\relax \bbl@gregyear=#1\relax
  \bbl@hebrfromgreg
    {\bbl@gregday}{\bbl@gregmonth}{\bbl@gregyear}%
    {\bbl@hebrday}{\bbl@hebrmonth}{\bbl@hebryear}%
  \edef#4{\the\bbl@hebryear}%
  \edef#5{\the\bbl@hebrmonth}%
  \edef#6{\the\bbl@hebrday}}
\endinput
%%
%% End of file `babel-ca-hebrew.tex'.
