summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/lualatex/simurgh/simurgh-jalalical.sty
blob: ee0bbb5c42aa38a5d6f3811ea31b6abc4e9aee00 (plain)
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{simurgh-jalalical}[2013/09/18 v0.01a jalali calendar]
%  jalali calendar needs to be done entirely in lua
\newif\ifsimurgh@leap \newif\ifsimurgh@kabiseh
\newcount\simurgh@i  \newcount\simurgh@year  \newcount\simurgh@month  \newcount\simurgh@day
\newcount\simurgh@latini    \newcount\simurgh@jalalii
\newcount\simurgh@latinii   \newcount\simurgh@jalaliii
\newcount\simurgh@latiniii  \newcount\simurgh@jalaliiii
\newcount\simurgh@latiniv   \newcount\simurgh@jalaliiv
\newcount\simurgh@latinv    \newcount\simurgh@jalaliv
\newcount\simurgh@latinvi   \newcount\simurgh@jalalivi
\newcount\simurgh@latinvii  \newcount\simurgh@jalalivii
\newcount\simurgh@latinviii \newcount\simurgh@jalaliviii
\newcount\simurgh@latinix   \newcount\simurgh@jalaliix
\newcount\simurgh@latinx    \newcount\simurgh@jalalix
\newcount\simurgh@latinxi   \newcount\simurgh@jalalixi
\newcount\simurgh@latinxii  \newcount\simurgh@jalalixii
                       \newcount\simurgh@jalalixiii

\newcount\simurgh@temp
\newcount\simurgh@temptwo
\newcount\simurgh@tempthree
\newcount\simurgh@yearModHundred
\newcount\simurgh@thirtytwo
\newcount\simurgh@dayn
\newcount\simurgh@sn
\newcount\simurgh@monthminusone

\simurgh@year=\year \simurgh@month=\month \simurgh@day=\day
\simurgh@temp=\simurgh@year
\divide\simurgh@temp by 100\relax
\multiply\simurgh@temp by 100\relax
\simurgh@yearModHundred=\simurgh@year
\advance\simurgh@yearModHundred by -\simurgh@temp\relax
\ifodd\simurgh@yearModHundred
   \simurgh@leapfalse
\else
   \simurgh@temp=\simurgh@yearModHundred
   \divide\simurgh@temp by 2\relax
   \ifodd\simurgh@temp\simurgh@leapfalse
   \else
      \ifnum\simurgh@yearModHundred=0%
         \simurgh@temp=\simurgh@year
         \divide\simurgh@temp by 400\relax
         \multiply\simurgh@temp by 400\relax
         \ifnum\simurgh@year=\simurgh@temp\simurgh@leaptrue\else\simurgh@leapfalse\fi
      \else\simurgh@leaptrue
      \fi
   \fi
\fi
\simurgh@latini=31\relax
\ifsimurgh@leap
  \simurgh@latinii = 29\relax
\else
  \simurgh@latinii = 28\relax
\fi
\simurgh@latiniii = 31\relax
\simurgh@latiniv  = 30\relax
\simurgh@latinv = 31\relax
\simurgh@latinvi = 30\relax
\simurgh@latinvii = 31\relax
\simurgh@latinviii = 31\relax
\simurgh@latinix = 30\relax
\simurgh@latinx = 31\relax
\simurgh@latinxi = 30\relax
\simurgh@latinxii = 31\relax
\simurgh@thirtytwo=32\relax
\simurgh@temp=\simurgh@year
\advance\simurgh@temp by -17\relax
\simurgh@temptwo=\simurgh@temp
\divide\simurgh@temptwo by 33\relax
\multiply\simurgh@temptwo by 33\relax
\advance\simurgh@temp by -\simurgh@temptwo
\ifnum\simurgh@temp=\simurgh@thirtytwo\simurgh@kabisehfalse
\else
   \simurgh@temptwo=\simurgh@temp
   \divide\simurgh@temptwo by 4\relax
   \multiply\simurgh@temptwo by 4\relax
   \advance\simurgh@temp by -\simurgh@temptwo
   \ifnum\simurgh@temp=\z@\simurgh@kabisehtrue\else\simurgh@kabisehfalse\fi
