ruby-calendrical 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +26 -0
- data/README +72 -0
- data/README.en +76 -0
- data/example/cal.rb +39 -0
- data/ext/calendrical/MANIFEST +10 -0
- data/ext/calendrical/calendrical.c +1197 -0
- data/ext/calendrical/calendrical.h +99 -0
- data/ext/calendrical/calendrical2.c +802 -0
- data/ext/calendrical/calendrical2.h +72 -0
- data/ext/calendrical/calendricalmodule.c +1796 -0
- data/ext/calendrical/depend +4 -0
- data/ext/calendrical/extconf.rb +2 -0
- data/ext/calendrical/qref.c +20655 -0
- data/ext/calendrical/qref.h +13 -0
- metadata +58 -0
@@ -0,0 +1,72 @@
|
|
1
|
+
/*
|
2
|
+
calendrical2.h (beta): Written by Tadayoshi Funaba 1997,1999,2000,2002,2007,2014
|
3
|
+
|
4
|
+
This code is in the public domain, but any use of it
|
5
|
+
should publically acknowledge its source.
|
6
|
+
|
7
|
+
$Id: calendrical2.h,v 1.8 2014-04-27 09:42:02+09 tadf Exp $
|
8
|
+
*/
|
9
|
+
|
10
|
+
#if !defined(__GNUC__) \
|
11
|
+
|| !( __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 6))
|
12
|
+
#undef __attribute__
|
13
|
+
#define __attribute__(x)
|
14
|
+
#endif
|
15
|
+
|
16
|
+
extern int world_leap_year(int year) __attribute__ ((const));
|
17
|
+
extern int world_last_day_of_month(int year, int month) __attribute__ ((const));
|
18
|
+
extern int world_to_rd(int year, int month, int day) __attribute__ ((const));
|
19
|
+
extern void rd_to_world(int date, int *ryear, int *rmonth, int *rday);
|
20
|
+
extern int rd_to_world_day_of_week(int date) __attribute__ ((const));
|
21
|
+
extern int coptic_leap_year(int year) __attribute__ ((const));
|
22
|
+
extern int coptic_last_day_of_month(int year, int month) __attribute__ ((const));
|
23
|
+
extern int coptic_to_rd(int year, int month, int day) __attribute__ ((const));
|
24
|
+
extern void rd_to_coptic(int date, int *ryear, int *rmonth, int *rday);
|
25
|
+
extern int ethiopian_leap_year(int year) __attribute__ ((const));
|
26
|
+
extern int ethiopian_last_day_of_month(int year, int month) __attribute__ ((const));
|
27
|
+
extern int ethiopian_to_rd(int year, int month, int day) __attribute__ ((const));
|
28
|
+
extern void rd_to_ethiopian(int date, int *ryear, int *rmonth, int *rday);
|
29
|
+
extern int jalali_leap_year(int year) __attribute__ ((const));
|
30
|
+
extern int jalali_last_day_of_month(int year, int month) __attribute__ ((const));
|
31
|
+
extern int jalali_to_rd(int year, int month, int day) __attribute__ ((const));
|
32
|
+
extern void rd_to_jalali(int date, int *ryear, int *rmonth, int *rday);
|
33
|
+
extern int bahai_leap_year(int year) __attribute__ ((const));
|
34
|
+
extern int bahai_last_day_of_month(int year, int month) __attribute__ ((const));
|
35
|
+
extern int bahai_to_rd(int year, int month, int day) __attribute__ ((const));
|
36
|
+
extern void rd_to_bahai(int date, int *ryear, int *rmonth, int *rday);
|
37
|
+
extern void bahai_year_to_vahid(int year, int *rkull, int *rvahid, int *ryear);
|
38
|
+
extern int bahai_vahid_to_year(int kull, int vahid, int year) __attribute__ ((const));
|
39
|
+
extern int indian_national_leap_year(int year) __attribute__ ((const));
|
40
|
+
extern int indian_national_last_day_of_month(int year, int month) __attribute__ ((const));
|
41
|
+
extern int indian_national_to_rd(int year, int month, int day) __attribute__ ((const));
|
42
|
+
extern void rd_to_indian_national(int date, int *ryear, int *rmonth, int *rday);
|
43
|
+
extern int bengali_leap_year(int year) __attribute__ ((const));
|
44
|
+
extern int bengali_last_day_of_month(int year, int month) __attribute__ ((const));
|
45
|
+
extern int bengali_to_rd(int year, int month, int day) __attribute__ ((const));
|
46
|
+
extern void rd_to_bengali(int date, int *ryear, int *rmonth, int *rday);
|
47
|
+
extern int nanakshahi_leap_year(int year) __attribute__ ((const));
|
48
|
+
extern int nanakshahi_last_day_of_month(int year, int month) __attribute__ ((const));
|
49
|
+
extern int nanakshahi_to_rd(int year, int month, int day) __attribute__ ((const));
|
50
|
+
extern void rd_to_nanakshahi(int date, int *ryear, int *rmonth, int *rday);
|
51
|
+
#ifndef PLUTO
|
52
|
+
extern int ordinal_to_rd(int year, int day) __attribute__ ((const));
|
53
|
+
extern void rd_to_ordinal(int date, int *ryear, int *rday);
|
54
|
+
#endif
|
55
|
+
extern int jd_to_rd(int date) __attribute__ ((const));
|
56
|
+
extern int rd_to_jd(int date) __attribute__ ((const));
|
57
|
+
#ifndef PLUTO
|
58
|
+
extern int mjd_to_rd(int date) __attribute__ ((const));
|
59
|
+
extern int rd_to_mjd(int date) __attribute__ ((const));
|
60
|
+
extern int jd_to_mjd(int date) __attribute__ ((const));
|
61
|
+
extern int mjd_to_jd(int date) __attribute__ ((const));
|
62
|
+
extern int ld_to_rd(int date) __attribute__ ((const));
|
63
|
+
extern int rd_to_ld(int date) __attribute__ ((const));
|
64
|
+
extern int rd_to_day_of_week(int date) __attribute__ ((const));
|
65
|
+
#endif /* not PLUTO */
|
66
|
+
|
67
|
+
|
68
|
+
/*
|
69
|
+
Local Variables:
|
70
|
+
c-basic-offset: 2
|
71
|
+
End:
|
72
|
+
*/
|
@@ -0,0 +1,1796 @@
|
|
1
|
+
/*
|
2
|
+
calendricalmodule.c: Copyright (C) 1997-2002,2007,2014 Tadayoshi Funaba All rights reserved
|
3
|
+
$Id: calendricalmodule.c,v 1.16 2014-04-27 09:42:19+09 tadf Exp $
|
4
|
+
*/
|
5
|
+
|
6
|
+
#include "ruby.h"
|
7
|
+
#ifdef HAVE_RUBY_ENCODING_H
|
8
|
+
#include "ruby/encoding.h"
|
9
|
+
#endif
|
10
|
+
#include "calendrical.h"
|
11
|
+
#include "calendrical2.h"
|
12
|
+
#include "qref.h"
|
13
|
+
|
14
|
+
#define INT2BOOL(x) ((x) ? Qtrue : Qfalse)
|
15
|
+
#define BOOL2INT(x) (RTEST(x) ? 1 : 0)
|
16
|
+
|
17
|
+
#define CHECK_RANGE(v, m) \
|
18
|
+
{ \
|
19
|
+
if ((v) < (m)) \
|
20
|
+
rb_raise(rb_eArgError, "out of range"); \
|
21
|
+
}
|
22
|
+
|
23
|
+
#define CHECK_DOMAIN(v, m) \
|
24
|
+
{ \
|
25
|
+
if ((v) < (m)) \
|
26
|
+
rb_raise(rb_eArgError, "out of domain");\
|
27
|
+
}
|
28
|
+
|
29
|
+
#define CHECK_DOMAIN2(v, m, n) \
|
30
|
+
{ \
|
31
|
+
if ((v) < (m) || (v) > (n)) \
|
32
|
+
rb_raise(rb_eArgError, "out of domain");\
|
33
|
+
}
|
34
|
+
|
35
|
+
static VALUE
|
36
|
+
calendrical_gregorian_leap_year(VALUE obj, VALUE y)
|
37
|
+
{
|
38
|
+
int iy, l;
|
39
|
+
|
40
|
+
iy = NUM2INT(y);
|
41
|
+
l = gregorian_leap_year(iy);
|
42
|
+
return INT2BOOL(l);
|
43
|
+
}
|
44
|
+
|
45
|
+
static VALUE
|
46
|
+
calendrical_gregorian_last_day_of_month(VALUE obj, VALUE y, VALUE m)
|
47
|
+
{
|
48
|
+
int iy, im, md;
|
49
|
+
|
50
|
+
im = NUM2INT(m); CHECK_DOMAIN2(im, 1, 12);
|
51
|
+
iy = NUM2INT(y);
|
52
|
+
md = gregorian_last_day_of_month(iy, im);
|
53
|
+
return INT2NUM(md);
|
54
|
+
}
|
55
|
+
|
56
|
+
static VALUE
|
57
|
+
calendrical_gregorian_to_rd(VALUE obj, VALUE y, VALUE m, VALUE md)
|
58
|
+
{
|
59
|
+
int iy, im, imd, a, iy2, im2, imd2;
|
60
|
+
|
61
|
+
im = NUM2INT(m); CHECK_DOMAIN2(im, 1, 12);
|
62
|
+
imd = NUM2INT(md); CHECK_DOMAIN2(imd, 1, 31);
|
63
|
+
iy = NUM2INT(y);
|
64
|
+
a = gregorian_to_rd(iy, im, imd);
|
65
|
+
rd_to_gregorian(a, &iy2, &im2, &imd2);
|
66
|
+
if (im != im2 || imd != imd2 || iy != iy2)
|
67
|
+
rb_raise(rb_eArgError, "invalid date");
|
68
|
+
return INT2NUM(a);
|
69
|
+
}
|
70
|
+
|
71
|
+
static VALUE
|
72
|
+
calendrical_rd_to_gregorian(VALUE obj, VALUE a)
|
73
|
+
{
|
74
|
+
int ia, y, m, md;
|
75
|
+
|
76
|
+
ia = NUM2INT(a);
|
77
|
+
rd_to_gregorian(ia, &y, &m, &md);
|
78
|
+
return rb_ary_new3(3, INT2NUM(y), INT2NUM(m), INT2NUM(md));
|
79
|
+
}
|
80
|
+
|
81
|
+
static VALUE
|
82
|
+
calendrical_kday_on_or_before(VALUE obj, VALUE a, VALUE k)
|
83
|
+
{
|
84
|
+
int ia, ik, b;
|
85
|
+
|
86
|
+
ia = NUM2INT(a);
|
87
|
+
ik = NUM2INT(k); CHECK_DOMAIN2(ik, 0, 6);
|
88
|
+
b = kday_on_or_before(ia, NUM2INT(k));
|
89
|
+
return INT2NUM(b);
|
90
|
+
}
|
91
|
+
|
92
|
+
static VALUE
|
93
|
+
calendrical_iso_to_rd(VALUE obj, VALUE y, VALUE w, VALUE wd)
|
94
|
+
{
|
95
|
+
int iy, iw, iwd, a, iy2, iw2, iwd2;
|
96
|
+
|
97
|
+
iw = NUM2INT(w); CHECK_DOMAIN2(iw, 1, 53);
|
98
|
+
iwd = NUM2INT(wd); CHECK_DOMAIN2(iwd, 1, 7);
|
99
|
+
iy = NUM2INT(y);
|
100
|
+
a = iso_to_rd(iy, iw, iwd);
|
101
|
+
rd_to_iso(a, &iy2, &iw2, &iwd2);
|
102
|
+
if (iw != iw2 || iwd != iwd2 || iy != iy2)
|
103
|
+
rb_raise(rb_eArgError, "invalid date");
|
104
|
+
return INT2NUM(a);
|
105
|
+
}
|
106
|
+
|
107
|
+
static VALUE
|
108
|
+
calendrical_rd_to_iso(VALUE obj, VALUE a)
|
109
|
+
{
|
110
|
+
int ia, y, w, wd;
|
111
|
+
|
112
|
+
ia = NUM2INT(a);
|
113
|
+
rd_to_iso(ia, &y, &w, &wd);
|
114
|
+
return rb_ary_new3(3, INT2NUM(y), INT2NUM(w), INT2NUM(wd));
|
115
|
+
}
|
116
|
+
|
117
|
+
static VALUE
|
118
|
+
calendrical_julian_leap_year(VALUE obj, VALUE y)
|
119
|
+
{
|
120
|
+
int iy, l;
|
121
|
+
|
122
|
+
iy = NUM2INT(y);
|
123
|
+
l = julian_leap_year(iy);
|
124
|
+
return INT2BOOL(l);
|
125
|
+
}
|
126
|
+
|
127
|
+
static VALUE
|
128
|
+
calendrical_julian_last_day_of_month(VALUE obj, VALUE y, VALUE m)
|
129
|
+
{
|
130
|
+
int iy, im, md;
|
131
|
+
|
132
|
+
im = NUM2INT(m); CHECK_DOMAIN2(im, 1, 12);
|
133
|
+
iy = NUM2INT(y);
|
134
|
+
md = julian_last_day_of_month(iy, im);
|
135
|
+
return INT2NUM(md);
|
136
|
+
}
|
137
|
+
|
138
|
+
static VALUE
|
139
|
+
calendrical_julian_to_rd(VALUE obj, VALUE y, VALUE m, VALUE md)
|
140
|
+
{
|
141
|
+
int iy, im, imd, a, iy2, im2, imd2;
|
142
|
+
|
143
|
+
im = NUM2INT(m); CHECK_DOMAIN2(im, 1, 12);
|
144
|
+
imd = NUM2INT(md); CHECK_DOMAIN2(imd, 1, 31);
|
145
|
+
iy = NUM2INT(y);
|
146
|
+
a = julian_to_rd(iy, im, imd);
|
147
|
+
rd_to_julian(a, &iy2, &im2, &imd2);
|
148
|
+
if (im != im2 || imd != imd2 || iy != iy2)
|
149
|
+
rb_raise(rb_eArgError, "invalid date");
|
150
|
+
return INT2NUM(a);
|
151
|
+
}
|
152
|
+
|
153
|
+
static VALUE
|
154
|
+
calendrical_rd_to_julian(VALUE obj, VALUE a)
|
155
|
+
{
|
156
|
+
int ia, y, m, md;
|
157
|
+
|
158
|
+
ia = NUM2INT(a);
|
159
|
+
rd_to_julian(ia, &y, &m, &md);
|
160
|
+
return rb_ary_new3(3, INT2NUM(y), INT2NUM(m), INT2NUM(md));
|
161
|
+
}
|
162
|
+
|
163
|
+
static VALUE
|
164
|
+
calendrical_islamic_leap_year(VALUE obj, VALUE y)
|
165
|
+
{
|
166
|
+
int iy, l;
|
167
|
+
|
168
|
+
iy = NUM2INT(y);
|
169
|
+
l = islamic_leap_year(iy);
|
170
|
+
return INT2BOOL(l);
|
171
|
+
}
|
172
|
+
|
173
|
+
static VALUE
|
174
|
+
calendrical_islamic_last_day_of_month(VALUE obj, VALUE y, VALUE m)
|
175
|
+
{
|
176
|
+
int iy, im, md;
|
177
|
+
|
178
|
+
im = NUM2INT(m); CHECK_DOMAIN2(im, 1, 12);
|
179
|
+
iy = NUM2INT(y);
|
180
|
+
md = islamic_last_day_of_month(iy, im);
|
181
|
+
return INT2NUM(md);
|
182
|
+
}
|
183
|
+
|
184
|
+
static VALUE
|
185
|
+
calendrical_islamic_to_rd(VALUE obj, VALUE y, VALUE m, VALUE md)
|
186
|
+
{
|
187
|
+
int iy, im, imd, a, iy2, im2, imd2;
|
188
|
+
|
189
|
+
im = NUM2INT(m); CHECK_DOMAIN2(im, 1, 12);
|
190
|
+
imd = NUM2INT(md); CHECK_DOMAIN2(imd, 1, 30);
|
191
|
+
iy = NUM2INT(y);
|
192
|
+
a = islamic_to_rd(iy, im, imd);
|
193
|
+
rd_to_islamic(a, &iy2, &im2, &imd2);
|
194
|
+
if (im != im2 || imd != imd2 || iy != iy2)
|
195
|
+
rb_raise(rb_eArgError, "invalid date");
|
196
|
+
return INT2NUM(a);
|
197
|
+
}
|
198
|
+
|
199
|
+
static VALUE
|
200
|
+
calendrical_rd_to_islamic(VALUE obj, VALUE a)
|
201
|
+
{
|
202
|
+
int ia, y, m, md;
|
203
|
+
|
204
|
+
ia = NUM2INT(a);
|
205
|
+
rd_to_islamic(ia, &y, &m, &md);
|
206
|
+
return rb_ary_new3(3, INT2NUM(y), INT2NUM(m), INT2NUM(md));
|
207
|
+
}
|
208
|
+
|
209
|
+
static VALUE
|
210
|
+
calendrical_hebrew_leap_year(VALUE obj, VALUE y)
|
211
|
+
{
|
212
|
+
int iy, l;
|
213
|
+
|
214
|
+
iy = NUM2INT(y);
|
215
|
+
l = hebrew_leap_year(iy);
|
216
|
+
return INT2BOOL(l);
|
217
|
+
}
|
218
|
+
|
219
|
+
static VALUE
|
220
|
+
calendrical_hebrew_last_month_of_year(VALUE obj, VALUE y)
|
221
|
+
{
|
222
|
+
int iy, m;
|
223
|
+
|
224
|
+
iy = NUM2INT(y);
|
225
|
+
m = hebrew_last_month_of_year(iy);
|
226
|
+
return INT2NUM(m);
|
227
|
+
}
|
228
|
+
|
229
|
+
static VALUE
|
230
|
+
calendrical_hebrew_last_day_of_month(VALUE obj, VALUE y, VALUE m)
|
231
|
+
{
|
232
|
+
int iy, im, md;
|
233
|
+
|
234
|
+
im = NUM2INT(m); CHECK_DOMAIN2(im, 1, 13);
|
235
|
+
iy = NUM2INT(y);
|
236
|
+
md = hebrew_last_day_of_month(iy, im);
|
237
|
+
return INT2NUM(md);
|
238
|
+
}
|
239
|
+
|
240
|
+
static VALUE
|
241
|
+
calendrical_hebrew_calendar_elapsed_days(VALUE obj, VALUE y)
|
242
|
+
{
|
243
|
+
int iy, d;
|
244
|
+
|
245
|
+
iy = NUM2INT(y);
|
246
|
+
d = hebrew_calendar_elapsed_days(iy);
|
247
|
+
return INT2NUM(d);
|
248
|
+
}
|
249
|
+
|
250
|
+
static VALUE
|
251
|
+
calendrical_hebrew_days_in_year(VALUE obj, VALUE y)
|
252
|
+
{
|
253
|
+
int iy, d;
|
254
|
+
|
255
|
+
iy = NUM2INT(y);
|
256
|
+
d = hebrew_days_in_year(iy);
|
257
|
+
return INT2NUM(d);
|
258
|
+
}
|
259
|
+
|
260
|
+
static VALUE
|
261
|
+
calendrical_long_heshvan(VALUE obj, VALUE y)
|
262
|
+
{
|
263
|
+
int iy, l;
|
264
|
+
|
265
|
+
iy = NUM2INT(y);
|
266
|
+
l = long_heshvan(iy);
|
267
|
+
return INT2BOOL(l);
|
268
|
+
}
|
269
|
+
|
270
|
+
static VALUE
|
271
|
+
calendrical_short_kislev(VALUE obj, VALUE y)
|
272
|
+
{
|
273
|
+
int iy, s;
|
274
|
+
|
275
|
+
iy = NUM2INT(y);
|
276
|
+
s = short_kislev(iy);
|
277
|
+
return INT2BOOL(s);
|
278
|
+
}
|
279
|
+
|
280
|
+
static VALUE
|
281
|
+
calendrical_hebrew_to_rd(VALUE obj, VALUE y, VALUE m, VALUE md)
|
282
|
+
{
|
283
|
+
int iy, im, imd, a, iy2, im2, imd2;
|
284
|
+
|
285
|
+
im = NUM2INT(m); CHECK_DOMAIN2(im, 1, 13);
|
286
|
+
imd = NUM2INT(md); CHECK_DOMAIN2(imd, 1, 30);
|
287
|
+
iy = NUM2INT(y);
|
288
|
+
a = hebrew_to_rd(iy, im, imd);
|
289
|
+
rd_to_hebrew(a, &iy2, &im2, &imd2);
|
290
|
+
if (im != im2 || imd != imd2 || iy != iy2)
|
291
|
+
rb_raise(rb_eArgError, "invalid date");
|
292
|
+
return INT2NUM(a);
|
293
|
+
}
|
294
|
+
|
295
|
+
static VALUE
|
296
|
+
calendrical_rd_to_hebrew(VALUE obj, VALUE a)
|
297
|
+
{
|
298
|
+
int ia, y, m, md;
|
299
|
+
|
300
|
+
ia = NUM2INT(a);
|
301
|
+
rd_to_hebrew(ia, &y, &m, &md);
|
302
|
+
return rb_ary_new3(3, INT2NUM(y), INT2NUM(m), INT2NUM(md));
|
303
|
+
}
|
304
|
+
|
305
|
+
static VALUE
|
306
|
+
calendrical_nth_kday(VALUE obj, VALUE y, VALUE m, VALUE n, VALUE k)
|
307
|
+
{
|
308
|
+
int iy, im, in, ik, b;
|
309
|
+
|
310
|
+
in = NUM2INT(n);
|
311
|
+
if (in < -5 || in == 0 || in > 5)
|
312
|
+
rb_raise(rb_eArgError, "out of range");
|
313
|
+
ik = NUM2INT(k); CHECK_DOMAIN2(ik, 0, 6);
|
314
|
+
im = NUM2INT(m); CHECK_DOMAIN2(im, 1, 12);
|
315
|
+
iy = NUM2INT(y);
|
316
|
+
b = nth_kday(iy, im, in, ik);
|
317
|
+
return INT2NUM(b);
|
318
|
+
}
|
319
|
+
|
320
|
+
static VALUE
|
321
|
+
calendrical_nicaean_rule_easter(VALUE obj, VALUE y)
|
322
|
+
{
|
323
|
+
int iy, a;
|
324
|
+
|
325
|
+
iy = NUM2INT(y);
|
326
|
+
a = nicaean_rule_easter(iy);
|
327
|
+
return INT2NUM(a);
|
328
|
+
}
|
329
|
+
|
330
|
+
static VALUE
|
331
|
+
calendrical_easter(VALUE obj, VALUE y)
|
332
|
+
{
|
333
|
+
int iy, a;
|
334
|
+
|
335
|
+
iy = NUM2INT(y);
|
336
|
+
a = easter(iy);
|
337
|
+
return INT2NUM(a);
|
338
|
+
}
|
339
|
+
|
340
|
+
static VALUE
|
341
|
+
calendrical_mayan_long_count_to_rd
|
342
|
+
(VALUE obj, VALUE bt, VALUE kt, VALUE t, VALUE u, VALUE k)
|
343
|
+
{
|
344
|
+
int ibt, ikt, it, iu, ik, a, ibt2, ikt2, it2, iu2, ik2;
|
345
|
+
|
346
|
+
ibt = NUM2INT(bt);
|
347
|
+
ikt = NUM2INT(kt); CHECK_DOMAIN2(ikt, 0, 19);
|
348
|
+
it = NUM2INT(t); CHECK_DOMAIN2(it, 0, 19);
|
349
|
+
iu = NUM2INT(u); CHECK_DOMAIN2(iu, 0, 17);
|
350
|
+
ik = NUM2INT(k); CHECK_DOMAIN2(ik, 0, 19);
|
351
|
+
a = mayan_long_count_to_rd(ibt, ikt, it, iu, ik);
|
352
|
+
rd_to_mayan_long_count(a, &ibt2, &ikt2, &it2, &iu2, &ik2);
|
353
|
+
if (ibt != ibt2 || ikt != ikt2 || it != it2 || iu != iu2 || ik != ik2)
|
354
|
+
rb_raise(rb_eArgError, "invalid date");
|
355
|
+
return INT2NUM(a);
|
356
|
+
}
|
357
|
+
|
358
|
+
static VALUE
|
359
|
+
calendrical_rd_to_mayan_long_count(VALUE obj, VALUE a)
|
360
|
+
{
|
361
|
+
int ia, bt, kt, t, u, k;
|
362
|
+
|
363
|
+
ia = NUM2INT(a);
|
364
|
+
rd_to_mayan_long_count(ia, &bt, &kt, &t, &u, &k);
|
365
|
+
return rb_ary_new3
|
366
|
+
(5, INT2NUM(bt), INT2NUM(kt), INT2NUM(t), INT2NUM(u), INT2NUM(k));
|
367
|
+
}
|
368
|
+
|
369
|
+
static VALUE
|
370
|
+
calendrical_rd_to_mayan_haab(VALUE obj, VALUE a)
|
371
|
+
{
|
372
|
+
int ia, md, m;
|
373
|
+
|
374
|
+
ia = NUM2INT(a);
|
375
|
+
rd_to_mayan_haab(ia, &m, &md);
|
376
|
+
return rb_ary_new3(2, INT2NUM(m), INT2NUM(md));
|
377
|
+
}
|
378
|
+
|
379
|
+
static VALUE
|
380
|
+
calendrical_mayan_haab_difference
|
381
|
+
(VALUE obj, VALUE m1, VALUE md1, VALUE m2, VALUE md2)
|
382
|
+
{
|
383
|
+
int imd1, im1, imd2, im2, d;
|
384
|
+
|
385
|
+
im1 = NUM2INT(m1); CHECK_DOMAIN2(im1, 1, 19);
|
386
|
+
imd1 = NUM2INT(md1); CHECK_DOMAIN2(imd1, 0, (im1 == 19) ? 4 : 19);
|
387
|
+
im2 = NUM2INT(m2); CHECK_DOMAIN2(im2, 1, 19);
|
388
|
+
imd2 = NUM2INT(md2); CHECK_DOMAIN2(imd2, 0, (im2 == 19) ? 4 : 19);
|
389
|
+
d = mayan_haab_difference(im1, imd1, im2, imd2);
|
390
|
+
return INT2NUM(d);
|
391
|
+
}
|
392
|
+
|
393
|
+
static VALUE
|
394
|
+
calendrical_mayan_haab_on_or_before(VALUE obj, VALUE m, VALUE md, VALUE a)
|
395
|
+
{
|
396
|
+
int imd, im, ia, d;
|
397
|
+
|
398
|
+
im = NUM2INT(m); CHECK_DOMAIN2(im, 1, 19);
|
399
|
+
imd = NUM2INT(md); CHECK_DOMAIN2(imd, 0, (im == 19) ? 4 : 19);
|
400
|
+
ia = NUM2INT(a);
|
401
|
+
d = mayan_haab_on_or_before(im, imd, ia);
|
402
|
+
return INT2NUM(d);
|
403
|
+
}
|
404
|
+
|
405
|
+
static VALUE
|
406
|
+
calendrical_rd_to_mayan_tzolkin(VALUE obj, VALUE a)
|
407
|
+
{
|
408
|
+
int ia, nu, na;
|
409
|
+
|
410
|
+
ia = NUM2INT(a);
|
411
|
+
rd_to_mayan_tzolkin(ia, &na, &nu);
|
412
|
+
return rb_ary_new3(2, INT2NUM(na), INT2NUM(nu));
|
413
|
+
}
|
414
|
+
|
415
|
+
static VALUE
|
416
|
+
calendrical_mayan_tzolkin_difference
|
417
|
+
(VALUE obj, VALUE na1, VALUE nu1, VALUE na2, VALUE nu2)
|
418
|
+
{
|
419
|
+
int inu1, ina1, inu2, ina2, d;
|
420
|
+
|
421
|
+
inu1 = NUM2INT(nu1); CHECK_DOMAIN2(inu1, 1, 13);
|
422
|
+
ina1 = NUM2INT(na1); CHECK_DOMAIN2(ina1, 1, 20);
|
423
|
+
inu2 = NUM2INT(nu2); CHECK_DOMAIN2(inu2, 1, 13);
|
424
|
+
ina2 = NUM2INT(na2); CHECK_DOMAIN2(ina2, 1, 20);
|
425
|
+
d = mayan_tzolkin_difference(ina1, inu1, ina2, inu2);
|
426
|
+
return INT2NUM(d);
|
427
|
+
}
|
428
|
+
|
429
|
+
static VALUE
|
430
|
+
calendrical_mayan_tzolkin_on_or_before(VALUE obj, VALUE na, VALUE nu, VALUE a)
|
431
|
+
{
|
432
|
+
int inu, ina, ia, d;
|
433
|
+
|
434
|
+
inu = NUM2INT(nu); CHECK_DOMAIN2(inu, 1, 13);
|
435
|
+
ina = NUM2INT(na); CHECK_DOMAIN2(ina, 1, 20);
|
436
|
+
ia = NUM2INT(a);
|
437
|
+
d = mayan_tzolkin_on_or_before(ina, inu, ia);
|
438
|
+
return INT2NUM(d);
|
439
|
+
}
|
440
|
+
|
441
|
+
static VALUE
|
442
|
+
calendrical_mayan_haab_tzolkin_on_or_before
|
443
|
+
(VALUE obj, VALUE m, VALUE md, VALUE na, VALUE nu, VALUE a)
|
444
|
+
{
|
445
|
+
int imd, im, inu, ina, ia, d;
|
446
|
+
|
447
|
+
imd = NUM2INT(md); CHECK_DOMAIN2(imd, 0, 19);
|
448
|
+
im = NUM2INT(m); CHECK_DOMAIN2(im, 1, 19);
|
449
|
+
inu = NUM2INT(nu); CHECK_DOMAIN2(inu, 1, 13);
|
450
|
+
ina = NUM2INT(na); CHECK_DOMAIN2(ina, 1, 20);
|
451
|
+
ia = NUM2INT(a);
|
452
|
+
d = mayan_haab_tzolkin_on_or_before(im, imd, ina, inu, ia);
|
453
|
+
return INT2NUM(d);
|
454
|
+
}
|
455
|
+
|
456
|
+
static VALUE
|
457
|
+
calendrical_french_leap_year(VALUE obj, VALUE y)
|
458
|
+
{
|
459
|
+
int iy, l;
|
460
|
+
|
461
|
+
iy = NUM2INT(y);
|
462
|
+
l = french_leap_year(iy);
|
463
|
+
return INT2BOOL(l);
|
464
|
+
}
|
465
|
+
|
466
|
+
static VALUE
|
467
|
+
calendrical_french_last_day_of_month(VALUE obj, VALUE y, VALUE m)
|
468
|
+
{
|
469
|
+
int iy, im, md;
|
470
|
+
|
471
|
+
im = NUM2INT(m); CHECK_DOMAIN2(im, 1, 13);
|
472
|
+
iy = NUM2INT(y);
|
473
|
+
md = french_last_day_of_month(iy, im);
|
474
|
+
return INT2NUM(md);
|
475
|
+
}
|
476
|
+
|
477
|
+
static VALUE
|
478
|
+
calendrical_french_to_rd(VALUE obj, VALUE y, VALUE m, VALUE md)
|
479
|
+
{
|
480
|
+
int iy, im, imd, a, iy2, im2, imd2;
|
481
|
+
|
482
|
+
im = NUM2INT(m); CHECK_DOMAIN2(im, 1, 13);
|
483
|
+
imd = NUM2INT(md); CHECK_DOMAIN2(imd, 1, 30);
|
484
|
+
iy = NUM2INT(y);
|
485
|
+
a = french_to_rd(iy, im, imd);
|
486
|
+
rd_to_french(a, &iy2, &im2, &imd2);
|
487
|
+
if (im != im2 || imd != imd2 || iy != iy2)
|
488
|
+
rb_raise(rb_eArgError, "invalid date");
|
489
|
+
return INT2NUM(a);
|
490
|
+
}
|
491
|
+
|
492
|
+
static VALUE
|
493
|
+
calendrical_rd_to_french(VALUE obj, VALUE a)
|
494
|
+
{
|
495
|
+
int ia, y, m, md;
|
496
|
+
|
497
|
+
ia = NUM2INT(a);
|
498
|
+
rd_to_french(ia, &y, &m, &md);
|
499
|
+
return rb_ary_new3(3, INT2NUM(y), INT2NUM(m), INT2NUM(md));
|
500
|
+
}
|
501
|
+
|
502
|
+
static double
|
503
|
+
getfloat(VALUE x)
|
504
|
+
{
|
505
|
+
if (TYPE(x) == T_FLOAT)
|
506
|
+
#ifndef RFLOAT_VALUE
|
507
|
+
return RFLOAT(x)->value;
|
508
|
+
#else
|
509
|
+
return RFLOAT_VALUE(x);
|
510
|
+
#endif
|
511
|
+
return (double)NUM2INT(x);
|
512
|
+
}
|
513
|
+
|
514
|
+
static VALUE
|
515
|
+
calendrical_solar_longitude(VALUE obj, VALUE d)
|
516
|
+
{
|
517
|
+
double l;
|
518
|
+
|
519
|
+
l = solar_longitude(getfloat(d));
|
520
|
+
return rb_float_new(l);
|
521
|
+
}
|
522
|
+
|
523
|
+
static VALUE
|
524
|
+
calendrical_zodiac(VALUE obj, VALUE d)
|
525
|
+
{
|
526
|
+
double l;
|
527
|
+
|
528
|
+
l = zodiac(getfloat(d));
|
529
|
+
return rb_float_new(l);
|
530
|
+
}
|
531
|
+
|
532
|
+
static VALUE
|
533
|
+
calendrical_rd_to_old_hindu_solar(VALUE obj, VALUE a)
|
534
|
+
{
|
535
|
+
int ia, y, m, md;
|
536
|
+
|
537
|
+
ia = NUM2INT(a);
|
538
|
+
rd_to_old_hindu_solar(ia, &y, &m, &md);
|
539
|
+
return rb_ary_new3(3, INT2NUM(y), INT2NUM(m), INT2NUM(md));
|
540
|
+
}
|
541
|
+
|
542
|
+
static VALUE
|
543
|
+
calendrical_old_hindu_solar_to_rd(VALUE obj, VALUE y, VALUE m, VALUE md)
|
544
|
+
{
|
545
|
+
int iy, im, imd, a, iy2, im2, imd2;
|
546
|
+
|
547
|
+
im = NUM2INT(m); CHECK_DOMAIN2(im, 1, 12);
|
548
|
+
imd = NUM2INT(md); CHECK_DOMAIN2(imd, 1, 31);
|
549
|
+
iy = NUM2INT(y);
|
550
|
+
a = old_hindu_solar_to_rd(iy, im, imd);
|
551
|
+
rd_to_old_hindu_solar(a, &iy2, &im2, &imd2);
|
552
|
+
if (im != im2 || imd != imd2 || iy != iy2)
|
553
|
+
rb_raise(rb_eArgError, "invalid date");
|
554
|
+
return INT2NUM(a);
|
555
|
+
}
|
556
|
+
|
557
|
+
static VALUE
|
558
|
+
calendrical_lunar_longitude(VALUE obj, VALUE d)
|
559
|
+
{
|
560
|
+
double l;
|
561
|
+
|
562
|
+
l = lunar_longitude(getfloat(d));
|
563
|
+
return rb_float_new(l);
|
564
|
+
}
|
565
|
+
|
566
|
+
static VALUE
|
567
|
+
calendrical_lunar_phase(VALUE obj, VALUE d)
|
568
|
+
{
|
569
|
+
double p;
|
570
|
+
|
571
|
+
p = lunar_phase(getfloat(d));
|
572
|
+
return rb_float_new(p);
|
573
|
+
}
|
574
|
+
|
575
|
+
static VALUE
|
576
|
+
calendrical_new_moon(VALUE obj, VALUE d)
|
577
|
+
{
|
578
|
+
double n;
|
579
|
+
|
580
|
+
n = new_moon(getfloat(d));
|
581
|
+
return rb_float_new(n);
|
582
|
+
}
|
583
|
+
|
584
|
+
static VALUE
|
585
|
+
calendrical_rd_to_old_hindu_lunar(VALUE obj, VALUE a)
|
586
|
+
{
|
587
|
+
int ia, y, m, l, md;
|
588
|
+
|
589
|
+
ia = NUM2INT(a);
|
590
|
+
rd_to_old_hindu_lunar(ia, &y, &m, &l, &md);
|
591
|
+
return rb_ary_new3(4, INT2NUM(y), INT2NUM(m), INT2BOOL(l), INT2NUM(md));
|
592
|
+
}
|
593
|
+
|
594
|
+
static VALUE
|
595
|
+
calendrical_old_hindu_lunar_precedes
|
596
|
+
(VALUE obj,
|
597
|
+
VALUE y1, VALUE m1, VALUE l1, VALUE md1,
|
598
|
+
VALUE y2, VALUE m2, VALUE l2, VALUE md2)
|
599
|
+
{
|
600
|
+
int iy1, im1, il1, imd1, iy2, im2, il2, imd2, d;
|
601
|
+
|
602
|
+
im1 = NUM2INT(m1); CHECK_DOMAIN2(im1, 1, 12);
|
603
|
+
il1 = BOOL2INT(l1);
|
604
|
+
imd1 = NUM2INT(md1); CHECK_DOMAIN2(imd1, 1, 30);
|
605
|
+
iy1 = NUM2INT(y1);
|
606
|
+
im2 = NUM2INT(m2); CHECK_DOMAIN2(im2, 1, 12);
|
607
|
+
il2 = BOOL2INT(l2);
|
608
|
+
imd2 = NUM2INT(md2); CHECK_DOMAIN2(imd2, 1, 30);
|
609
|
+
iy2 = NUM2INT(y2);
|
610
|
+
d = old_hindu_lunar_precedes(iy1, im1, il1, imd1, iy2, im2, il2, imd2);
|
611
|
+
return INT2BOOL(d);
|
612
|
+
}
|
613
|
+
|
614
|
+
static VALUE
|
615
|
+
calendrical_old_hindu_lunar_to_rd
|
616
|
+
(VALUE obj, VALUE y, VALUE m, VALUE l, VALUE md)
|
617
|
+
{
|
618
|
+
int iy, im, il, imd, a, iy2, im2, il2, imd2;
|
619
|
+
|
620
|
+
im = NUM2INT(m); CHECK_DOMAIN2(im, 1, 12);
|
621
|
+
il = BOOL2INT(l);
|
622
|
+
imd = NUM2INT(md); CHECK_DOMAIN2(imd, 1, 30);
|
623
|
+
iy = NUM2INT(y);
|
624
|
+
a = old_hindu_lunar_to_rd(iy, im, il, imd);
|
625
|
+
rd_to_old_hindu_lunar(a, &iy2, &im2, &il2, &imd2);
|
626
|
+
if (im != im2 || il != il2 || imd != imd2 || iy != iy2)
|
627
|
+
rb_raise(rb_eArgError, "invalid date");
|
628
|
+
return INT2NUM(a);
|
629
|
+
}
|
630
|
+
|
631
|
+
static VALUE
|
632
|
+
calendrical_world_leap_year(VALUE obj, VALUE y)
|
633
|
+
{
|
634
|
+
int iy, l;
|
635
|
+
|
636
|
+
iy = NUM2INT(y);
|
637
|
+
l = world_leap_year(iy);
|
638
|
+
return INT2BOOL(l);
|
639
|
+
}
|
640
|
+
|
641
|
+
static VALUE
|
642
|
+
calendrical_world_last_day_of_month(VALUE obj, VALUE y, VALUE m)
|
643
|
+
{
|
644
|
+
int iy, im, md;
|
645
|
+
|
646
|
+
im = NUM2INT(m); CHECK_DOMAIN2(im, 1, 12);
|
647
|
+
iy = NUM2INT(y);
|
648
|
+
md = world_last_day_of_month(iy, im);
|
649
|
+
return INT2NUM(md);
|
650
|
+
}
|
651
|
+
|
652
|
+
static VALUE
|
653
|
+
calendrical_world_to_rd(VALUE obj, VALUE y, VALUE m, VALUE md)
|
654
|
+
{
|
655
|
+
int iy, im, imd, a, iy2, im2, imd2;
|
656
|
+
|
657
|
+
im = NUM2INT(m); CHECK_DOMAIN2(im, 1, 12);
|
658
|
+
imd = NUM2INT(md); CHECK_DOMAIN2(imd, 1, 31);
|
659
|
+
iy = NUM2INT(y);
|
660
|
+
a = world_to_rd(iy, im, imd);
|
661
|
+
rd_to_world(a, &iy2, &im2, &imd2);
|
662
|
+
if (im != im2 || imd != imd2 || iy != iy2)
|
663
|
+
rb_raise(rb_eArgError, "invalid date");
|
664
|
+
return INT2NUM(a);
|
665
|
+
}
|
666
|
+
|
667
|
+
static VALUE
|
668
|
+
calendrical_rd_to_world(VALUE obj, VALUE a)
|
669
|
+
{
|
670
|
+
int ia, y, m, md;
|
671
|
+
|
672
|
+
ia = NUM2INT(a);
|
673
|
+
rd_to_world(ia, &y, &m, &md);
|
674
|
+
return rb_ary_new3(3, INT2NUM(y), INT2NUM(m), INT2NUM(md));
|
675
|
+
}
|
676
|
+
|
677
|
+
static VALUE
|
678
|
+
calendrical_rd_to_world_day_of_week(VALUE obj, VALUE a)
|
679
|
+
{
|
680
|
+
int ia, w;
|
681
|
+
|
682
|
+
ia = NUM2INT(a);
|
683
|
+
w = rd_to_world_day_of_week(ia);
|
684
|
+
return INT2NUM(w);
|
685
|
+
}
|
686
|
+
|
687
|
+
static VALUE
|
688
|
+
calendrical_coptic_leap_year(VALUE obj, VALUE y)
|
689
|
+
{
|
690
|
+
int iy, l;
|
691
|
+
|
692
|
+
iy = NUM2INT(y);
|
693
|
+
l = coptic_leap_year(iy);
|
694
|
+
return INT2BOOL(l);
|
695
|
+
}
|
696
|
+
|
697
|
+
static VALUE
|
698
|
+
calendrical_coptic_last_day_of_month(VALUE obj, VALUE y, VALUE m)
|
699
|
+
{
|
700
|
+
int iy, im, md;
|
701
|
+
|
702
|
+
im = NUM2INT(m); CHECK_DOMAIN2(im, 1, 13);
|
703
|
+
iy = NUM2INT(y);
|
704
|
+
md = coptic_last_day_of_month(iy, im);
|
705
|
+
return INT2NUM(md);
|
706
|
+
}
|
707
|
+
|
708
|
+
static VALUE
|
709
|
+
calendrical_coptic_to_rd(VALUE obj, VALUE y, VALUE m, VALUE md)
|
710
|
+
{
|
711
|
+
int iy, im, imd, a, iy2, im2, imd2;
|
712
|
+
|
713
|
+
im = NUM2INT(m); CHECK_DOMAIN2(im, 1, 13);
|
714
|
+
imd = NUM2INT(md); CHECK_DOMAIN2(imd, 1, 30);
|
715
|
+
iy = NUM2INT(y);
|
716
|
+
a = coptic_to_rd(iy, im, imd);
|
717
|
+
rd_to_coptic(a, &iy2, &im2, &imd2);
|
718
|
+
if (im != im2 || imd != imd2 || iy != iy2)
|
719
|
+
rb_raise(rb_eArgError, "invalid date");
|
720
|
+
return INT2NUM(a);
|
721
|
+
}
|
722
|
+
|
723
|
+
static VALUE
|
724
|
+
calendrical_rd_to_coptic(VALUE obj, VALUE a)
|
725
|
+
{
|
726
|
+
int ia, y, m, md;
|
727
|
+
|
728
|
+
ia = NUM2INT(a);
|
729
|
+
rd_to_coptic(ia, &y, &m, &md);
|
730
|
+
return rb_ary_new3(3, INT2NUM(y), INT2NUM(m), INT2NUM(md));
|
731
|
+
}
|
732
|
+
|
733
|
+
static VALUE
|
734
|
+
calendrical_ethiopian_leap_year(VALUE obj, VALUE y)
|
735
|
+
{
|
736
|
+
int iy, l;
|
737
|
+
|
738
|
+
iy = NUM2INT(y);
|
739
|
+
l = ethiopian_leap_year(iy);
|
740
|
+
return INT2BOOL(l);
|
741
|
+
}
|
742
|
+
|
743
|
+
static VALUE
|
744
|
+
calendrical_ethiopian_last_day_of_month(VALUE obj, VALUE y, VALUE m)
|
745
|
+
{
|
746
|
+
int iy, im, md;
|
747
|
+
|
748
|
+
im = NUM2INT(m); CHECK_DOMAIN2(im, 1, 13);
|
749
|
+
iy = NUM2INT(y);
|
750
|
+
md = ethiopian_last_day_of_month(iy, im);
|
751
|
+
return INT2NUM(md);
|
752
|
+
}
|
753
|
+
|
754
|
+
static VALUE
|
755
|
+
calendrical_ethiopian_to_rd(VALUE obj, VALUE y, VALUE m, VALUE md)
|
756
|
+
{
|
757
|
+
int iy, im, imd, a, iy2, im2, imd2;
|
758
|
+
|
759
|
+
im = NUM2INT(m); CHECK_DOMAIN2(im, 1, 13);
|
760
|
+
imd = NUM2INT(md); CHECK_DOMAIN2(imd, 1, 30);
|
761
|
+
iy = NUM2INT(y);
|
762
|
+
a = ethiopian_to_rd(iy, im, imd);
|
763
|
+
rd_to_ethiopian(a, &iy2, &im2, &imd2);
|
764
|
+
if (im != im2 || imd != imd2 || iy != iy2)
|
765
|
+
rb_raise(rb_eArgError, "invalid date");
|
766
|
+
return INT2NUM(a);
|
767
|
+
}
|
768
|
+
|
769
|
+
static VALUE
|
770
|
+
calendrical_rd_to_ethiopian(VALUE obj, VALUE a)
|
771
|
+
{
|
772
|
+
int ia, y, m, md;
|
773
|
+
|
774
|
+
ia = NUM2INT(a);
|
775
|
+
rd_to_ethiopian(ia, &y, &m, &md);
|
776
|
+
return rb_ary_new3(3, INT2NUM(y), INT2NUM(m), INT2NUM(md));
|
777
|
+
}
|
778
|
+
|
779
|
+
static VALUE
|
780
|
+
calendrical_jalali_leap_year(VALUE obj, VALUE y)
|
781
|
+
{
|
782
|
+
int iy, l;
|
783
|
+
|
784
|
+
iy = NUM2INT(y);
|
785
|
+
l = jalali_leap_year(iy);
|
786
|
+
return INT2BOOL(l);
|
787
|
+
}
|
788
|
+
|
789
|
+
static VALUE
|
790
|
+
calendrical_jalali_last_day_of_month(VALUE obj, VALUE y, VALUE m)
|
791
|
+
{
|
792
|
+
int iy, im, md;
|
793
|
+
|
794
|
+
im = NUM2INT(m); CHECK_DOMAIN2(im, 1, 12);
|
795
|
+
iy = NUM2INT(y);
|
796
|
+
md = jalali_last_day_of_month(iy, im);
|
797
|
+
return INT2NUM(md);
|
798
|
+
}
|
799
|
+
|
800
|
+
static VALUE
|
801
|
+
calendrical_jalali_to_rd(VALUE obj, VALUE y, VALUE m, VALUE md)
|
802
|
+
{
|
803
|
+
int iy, im, imd, a, iy2, im2, imd2;
|
804
|
+
|
805
|
+
im = NUM2INT(m); CHECK_DOMAIN2(im, 1, 12);
|
806
|
+
imd = NUM2INT(md); CHECK_DOMAIN2(imd, 1, 31);
|
807
|
+
iy = NUM2INT(y);
|
808
|
+
a = jalali_to_rd(iy, im, imd);
|
809
|
+
rd_to_jalali(a, &iy2, &im2, &imd2);
|
810
|
+
if (im != im2 || imd != imd2 || iy != iy2)
|
811
|
+
rb_raise(rb_eArgError, "invalid date");
|
812
|
+
return INT2NUM(a);
|
813
|
+
}
|
814
|
+
|
815
|
+
static VALUE
|
816
|
+
calendrical_rd_to_jalali(VALUE obj, VALUE a)
|
817
|
+
{
|
818
|
+
int ia, y, m, md;
|
819
|
+
|
820
|
+
ia = NUM2INT(a);
|
821
|
+
rd_to_jalali(ia, &y, &m, &md);
|
822
|
+
return rb_ary_new3(3, INT2NUM(y), INT2NUM(m), INT2NUM(md));
|
823
|
+
}
|
824
|
+
|
825
|
+
static VALUE
|
826
|
+
calendrical_bahai_leap_year(VALUE obj, VALUE y)
|
827
|
+
{
|
828
|
+
int iy, l;
|
829
|
+
|
830
|
+
iy = NUM2INT(y);
|
831
|
+
l = bahai_leap_year(iy);
|
832
|
+
return INT2BOOL(l);
|
833
|
+
}
|
834
|
+
|
835
|
+
static VALUE
|
836
|
+
calendrical_bahai_last_day_of_month(VALUE obj, VALUE y, VALUE m)
|
837
|
+
{
|
838
|
+
int iy, im, md;
|
839
|
+
|
840
|
+
im = NUM2INT(m); CHECK_DOMAIN2(im, 1, 20);
|
841
|
+
iy = NUM2INT(y);
|
842
|
+
md = bahai_last_day_of_month(iy, im);
|
843
|
+
return INT2NUM(md);
|
844
|
+
}
|
845
|
+
|
846
|
+
static VALUE
|
847
|
+
calendrical_bahai_to_rd(VALUE obj, VALUE y, VALUE m, VALUE md)
|
848
|
+
{
|
849
|
+
int iy, im, imd, a, iy2, im2, imd2;
|
850
|
+
|
851
|
+
im = NUM2INT(m); CHECK_DOMAIN2(im, 1, 20);
|
852
|
+
imd = NUM2INT(md); CHECK_DOMAIN2(imd, 1, 19);
|
853
|
+
iy = NUM2INT(y);
|
854
|
+
a = bahai_to_rd(iy, im, imd);
|
855
|
+
rd_to_bahai(a, &iy2, &im2, &imd2);
|
856
|
+
if (im != im2 || imd != imd2 || iy != iy2)
|
857
|
+
rb_raise(rb_eArgError, "invalid date");
|
858
|
+
return INT2NUM(a);
|
859
|
+
}
|
860
|
+
|
861
|
+
static VALUE
|
862
|
+
calendrical_rd_to_bahai(VALUE obj, VALUE a)
|
863
|
+
{
|
864
|
+
int ia, y, m, md;
|
865
|
+
|
866
|
+
ia = NUM2INT(a);
|
867
|
+
rd_to_bahai(ia, &y, &m, &md);
|
868
|
+
return rb_ary_new3(3, INT2NUM(y), INT2NUM(m), INT2NUM(md));
|
869
|
+
}
|
870
|
+
|
871
|
+
static VALUE
|
872
|
+
calendrical_bahai_year_to_vahid(VALUE obj, VALUE y)
|
873
|
+
{
|
874
|
+
int iy, k, v, iy2;
|
875
|
+
|
876
|
+
iy = NUM2INT(y);
|
877
|
+
bahai_year_to_vahid(iy, &k, &v, &iy2);
|
878
|
+
return rb_ary_new3(3, INT2NUM(k), INT2NUM(v), INT2NUM(iy2));
|
879
|
+
}
|
880
|
+
|
881
|
+
static VALUE
|
882
|
+
calendrical_bahai_vahid_to_year(VALUE obj, VALUE k, VALUE v, VALUE y)
|
883
|
+
{
|
884
|
+
int ik, iv, iy, iy2;
|
885
|
+
|
886
|
+
ik = NUM2INT(k);
|
887
|
+
iv = NUM2INT(v); CHECK_DOMAIN2(iv, 1, 19);
|
888
|
+
iy = NUM2INT(y); CHECK_DOMAIN2(iy, 1, 19);
|
889
|
+
iy2 = bahai_vahid_to_year(ik, iv, iy);
|
890
|
+
return INT2NUM(iy2);
|
891
|
+
}
|
892
|
+
|
893
|
+
static VALUE
|
894
|
+
calendrical_indian_national_leap_year(VALUE obj, VALUE y)
|
895
|
+
{
|
896
|
+
int iy, l;
|
897
|
+
|
898
|
+
iy = NUM2INT(y);
|
899
|
+
l = indian_national_leap_year(iy);
|
900
|
+
return INT2BOOL(l);
|
901
|
+
}
|
902
|
+
|
903
|
+
static VALUE
|
904
|
+
calendrical_indian_national_last_day_of_month(VALUE obj, VALUE y, VALUE m)
|
905
|
+
{
|
906
|
+
int iy, im, md;
|
907
|
+
|
908
|
+
im = NUM2INT(m); CHECK_DOMAIN2(im, 1, 12);
|
909
|
+
iy = NUM2INT(y);
|
910
|
+
md = indian_national_last_day_of_month(iy, im);
|
911
|
+
return INT2NUM(md);
|
912
|
+
}
|
913
|
+
|
914
|
+
static VALUE
|
915
|
+
calendrical_indian_national_to_rd(VALUE obj, VALUE y, VALUE m, VALUE md)
|
916
|
+
{
|
917
|
+
int iy, im, imd, a, iy2, im2, imd2;
|
918
|
+
|
919
|
+
im = NUM2INT(m); CHECK_DOMAIN2(im, 1, 12);
|
920
|
+
imd = NUM2INT(md); CHECK_DOMAIN2(imd, 1, 31);
|
921
|
+
iy = NUM2INT(y);
|
922
|
+
a = indian_national_to_rd(iy, im, imd);
|
923
|
+
rd_to_indian_national(a, &iy2, &im2, &imd2);
|
924
|
+
if (im != im2 || imd != imd2 || iy != iy2)
|
925
|
+
rb_raise(rb_eArgError, "invalid date");
|
926
|
+
return INT2NUM(a);
|
927
|
+
}
|
928
|
+
|
929
|
+
static VALUE
|
930
|
+
calendrical_rd_to_indian_national(VALUE obj, VALUE a)
|
931
|
+
{
|
932
|
+
int ia, y, m, md;
|
933
|
+
|
934
|
+
ia = NUM2INT(a);
|
935
|
+
rd_to_indian_national(ia, &y, &m, &md);
|
936
|
+
return rb_ary_new3(3, INT2NUM(y), INT2NUM(m), INT2NUM(md));
|
937
|
+
}
|
938
|
+
|
939
|
+
static VALUE
|
940
|
+
calendrical_bengali_leap_year(VALUE obj, VALUE y)
|
941
|
+
{
|
942
|
+
int iy, l;
|
943
|
+
|
944
|
+
iy = NUM2INT(y);
|
945
|
+
l = bengali_leap_year(iy);
|
946
|
+
return INT2BOOL(l);
|
947
|
+
}
|
948
|
+
|
949
|
+
static VALUE
|
950
|
+
calendrical_bengali_last_day_of_month(VALUE obj, VALUE y, VALUE m)
|
951
|
+
{
|
952
|
+
int iy, im, md;
|
953
|
+
|
954
|
+
im = NUM2INT(m); CHECK_DOMAIN2(im, 1, 12);
|
955
|
+
iy = NUM2INT(y);
|
956
|
+
md = bengali_last_day_of_month(iy, im);
|
957
|
+
return INT2NUM(md);
|
958
|
+
}
|
959
|
+
|
960
|
+
static VALUE
|
961
|
+
calendrical_bengali_to_rd(VALUE obj, VALUE y, VALUE m, VALUE md)
|
962
|
+
{
|
963
|
+
int iy, im, imd, a, iy2, im2, imd2;
|
964
|
+
|
965
|
+
im = NUM2INT(m); CHECK_DOMAIN2(im, 1, 12);
|
966
|
+
imd = NUM2INT(md); CHECK_DOMAIN2(imd, 1, 31);
|
967
|
+
iy = NUM2INT(y);
|
968
|
+
a = bengali_to_rd(iy, im, imd);
|
969
|
+
rd_to_bengali(a, &iy2, &im2, &imd2);
|
970
|
+
if (im != im2 || imd != imd2 || iy != iy2)
|
971
|
+
rb_raise(rb_eArgError, "invalid date");
|
972
|
+
return INT2NUM(a);
|
973
|
+
}
|
974
|
+
|
975
|
+
static VALUE
|
976
|
+
calendrical_rd_to_bengali(VALUE obj, VALUE a)
|
977
|
+
{
|
978
|
+
int ia, y, m, md;
|
979
|
+
|
980
|
+
ia = NUM2INT(a);
|
981
|
+
rd_to_bengali(ia, &y, &m, &md);
|
982
|
+
return rb_ary_new3(3, INT2NUM(y), INT2NUM(m), INT2NUM(md));
|
983
|
+
}
|
984
|
+
|
985
|
+
static VALUE
|
986
|
+
calendrical_nanakshahi_leap_year(VALUE obj, VALUE y)
|
987
|
+
{
|
988
|
+
int iy, l;
|
989
|
+
|
990
|
+
iy = NUM2INT(y);
|
991
|
+
l = nanakshahi_leap_year(iy);
|
992
|
+
return INT2BOOL(l);
|
993
|
+
}
|
994
|
+
|
995
|
+
static VALUE
|
996
|
+
calendrical_nanakshahi_last_day_of_month(VALUE obj, VALUE y, VALUE m)
|
997
|
+
{
|
998
|
+
int iy, im, md;
|
999
|
+
|
1000
|
+
im = NUM2INT(m); CHECK_DOMAIN2(im, 1, 12);
|
1001
|
+
iy = NUM2INT(y);
|
1002
|
+
md = nanakshahi_last_day_of_month(iy, im);
|
1003
|
+
return INT2NUM(md);
|
1004
|
+
}
|
1005
|
+
|
1006
|
+
static VALUE
|
1007
|
+
calendrical_nanakshahi_to_rd(VALUE obj, VALUE y, VALUE m, VALUE md)
|
1008
|
+
{
|
1009
|
+
int iy, im, imd, a, iy2, im2, imd2;
|
1010
|
+
|
1011
|
+
im = NUM2INT(m); CHECK_DOMAIN2(im, 1, 12);
|
1012
|
+
imd = NUM2INT(md); CHECK_DOMAIN2(imd, 1, 31);
|
1013
|
+
iy = NUM2INT(y);
|
1014
|
+
a = nanakshahi_to_rd(iy, im, imd);
|
1015
|
+
rd_to_nanakshahi(a, &iy2, &im2, &imd2);
|
1016
|
+
if (im != im2 || imd != imd2 || iy != iy2)
|
1017
|
+
rb_raise(rb_eArgError, "invalid date");
|
1018
|
+
return INT2NUM(a);
|
1019
|
+
}
|
1020
|
+
|
1021
|
+
static VALUE
|
1022
|
+
calendrical_rd_to_nanakshahi(VALUE obj, VALUE a)
|
1023
|
+
{
|
1024
|
+
int ia, y, m, md;
|
1025
|
+
|
1026
|
+
ia = NUM2INT(a);
|
1027
|
+
rd_to_nanakshahi(ia, &y, &m, &md);
|
1028
|
+
return rb_ary_new3(3, INT2NUM(y), INT2NUM(m), INT2NUM(md));
|
1029
|
+
}
|
1030
|
+
|
1031
|
+
static VALUE
|
1032
|
+
calendrical_ordinal_to_rd(VALUE obj, VALUE y, VALUE yd)
|
1033
|
+
{
|
1034
|
+
int iy, iyd, a, iy2, iyd2;
|
1035
|
+
|
1036
|
+
iyd = NUM2INT(yd); CHECK_DOMAIN2(iyd, 1, 366);
|
1037
|
+
iy = NUM2INT(y);
|
1038
|
+
a = ordinal_to_rd(iy, iyd);
|
1039
|
+
rd_to_ordinal(a, &iy2, &iyd2);
|
1040
|
+
if (iyd != iyd2 || iy != iy2)
|
1041
|
+
rb_raise(rb_eArgError, "invalid date");
|
1042
|
+
return INT2NUM(a);
|
1043
|
+
}
|
1044
|
+
|
1045
|
+
static VALUE
|
1046
|
+
calendrical_rd_to_ordinal(VALUE obj, VALUE a)
|
1047
|
+
{
|
1048
|
+
int ia, y, yd;
|
1049
|
+
|
1050
|
+
ia = NUM2INT(a);
|
1051
|
+
rd_to_ordinal(ia, &y, &yd);
|
1052
|
+
return rb_ary_new3(2, INT2NUM(y), INT2NUM(yd));
|
1053
|
+
}
|
1054
|
+
|
1055
|
+
static VALUE
|
1056
|
+
calendrical_jd_to_rd(VALUE obj, VALUE j)
|
1057
|
+
{
|
1058
|
+
int ij, a;
|
1059
|
+
|
1060
|
+
ij = NUM2INT(j);
|
1061
|
+
a = jd_to_rd(ij);
|
1062
|
+
return INT2NUM(a);
|
1063
|
+
}
|
1064
|
+
|
1065
|
+
static VALUE
|
1066
|
+
calendrical_rd_to_jd(VALUE obj, VALUE a)
|
1067
|
+
{
|
1068
|
+
int ia, j;
|
1069
|
+
|
1070
|
+
ia = NUM2INT(a);
|
1071
|
+
j = rd_to_jd(ia);
|
1072
|
+
return INT2NUM(j);
|
1073
|
+
}
|
1074
|
+
|
1075
|
+
static VALUE
|
1076
|
+
calendrical_mjd_to_rd(VALUE obj, VALUE m)
|
1077
|
+
{
|
1078
|
+
int im, a;
|
1079
|
+
|
1080
|
+
im = NUM2INT(m);
|
1081
|
+
a = mjd_to_rd(im);
|
1082
|
+
return INT2NUM(a);
|
1083
|
+
}
|
1084
|
+
|
1085
|
+
static VALUE
|
1086
|
+
calendrical_rd_to_mjd(VALUE obj, VALUE a)
|
1087
|
+
{
|
1088
|
+
int ia, m;
|
1089
|
+
|
1090
|
+
ia = NUM2INT(a);
|
1091
|
+
m = rd_to_mjd(ia);
|
1092
|
+
return INT2NUM(m);
|
1093
|
+
}
|
1094
|
+
|
1095
|
+
static VALUE
|
1096
|
+
calendrical_mjd_to_jd(VALUE obj, VALUE m)
|
1097
|
+
{
|
1098
|
+
int im, j;
|
1099
|
+
|
1100
|
+
im = NUM2INT(m);
|
1101
|
+
j = mjd_to_jd(im);
|
1102
|
+
return INT2NUM(j);
|
1103
|
+
|
1104
|
+
}
|
1105
|
+
|
1106
|
+
static VALUE
|
1107
|
+
calendrical_jd_to_mjd(VALUE obj, VALUE j)
|
1108
|
+
{
|
1109
|
+
int ij, m;
|
1110
|
+
|
1111
|
+
ij = NUM2INT(j);
|
1112
|
+
m = jd_to_mjd(ij);
|
1113
|
+
return INT2NUM(m);
|
1114
|
+
}
|
1115
|
+
|
1116
|
+
static VALUE
|
1117
|
+
calendrical_ld_to_rd(VALUE obj, VALUE l)
|
1118
|
+
{
|
1119
|
+
int il, a;
|
1120
|
+
|
1121
|
+
il = NUM2INT(l);
|
1122
|
+
a = ld_to_rd(il);
|
1123
|
+
return INT2NUM(a);
|
1124
|
+
}
|
1125
|
+
|
1126
|
+
static VALUE
|
1127
|
+
calendrical_rd_to_ld(VALUE obj, VALUE a)
|
1128
|
+
{
|
1129
|
+
int ia, l;
|
1130
|
+
|
1131
|
+
ia = NUM2INT(a);
|
1132
|
+
l = rd_to_ld(ia);
|
1133
|
+
return INT2NUM(l);
|
1134
|
+
}
|
1135
|
+
|
1136
|
+
static VALUE
|
1137
|
+
calendrical_rd_to_day_of_week(VALUE obj, VALUE a)
|
1138
|
+
{
|
1139
|
+
int ia, w;
|
1140
|
+
|
1141
|
+
ia = NUM2INT(a);
|
1142
|
+
w = rd_to_day_of_week(ia);
|
1143
|
+
return INT2NUM(w);
|
1144
|
+
}
|
1145
|
+
|
1146
|
+
static VALUE
|
1147
|
+
calendrical_kyureki_to_rd(VALUE obj, VALUE y, VALUE m, VALUE l, VALUE md)
|
1148
|
+
{
|
1149
|
+
int j, a;
|
1150
|
+
QDATE q, q2;
|
1151
|
+
|
1152
|
+
q.j = 0;
|
1153
|
+
q.y = NUM2INT(y);
|
1154
|
+
q.yd = 0;
|
1155
|
+
q.m = NUM2INT(m); CHECK_DOMAIN2(q.m, 1, 12);
|
1156
|
+
q.md = NUM2INT(md); CHECK_DOMAIN2(q.md, 1, 30);
|
1157
|
+
q.wd = 0;
|
1158
|
+
q.leap = BOOL2INT(l);
|
1159
|
+
j = rqref(&q);
|
1160
|
+
if (j == 0)
|
1161
|
+
rb_raise(rb_eArgError, "invalid date");
|
1162
|
+
a = jd_to_rd(j);
|
1163
|
+
qref(j, &q2);
|
1164
|
+
if (q.y != q2.y || q.m != q2.m || q.md != q2.md || q.leap != q2.leap)
|
1165
|
+
rb_raise(rb_eArgError, "invalid date");
|
1166
|
+
return INT2NUM(a);
|
1167
|
+
}
|
1168
|
+
|
1169
|
+
static VALUE
|
1170
|
+
calendrical_rd_to_kyureki(VALUE obj, VALUE a)
|
1171
|
+
{
|
1172
|
+
int ia, j;
|
1173
|
+
QDATE q;
|
1174
|
+
|
1175
|
+
ia = NUM2INT(a); CHECK_DOMAIN2(ia, 162193, 767009);
|
1176
|
+
j = rd_to_jd(ia);
|
1177
|
+
qref(j, &q);
|
1178
|
+
if (q.j == 0)
|
1179
|
+
rb_raise(rb_eArgError, "invalid date");
|
1180
|
+
return rb_ary_new3
|
1181
|
+
(4, INT2NUM(q.y), INT2NUM(q.m), INT2BOOL(q.leap), INT2NUM(q.md));
|
1182
|
+
}
|
1183
|
+
|
1184
|
+
static VALUE
|
1185
|
+
calendrical_rd_to_kyureki_day_of_week(VALUE obj, VALUE a)
|
1186
|
+
{
|
1187
|
+
int ia, j;
|
1188
|
+
QDATE q;
|
1189
|
+
|
1190
|
+
ia = NUM2INT(a);
|
1191
|
+
j = rd_to_jd(ia);
|
1192
|
+
qref(j, &q);
|
1193
|
+
if (q.j == 0)
|
1194
|
+
rb_raise(rb_eArgError, "invalid date");
|
1195
|
+
return INT2NUM(q.wd);
|
1196
|
+
}
|
1197
|
+
|
1198
|
+
static VALUE
|
1199
|
+
mk_ary_of_str(long len, const char *a[])
|
1200
|
+
{
|
1201
|
+
VALUE o;
|
1202
|
+
long i;
|
1203
|
+
|
1204
|
+
o = rb_ary_new2(len);
|
1205
|
+
for (i = 0; i < len; i++) {
|
1206
|
+
VALUE e;
|
1207
|
+
|
1208
|
+
if (!a[i])
|
1209
|
+
e = Qnil;
|
1210
|
+
else {
|
1211
|
+
e = rb_str_new2(a[i]);
|
1212
|
+
#ifdef HAVE_RUBY_ENCODING_H
|
1213
|
+
rb_enc_associate(e, rb_utf8_encoding());
|
1214
|
+
ENC_CODERANGE_CLEAR(e);
|
1215
|
+
#endif
|
1216
|
+
rb_obj_freeze(e);
|
1217
|
+
}
|
1218
|
+
rb_ary_push(o, e);
|
1219
|
+
}
|
1220
|
+
rb_obj_freeze(o);
|
1221
|
+
return o;
|
1222
|
+
}
|
1223
|
+
|
1224
|
+
static const char *day_names[] = {
|
1225
|
+
"Sunday", "Monday", "Tuesday",
|
1226
|
+
"Wednesday", "Thursday",
|
1227
|
+
"Friday", "Saturday"
|
1228
|
+
};
|
1229
|
+
|
1230
|
+
static const char *month_names[] = {
|
1231
|
+
"*", "January", "February", "March",
|
1232
|
+
"April", "May", "June", "July",
|
1233
|
+
"August", "September", "October",
|
1234
|
+
"November", "December"
|
1235
|
+
};
|
1236
|
+
|
1237
|
+
static const char *islamic_day_names[] = {
|
1238
|
+
"al-Aḥad", "al-Ithnayn",
|
1239
|
+
"ath-Thalaathaaʼ", "al-Arba‘aa’",
|
1240
|
+
"al-Khamīs", "al-Jumu‘ah", "as-Sabt"
|
1241
|
+
};
|
1242
|
+
|
1243
|
+
static const char *islamic_month_names[] = {
|
1244
|
+
"*", "Muḥarram", "Ṣafar",
|
1245
|
+
"Rabīʿ I", "Rabīʿ II",
|
1246
|
+
"Jumādā I", "Jumādā II",
|
1247
|
+
"Rajab", "Shaʿbān",
|
1248
|
+
"Ramaḍān", "Shawwāl",
|
1249
|
+
"Dhū al-Qaʿda", "Dhū al-Ḥijja"
|
1250
|
+
};
|
1251
|
+
|
1252
|
+
static const char *hebrew_day_names[] = {
|
1253
|
+
"Yom Rishon", "Yom Sheni", "Yom Shlishi",
|
1254
|
+
"Yom Reviʻi", "Yom Chamishi",
|
1255
|
+
"Yom Shishi", "Yom Shabbat"
|
1256
|
+
};
|
1257
|
+
|
1258
|
+
static const char *hebrew_common_year_month_names[] = {
|
1259
|
+
"*", "Nisan", "Iyyar",
|
1260
|
+
"Sivan", "Tammuz", "Av",
|
1261
|
+
"Elul", "Tishri", "Heshvan",
|
1262
|
+
"Kislev", "Teveth", "Shevat",
|
1263
|
+
"Adar", "*"
|
1264
|
+
};
|
1265
|
+
|
1266
|
+
static const char *hebrew_leap_year_month_names[] = {
|
1267
|
+
"*", "Nisan", "Iyyar",
|
1268
|
+
"Sivan", "Tammuz", "Av",
|
1269
|
+
"Elul", "Tishri", "Heshvan",
|
1270
|
+
"Kislev", "Teveth", "Shevat",
|
1271
|
+
"Adar I", "Adar II"
|
1272
|
+
};
|
1273
|
+
|
1274
|
+
static const char *mayan_haab_month_names[] = {
|
1275
|
+
"*", "Pop", "Wo'",
|
1276
|
+
"Sip", "Sotz'", "Sek",
|
1277
|
+
"Xul", "Yaxk'in'", "Mol",
|
1278
|
+
"Ch'en", "Yax", "Sak'",
|
1279
|
+
"Keh", "Mak", "K'ank'in",
|
1280
|
+
"Muwan'", "Pax", "K'ayab",
|
1281
|
+
"Kumk'u", "Wayeb'"
|
1282
|
+
};
|
1283
|
+
|
1284
|
+
static const char *mayan_tzolkin_month_names[] = {
|
1285
|
+
"*", "Imix'", "Ik'",
|
1286
|
+
"Ak'b'al", "K'an", "Chikchan",
|
1287
|
+
"Kimi", "Manik'", "Lamat",
|
1288
|
+
"Muluk", "Ok", "Chuwen",
|
1289
|
+
"Eb'", "B'en", "Ix",
|
1290
|
+
"Men", "K'ib'", "Kab'an",
|
1291
|
+
"Etz'nab'", "Kawak", "Ajaw"
|
1292
|
+
};
|
1293
|
+
|
1294
|
+
static const char *french_day_names[] = {
|
1295
|
+
"Primidi", "Doudi",
|
1296
|
+
"Tridi", "Quartidi",
|
1297
|
+
"Quintidi", "Sextidi",
|
1298
|
+
"Septidi", "Octidi",
|
1299
|
+
"Nonidi", "Décadi"
|
1300
|
+
};
|
1301
|
+
|
1302
|
+
static const char *french_sansculottides_names[] = {
|
1303
|
+
"Vertu", "Génie",
|
1304
|
+
"Labour", "Raison",
|
1305
|
+
"Récompenses", "Révolution",
|
1306
|
+
"*", "*", "*", "*"
|
1307
|
+
};
|
1308
|
+
|
1309
|
+
static const char *french_month_names[] = {
|
1310
|
+
"*", "Vendémiaire",
|
1311
|
+
"Brumaire", "Frimaire",
|
1312
|
+
"Nivôse", "Pluviôse",
|
1313
|
+
"Ventôse", "Germinal",
|
1314
|
+
"Floréal", "Prairial",
|
1315
|
+
"Messidor", "Thermidor",
|
1316
|
+
"Fructidor", "(Sansculottides)"
|
1317
|
+
};
|
1318
|
+
|
1319
|
+
static const char *old_hindu_solar_month_names[] = {
|
1320
|
+
"*", "Meṣa", "Vṛṣabha",
|
1321
|
+
"Mithuna", "Karkaṭa", "Siṃha",
|
1322
|
+
"Kanyā", "Tulā", "Vṛścika",
|
1323
|
+
"Dhanu", "Makara", "Kumbha",
|
1324
|
+
"Mīna"
|
1325
|
+
};
|
1326
|
+
|
1327
|
+
static const char *old_hindu_lunar_month_names[] = {
|
1328
|
+
"*", "Chaitra", "Vaiśākha",
|
1329
|
+
"Jyaiṣṭha", "Āṣāḍha",
|
1330
|
+
"Śrāvaṇa", "Bhādrapada",
|
1331
|
+
"Āśvina", "Kārtika",
|
1332
|
+
"Mārgaśīrṣa", "Pauṣa",
|
1333
|
+
"Māgha", "Phālguna"
|
1334
|
+
};
|
1335
|
+
|
1336
|
+
static const char *world_day_names[] = {
|
1337
|
+
"Sunday", "Monday", "Tuesday",
|
1338
|
+
"Wednesday", "Thursday",
|
1339
|
+
"Friday", "Saturday",
|
1340
|
+
"World", "Leap"
|
1341
|
+
};
|
1342
|
+
|
1343
|
+
static const char *coptic_month_names[] = {
|
1344
|
+
"*", "Tut", "Babah",
|
1345
|
+
"Hatur", "Kiyahk", "Tubah",
|
1346
|
+
"Amshir", "Baramhat",
|
1347
|
+
"Baramundah", "Bashans",
|
1348
|
+
"Ba'unah", "Abib", "Misra",
|
1349
|
+
"al-Nasi"
|
1350
|
+
};
|
1351
|
+
|
1352
|
+
static const char *ethiopian_month_names[] = {
|
1353
|
+
"*", "Mäskäräm", "Ṭəqəmt",
|
1354
|
+
"Ḫədar", "Taḫśaś'", "Ṭərr",
|
1355
|
+
"Yäkatit", "Mägabit",
|
1356
|
+
"Miyazya", "Gənbot", "Säne",
|
1357
|
+
"Ḥamle", "Nähase",
|
1358
|
+
"Ṗagʷəmen"
|
1359
|
+
};
|
1360
|
+
|
1361
|
+
static const char *jalali_month_names[] = {
|
1362
|
+
"*", "Farvardin",
|
1363
|
+
"Ordibehesht ", "Khordad",
|
1364
|
+
"Tir", "Mordad", "Shahrivar",
|
1365
|
+
"Mehr", "Aban", "Azar",
|
1366
|
+
"Dey", "Bahman", "Esfand"
|
1367
|
+
};
|
1368
|
+
|
1369
|
+
static const char *bahai_day_names[] = {
|
1370
|
+
"Jamál", "Kamál", "Fiḍál",
|
1371
|
+
"‘Idál", "Istijlál",
|
1372
|
+
"Istiqlál", "Jalál"
|
1373
|
+
};
|
1374
|
+
|
1375
|
+
static const char *bahai_month_names[] = {
|
1376
|
+
"*", "Bahá", "Jalál",
|
1377
|
+
"Jamál", "‘Aẓamat", "Núr",
|
1378
|
+
"Raḥmat", "Kalimát", "Kamál",
|
1379
|
+
"Asmá’", "‘Izzat", "Mashíyyat",
|
1380
|
+
"‘Ilm", "Qudrat", "Qawl",
|
1381
|
+
"Masá’il", "Sharaf", "Sulṭán",
|
1382
|
+
"Mulk", "Ayyám-i-Há", "‘Alá’"
|
1383
|
+
};
|
1384
|
+
|
1385
|
+
static const char *bahai_vahid_names[] = {
|
1386
|
+
"*", "Alif", "Bá’",
|
1387
|
+
"Ab", "Dál", "Báb",
|
1388
|
+
"Váv", "Abad", "Jád",
|
1389
|
+
"Bahá'", "Ḥubb", "Bahháj",
|
1390
|
+
"Javáb", "Aḥad", "Vahháb",
|
1391
|
+
"Vidád", "Badí‘", "Bahí",
|
1392
|
+
"Abhá", "Váḥid"
|
1393
|
+
};
|
1394
|
+
|
1395
|
+
static const char *indian_national_month_names[] = {
|
1396
|
+
"*", "Chaitra", "Vaishākha",
|
1397
|
+
"Jyaishtha", "Āshādha",
|
1398
|
+
"Shrāvana", "Bhādrapada",
|
1399
|
+
"Āshwin", "Kārtika",
|
1400
|
+
"Agrahayana", "Pausha",
|
1401
|
+
"Māgha", "Phālguna"
|
1402
|
+
};
|
1403
|
+
|
1404
|
+
static const char *bengali_day_names[] = {
|
1405
|
+
"Rôbibar", "Sombar",
|
1406
|
+
"Mônggôlbar", "Budhbar",
|
1407
|
+
"Brihôspôtibar", "Shukrôbar",
|
1408
|
+
"Shônibar"
|
1409
|
+
};
|
1410
|
+
|
1411
|
+
static const char *bengali_month_names[] = {
|
1412
|
+
"*", "Bôishakh", "Jyôishţhô",
|
1413
|
+
"Ashaŗh", "Shrabôn",
|
1414
|
+
"Bhadrô", "Ashbin",
|
1415
|
+
"Kartik", "Ogrôhayôn",
|
1416
|
+
"Poush", "Magh",
|
1417
|
+
"Falgun", "Chôitrô"
|
1418
|
+
};
|
1419
|
+
|
1420
|
+
static const char *nanakshahi_month_names[] = {
|
1421
|
+
"*", "Chet",
|
1422
|
+
"Vaisakh", "Jeth",
|
1423
|
+
"Harh", "Sawan",
|
1424
|
+
"Bhadon", "Assu",
|
1425
|
+
"Katak", "Maghar",
|
1426
|
+
"Poh", "Magh",
|
1427
|
+
"Phagun"
|
1428
|
+
};
|
1429
|
+
|
1430
|
+
static const char *kyureki_day_names[] = {
|
1431
|
+
"Senkachi", "Tomobiki",
|
1432
|
+
"Semmake", "Butsumetsu",
|
1433
|
+
"Taian", "Shakku"
|
1434
|
+
};
|
1435
|
+
|
1436
|
+
static const char *kyureki_month_names[] = {
|
1437
|
+
"*", "Mutsuki", "Kisaragi",
|
1438
|
+
"Yayoi", "Uzuki", "Satsuki",
|
1439
|
+
"Minazuki", "Fuzuki",
|
1440
|
+
"Hazuki", "Nagatsuki",
|
1441
|
+
"Kannazuki", "Shimotsuki",
|
1442
|
+
"Shiwasu"
|
1443
|
+
};
|
1444
|
+
|
1445
|
+
void
|
1446
|
+
Init_calendrical(void)
|
1447
|
+
{
|
1448
|
+
VALUE mod, cc_month_names;
|
1449
|
+
|
1450
|
+
mod = rb_define_module("Calendrical");
|
1451
|
+
rb_define_module_function
|
1452
|
+
(mod, "gregorian_leap_year", calendrical_gregorian_leap_year, 1);
|
1453
|
+
rb_define_module_function
|
1454
|
+
(mod, "gregorian_leap_year?", calendrical_gregorian_leap_year, 1);
|
1455
|
+
rb_define_module_function
|
1456
|
+
(mod, "gregorian_last_day_of_month",
|
1457
|
+
calendrical_gregorian_last_day_of_month, 2);
|
1458
|
+
rb_define_module_function
|
1459
|
+
(mod, "gregorian_to_rd", calendrical_gregorian_to_rd, 3);
|
1460
|
+
rb_define_module_function
|
1461
|
+
(mod, "rd_to_gregorian", calendrical_rd_to_gregorian, 1);
|
1462
|
+
rb_define_module_function
|
1463
|
+
(mod, "kday_on_or_before", calendrical_kday_on_or_before, 2);
|
1464
|
+
|
1465
|
+
rb_define_module_function
|
1466
|
+
(mod, "iso_to_rd", calendrical_iso_to_rd, 3);
|
1467
|
+
rb_define_module_function
|
1468
|
+
(mod, "rd_to_iso", calendrical_rd_to_iso, 1);
|
1469
|
+
rb_define_module_function
|
1470
|
+
(mod, "week_date_to_rd", calendrical_iso_to_rd, 3);
|
1471
|
+
rb_define_module_function
|
1472
|
+
(mod, "rd_to_week_date", calendrical_rd_to_iso, 1);
|
1473
|
+
|
1474
|
+
rb_define_module_function
|
1475
|
+
(mod, "julian_leap_year", calendrical_julian_leap_year, 1);
|
1476
|
+
rb_define_module_function
|
1477
|
+
(mod, "julian_leap_year?", calendrical_julian_leap_year, 1);
|
1478
|
+
rb_define_module_function
|
1479
|
+
(mod, "julian_last_day_of_month",
|
1480
|
+
calendrical_julian_last_day_of_month, 2);
|
1481
|
+
rb_define_module_function
|
1482
|
+
(mod, "julian_to_rd", calendrical_julian_to_rd, 3);
|
1483
|
+
rb_define_module_function
|
1484
|
+
(mod, "rd_to_julian", calendrical_rd_to_julian, 1);
|
1485
|
+
|
1486
|
+
rb_define_module_function
|
1487
|
+
(mod, "islamic_leap_year", calendrical_islamic_leap_year, 1);
|
1488
|
+
rb_define_module_function
|
1489
|
+
(mod, "islamic_leap_year?", calendrical_islamic_leap_year, 1);
|
1490
|
+
rb_define_module_function
|
1491
|
+
(mod, "islamic_last_day_of_month",
|
1492
|
+
calendrical_islamic_last_day_of_month, 2);
|
1493
|
+
rb_define_module_function
|
1494
|
+
(mod, "islamic_to_rd", calendrical_islamic_to_rd, 3);
|
1495
|
+
rb_define_module_function
|
1496
|
+
(mod, "rd_to_islamic", calendrical_rd_to_islamic, 1);
|
1497
|
+
|
1498
|
+
rb_define_module_function
|
1499
|
+
(mod, "hebrew_leap_year", calendrical_hebrew_leap_year, 1);
|
1500
|
+
rb_define_module_function
|
1501
|
+
(mod, "hebrew_leap_year?", calendrical_hebrew_leap_year, 1);
|
1502
|
+
rb_define_module_function
|
1503
|
+
(mod, "hebrew_last_month_of_year",
|
1504
|
+
calendrical_hebrew_last_month_of_year, 1);
|
1505
|
+
rb_define_module_function
|
1506
|
+
(mod, "hebrew_last_day_of_month",
|
1507
|
+
calendrical_hebrew_last_day_of_month, 2);
|
1508
|
+
rb_define_module_function
|
1509
|
+
(mod, "hebrew_calendar_elapsed_days",
|
1510
|
+
calendrical_hebrew_calendar_elapsed_days, 1);
|
1511
|
+
rb_define_module_function
|
1512
|
+
(mod, "hebrew_days_in_year", calendrical_hebrew_days_in_year, 1);
|
1513
|
+
rb_define_module_function
|
1514
|
+
(mod, "long_heshvan", calendrical_long_heshvan, 1);
|
1515
|
+
rb_define_module_function
|
1516
|
+
(mod, "long_heshvan?", calendrical_long_heshvan, 1);
|
1517
|
+
rb_define_module_function
|
1518
|
+
(mod, "short_kislev", calendrical_short_kislev, 1);
|
1519
|
+
rb_define_module_function
|
1520
|
+
(mod, "short_kislev?", calendrical_short_kislev, 1);
|
1521
|
+
rb_define_module_function
|
1522
|
+
(mod, "hebrew_to_rd", calendrical_hebrew_to_rd, 3);
|
1523
|
+
rb_define_module_function
|
1524
|
+
(mod, "rd_to_hebrew", calendrical_rd_to_hebrew, 1);
|
1525
|
+
|
1526
|
+
rb_define_module_function
|
1527
|
+
(mod, "nth_kday", calendrical_nth_kday, 4);
|
1528
|
+
rb_define_module_function
|
1529
|
+
(mod, "nicaean_rule_easter", calendrical_nicaean_rule_easter, 1);
|
1530
|
+
rb_define_module_function
|
1531
|
+
(mod, "easter", calendrical_easter, 1);
|
1532
|
+
|
1533
|
+
rb_define_module_function
|
1534
|
+
(mod, "mayan_long_count_to_rd",
|
1535
|
+
calendrical_mayan_long_count_to_rd, 5);
|
1536
|
+
rb_define_module_function
|
1537
|
+
(mod, "rd_to_mayan_long_count",
|
1538
|
+
calendrical_rd_to_mayan_long_count, 1);
|
1539
|
+
rb_define_module_function
|
1540
|
+
(mod, "rd_to_mayan_haab",
|
1541
|
+
calendrical_rd_to_mayan_haab, 1);
|
1542
|
+
rb_define_module_function
|
1543
|
+
(mod, "mayan_haab_difference", calendrical_mayan_haab_difference, 4);
|
1544
|
+
rb_define_module_function
|
1545
|
+
(mod, "mayan_haab_on_or_before", calendrical_mayan_haab_on_or_before, 3);
|
1546
|
+
rb_define_module_function
|
1547
|
+
(mod, "rd_to_mayan_tzolkin",
|
1548
|
+
calendrical_rd_to_mayan_tzolkin, 1);
|
1549
|
+
rb_define_module_function
|
1550
|
+
(mod, "mayan_tzolkin_difference",
|
1551
|
+
calendrical_mayan_tzolkin_difference, 4);
|
1552
|
+
rb_define_module_function
|
1553
|
+
(mod, "mayan_tzolkin_on_or_before",
|
1554
|
+
calendrical_mayan_tzolkin_on_or_before, 3);
|
1555
|
+
rb_define_module_function
|
1556
|
+
(mod, "mayan_haab_tzolkin_on_or_before",
|
1557
|
+
calendrical_mayan_haab_tzolkin_on_or_before, 5);
|
1558
|
+
|
1559
|
+
rb_define_module_function
|
1560
|
+
(mod, "french_leap_year", calendrical_french_leap_year, 1);
|
1561
|
+
rb_define_module_function
|
1562
|
+
(mod, "french_leap_year?", calendrical_french_leap_year, 1);
|
1563
|
+
rb_define_module_function
|
1564
|
+
(mod, "french_last_day_of_month",
|
1565
|
+
calendrical_french_last_day_of_month, 2);
|
1566
|
+
rb_define_module_function
|
1567
|
+
(mod, "french_to_rd", calendrical_french_to_rd, 3);
|
1568
|
+
rb_define_module_function
|
1569
|
+
(mod, "rd_to_french", calendrical_rd_to_french, 1);
|
1570
|
+
|
1571
|
+
rb_define_module_function
|
1572
|
+
(mod, "solar_longitude", calendrical_solar_longitude, 1);
|
1573
|
+
rb_define_module_function
|
1574
|
+
(mod, "zodiac", calendrical_zodiac, 1);
|
1575
|
+
rb_define_module_function
|
1576
|
+
(mod, "rd_to_old_hindu_solar",
|
1577
|
+
calendrical_rd_to_old_hindu_solar, 1);
|
1578
|
+
rb_define_module_function
|
1579
|
+
(mod, "old_hindu_solar_to_rd",
|
1580
|
+
calendrical_old_hindu_solar_to_rd, 3);
|
1581
|
+
rb_define_module_function
|
1582
|
+
(mod, "lunar_longitude", calendrical_lunar_longitude, 1);
|
1583
|
+
rb_define_module_function
|
1584
|
+
(mod, "lunar_phase", calendrical_lunar_phase, 1);
|
1585
|
+
rb_define_module_function
|
1586
|
+
(mod, "new_moon", calendrical_new_moon, 1);
|
1587
|
+
rb_define_module_function
|
1588
|
+
(mod, "rd_to_old_hindu_lunar",
|
1589
|
+
calendrical_rd_to_old_hindu_lunar, 1);
|
1590
|
+
rb_define_module_function
|
1591
|
+
(mod, "old_hindu_lunar_precedes",
|
1592
|
+
calendrical_old_hindu_lunar_precedes, 8);
|
1593
|
+
rb_define_module_function
|
1594
|
+
(mod, "old_hindu_lunar_to_rd",
|
1595
|
+
calendrical_old_hindu_lunar_to_rd, 4);
|
1596
|
+
|
1597
|
+
rb_define_module_function
|
1598
|
+
(mod, "world_leap_year", calendrical_world_leap_year, 1);
|
1599
|
+
rb_define_module_function
|
1600
|
+
(mod, "world_leap_year?", calendrical_world_leap_year, 1);
|
1601
|
+
rb_define_module_function
|
1602
|
+
(mod, "world_last_day_of_month", calendrical_world_last_day_of_month, 2);
|
1603
|
+
rb_define_module_function
|
1604
|
+
(mod, "world_to_rd", calendrical_world_to_rd, 3);
|
1605
|
+
rb_define_module_function
|
1606
|
+
(mod, "rd_to_world", calendrical_rd_to_world, 1);
|
1607
|
+
rb_define_module_function
|
1608
|
+
(mod, "rd_to_world_day_of_week",
|
1609
|
+
calendrical_rd_to_world_day_of_week, 1);
|
1610
|
+
|
1611
|
+
rb_define_module_function
|
1612
|
+
(mod, "coptic_leap_year", calendrical_coptic_leap_year, 1);
|
1613
|
+
rb_define_module_function
|
1614
|
+
(mod, "coptic_leap_year?", calendrical_coptic_leap_year, 1);
|
1615
|
+
rb_define_module_function
|
1616
|
+
(mod, "coptic_last_day_of_month",
|
1617
|
+
calendrical_coptic_last_day_of_month, 2);
|
1618
|
+
rb_define_module_function
|
1619
|
+
(mod, "coptic_to_rd", calendrical_coptic_to_rd, 3);
|
1620
|
+
rb_define_module_function
|
1621
|
+
(mod, "rd_to_coptic", calendrical_rd_to_coptic, 1);
|
1622
|
+
|
1623
|
+
rb_define_module_function
|
1624
|
+
(mod, "ethiopian_leap_year", calendrical_ethiopian_leap_year, 1);
|
1625
|
+
rb_define_module_function
|
1626
|
+
(mod, "ethiopian_leap_year?", calendrical_ethiopian_leap_year, 1);
|
1627
|
+
rb_define_module_function
|
1628
|
+
(mod, "ethiopian_last_day_of_month",
|
1629
|
+
calendrical_ethiopian_last_day_of_month, 2);
|
1630
|
+
rb_define_module_function
|
1631
|
+
(mod, "ethiopian_to_rd", calendrical_ethiopian_to_rd, 3);
|
1632
|
+
rb_define_module_function
|
1633
|
+
(mod, "rd_to_ethiopian", calendrical_rd_to_ethiopian, 1);
|
1634
|
+
|
1635
|
+
rb_define_module_function
|
1636
|
+
(mod, "jalali_leap_year", calendrical_jalali_leap_year, 1);
|
1637
|
+
rb_define_module_function
|
1638
|
+
(mod, "jalali_leap_year?", calendrical_jalali_leap_year, 1);
|
1639
|
+
rb_define_module_function
|
1640
|
+
(mod, "jalali_last_day_of_month",
|
1641
|
+
calendrical_jalali_last_day_of_month, 2);
|
1642
|
+
rb_define_module_function
|
1643
|
+
(mod, "jalali_to_rd", calendrical_jalali_to_rd, 3);
|
1644
|
+
rb_define_module_function
|
1645
|
+
(mod, "rd_to_jalali", calendrical_rd_to_jalali, 1);
|
1646
|
+
|
1647
|
+
rb_define_module_function
|
1648
|
+
(mod, "bahai_leap_year", calendrical_bahai_leap_year, 1);
|
1649
|
+
rb_define_module_function
|
1650
|
+
(mod, "bahai_leap_year?", calendrical_bahai_leap_year, 1);
|
1651
|
+
rb_define_module_function
|
1652
|
+
(mod, "bahai_last_day_of_month",
|
1653
|
+
calendrical_bahai_last_day_of_month, 2);
|
1654
|
+
rb_define_module_function
|
1655
|
+
(mod, "bahai_to_rd", calendrical_bahai_to_rd, 3);
|
1656
|
+
rb_define_module_function
|
1657
|
+
(mod, "rd_to_bahai", calendrical_rd_to_bahai, 1);
|
1658
|
+
rb_define_module_function
|
1659
|
+
(mod, "bahai_year_to_vahid",
|
1660
|
+
calendrical_bahai_year_to_vahid, 1);
|
1661
|
+
rb_define_module_function
|
1662
|
+
(mod, "bahai_vahid_to_year",
|
1663
|
+
calendrical_bahai_vahid_to_year, 3);
|
1664
|
+
|
1665
|
+
rb_define_module_function
|
1666
|
+
(mod, "indian_national_leap_year", calendrical_indian_national_leap_year, 1);
|
1667
|
+
rb_define_module_function
|
1668
|
+
(mod, "indian_national_leap_year?", calendrical_indian_national_leap_year, 1);
|
1669
|
+
rb_define_module_function
|
1670
|
+
(mod, "indian_national_last_day_of_month",
|
1671
|
+
calendrical_indian_national_last_day_of_month, 2);
|
1672
|
+
rb_define_module_function
|
1673
|
+
(mod, "indian_national_to_rd", calendrical_indian_national_to_rd, 3);
|
1674
|
+
rb_define_module_function
|
1675
|
+
(mod, "rd_to_indian_national", calendrical_rd_to_indian_national, 1);
|
1676
|
+
|
1677
|
+
rb_define_module_function
|
1678
|
+
(mod, "bengali_leap_year", calendrical_bengali_leap_year, 1);
|
1679
|
+
rb_define_module_function
|
1680
|
+
(mod, "bengali_leap_year?", calendrical_bengali_leap_year, 1);
|
1681
|
+
rb_define_module_function
|
1682
|
+
(mod, "bengali_last_day_of_month",
|
1683
|
+
calendrical_bengali_last_day_of_month, 2);
|
1684
|
+
rb_define_module_function
|
1685
|
+
(mod, "bengali_to_rd", calendrical_bengali_to_rd, 3);
|
1686
|
+
rb_define_module_function
|
1687
|
+
(mod, "rd_to_bengali", calendrical_rd_to_bengali, 1);
|
1688
|
+
|
1689
|
+
rb_define_module_function
|
1690
|
+
(mod, "nanakshahi_leap_year", calendrical_nanakshahi_leap_year, 1);
|
1691
|
+
rb_define_module_function
|
1692
|
+
(mod, "nanakshahi_leap_year?", calendrical_nanakshahi_leap_year, 1);
|
1693
|
+
rb_define_module_function
|
1694
|
+
(mod, "nanakshahi_last_day_of_month",
|
1695
|
+
calendrical_nanakshahi_last_day_of_month, 2);
|
1696
|
+
rb_define_module_function
|
1697
|
+
(mod, "nanakshahi_to_rd", calendrical_nanakshahi_to_rd, 3);
|
1698
|
+
rb_define_module_function
|
1699
|
+
(mod, "rd_to_nanakshahi", calendrical_rd_to_nanakshahi, 1);
|
1700
|
+
|
1701
|
+
rb_define_module_function
|
1702
|
+
(mod, "ordinal_to_rd", calendrical_ordinal_to_rd, 2);
|
1703
|
+
rb_define_module_function
|
1704
|
+
(mod, "rd_to_ordinal", calendrical_rd_to_ordinal, 1);
|
1705
|
+
|
1706
|
+
rb_define_module_function
|
1707
|
+
(mod, "jd_to_rd", calendrical_jd_to_rd, 1);
|
1708
|
+
rb_define_module_function
|
1709
|
+
(mod, "rd_to_jd", calendrical_rd_to_jd, 1);
|
1710
|
+
|
1711
|
+
rb_define_module_function
|
1712
|
+
(mod, "mjd_to_rd", calendrical_mjd_to_rd, 1);
|
1713
|
+
rb_define_module_function
|
1714
|
+
(mod, "rd_to_mjd", calendrical_rd_to_mjd, 1);
|
1715
|
+
|
1716
|
+
rb_define_module_function
|
1717
|
+
(mod, "mjd_to_jd", calendrical_mjd_to_jd, 1);
|
1718
|
+
rb_define_module_function
|
1719
|
+
(mod, "jd_to_mjd", calendrical_jd_to_mjd, 1);
|
1720
|
+
|
1721
|
+
rb_define_module_function
|
1722
|
+
(mod, "ld_to_rd", calendrical_ld_to_rd, 1);
|
1723
|
+
rb_define_module_function
|
1724
|
+
(mod, "rd_to_ld", calendrical_rd_to_ld, 1);
|
1725
|
+
|
1726
|
+
rb_define_module_function
|
1727
|
+
(mod, "rd_to_day_of_week", calendrical_rd_to_day_of_week, 1);
|
1728
|
+
|
1729
|
+
rb_define_module_function
|
1730
|
+
(mod, "kyureki_to_rd", calendrical_kyureki_to_rd, 4);
|
1731
|
+
rb_define_module_function
|
1732
|
+
(mod, "rd_to_kyureki", calendrical_rd_to_kyureki, 1);
|
1733
|
+
rb_define_module_function
|
1734
|
+
(mod, "rd_to_kyureki_day_of_week",
|
1735
|
+
calendrical_rd_to_kyureki_day_of_week, 1);
|
1736
|
+
|
1737
|
+
rb_define_const
|
1738
|
+
(mod, "VERSION",
|
1739
|
+
rb_obj_freeze(rb_str_new2("$Revision: 1.16 $")));
|
1740
|
+
|
1741
|
+
#define const_array(a) mk_ary_of_str(sizeof a / sizeof a[0], a)
|
1742
|
+
#define def_const(n, o) rb_define_const(mod, n, o)
|
1743
|
+
#define def_const_array(n, a) def_const(n, const_array(a))
|
1744
|
+
|
1745
|
+
def_const_array("DAY_NAMES", day_names);
|
1746
|
+
cc_month_names = const_array(month_names);
|
1747
|
+
def_const("MONTH_NAMES", cc_month_names);
|
1748
|
+
|
1749
|
+
def_const_array("ISLAMIC_DAY_NAMES", islamic_day_names);
|
1750
|
+
def_const_array("ISLAMIC_MONTH_NAMES", islamic_month_names);
|
1751
|
+
def_const_array("HEBREW_DAY_NAMES", hebrew_day_names);
|
1752
|
+
def_const("HEBREW_MONTH_NAMES",
|
1753
|
+
rb_obj_freeze(rb_ary_new3(2,
|
1754
|
+
const_array(hebrew_common_year_month_names),
|
1755
|
+
const_array(hebrew_leap_year_month_names))));
|
1756
|
+
|
1757
|
+
def_const_array("MAYAN_HAAB_MONTH_NAMES", mayan_haab_month_names);
|
1758
|
+
def_const_array("MAYAN_TZOLKIN_MONTH_NAMES", mayan_tzolkin_month_names);
|
1759
|
+
|
1760
|
+
def_const_array("FRENCH_DAY_NAMES", french_day_names);
|
1761
|
+
def_const_array("FRENCH_SANSCULOTTIDES_NAMES", french_sansculottides_names);
|
1762
|
+
def_const_array("FRENCH_MONTH_NAMES", french_month_names);
|
1763
|
+
|
1764
|
+
def_const_array("OLD_HINDU_SOLAR_MONTH_NAMES", old_hindu_solar_month_names);
|
1765
|
+
def_const_array("OLD_HINDU_LUNAR_MONTH_NAMES", old_hindu_lunar_month_names);
|
1766
|
+
|
1767
|
+
def_const_array("WORLD_DAY_NAMES", world_day_names);
|
1768
|
+
|
1769
|
+
def_const_array("COPTIC_MONTH_NAMES", coptic_month_names);
|
1770
|
+
def_const_array("ETHIOPIAN_MONTH_NAMES", ethiopian_month_names);
|
1771
|
+
def_const_array("JALALI_MONTH_NAMES", jalali_month_names);
|
1772
|
+
|
1773
|
+
def_const_array("BAHAI_DAY_NAMES", bahai_day_names);
|
1774
|
+
def_const_array("BAHAI_MONTH_NAMES", bahai_month_names);
|
1775
|
+
def_const_array("BAHAI_VAHID_NAMES", bahai_vahid_names);
|
1776
|
+
|
1777
|
+
def_const_array("INDIAN_NATIONAL_MONTH_NAMES", indian_national_month_names);
|
1778
|
+
|
1779
|
+
def_const_array("BENGALI_DAY_NAMES", bengali_day_names);
|
1780
|
+
def_const_array("BENGALI_MONTH_NAMES", bengali_month_names);
|
1781
|
+
|
1782
|
+
def_const_array("NANAKSHAHI_MONTH_NAMES", nanakshahi_month_names);
|
1783
|
+
|
1784
|
+
def_const_array("KYUREKI_DAY_NAMES", kyureki_day_names);
|
1785
|
+
def_const_array("KYUREKI_MONTH_NAMES", kyureki_month_names);
|
1786
|
+
|
1787
|
+
def_const("GREGORIAN_MONTH_NAMES", cc_month_names);
|
1788
|
+
def_const("JULIAN_MONTH_NAMES", cc_month_names);
|
1789
|
+
def_const("WORLD_MONTH_NAMES", cc_month_names);
|
1790
|
+
}
|
1791
|
+
|
1792
|
+
/*
|
1793
|
+
Local variables:
|
1794
|
+
c-file-style: "ruby"
|
1795
|
+
End:
|
1796
|
+
*/
|