diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/babel/babel.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/babel/babel.dtx | 474 |
1 files changed, 468 insertions, 6 deletions
diff --git a/Master/texmf-dist/source/latex/babel/babel.dtx b/Master/texmf-dist/source/latex/babel/babel.dtx index 6bc32b0c7b9..4d1fec7dcda 100644 --- a/Master/texmf-dist/source/latex/babel/babel.dtx +++ b/Master/texmf-dist/source/latex/babel/babel.dtx @@ -32,7 +32,7 @@ % % \iffalse %<*filedriver> -\ProvidesFile{babel.dtx}[2022/05/22 v3.75 The Babel package] +\ProvidesFile{babel.dtx}[2022/06/06 v3.76 The Babel package] \documentclass{ltxdoc} \GetFileInfo{babel.dtx} \usepackage{fontspec} @@ -2850,7 +2850,7 @@ date corresponding to the Gregorian calendar and other lunisolar systems with the following command. \Describe{\localedate}{\oarg{calendar=.., variant=..}% - {\marg{year}\m{month}\m{day}}} + {\marg{year}\marg{month}\marg{day}}} By default the calendar is the Gregorian, but an |ini| file may define strings for other calendars (currently |ar|, |ar-|*, |he|, |fa|, |hi|). @@ -2863,6 +2863,20 @@ Even with a certain calendar there may be variants. In Kurmanji the default variant prints something like \textit{30. Çileya Pêşîn 2019}, but with |variant=izafa| it prints \textit{31’ê Çileya Pêşînê 2019}. +\Describe{\babelcalendar}{\oarg{date}% + \marg{calendar}\marg{year-macro}\m{month-macro}\m{day-macro}} + +\New{3.76} Although calendars aren’t the primary concern of \babel, the +package should be able to, at least, generate correctly the current +date in the way users would expect in their own culture. Currently, +|\localedate| can print dates in a few calendars (provided the +\textsf{ini} locale file has been imported), but year, month and day +had to be entered by hand, which is very inconvenient. With this macro, +the current date is converted and stored in the three last arguments, +which must be macros. The optional argument converts the given date, in +the form ‘\m{year}-\m{month}-\m{day}’. Please, refer to the page on the +news for 3.76 in the \babel{} site for further details. + \subsection{Accessing language info} \Describe{\languagename}{} @@ -5143,8 +5157,8 @@ help from Bernd Raichle, for which I am grateful. % \section{Tools} % % \begin{macrocode} -%<<version=3.75>> -%<<date=2022/05/22>> +%<<version=3.76>> +%<<date=2022/06/06>> % \end{macrocode} % % \textbf{Do not use the following macros in \texttt{ldf} files. They @@ -9682,6 +9696,7 @@ help from Bernd Raichle, for which I am grateful. \let\bbl@KVP@Alph\@nil \let\bbl@KVP@labels\@nil \bbl@csarg\let{KVP@labels*}\@nil + \let\bbl@calendars\@empty \global\let\bbl@inidata\@empty \global\let\bbl@extend@ini\@gobble \gdef\bbl@key@list{;}% @@ -10018,6 +10033,14 @@ help from Bernd Raichle, for which I am grateful. \let\atcatcode\relax \global\bbl@csarg\let{rqtex@\languagename}\relax \fi}% + \bbl@foreach\bbl@calendars{% + \bbl@ifunset{bbl@ca@##1}{% + \chardef\atcatcode=\catcode`\@ + \catcode`\@=11\relax + \InputIfFileExists{babel-ca-##1.tex}{}{}% + \catcode`\@=\atcatcode + \let\atcatcode\relax}% + {}}% \fi % == frenchspacing == \ifcase\bbl@howloaded\in@true\else\in@false\fi @@ -10281,7 +10304,9 @@ help from Bernd Raichle, for which I am grateful. \def\bbl@section{##1}% \in@{=date.}{=##1}% Find a better place \ifin@ - \bbl@ini@calendar{##1}% + \bbl@ifunset{bbl@inikv@##1}% + {\bbl@ini@calendar{##1}}% + {}% \fi \in@{=identification/extension.}{=##1/##2}% \ifin@ @@ -10325,7 +10350,7 @@ help from Bernd Raichle, for which I am grateful. \bbl@endcommands} % \end{macrocode} % -% A somewhat hackish tool to handle calendar sections. To be improved. +% A somewhat hackish tool to handle calendar sections. TODO. To be improved. % % \begin{macrocode} \def\bbl@ini@calendar#1{% @@ -10342,6 +10367,9 @@ help from Bernd Raichle, for which I am grateful. \fi \ifx\bbl@tempa\relax\else \bbl@replace\bbl@tempa{=}{}% + \ifx\bbl@tempa\@empty\else + \xdef\bbl@calendars{,\bbl@tempa}% + \fi \bbl@exp{% \def\<bbl@inikv@#1>####1####2{% \\\bbl@inidate####1...\relax{####2}{\bbl@tempa}}}% @@ -10753,6 +10781,8 @@ help from Bernd Raichle, for which I am grateful. % % \begin{macrocode} \let\bbl@calendar\@empty +\newcommand\babelcalendar[2][\the\year-\the\month-\the\day]{% + \@nameuse{bbl@ca@#2}#1\@@} \newcommand\BabelDateSpace{\nobreakspace} \newcommand\BabelDateDot{.\@} % TODO. \let instead of repeating \newcommand\BabelDated[1]{{\number#1}} @@ -22685,6 +22715,438 @@ Babel.cjk_breaks = { %</nil> % \end{macrocode} % +% \section{Calendars} +% +% The code for specific calendars are placed in the +% specific files, loaded when requested by an |ini| file in the +% |identification| section with |require.calendars|. +% +% \subsection{Islamic} +% +% Start with function to compute the Julian day. It’s based on the +% little library |calendar.js|, by John Walker, in the public domain. +% The code for the Civil calendar is based on it, too. +% +% \begin{macrocode} +%<*ca-islamic> +\ExplSyntaxOn +\def\bbl@fpmod#1#2{(#1-#2*floor(#1/#2))} +\def\bbl@cs@gregleap#1{% + (\bbl@fpmod{#1}{4} == 0) && + (!((\bbl@fpmod{#1}{100} == 0) && (\bbl@fpmod{#1}{400} != 0)))} +\def\bbl@ca@jd#1#2#3{% year, month, day + \fp_eval:n{ 1721424.5 + (365 * (#1 - 1)) + + floor((#1 - 1) / 4) + (-floor((#1 - 1) / 100)) + + floor((#1 - 1) / 400) + floor((((367 * #2) - 362) / 12) + + ((#2 <= 2) ? 0 : (\bbl@cs@gregleap{#1} ? -1 : -2)) + #3) }} +% == islamic (default) +% Not yet implemented +\def\bbl@ca@islamic#1-#2-#3\@@#4#5#6{} +% \end{macrocode} +% +% The Civil calendar. +% +% \begin{macrocode} +\def\bbl@cs@isltojd#1#2#3{ % year, month, day + ((#3 + ceil(29.5 * (#2 - 1)) + + (#1 - 1) * 354 + floor((3 + (11 * #1)) / 30) + + 1948439.5) - 1) } +\@namedef{bbl@ca@islamic-civil++}{\bbl@ca@islamicvl@x{+2}} +\@namedef{bbl@ca@islamic-civil+}{\bbl@ca@islamicvl@x{+1}} +\@namedef{bbl@ca@islamic-civil}{\bbl@ca@islamicvl@x{}} +\@namedef{bbl@ca@islamic-civil-}{\bbl@ca@islamicvl@x{-1}} +\@namedef{bbl@ca@islamic-civil--}{\bbl@ca@islamicvl@x{-2}} +\def\bbl@ca@islamicvl@x#1#2-#3-#4\@@#5#6#7{% + \edef\bbl@tempa{% + \fp_eval:n{ floor(\bbl@ca@jd{#2}{#3}{#4})+0.5 #1}}% + \edef#5{% + \fp_eval:n{ floor(((30*(\bbl@tempa-1948439.5)) + 10646)/10631) }}% + \edef#6{\fp_eval:n{ + min(12,ceil((\bbl@tempa-(29+\bbl@cs@isltojd{#5}{1}{1}))/29.5)+1) }}% + \edef#7{\fp_eval:n{ \bbl@tempa - \bbl@cs@isltojd{#5}{#6}{1} + 1} }} +% \end{macrocode} +% +% The Umm al-Qura calendar, used mainly in Saudi Arabia, is based +% on \textsf{moment-hijri}, by Abdullah Alsigar (license MIT). +% +% Since the main aim is to provide a suitable |\today|, and maybe some +% close dates, data just covers Hijri $\sim$1435/$\sim$1460 (Gregorian +% $\sim$2014/$\sim$2038). +% +% \begin{macrocode} +\def\bbl@ca@umalqura@data{56660, 56690,56719,56749,56778,56808,% + 56837,56867,56897,56926,56956,56985,57015,57044,57074,57103,% + 57133,57162,57192,57221,57251,57280,57310,57340,57369,57399,% + 57429,57458,57487,57517,57546,57576,57605,57634,57664,57694,% + 57723,57753,57783,57813,57842,57871,57901,57930,57959,57989,% + 58018,58048,58077,58107,58137,58167,58196,58226,58255,58285,% + 58314,58343,58373,58402,58432,58461,58491,58521,58551,58580,% + 58610,58639,58669,58698,58727,58757,58786,58816,58845,58875,% + 58905,58934,58964,58994,59023,59053,59082,59111,59141,59170,% + 59200,59229,59259,59288,59318,59348,59377,59407,59436,59466,% + 59495,59525,59554,59584,59613,59643,59672,59702,59731,59761,% + 59791,59820,59850,59879,59909,59939,59968,59997,60027,60056,% + 60086,60115,60145,60174,60204,60234,60264,60293,60323,60352,% + 60381,60411,60440,60469,60499,60528,60558,60588,60618,60648,% + 60677,60707,60736,60765,60795,60824,60853,60883,60912,60942,% + 60972,61002,61031,61061,61090,61120,61149,61179,61208,61237,% + 61267,61296,61326,61356,61385,61415,61445,61474,61504,61533,% + 61563,61592,61621,61651,61680,61710,61739,61769,61799,61828,% + 61858,61888,61917,61947,61976,62006,62035,62064,62094,62123,% + 62153,62182,62212,62242,62271,62301,62331,62360,62390,62419,% + 62448,62478,62507,62537,62566,62596,62625,62655,62685,62715,% + 62744,62774,62803,62832,62862,62891,62921,62950,62980,63009,% + 63039,63069,63099,63128,63157,63187,63216,63246,63275,63305,% + 63334,63363,63393,63423,63453,63482,63512,63541,63571,63600,% + 63630,63659,63689,63718,63747,63777,63807,63836,63866,63895,% + 63925,63955,63984,64014,64043,64073,64102,64131,64161,64190,% + 64220,64249,64279,64309,64339,64368,64398,64427,64457,64486,% + 64515,64545,64574,64603,64633,64663,64692,64722,64752,64782,% + 64811,64841,64870,64899,64929,64958,64987,65017,65047,65076,% + 65106,65136,65166,65195,65225,65254,65283,65313,65342,65371,% + 65401,65431,65460,65490,65520} +\@namedef{bbl@ca@islamic-umalqura+}{\bbl@ca@islamcuqr@x{+1}} +\@namedef{bbl@ca@islamic-umalqura}{\bbl@ca@islamcuqr@x{}} +\@namedef{bbl@ca@islamic-umalqura-}{\bbl@ca@islamcuqr@x{-1}} +\def\bbl@ca@islamcuqr@x#1#2-#3-#4\@@#5#6#7{% + \ifnum#2>2014 \ifnum#2<2038 + \bbl@afterfi\expandafter\@gobble + \fi\fi + {\bbl@error{Year~out~of~range}{The~allowed~range~is~2014-2038}}% + \edef\bbl@tempd{\fp_eval:n{ % (Julian) day + \bbl@ca@jd{#2}{#3}{#4} + 0.5 - 2400000 #1}}% + \count@\@ne + \bbl@foreach\bbl@ca@umalqura@data{% + \advance\count@\@ne + \ifnum##1>\bbl@tempd\else + \edef\bbl@tempe{\the\count@}% + \edef\bbl@tempb{##1}% + \fi}% + \edef\bbl@templ{\fp_eval:n{ \bbl@tempe + 16260 + 949 }}% month~lunar + \edef\bbl@tempa{\fp_eval:n{ floor((\bbl@templ - 1 ) / 12) }}% annus + \edef#5{\fp_eval:n{ \bbl@tempa + 1 }}% + \edef#6{\fp_eval:n{ \bbl@templ - (12 * \bbl@tempa) }}% + \edef#7{\fp_eval:n{ \bbl@tempd - \bbl@tempb + 1 }}} +\ExplSyntaxOff +%</ca-islamic> +% \end{macrocode} +% +% \section{Hebrew} +% +% This is basically the set of macros written by Michail Rozman in +% 1991, with corrections and adaptions by Rama Porrat, Misha, Dan Haran +% and Boris Lavva. This must be eventually replaced by computations +% with \textsf{l3fp}. +% +% \begin{macrocode} +%<*ca-hebrew> +\newcount\bbl@cntcommon +\def\bbl@remainder#1#2#3{% + #3 = #1 % c = a + \divide #3 by #2 % c = a/b + \multiply #3 by -#2 % c = -b(a/b) + \advance #3 by #1 }% % c = a - b(a/b) +\newif\ifbbl@divisible +\def\bbl@checkifdivisible#1#2{% + {\countdef\tmp = 0 % \tmp == \count0 - temporary variable + \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{% no month number 0 + {#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 % if month after February + \advance #3 by 1 % add leap day + \fi + \fi + \global\bbl@cntcommon = #3}% + #3 = \bbl@cntcommon} +\def\bbl@gregdaysprioryears#1#2{% + {\countdef\tmpc = 4 % \tmpc==\count4 + \countdef\tmpb = 2 % \tmpb==\count2 + \tmpb = #1 % + \advance \tmpb by -1 % + \tmpc = \tmpb % \tmpc = \tmpb = year-1 + \multiply \tmpc by 365 % Days in prior years = + #2 = \tmpc % = 365*(year-1) ... + \tmpc = \tmpb % + \divide \tmpc by 4 % \tmpc = (year-1)/4 + \advance #2 by \tmpc % ... plus Julian leap days ... + \tmpc = \tmpb % + \divide \tmpc by 100 % \tmpc = (year-1)/100 + \advance #2 by -\tmpc % ... minus century years ... + \tmpc = \tmpb % + \divide \tmpc by 400 % \tmpc = (year-1)/400 + \advance #2 by \tmpc % ... plus 4-century years. + \global\bbl@cntcommon = #2}% + #2 = \bbl@cntcommon} +\def\bbl@absfromgreg#1#2#3#4{% + {\countdef\tmpd = 0 % \tmpd==\count0 + #4 = #1 % days so far this month + \bbl@gregdayspriormonths{#2}{#3}{\tmpd}% + \advance #4 by \tmpd % add days in prior months + \bbl@gregdaysprioryears{#3}{\tmpd}% + \advance #4 by \tmpd % add days in prior years + \global\bbl@cntcommon = #4}% + #4 = \bbl@cntcommon} +\newif\ifbbl@hebrleap +\def\bbl@checkleaphebryear#1{% + {\countdef\tmpa = 0 % \tmpa==\count0 + \countdef\tmpb = 1 % \tmpb==\count1 + \tmpa = #1 + \multiply \tmpa by 7 + \advance \tmpa by 1 + \bbl@remainder{\tmpa}{19}{\tmpb}% + \ifnum \tmpb < 7 % \tmpb = (7*year+1)%19 + \global\bbl@hebrleaptrue + \else + \global\bbl@hebrleapfalse + \fi}} +\def\bbl@hebrelapsedmonths#1#2{% + {\countdef\tmpa = 0 % \tmpa==\count0 + \countdef\tmpb = 1 % \tmpb==\count1 + \countdef\tmpc = 2 % \tmpc==\count2 + \tmpa = #1 % + \advance \tmpa by -1 % + #2 = \tmpa % #2 = \tmpa = year-1 + \divide #2 by 19 % Number of complete Meton cycles + \multiply #2 by 235 % #2 = 235*((year-1)/19) + \bbl@remainder{\tmpa}{19}{\tmpb}% \tmpa = years%19-years this cycle + \tmpc = \tmpb % + \multiply \tmpb by 12 % + \advance #2 by \tmpb % add regular months this cycle + \multiply \tmpc by 7 % + \advance \tmpc by 1 % + \divide \tmpc by 19 % \tmpc = (1+7*((year-1)%19))/19 - + \advance #2 by \tmpc % add leap months + \global\bbl@cntcommon = #2}% + #2 = \bbl@cntcommon} +\def\bbl@hebrelapseddays#1#2{% + {\countdef\tmpa = 0 % \tmpa==\count0 + \countdef\tmpb = 1 % \tmpb==\count1 + \countdef\tmpc = 2 % \tmpc==\count2 + \bbl@hebrelapsedmonths{#1}{#2}% + \tmpa = #2 % + \multiply \tmpa by 13753 % + \advance \tmpa by 5604 % \tmpa=MonthsElapsed*13758 + 5604 + \bbl@remainder{\tmpa}{25920}{\tmpc}% \tmpc == ConjunctionParts + \divide \tmpa by 25920 + \multiply #2 by 29 + \advance #2 by 1 + \advance #2 by \tmpa % #2 = 1 + MonthsElapsed*29 + + \bbl@remainder{#2}{7}{\tmpa}% % \tmpa == DayOfWeek + \ifnum \tmpc < 19440 + \ifnum \tmpc < 9924 + \else % New moon at 9 h. 204 p. or later + \ifnum \tmpa = 2 % on Tuesday ... + \bbl@checkleaphebryear{#1}% of a common year + \ifbbl@hebrleap + \else + \advance #2 by 1 + \fi + \fi + \fi + \ifnum \tmpc < 16789 + \else % New moon at 15 h. 589 p. or later + \ifnum \tmpa = 1 % on Monday ... + \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 % new moon at or after midday + \fi + \bbl@remainder{#2}{7}{\tmpa}% % \tmpa == DayOfWeek + \ifnum \tmpa = 0 % if Sunday ... + \advance #2 by 1 + \else % + \ifnum \tmpa = 3 % Wednesday ... + \advance #2 by 1 + \else + \ifnum \tmpa = 5 % or Friday + \advance #2 by 1 + \fi + \fi + \fi + \global\bbl@cntcommon = #2}% + #2 = \bbl@cntcommon} +\def\bbl@daysinhebryear#1#2{% + {\countdef\tmpe = 12 % \tmpe==\count12 + \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 % \tmpf==\count14 + #3 = \ifcase #1 % Days in prior month of regular year + 0 \or % no month number 0 + 0 \or % Tishri + 30 \or % Heshvan + 59 \or % Kislev + 89 \or % Tebeth + 118 \or % Shebat + 148 \or % Adar I + 148 \or % Adar II + 177 \or % Nisan + 207 \or % Iyar + 236 \or % Sivan + 266 \or % Tammuz + 295 \or % Av + 325 \or % Elul + 400 % Dummy + \fi + \bbl@checkleaphebryear{#2}% + \ifbbl@hebrleap % in leap year + \ifnum #1 > 6 % if month after Adar I + \advance #3 by 30 % add 30 days + \fi + \fi + \bbl@daysinhebryear{#2}{\tmpf}% + \ifnum #1 > 3 + \ifnum \tmpf = 353 % + \advance #3 by -1 % + \fi % Short Kislev + \ifnum \tmpf = 383 % + \advance #3 by -1 % + \fi % + \fi + \ifnum #1 > 2 + \ifnum \tmpf = 355 % + \advance #3 by 1 % + \fi % Long Heshvan + \ifnum \tmpf = 385 % + \advance #3 by 1 % + \fi % + \fi + \global\bbl@cntcommon = #3}% + #3 = \bbl@cntcommon} +\def\bbl@absfromhebr#1#2#3#4{% + {#4 = #1 + \bbl@hebrdayspriormonths{#2}{#3}{#1}% + \advance #4 by #1 % Add days in prior months this year + \bbl@hebrelapseddays{#3}{#1}% + \advance #4 by #1 % Add days in prior years + \advance #4 by -1373429 % Subtract days before Gregorian + \global\bbl@cntcommon = #4}% % 01.01.0001 + #4 = \bbl@cntcommon} +\def\bbl@hebrfromgreg#1#2#3#4#5#6{% + {\countdef\tmpx= 17 % \tmpx==\count17 + \countdef\tmpy= 18 % \tmpy==\count18 + \countdef\tmpz= 19 % \tmpz==\count19 + #6 = #3 % + \global\advance #6 by 3761 % approximation from above + \bbl@absfromgreg{#1}{#2}{#3}{#4}% + \tmpz = 1 \tmpy = 1 + \bbl@absfromhebr{\tmpz}{\tmpy}{#6}{\tmpx}% + \ifnum \tmpx > #4 % + \global\advance #6 by -1 % Hyear = Gyear + 3760 + \bbl@absfromhebr{\tmpz}{\tmpy}{#6}{\tmpx}% + \fi % + \advance #4 by -\tmpx % Days in this year + \advance #4 by 1 % + #5 = #4 % + \divide #5 by 30 % Approximation for month from below + \loop % Search for month + \bbl@hebrdayspriormonths{#5}{#6}{\tmpx}% + \ifnum \tmpx < #4 + \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 \bbl@gregmonth=#2 \bbl@gregyear=#1 + \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}} +%</ca-hebrew> +% \end{macrocode} +% +% \section{Persian} +% +% There is an algorithm written in TeX by Jabri, Abolhassani, Pournader +% and Esfahbod, created for the first versions of the FarsiTeX system +% (no longer available), but the original license is GPL, so its use +% with LPPL is problematic. The code here follows loosely that by John +% Walker, which is free and accurate, but sadly very complex, so +% the relevant data for the years 2013-2050 have been pre-calculated +% and stored. Actually, all we need is the first day (either March 20 or +% March 21). +% +% \begin{macrocode} +%<*ca-persian> +\ExplSyntaxOn +\def\bbl@fpmod#1#2{(#1-#2*floor(#1/#2))} +\def\bbl@cs@gregleap#1{% + (\bbl@fpmod{#1}{4} == 0) && + (!((\bbl@fpmod{#1}{100} == 0) && (\bbl@fpmod{#1}{400} != 0)))} +\def\bbl@ca@jd#1#2#3{% year, month, day + \fp_eval:n{ 1721424.5 + (365 * (#1 - 1)) + + floor((#1 - 1) / 4) + (-floor((#1 - 1) / 100)) + + floor((#1 - 1) / 400) + floor((((367 * #2) - 362) / 12) + + ((#2 <= 2) ? 0 : (\bbl@cs@gregleap{#1} ? -1 : -2)) + #3) }} +\def\bbl@ca@firstjal@xx{2012,2016,2020,2024,2028,2029,% March 20 + 2032,2033,2036,2037,2040,2041,2044,2045,2048,2049} +\def\bbl@ca@persian#1-#2-#3\@@#4#5#6{% + \edef\bbl@tempa{#1}% 20XX-03-\bbl@tempe = 1 farvardin: + \ifnum\bbl@tempa>2012 \ifnum\bbl@tempa<2051 + \bbl@afterfi\expandafter\@gobble + \fi\fi + {\bbl@error{Year~out~of~range}{The~allowed~range~is~2013-2050}}% + \bbl@xin@{\bbl@tempa}{\bbl@ca@firstjal@xx}% + \ifin@\def\bbl@tempe{20}\else\def\bbl@tempe{21}\fi + \edef\bbl@tempc{\fp_eval:n{\bbl@ca@jd{\bbl@tempa}{#2}{#3}+.5}}% current + \edef\bbl@tempb{\fp_eval:n{\bbl@ca@jd{\bbl@tempa}{03}{\bbl@tempe}+.5}}% begin + \ifnum\bbl@tempc<\bbl@tempb + \edef\bbl@tempa{\fp_eval:n{\bbl@tempa-1}}% go back 1 year and redo + \bbl@xin@{\bbl@tempa}{\bbl@ca@firstjal@xx}% + \ifin@\def\bbl@tempe{20}\else\def\bbl@tempe{21}\fi + \edef\bbl@tempb{\fp_eval:n{\bbl@ca@jd{\bbl@tempa}{03}{\bbl@tempe}+.5}}% + \fi + \edef#4{\fp_eval:n{\bbl@tempa-621}}% set Jalali year + \edef#6{\fp_eval:n{\bbl@tempc-\bbl@tempb+1}}% days from 1 farvardin + \edef#5{\fp_eval:n{% set Jalali month + (#6 <= 186) ? ceil(#6 / 31) : ceil((#6 - 6) / 30)}} + \edef#6{\fp_eval:n{% set Jalali day + (#6 - ((#5 <= 7) ? ((#5 - 1) * 31) : (((#5 - 1) * 30) + 6)))}}} +\ExplSyntaxOff +%</ca-persian> +% \end{macrocode} +% % \section{Support for Plain \TeX\ (\texttt{plain.def})} % % \subsection{Not renaming \file{hyphen.tex}} |