\fi
\simurgh@tempthree=\simurgh@year                 % Number of Leap years
\advance\simurgh@tempthree by -1
\simurgh@temp=\simurgh@tempthree              % T := (MY-1) div 4
\divide\simurgh@temp by 4\relax
\simurgh@temptwo=\simurgh@tempthree           % T := T - ((MY-1) div 100)
\divide\simurgh@temptwo by 100\relax
\advance\simurgh@temp by -\simurgh@temptwo
\simurgh@temptwo=\simurgh@tempthree           % T := T + ((MY-1) div 400)
\divide\simurgh@temptwo by 400\relax
\advance\simurgh@temp by \simurgh@temptwo
\advance\simurgh@tempthree by -611       % Number of Kabise years
\simurgh@temptwo=\simurgh@tempthree           % T := T - ((SY+10) div 33) * 8
\divide\simurgh@temptwo by 33\relax
\multiply\simurgh@temptwo by 8\relax
\advance\simurgh@temp by -\simurgh@temptwo
\simurgh@temptwo=\simurgh@tempthree           %
\divide\simurgh@temptwo by 33\relax
\multiply\simurgh@temptwo by 33\relax
\advance\simurgh@tempthree by -\simurgh@temptwo
\ifnum\simurgh@tempthree=32\advance\simurgh@temp by 1\fi % if (SY+10) mod 33=32 then Inc(T);
\divide\simurgh@tempthree by 4\relax     % T := T - ((SY+10) mod 33) div 4
\advance\simurgh@temp by -\simurgh@tempthree
\advance\simurgh@temp by -137            % T := T - 137  Adjust the value
\simurgh@jalalii=31
\advance\simurgh@jalalii by -\simurgh@temp                 % now 31 - T is the jalalii
\simurgh@jalaliii = 30\relax
\ifsimurgh@kabiseh
  \simurgh@jalaliiii = 30\relax
\else
  \simurgh@jalaliiii = 29\relax
\fi
\simurgh@jalaliiv  = 31\relax
\simurgh@jalaliv   = 31\relax
\simurgh@jalalivi  = 31\relax
\simurgh@jalalivii = 31\relax
\simurgh@jalaliviii= 31\relax
\simurgh@jalaliix  = 31\relax
\simurgh@jalalix   = 30\relax
\simurgh@jalalixi  = 30\relax
\simurgh@jalalixii = 30\relax
\simurgh@jalalixiii= 30\relax
\simurgh@dayn= 0\relax
\simurgh@sn= 0\relax
\simurgh@monthminusone=\simurgh@month
\advance\simurgh@monthminusone by -1\relax
\simurgh@i=0\relax
\ifnum\simurgh@i < \simurgh@monthminusone
\loop
\advance \simurgh@i by 1\relax
\advance\simurgh@dayn by \csname simurgh@latin\romannumeral\the\simurgh@i\endcsname
\ifnum\simurgh@i<\simurgh@monthminusone \repeat
\fi
\advance \simurgh@dayn by \simurgh@day
\simurgh@i=1\relax
\simurgh@sn = \simurgh@jalalii
\ifnum \simurgh@sn<\simurgh@dayn
\loop
\advance \simurgh@i by 1\relax
\advance\simurgh@sn by \csname simurgh@jalali\romannumeral\the\simurgh@i\endcsname
\ifnum \simurgh@sn<\simurgh@dayn \repeat
\fi
\ifnum \simurgh@i < 4
   \simurgh@month = 9 \advance\simurgh@month by \simurgh@i
   \advance \simurgh@year by -622\relax
\else
   \simurgh@month = \simurgh@i \advance \simurgh@month by -3\relax
   \advance \simurgh@year by -621\relax
\fi
\advance\simurgh@sn by -\csname simurgh@jalali\romannumeral\the\simurgh@i%
\endcsname
\ifnum\simurgh@i = 1
  \simurgh@day = \simurgh@dayn \advance \simurgh@day by 30 \advance\simurgh@day by -\simurgh@jalalii
\else
  \simurgh@day = \simurgh@dayn \advance \simurgh@day by -\simurgh@sn
\fi
\newcommand*{\jalalitoday}{%
\number\simurgh@day\space%
\simurgh@jalali@month{\simurgh@month}\space\number\simurgh@year%
}
\let\jalaliyear\simurgh@year
\let\jalalimonth\simurgh@month
\let\jalaliday\simurgh@day
\def\simurgh@jalali@month#1{\ifcase#1\or فروردین\or
اردیبهشت\or
خرداد\or تیر\or
مرداد\or
شهریور\or مهر\or
آبان\or آذر\or
دی\or بهمن\or
اسفند\fi}

\let\simurgh@ltx@today\today
\def\gregoriantoday{\ensurelatintext{\simurgh@ltx@today}}
\def\today{\ensureparsitext{\jalalitoday}}
\endinput