Hi,

This is the macro for Jalali Calendar taken from xepersian

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newif\i...@leap \newif\i...@kabiseh
\newcount...@i  \newcount...@y  \newcount...@m  \newcount...@d
\newcount...@latini    \newcount...@persiani
\newcount...@latinii   \newcount...@persianii
\newcount...@latiniii  \newcount...@persianiii
\newcount...@latiniv   \newcount...@persianiv
\newcount...@latinv    \newcount...@persianv
\newcount...@latinvi   \newcount...@persianvi
\newcount...@latinvii  \newcount...@persianvii
\newcount...@latinviii \newcount...@persianviii
\newcount...@latinix   \newcount...@persianix
\newcount...@latinx    \newcount...@persianx
\newcount...@latinxi   \newcount...@persianxi
\newcount...@latinxii  \newcount...@persianxii
                       \newcount...@persianxiii

\newcount...@temp
\newcount...@temptwo
\newcount...@tempthree
\newcount...@ymodhundred
\newcount...@thirtytwo
\newcount...@dn
\newcount...@sn
\newcount...@mminusone

\def\ftoday{%
\...@y=\year \...@m=\month \...@d=\day
%
\...@temp=\ft@y
\divide...@temp by 100\relax
\multiply...@temp by 100\relax
\...@ymodhundred=\ft@y
\advance...@ymodhundred by -...@temp\relax
%
\ifodd...@ymodhundred
   \...@leapfalse
\else
   \...@temp=\ft@yModHundred
   \divide...@temp by 2\relax
   \ifodd...@temp\ft@leapfalse
   \else
      \ifnum...@ymodhundred=0%
         \...@temp=\ft@y
         \divide...@temp by 400\relax
         \multiply...@temp by 400\relax
         \ifnum...@y=\ft@temp...@leaptrue\else\ft@leapfalse\fi
      \else...@leaptrue
      \fi
   \fi
\fi
%
\...@latini=31\relax
\i...@leap
  \...@latinii = 29\relax
\else
  \...@latinii = 28\relax
\fi
\...@latiniii = 31\relax
\...@latiniv  = 30\relax
\...@latinv = 31\relax
\...@latinvi = 30\relax
\...@latinvii = 31\relax
\...@latinviii = 31\relax
\...@latinix = 30\relax
\...@latinx = 31\relax
\...@latinxi = 30\relax
\...@latinxii = 31\relax
%
\...@thirtytwo=32\relax
%
\...@temp=\ft@y
\advance...@temp by -17\relax
\...@temptwo=\ft@temp
\divide...@temptwo by 33\relax
\multiply...@temptwo by 33\relax
\advance...@temp by -...@temptwo
\ifnum...@temp=\ft@thirtytwo...@kabisehfalse
\else
   \...@temptwo=\ft@temp
   \divide...@temptwo by 4\relax
   \multiply...@temptwo by 4\relax
   \advance...@temp by -...@temptwo
   \ifnum...@temp=\z@\...@kabisehtrue\else\ft@kabisehfalse\fi
\fi
%
% --VK
% In fact persiani is equal to the Leap years from a fixed year to the last
% year minus the Kabise years from a fixed year to the last year plus a
const.
%
\...@tempthree=\ft@y                 % Number of Leap years
\advance...@tempthree by -1
\...@temp=\ft@tempthree              % T := (MY-1) div 4
\divide...@temp by 4\relax
\...@temptwo=\ft@tempthree           % T := T - ((MY-1) div 100)
\divide...@temptwo by 100\relax
\advance...@temp by -...@temptwo
\...@temptwo=\ft@tempthree           % T := T + ((MY-1) div 400)
\divide...@temptwo by 400\relax
\advance...@temp by \...@temptwo
\advance...@tempthree by -611       % Number of Kabise years
\...@temptwo=\ft@tempthree           % T := T - ((SY+10) div 33) * 8
\divide...@temptwo by 33\relax
\multiply...@temptwo by 8\relax
\advance...@temp by -...@temptwo
\...@temptwo=\ft@tempthree           %
\divide...@temptwo by 33\relax
\multiply...@temptwo by 33\relax
\advance...@tempthree by -...@temptwo
\ifnum...@tempthree=32\advance\ft@temp by 1\fi % if (SY+10) mod 33=32 then
Inc(T);
\divide...@tempthree by 4\relax     % T := T - ((SY+10) mod 33) div 4
\advance...@temp by -...@tempthree
\advance...@temp by -137            % T := T - 137  Adjust the value
\...@persiani=31
\advance...@persiani by -...@temp                 % now 31 - T is the
persiani
%
\...@persianii = 30\relax
\i...@kabiseh
  \...@persianiii = 30\relax
\else
  \...@persianiii = 29\relax
\fi
\...@persianiv  = 31\relax
\...@persianv   = 31\relax
\...@persianvi  = 31\relax
\...@persianvii = 31\relax
\...@persianviii= 31\relax
\...@persianix  = 31\relax
\...@persianx   = 30\relax
\...@persianxi  = 30\relax
\...@persianxii = 30\relax
\...@persianxiii= 30\relax
%
\...@dn= 0\relax
\...@sn= 0\relax
\...@mminusone=\ft@m
\advance...@mminusone by -1\relax
%
\...@i=0\relax
\ifnum...@i < \...@mminusone
\loop
\advance \...@i by 1\relax
\advance...@dn by \csname f...@latin\romannumeral\the\ft@i\endcsname
\ifnum...@i<\...@mminusone \repeat
\fi
\advance \...@dn by \...@d
%
\...@i=1\relax
\...@sn = \...@persiani
\ifnum \...@sn<\...@dn
\loop
\advance \...@i by 1\relax
\advance...@sn by \csname f...@persian\romannumeral\the\ft@i\endcsname
\ifnum \...@sn<\...@dn \repeat
\fi
\ifnum \...@i < 4
   \...@m = 9 \advance...@m by \...@i
   \advance \...@y by -622\relax
\else
   \...@m = \...@i \advance \...@m by -3\relax
   \advance \...@y by -621\relax
\fi
\advance...@sn by -\csname f...@persian\romannumeral\the\ft@i%
\endcsname
\ifnum...@i = 1
  \...@d = \...@dn \advance \...@d by 30 \advance...@d by -...@persiani
\else
  \...@d = \...@dn \advance \...@d by -...@sn
\fi
\beginl\number...@d\endl\space%
%Changedc from here YJ
\persianmonth{...@m}\space\beginl\number\ft@y\endL%
}
% added \persianmonth YJ
\def\persianmonth#1{\ifcase#1\or فروردین\or
اردیبهشت\or
خرداد\or تیر\or
مرداد\or
شهریور\or مهر\or
آبان\or آذر\or
دی\or بهمن\or
اسفند\fi}
\let\originaltoday=\today
\def\today{\lr{\originaltoday}}
\let\romantoday\today
\def\today{\rl{\ftoday}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

can you include this in MKIV? Is there copyright issues?
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

Reply via email to