when_exe 0.3.6 → 0.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/README.md +171 -0
- data/lib/when_exe.rb +78 -47
- data/lib/when_exe/basictypes.rb +752 -747
- data/lib/when_exe/calendarnote.rb +805 -801
- data/lib/when_exe/calendartypes.rb +1583 -1531
- data/lib/when_exe/coordinates.rb +16 -15
- data/lib/when_exe/core/duration.rb +114 -110
- data/lib/when_exe/core/extension.rb +504 -504
- data/lib/when_exe/ephemeris.rb +1917 -1913
- data/lib/when_exe/ephemeris/moon.rb +333 -333
- data/lib/when_exe/ephemeris/notes.rb +389 -387
- data/lib/when_exe/ephemeris/planets.rb +585 -585
- data/lib/when_exe/ephemeris/sun.rb +214 -214
- data/lib/when_exe/googlecalendar.rb +144 -140
- data/lib/when_exe/icalendar.rb +1636 -1636
- data/lib/when_exe/inspect.rb +46 -22
- data/lib/when_exe/locales/akt.rb +176 -176
- data/lib/when_exe/locales/encoding_conversion.rb +134 -126
- data/lib/when_exe/locales/iast.rb +90 -90
- data/lib/when_exe/locales/locale.rb +750 -746
- data/lib/when_exe/locales/transliteration_table.rb +62 -62
- data/lib/when_exe/mini_application.rb +307 -305
- data/lib/when_exe/parts/enumerator.rb +2 -2
- data/lib/when_exe/parts/geometric_complex.rb +397 -397
- data/lib/when_exe/parts/method_cash.rb +224 -224
- data/lib/when_exe/parts/resource.rb +1069 -1071
- data/lib/when_exe/parts/timezone.rb +240 -230
- data/lib/when_exe/region/armenian.rb +56 -56
- data/lib/when_exe/region/babylonian.rb +405 -0
- data/lib/when_exe/region/bahai.rb +146 -146
- data/lib/when_exe/region/balinese.rb +622 -622
- data/lib/when_exe/region/chinese.rb +95 -25
- data/lib/when_exe/region/chinese/calendars.rb +1016 -1016
- data/lib/when_exe/region/chinese/epochs.rb +1 -1
- data/lib/when_exe/region/chinese/twins.rb +803 -795
- data/lib/when_exe/region/christian.rb +824 -824
- data/lib/when_exe/region/coptic.rb +106 -87
- data/lib/when_exe/region/discordian.rb +225 -225
- data/lib/when_exe/region/far_east.rb +188 -188
- data/lib/when_exe/region/french.rb +56 -56
- data/lib/when_exe/region/geologicalage.rb +639 -639
- data/lib/when_exe/region/goddess.rb +58 -58
- data/lib/when_exe/region/indian.rb +1254 -1251
- data/lib/when_exe/region/iranian.rb +8 -8
- data/lib/when_exe/region/islamic.rb +3 -3
- data/lib/when_exe/region/japanese.rb +93 -99
- data/lib/when_exe/region/japanese/calendars.rb +396 -397
- data/lib/when_exe/region/japanese/epochs.rb +26 -26
- data/lib/when_exe/region/japanese/nihon_shoki.rb +71 -71
- data/lib/when_exe/region/japanese/notes.rb +1383 -1386
- data/lib/when_exe/region/japanese/residues.rb +1306 -1306
- data/lib/when_exe/region/japanese/twins.rb +225 -225
- data/lib/when_exe/region/japanese/weeks.rb +112 -0
- data/lib/when_exe/region/javanese.rb +230 -230
- data/lib/when_exe/region/jewish.rb +126 -126
- data/lib/when_exe/region/korean.rb +378 -378
- data/lib/when_exe/region/m17n.rb +114 -113
- data/lib/when_exe/region/martian.rb +258 -255
- data/lib/when_exe/region/mayan.rb +32 -32
- data/lib/when_exe/region/residue.rb +89 -89
- data/lib/when_exe/region/roman.rb +36 -24
- data/lib/when_exe/region/ryukyu.rb +97 -97
- data/lib/when_exe/region/shire.rb +240 -240
- data/lib/when_exe/region/soviet.rb +209 -0
- data/lib/when_exe/region/symmetry.rb +50 -50
- data/lib/when_exe/region/thai.rb +336 -335
- data/lib/when_exe/region/tibetan.rb +316 -315
- data/lib/when_exe/region/vietnamese.rb +440 -439
- data/lib/when_exe/region/weekdate.rb +80 -80
- data/lib/when_exe/region/world.rb +175 -175
- data/lib/when_exe/region/yerm.rb +14 -14
- data/lib/when_exe/region/zoroastrian.rb +203 -203
- data/lib/when_exe/timestandard.rb +707 -681
- data/lib/when_exe/tmduration.rb +338 -330
- data/lib/when_exe/tmobjects.rb +1346 -1325
- data/lib/when_exe/tmposition.rb +2115 -2072
- data/lib/when_exe/tmreference.rb +1693 -1669
- data/lib/when_exe/version.rb +1 -1
- data/link_to_online_documents +1 -1
- data/test/examples/JapanHolidaysRFC6350.ics +1 -1
- data/test/test.rb +67 -61
- data/test/test/basictypes.rb +409 -409
- data/test/test/calendarnote.rb +86 -69
- data/test/test/calendartypes.rb +97 -97
- data/test/test/coordinates.rb +396 -396
- data/test/test/ephemeris.rb +83 -74
- data/test/test/ephemeris/moon.rb +14 -14
- data/test/test/ephemeris/planets.rb +14 -14
- data/test/test/ephemeris/sun.rb +14 -14
- data/test/test/googlecalendar.rb +194 -176
- data/test/test/icalendar.rb +867 -858
- data/test/test/inspect.rb +117 -117
- data/test/test/parts.rb +487 -487
- data/test/test/region/balinese.rb +34 -0
- data/test/test/region/chinese.rb +218 -206
- data/test/test/region/christian.rb +245 -245
- data/test/test/region/coptic.rb +27 -27
- data/test/test/region/french.rb +33 -33
- data/test/test/region/geologicalage.rb +17 -17
- data/test/test/region/indian.rb +57 -57
- data/test/test/region/iran.rb +54 -54
- data/test/test/region/islamic.rb +18 -18
- data/test/test/region/japanese.rb +237 -219
- data/test/test/region/jewish.rb +61 -61
- data/test/test/region/m17n.rb +184 -184
- data/test/test/region/mayan.rb +195 -195
- data/test/test/region/residue.rb +147 -139
- data/test/test/region/thai.rb +116 -116
- data/test/test/region/tibetan.rb +30 -30
- data/test/test/region/vietnamese.rb +102 -102
- data/test/test/region/yerm.rb +146 -146
- data/test/test/timestandard.rb +81 -81
- data/test/test/tmobjects.rb +328 -328
- data/test/test/tmposition.rb +397 -284
- data/test/test/tmreference.rb +157 -157
- metadata +13 -10
|
@@ -1,1531 +1,1583 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
=begin
|
|
3
|
-
Copyright (C) 2011-2014 Takashi SUGA
|
|
4
|
-
|
|
5
|
-
You may use and/or modify this file according to the license described in the LICENSE.txt file included in this archive.
|
|
6
|
-
=end
|
|
7
|
-
|
|
8
|
-
autoload :Rational, 'Rational' unless Object.const_defined?(:Rational)
|
|
9
|
-
|
|
10
|
-
#
|
|
11
|
-
# 具体的な When::TM::ReferenceSystem のサブクラスの実装
|
|
12
|
-
#
|
|
13
|
-
module When::CalendarTypes
|
|
14
|
-
|
|
15
|
-
#
|
|
16
|
-
# Universal Time, Coordinated
|
|
17
|
-
#
|
|
18
|
-
class UTC < When::TM::Clock
|
|
19
|
-
|
|
20
|
-
# この時法の時刻をUTC時刻に変換する
|
|
21
|
-
#
|
|
22
|
-
# Description of an operation for
|
|
23
|
-
# converting a time on this clock to a UTC time
|
|
24
|
-
#
|
|
25
|
-
# @param [When::TM::ClockTime] u_time
|
|
26
|
-
# @return [When::TM::ClockTime]
|
|
27
|
-
#
|
|
28
|
-
def utc_trans(u_time)
|
|
29
|
-
return u_time
|
|
30
|
-
end
|
|
31
|
-
alias :utcTrans :utc_trans
|
|
32
|
-
|
|
33
|
-
# UTC時刻をこの時法の時刻に変換する
|
|
34
|
-
#
|
|
35
|
-
# Description of an operation for
|
|
36
|
-
# converting a UTC time to a time on this clock
|
|
37
|
-
#
|
|
38
|
-
# @param [When::TM::ClockTime] clk_time
|
|
39
|
-
# @return [When::TM::ClockTime]
|
|
40
|
-
#
|
|
41
|
-
def clk_trans(clk_time)
|
|
42
|
-
return clk_time
|
|
43
|
-
end
|
|
44
|
-
alias :clkTrans :clk_trans
|
|
45
|
-
|
|
46
|
-
#
|
|
47
|
-
# Zone 名
|
|
48
|
-
#
|
|
49
|
-
# @return [String]
|
|
50
|
-
#
|
|
51
|
-
def zone
|
|
52
|
-
@label.to_s
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
private
|
|
56
|
-
|
|
57
|
-
# オブジェクトの正規化
|
|
58
|
-
def _normalize(args=[], options={})
|
|
59
|
-
@label ||= m17n('Z')
|
|
60
|
-
@indices ||= When::Coordinates::DefaultTimeIndices
|
|
61
|
-
@note ||= 'JulianDay'
|
|
62
|
-
_normalize_spatial
|
|
63
|
-
_normalize_temporal
|
|
64
|
-
@second = (@second||1/When::TM::Duration::SECOND).to_f
|
|
65
|
-
@zone = '+00:00'
|
|
66
|
-
@time_standard ||= When.Resource('_t:UniversalTime')
|
|
67
|
-
@utc_reference = When::TM::ClockTime.new([0,0,0,0], {:frame=>self})
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
#
|
|
72
|
-
# Abstract Local Time
|
|
73
|
-
#
|
|
74
|
-
class LocalTime < UTC
|
|
75
|
-
|
|
76
|
-
# 128秒単位の実数による参照事象の時刻
|
|
77
|
-
#
|
|
78
|
-
# Fraction time of the reference event
|
|
79
|
-
#
|
|
80
|
-
# @param [Integer] sdn 参照事象の通し番号
|
|
81
|
-
#
|
|
82
|
-
# @return [Numeric]
|
|
83
|
-
#
|
|
84
|
-
# T00:00:00Z からの参照事象の経過時間 / 128秒
|
|
85
|
-
#
|
|
86
|
-
def universal_time(sdn=nil)
|
|
87
|
-
return super unless sdn
|
|
88
|
-
time = When::TM::JulianDate._d_to_t(sdn-0.5)
|
|
89
|
-
@time_standard.to_dynamical_time(time) - When::TimeStandard.to_dynamical_time(time)
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
#
|
|
93
|
-
# Zone 名
|
|
94
|
-
#
|
|
95
|
-
# @return [String]
|
|
96
|
-
#
|
|
97
|
-
def zone
|
|
98
|
-
iri.split('/')[-1]
|
|
99
|
-
end
|
|
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
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
#
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
#
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
@
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
#
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
#
|
|
392
|
-
#
|
|
393
|
-
#
|
|
394
|
-
#
|
|
395
|
-
#
|
|
396
|
-
#
|
|
397
|
-
#
|
|
398
|
-
#
|
|
399
|
-
#
|
|
400
|
-
#
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
#
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
#
|
|
434
|
-
if @
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
rule['
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
#
|
|
500
|
-
#
|
|
501
|
-
# @
|
|
502
|
-
#
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
#
|
|
512
|
-
#
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
#
|
|
522
|
-
#
|
|
523
|
-
# @
|
|
524
|
-
#
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
#
|
|
532
|
-
#
|
|
533
|
-
# @
|
|
534
|
-
#
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
#
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
#
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
#
|
|
611
|
-
#
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
end
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
#
|
|
679
|
-
#
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
#
|
|
687
|
-
#
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
#
|
|
742
|
-
#
|
|
743
|
-
#
|
|
744
|
-
#
|
|
745
|
-
#
|
|
746
|
-
#
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
rule
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
#
|
|
756
|
-
#
|
|
757
|
-
#
|
|
758
|
-
#
|
|
759
|
-
# @return [Integer]
|
|
760
|
-
#
|
|
761
|
-
def
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
#
|
|
768
|
-
#
|
|
769
|
-
#
|
|
770
|
-
#
|
|
771
|
-
#
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
#
|
|
778
|
-
#
|
|
779
|
-
# @param [
|
|
780
|
-
#
|
|
781
|
-
#
|
|
782
|
-
#
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
#
|
|
792
|
-
#
|
|
793
|
-
# @
|
|
794
|
-
#
|
|
795
|
-
def
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
#
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
#
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
#
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
length
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
#
|
|
847
|
-
#
|
|
848
|
-
#
|
|
849
|
-
#
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
#
|
|
868
|
-
#
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
#
|
|
882
|
-
#
|
|
883
|
-
#
|
|
884
|
-
# @
|
|
885
|
-
#
|
|
886
|
-
#
|
|
887
|
-
#
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
#
|
|
918
|
-
#
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
if
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
end
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
#
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
'
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
#
|
|
995
|
-
#
|
|
996
|
-
#
|
|
997
|
-
#
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
#
|
|
1031
|
-
#
|
|
1032
|
-
#
|
|
1033
|
-
#
|
|
1034
|
-
#
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
#
|
|
1068
|
-
#
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
#
|
|
1072
|
-
|
|
1073
|
-
#
|
|
1074
|
-
#
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
#
|
|
1103
|
-
#
|
|
1104
|
-
#
|
|
1105
|
-
#
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
#
|
|
1109
|
-
|
|
1110
|
-
#
|
|
1111
|
-
#
|
|
1112
|
-
#
|
|
1113
|
-
#
|
|
1114
|
-
#
|
|
1115
|
-
#
|
|
1116
|
-
#
|
|
1117
|
-
#
|
|
1118
|
-
def
|
|
1119
|
-
y
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
#
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
#
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
#
|
|
1147
|
-
#
|
|
1148
|
-
#
|
|
1149
|
-
#
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
#
|
|
1168
|
-
#
|
|
1169
|
-
# @
|
|
1170
|
-
#
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
#
|
|
1201
|
-
|
|
1202
|
-
#
|
|
1203
|
-
#
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
#
|
|
1234
|
-
|
|
1235
|
-
#
|
|
1236
|
-
#
|
|
1237
|
-
# @param [Integer]
|
|
1238
|
-
#
|
|
1239
|
-
# @return [Integer]
|
|
1240
|
-
#
|
|
1241
|
-
def
|
|
1242
|
-
|
|
1243
|
-
end
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
#
|
|
1248
|
-
#
|
|
1249
|
-
#
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
#
|
|
1265
|
-
#
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
#
|
|
1269
|
-
|
|
1270
|
-
#
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
#
|
|
1286
|
-
#
|
|
1287
|
-
#
|
|
1288
|
-
#
|
|
1289
|
-
#
|
|
1290
|
-
#
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
#
|
|
1299
|
-
#
|
|
1300
|
-
#
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
#
|
|
1304
|
-
#
|
|
1305
|
-
#
|
|
1306
|
-
#
|
|
1307
|
-
#
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
#
|
|
1324
|
-
#
|
|
1325
|
-
#
|
|
1326
|
-
#
|
|
1327
|
-
#
|
|
1328
|
-
#
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
#
|
|
1341
|
-
#
|
|
1342
|
-
# @
|
|
1343
|
-
#
|
|
1344
|
-
#
|
|
1345
|
-
#
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
#
|
|
1353
|
-
#
|
|
1354
|
-
# @
|
|
1355
|
-
#
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
#
|
|
1406
|
-
#
|
|
1407
|
-
#
|
|
1408
|
-
#
|
|
1409
|
-
#
|
|
1410
|
-
#
|
|
1411
|
-
#
|
|
1412
|
-
def
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
#
|
|
1422
|
-
#
|
|
1423
|
-
def
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
end
|
|
1471
|
-
|
|
1472
|
-
end
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
#
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
@
|
|
1514
|
-
end
|
|
1515
|
-
end
|
|
1516
|
-
|
|
1517
|
-
#
|
|
1518
|
-
# 日時要素の境界 -
|
|
1519
|
-
#
|
|
1520
|
-
class
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
#
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
=begin
|
|
3
|
+
Copyright (C) 2011-2014 Takashi SUGA
|
|
4
|
+
|
|
5
|
+
You may use and/or modify this file according to the license described in the LICENSE.txt file included in this archive.
|
|
6
|
+
=end
|
|
7
|
+
|
|
8
|
+
autoload :Rational, 'Rational' unless Object.const_defined?(:Rational)
|
|
9
|
+
|
|
10
|
+
#
|
|
11
|
+
# 具体的な When::TM::ReferenceSystem のサブクラスの実装
|
|
12
|
+
#
|
|
13
|
+
module When::CalendarTypes
|
|
14
|
+
|
|
15
|
+
#
|
|
16
|
+
# Universal Time, Coordinated
|
|
17
|
+
#
|
|
18
|
+
class UTC < When::TM::Clock
|
|
19
|
+
|
|
20
|
+
# この時法の時刻をUTC時刻に変換する
|
|
21
|
+
#
|
|
22
|
+
# Description of an operation for
|
|
23
|
+
# converting a time on this clock to a UTC time
|
|
24
|
+
#
|
|
25
|
+
# @param [When::TM::ClockTime] u_time
|
|
26
|
+
# @return [When::TM::ClockTime]
|
|
27
|
+
#
|
|
28
|
+
def utc_trans(u_time)
|
|
29
|
+
return u_time
|
|
30
|
+
end
|
|
31
|
+
alias :utcTrans :utc_trans
|
|
32
|
+
|
|
33
|
+
# UTC時刻をこの時法の時刻に変換する
|
|
34
|
+
#
|
|
35
|
+
# Description of an operation for
|
|
36
|
+
# converting a UTC time to a time on this clock
|
|
37
|
+
#
|
|
38
|
+
# @param [When::TM::ClockTime] clk_time
|
|
39
|
+
# @return [When::TM::ClockTime]
|
|
40
|
+
#
|
|
41
|
+
def clk_trans(clk_time)
|
|
42
|
+
return clk_time
|
|
43
|
+
end
|
|
44
|
+
alias :clkTrans :clk_trans
|
|
45
|
+
|
|
46
|
+
#
|
|
47
|
+
# Zone 名
|
|
48
|
+
#
|
|
49
|
+
# @return [String]
|
|
50
|
+
#
|
|
51
|
+
def zone
|
|
52
|
+
@label.to_s
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
private
|
|
56
|
+
|
|
57
|
+
# オブジェクトの正規化
|
|
58
|
+
def _normalize(args=[], options={})
|
|
59
|
+
@label ||= m17n('Z')
|
|
60
|
+
@indices ||= When::Coordinates::DefaultTimeIndices
|
|
61
|
+
@note ||= 'JulianDay'
|
|
62
|
+
_normalize_spatial
|
|
63
|
+
_normalize_temporal
|
|
64
|
+
@second = (@second||1/When::TM::Duration::SECOND).to_f
|
|
65
|
+
@zone = '+00:00'
|
|
66
|
+
@time_standard ||= When.Resource('_t:UniversalTime')
|
|
67
|
+
@utc_reference = When::TM::ClockTime.new([0,0,0,0], {:frame=>self})
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
#
|
|
72
|
+
# Abstract Local Time
|
|
73
|
+
#
|
|
74
|
+
class LocalTime < UTC
|
|
75
|
+
|
|
76
|
+
# 128秒単位の実数による参照事象の時刻
|
|
77
|
+
#
|
|
78
|
+
# Fraction time of the reference event
|
|
79
|
+
#
|
|
80
|
+
# @param [Integer] sdn 参照事象の通し番号
|
|
81
|
+
#
|
|
82
|
+
# @return [Numeric]
|
|
83
|
+
#
|
|
84
|
+
# T00:00:00Z からの参照事象の経過時間 / 128秒
|
|
85
|
+
#
|
|
86
|
+
def universal_time(sdn=nil)
|
|
87
|
+
return super - @time_standard.localtime_difference unless sdn
|
|
88
|
+
time = When::TM::JulianDate._d_to_t(sdn-0.5)
|
|
89
|
+
@time_standard.to_dynamical_time(time) - When::TimeStandard.to_dynamical_time(time) - @time_standard.localtime_difference
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
#
|
|
93
|
+
# Zone 名
|
|
94
|
+
#
|
|
95
|
+
# @return [String]
|
|
96
|
+
#
|
|
97
|
+
def zone
|
|
98
|
+
iri.split('/')[-1]
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
private
|
|
102
|
+
|
|
103
|
+
# オブジェクトの正規化
|
|
104
|
+
def _normalize(args=[], options={})
|
|
105
|
+
@origin_of_LSC = - @time_standard.localtime_difference / When::TM::Duration::SECOND
|
|
106
|
+
super
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
#
|
|
111
|
+
# Local Mean Time
|
|
112
|
+
#
|
|
113
|
+
class LMT < LocalTime
|
|
114
|
+
|
|
115
|
+
private
|
|
116
|
+
|
|
117
|
+
# オブジェクトの正規化
|
|
118
|
+
def _normalize(args=[], options={})
|
|
119
|
+
@label = m17n('LMT')
|
|
120
|
+
@time_standard = When.Resource("_t:LocalMeanTime?location=_l:long=#{@long||0}")
|
|
121
|
+
super
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
#
|
|
126
|
+
# Local Apparent Time
|
|
127
|
+
#
|
|
128
|
+
class LAT < LocalTime
|
|
129
|
+
|
|
130
|
+
private
|
|
131
|
+
|
|
132
|
+
# オブジェクトの正規化
|
|
133
|
+
def _normalize(args=[], options={})
|
|
134
|
+
@label = m17n('LAT')
|
|
135
|
+
@time_standard = When.Resource("_t:LocalApparentTime?location=_l:long=#{@long||0}")
|
|
136
|
+
super
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
#
|
|
141
|
+
# Temporal Hour System
|
|
142
|
+
#
|
|
143
|
+
class THS < LocalTime
|
|
144
|
+
|
|
145
|
+
private
|
|
146
|
+
|
|
147
|
+
# オブジェクトの正規化
|
|
148
|
+
def _normalize(args=[], options={})
|
|
149
|
+
@label = m17n('THS')
|
|
150
|
+
@time_standard = When.Resource("_t:TemporalHourSystem?location=(_l:long=#{@long||0}&lat=#{@lat||0}&alt=#{@alt||0})")
|
|
151
|
+
super
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
#
|
|
156
|
+
# 太陰(太陽)暦の朔閏パターンを扱うモジュール
|
|
157
|
+
#
|
|
158
|
+
module Lunar
|
|
159
|
+
|
|
160
|
+
# @private
|
|
161
|
+
Pattern = ' ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
|
162
|
+
|
|
163
|
+
# 朔閏表を生成する
|
|
164
|
+
#
|
|
165
|
+
# @param [Range] range 生成範囲(西暦年)
|
|
166
|
+
# @param [Integer] length 大の月の日数
|
|
167
|
+
# @param [When::TM::Duration] duration チェックする月の間隔
|
|
168
|
+
#
|
|
169
|
+
# @return [Hash] 朔閏表
|
|
170
|
+
#
|
|
171
|
+
def lunar_table(range, length=30, duration=When::P1M)
|
|
172
|
+
date = When.TemporalPosition(range.first, {:frame=>self}).floor
|
|
173
|
+
table = []
|
|
174
|
+
hash = {
|
|
175
|
+
'origin_of_MSC' => range.first,
|
|
176
|
+
'origin_of_LSC' => date.to_i,
|
|
177
|
+
'rule_table' => table
|
|
178
|
+
}
|
|
179
|
+
list = ''
|
|
180
|
+
while range.include?(date[YEAR])
|
|
181
|
+
month = date[MONTH] * 1
|
|
182
|
+
char = Pattern[month..month]
|
|
183
|
+
char = char.downcase unless date.length(MONTH) == length
|
|
184
|
+
list += char
|
|
185
|
+
succ = date + duration
|
|
186
|
+
unless date[YEAR] == succ[YEAR]
|
|
187
|
+
table << list
|
|
188
|
+
list = ''
|
|
189
|
+
end
|
|
190
|
+
date = succ
|
|
191
|
+
end
|
|
192
|
+
hash
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
# 朔閏表を比較する
|
|
196
|
+
#
|
|
197
|
+
# @param [When::TM::Calendar] base 基準とする暦法
|
|
198
|
+
# @param [Range] range 比較範囲(西暦年)
|
|
199
|
+
# @param [Integer] length 大の月の日数
|
|
200
|
+
# @param [When::TM::Duration] duration チェックする月の間隔
|
|
201
|
+
#
|
|
202
|
+
# @return [Hash] 朔閏表の差分
|
|
203
|
+
#
|
|
204
|
+
def verify(base, range=base.range, length=30, duration=When::P1M)
|
|
205
|
+
range = When::Parts::GeometricComplex.new(range) & When::Parts::GeometricComplex.new(self.range) if respond_to?(:range)
|
|
206
|
+
base_table = base.lunar_table(range, length, duration)
|
|
207
|
+
self_table = self.lunar_table(range, length, duration)
|
|
208
|
+
hash = {}
|
|
209
|
+
range.each do |year|
|
|
210
|
+
difference = _verify(base_table['rule_table'][year-range.first],
|
|
211
|
+
self_table['rule_table'][year-range.first])
|
|
212
|
+
hash[year] = difference if difference
|
|
213
|
+
end
|
|
214
|
+
hash
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
# @private
|
|
218
|
+
def _verify(source, target)
|
|
219
|
+
return nil if source == target
|
|
220
|
+
return {source => target} unless source.length == target.length
|
|
221
|
+
indices = []
|
|
222
|
+
index = []
|
|
223
|
+
source.length.times do |i|
|
|
224
|
+
if source[i..i] == target[i..i]
|
|
225
|
+
unless index.empty?
|
|
226
|
+
indices << index
|
|
227
|
+
index = []
|
|
228
|
+
end
|
|
229
|
+
else
|
|
230
|
+
index << i
|
|
231
|
+
end
|
|
232
|
+
end
|
|
233
|
+
indices << index unless index.empty?
|
|
234
|
+
ranges = []
|
|
235
|
+
indices.each do |index|
|
|
236
|
+
if ranges.empty? || index.first > ranges.last.last + 2
|
|
237
|
+
ranges << index
|
|
238
|
+
else
|
|
239
|
+
ranges[-1] = [ranges.last.first,index.last]
|
|
240
|
+
end
|
|
241
|
+
end
|
|
242
|
+
hash = {}
|
|
243
|
+
ranges.each do |index|
|
|
244
|
+
range = index.first..index.last
|
|
245
|
+
hash[source[range]] = target[range]
|
|
246
|
+
end
|
|
247
|
+
test = source.dup
|
|
248
|
+
hash.each_pair do |key, value|
|
|
249
|
+
test.sub!(key, value)
|
|
250
|
+
end
|
|
251
|
+
# raise ArgumentError, "can't replace '#{source}'=>'#{target}' by #{hash}." unless test == target
|
|
252
|
+
return hash if test == target
|
|
253
|
+
{source => target}
|
|
254
|
+
end
|
|
255
|
+
end
|
|
256
|
+
|
|
257
|
+
#
|
|
258
|
+
# 朔閏パターンの表の拡張
|
|
259
|
+
#
|
|
260
|
+
module TableExtend
|
|
261
|
+
|
|
262
|
+
# 年月日 -> 通日
|
|
263
|
+
#
|
|
264
|
+
# @param [Numeric] y 年
|
|
265
|
+
# @param [Integer] m 月 (0 始まり)
|
|
266
|
+
# @param [Integer] d 日 (0 始まり)
|
|
267
|
+
#
|
|
268
|
+
# @return [Integer] 通日
|
|
269
|
+
#
|
|
270
|
+
def _coordinates_to_number(y, m, d)
|
|
271
|
+
if @after && y >= @rule_table[@entry_key]['Years']
|
|
272
|
+
_normalize_after
|
|
273
|
+
return @after._coordinates_to_number(y + @_after_offset, m, d)
|
|
274
|
+
end
|
|
275
|
+
if @before && y < 0
|
|
276
|
+
_normalize_before
|
|
277
|
+
return @before._coordinates_to_number(y + @_before_offset, m, d)
|
|
278
|
+
end
|
|
279
|
+
super
|
|
280
|
+
end
|
|
281
|
+
|
|
282
|
+
# 通日 - > 年月日
|
|
283
|
+
#
|
|
284
|
+
# @param [Integer] sdn 通日
|
|
285
|
+
#
|
|
286
|
+
# @return [Array<Integer>] [ y, m, d ]
|
|
287
|
+
# y 年
|
|
288
|
+
# m 月 (0 始まり)
|
|
289
|
+
# d 日 (0 始まり)
|
|
290
|
+
#
|
|
291
|
+
def _number_to_coordinates(sdn)
|
|
292
|
+
if @after && sdn >= @origin_of_LSC + @rule_table[@entry_key]['Days']
|
|
293
|
+
_normalize_after
|
|
294
|
+
y, m, d = @after._number_to_coordinates(sdn)
|
|
295
|
+
return [y - @_after_offset, m, d]
|
|
296
|
+
end
|
|
297
|
+
if @before && sdn < @origin_of_LSC
|
|
298
|
+
_normalize_before
|
|
299
|
+
y, m, d = @before._number_to_coordinates(sdn)
|
|
300
|
+
return [y - @_before_offset, m, d]
|
|
301
|
+
end
|
|
302
|
+
super
|
|
303
|
+
end
|
|
304
|
+
|
|
305
|
+
#
|
|
306
|
+
# その他のテーブル参照
|
|
307
|
+
#
|
|
308
|
+
%w(ids_ length).each do |method|
|
|
309
|
+
module_eval %Q{
|
|
310
|
+
def _#{method}(date)
|
|
311
|
+
if @after && +date[0] >= @rule_table[@entry_key]['Years']
|
|
312
|
+
_normalize_after
|
|
313
|
+
date[0] += @_after_offset
|
|
314
|
+
return @after.send(:_#{method}, date)
|
|
315
|
+
end
|
|
316
|
+
if @before && +date[0] < 0
|
|
317
|
+
_normalize_before
|
|
318
|
+
date[0] += @_before_offset
|
|
319
|
+
return @before.send(:_#{method}, date)
|
|
320
|
+
end
|
|
321
|
+
super
|
|
322
|
+
end
|
|
323
|
+
}
|
|
324
|
+
end
|
|
325
|
+
|
|
326
|
+
private
|
|
327
|
+
|
|
328
|
+
def _normalize_after
|
|
329
|
+
raise RangeError, "Out of range: #{iri}" if @after.kind_of?(Symbol)
|
|
330
|
+
@after = When.Calendar(@after)
|
|
331
|
+
@_after_offset = @origin_of_MSC - @after.origin_of_MSC
|
|
332
|
+
class << self; alias :_normalize_after :_normalize_non end
|
|
333
|
+
end
|
|
334
|
+
|
|
335
|
+
def _normalize_before
|
|
336
|
+
raise RangeError, "Out of range: #{iri}" if @before.kind_of?(Symbol)
|
|
337
|
+
@before = When.Calendar(@before)
|
|
338
|
+
@_before_offset = @origin_of_MSC - @before.origin_of_MSC
|
|
339
|
+
class << self; alias :_normalize_before :_normalize_non end
|
|
340
|
+
end
|
|
341
|
+
|
|
342
|
+
def _normalize_non
|
|
343
|
+
end
|
|
344
|
+
end
|
|
345
|
+
|
|
346
|
+
# 月日の配当パターンの種類が限定されている暦の抽象基底クラス
|
|
347
|
+
#
|
|
348
|
+
# Calendar which has some fixed arrangement rules for under year
|
|
349
|
+
#
|
|
350
|
+
# 新年の日付が専用メソッドで与えられ、月日の配当が1年の日数等
|
|
351
|
+
# で決まる暦。いわゆる Rule-Based な暦はほとんど該当します。
|
|
352
|
+
class TableBased < When::TM::Calendar
|
|
353
|
+
|
|
354
|
+
# 年月日 -> 通日
|
|
355
|
+
#
|
|
356
|
+
# @param [Numeric] y 年
|
|
357
|
+
# @param [Integer] m 月 (0 始まり)
|
|
358
|
+
# @param [Integer] d 日 (0 始まり)
|
|
359
|
+
#
|
|
360
|
+
# @return [Integer] 通日
|
|
361
|
+
#
|
|
362
|
+
def _coordinates_to_number(y, m, d)
|
|
363
|
+
sdn = _sdn([+y])
|
|
364
|
+
rule = _rule(_key([+y]))
|
|
365
|
+
sdn += d + rule['Offset'][m]
|
|
366
|
+
return sdn if d >= 0
|
|
367
|
+
return sdn + rule['Length'][m % rule['Length'].length]
|
|
368
|
+
end
|
|
369
|
+
|
|
370
|
+
# 通日 - > 年月日
|
|
371
|
+
#
|
|
372
|
+
# @param [Integer] sdn 通日
|
|
373
|
+
#
|
|
374
|
+
# @return [Array<Integer>] [ y, m, d ]
|
|
375
|
+
# y 年
|
|
376
|
+
# m 月 (0 始まり)
|
|
377
|
+
# d 日 (0 始まり)
|
|
378
|
+
#
|
|
379
|
+
def _number_to_coordinates(sdn)
|
|
380
|
+
y, d = Residue.mod(sdn) {|n| _sdn([n])}
|
|
381
|
+
rule = _rule(_key([y]))
|
|
382
|
+
(rule['Months']-1).downto(0) do |m|
|
|
383
|
+
if d >=rule['Offset'][m]
|
|
384
|
+
d -= rule['Offset'][m]
|
|
385
|
+
return [y, m, d]
|
|
386
|
+
end
|
|
387
|
+
end
|
|
388
|
+
return nil
|
|
389
|
+
end
|
|
390
|
+
|
|
391
|
+
# 暦要素数
|
|
392
|
+
#
|
|
393
|
+
# @overload _length(date)
|
|
394
|
+
# @param [Array<Integer>] date ( y )
|
|
395
|
+
#
|
|
396
|
+
# y 年
|
|
397
|
+
#
|
|
398
|
+
# @return [Integer] その年の月数
|
|
399
|
+
#
|
|
400
|
+
# @overload _length(date)
|
|
401
|
+
# @param [Array<Integer>] date ( y, m )
|
|
402
|
+
#
|
|
403
|
+
# y 年
|
|
404
|
+
#
|
|
405
|
+
# m 月 (0 始まり)
|
|
406
|
+
#
|
|
407
|
+
# @return [Integer] その年月の日数
|
|
408
|
+
#
|
|
409
|
+
def _length(date)
|
|
410
|
+
y, m = date
|
|
411
|
+
if (m)
|
|
412
|
+
# 指定した月に含まれる日の数を返します。
|
|
413
|
+
return @unit[2] if @unit[2]
|
|
414
|
+
rule = _rule(_key([y]))
|
|
415
|
+
return rule['Length'][m % rule['Length'].length]
|
|
416
|
+
else
|
|
417
|
+
# 指定した年に含まれる月の数を返します。
|
|
418
|
+
return @unit[1] if @unit[1]
|
|
419
|
+
return _rule(_key([y]))['Months']
|
|
420
|
+
end
|
|
421
|
+
end
|
|
422
|
+
|
|
423
|
+
private
|
|
424
|
+
|
|
425
|
+
# オブジェクトの正規化
|
|
426
|
+
def _normalize(args=[], options={})
|
|
427
|
+
# range extension
|
|
428
|
+
extend(TableExtend) if @before || @after
|
|
429
|
+
|
|
430
|
+
super
|
|
431
|
+
|
|
432
|
+
# rule_table
|
|
433
|
+
# @rule_table = @rule_table.dup
|
|
434
|
+
@rule_table = {'T' => {'Rule' => @rule_table }} if @rule_table.kind_of?(Array)
|
|
435
|
+
@_m_cash_ = {}
|
|
436
|
+
@_m_cash_["_rule"] = @rule_table
|
|
437
|
+
|
|
438
|
+
# unit length
|
|
439
|
+
unit = @unit[1..2]
|
|
440
|
+
@rule_table.each do |key, rule|
|
|
441
|
+
_make_rule(key, rule, unit) if rule.kind_of?(Hash)
|
|
442
|
+
end
|
|
443
|
+
|
|
444
|
+
# mean month length
|
|
445
|
+
if @entry_key
|
|
446
|
+
::Rational
|
|
447
|
+
@mean_month = Rational(@rule_table[@entry_key]['Days'], @rule_table[@entry_key]['Months'])
|
|
448
|
+
@mean_year = Rational(@rule_table[@entry_key]['Days'], @rule_table[@entry_key]['Years' ])
|
|
449
|
+
end
|
|
450
|
+
end
|
|
451
|
+
|
|
452
|
+
# rule の正規化
|
|
453
|
+
def _make_rule(key, rule, unit=[])
|
|
454
|
+
# @rule_table[key]['Years', 'Months', 'Offset', 'Days']
|
|
455
|
+
rule['IDs'] = Pair._en_pair_array(rule['IDs']) if rule['IDs'].kind_of?(String)
|
|
456
|
+
rule['Years'] ||= 1
|
|
457
|
+
rule['Months'] ||= (rule['IDs']||rule['Length']).length
|
|
458
|
+
rule['Offset'] = []
|
|
459
|
+
sum, len = 0, rule['Length'].length
|
|
460
|
+
rule['Months'].times do |k|
|
|
461
|
+
rule['Offset'] << sum
|
|
462
|
+
sum += rule['Length'][k % len]
|
|
463
|
+
end
|
|
464
|
+
rule['Days'] ||= sum
|
|
465
|
+
|
|
466
|
+
# Months in Year
|
|
467
|
+
unit[0] ||= rule['Months']
|
|
468
|
+
unit[0] = 0 unless (unit[0]==rule['Months'])
|
|
469
|
+
|
|
470
|
+
# Days in Month
|
|
471
|
+
len = rule['Length'][0]
|
|
472
|
+
if rule['Length'].length == 1 && (rule['Days'] % len) == 0
|
|
473
|
+
unit[1] ||= len
|
|
474
|
+
unit[1] = 0 unless (unit[1]==len)
|
|
475
|
+
else
|
|
476
|
+
unit[1] = 0
|
|
477
|
+
end
|
|
478
|
+
end
|
|
479
|
+
|
|
480
|
+
# 年初の通日によるセットアップ
|
|
481
|
+
def _sdn_setup(c_key, c_date)
|
|
482
|
+
n_date = c_date.dup
|
|
483
|
+
n_date[-1] += 1
|
|
484
|
+
n_key = (n_date.length<=1) ? n_date[0] : n_date
|
|
485
|
+
c_sdn = (@_m_cash_["_sdn"][c_key] ||= _sdn_(c_date))
|
|
486
|
+
n_sdn = (@_m_cash_["_sdn"][n_key] ||= _sdn_(n_date))
|
|
487
|
+
key = (n_sdn - c_sdn).to_i
|
|
488
|
+
rule = (@_m_cash_["_rule"][key] ||= _rule_(key))
|
|
489
|
+
@_m_cash_["_key"] ||= {}
|
|
490
|
+
@_m_cash_["_ids"] ||= {}
|
|
491
|
+
@_m_cash_["_key"][c_key] ||= key
|
|
492
|
+
@_m_cash_["_ids"][c_key] ||= rule['IDs']
|
|
493
|
+
return c_sdn
|
|
494
|
+
end
|
|
495
|
+
|
|
496
|
+
# 年初の通日
|
|
497
|
+
# このメソッドは subclass で定義します
|
|
498
|
+
#
|
|
499
|
+
# @param [Array<Numeric>] date ( 年 )
|
|
500
|
+
#
|
|
501
|
+
# @return [Integer] 年初の通日
|
|
502
|
+
#
|
|
503
|
+
def _sdn_(date)
|
|
504
|
+
raise TypeError, "Abstract TableBased Calendar Type"
|
|
505
|
+
end
|
|
506
|
+
|
|
507
|
+
# 暦日表のキー取得
|
|
508
|
+
#
|
|
509
|
+
# @param [Array<Numeric>] date ( 年 )
|
|
510
|
+
#
|
|
511
|
+
# @return [Integer] 暦日表のキー 本暦法では当該年の日数を暦日表のキーとします
|
|
512
|
+
#
|
|
513
|
+
def _key_(date)
|
|
514
|
+
n_date = date.dup
|
|
515
|
+
n_date[-1] += 1
|
|
516
|
+
(_sdn(n_date) - _sdn(date)).to_i
|
|
517
|
+
end
|
|
518
|
+
|
|
519
|
+
# 日時要素の翻訳表の取得
|
|
520
|
+
#
|
|
521
|
+
# @param [Array<Numeric>] date ( 年 )
|
|
522
|
+
#
|
|
523
|
+
# @return [Array<When::Coordinates::Pair>] 日時要素の翻訳表
|
|
524
|
+
#
|
|
525
|
+
def _ids_(date)
|
|
526
|
+
_rule(_key(date))['IDs']
|
|
527
|
+
end
|
|
528
|
+
|
|
529
|
+
# 暦要素数
|
|
530
|
+
#
|
|
531
|
+
# @param [Array<Numeric>] date ( 年 )
|
|
532
|
+
#
|
|
533
|
+
# @return [Integer] その年の日数
|
|
534
|
+
#
|
|
535
|
+
def _sum_(date)
|
|
536
|
+
return _rule(_key([date[0]]))['Days']
|
|
537
|
+
end
|
|
538
|
+
|
|
539
|
+
# 月日の配当
|
|
540
|
+
#
|
|
541
|
+
# @param [Numeric] year 年
|
|
542
|
+
#
|
|
543
|
+
# @return [Array<Integer>] [ 月の日数 ]
|
|
544
|
+
#
|
|
545
|
+
def month_arrangement_(year)
|
|
546
|
+
_rule(_key([year * 1 - @origin_of_MSC]))['Length']
|
|
547
|
+
end
|
|
548
|
+
|
|
549
|
+
# rule の遅延生成
|
|
550
|
+
def _rule_(key)
|
|
551
|
+
rule = {
|
|
552
|
+
'Years' => 1,
|
|
553
|
+
'Months' => key.length,
|
|
554
|
+
'Days' => _year_length(key),
|
|
555
|
+
'IDs' => [],
|
|
556
|
+
'Length' => [],
|
|
557
|
+
'Offset' => []
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
key.length.times do |m|
|
|
561
|
+
rule['Length'] << _month_length(key, m)
|
|
562
|
+
rule['Offset'] << (m == 0 ? 0 : rule['Offset'][m-1]+rule['Length'][m-1])
|
|
563
|
+
rule['IDs'] << _month_id(key, m)
|
|
564
|
+
end
|
|
565
|
+
return rule
|
|
566
|
+
end
|
|
567
|
+
end
|
|
568
|
+
|
|
569
|
+
# 表引きにより実現する太陰太陽暦
|
|
570
|
+
#
|
|
571
|
+
# Luni-Solar calendar which uses year / month /day table
|
|
572
|
+
#
|
|
573
|
+
class PatternTableBasedLuniSolar < TableBased
|
|
574
|
+
|
|
575
|
+
include Lunar
|
|
576
|
+
|
|
577
|
+
class << self
|
|
578
|
+
#
|
|
579
|
+
# ひとつのひな型朔閏表からの差分で朔閏表を生成する
|
|
580
|
+
#
|
|
581
|
+
# @param [Array] definition ひな型朔閏表
|
|
582
|
+
# @param [Range] range 生成する朔閏表の年代範囲
|
|
583
|
+
# @param [Hash{Integer=>(String or Hash{String or Regexp=>String})}] difference 差分情報
|
|
584
|
+
#
|
|
585
|
+
# @return [Array] 生成された朔閏表定義
|
|
586
|
+
#
|
|
587
|
+
def patch(definition, range=nil, difference={})
|
|
588
|
+
When.Calendar(definition)
|
|
589
|
+
base = When::CalendarTypes.const_get(definition)
|
|
590
|
+
hash = base[-1].dup
|
|
591
|
+
range ||= hash['origin_of_MSC']...(hash['origin_of_MSC']+hash['rule_table'].size)
|
|
592
|
+
range = range.to_a
|
|
593
|
+
hash['origin_of_LSC'] += hash['rule_table'][range[0]-hash['origin_of_MSC']][1]
|
|
594
|
+
hash['rule_table'] = range.map {|year|
|
|
595
|
+
original = hash['rule_table'][year-hash['origin_of_MSC']][0]
|
|
596
|
+
case difference[year]
|
|
597
|
+
when String ; next difference[year]
|
|
598
|
+
when nil ; next original
|
|
599
|
+
end
|
|
600
|
+
original = original.dup
|
|
601
|
+
difference[year].each_pair {|key,value|
|
|
602
|
+
raise ArgumentError, "Can't patch \"#{original}\" by {#{key}=>#{value}} at #{year}" unless original.sub!(key,value)
|
|
603
|
+
}
|
|
604
|
+
original
|
|
605
|
+
}
|
|
606
|
+
hash['origin_of_MSC'] = range[0]
|
|
607
|
+
base[0..-2] + [hash]
|
|
608
|
+
end
|
|
609
|
+
|
|
610
|
+
#
|
|
611
|
+
# 複数のひな型朔閏表からの差分で朔閏表を生成する
|
|
612
|
+
#
|
|
613
|
+
# @param [[Array<Array<String, Range>>]] definitions ひな型朔閏表
|
|
614
|
+
# - String - もとにする太陰太陽暦のIRI文字列
|
|
615
|
+
# - Range - 朔閏表の年代範囲(デフォルトはもとにする太陰太陽暦の年代範囲)
|
|
616
|
+
# @param [Hash{Integer=>(String or Hash{String or Regexp=>String})}] difference 差分情報
|
|
617
|
+
#
|
|
618
|
+
# @return [Array] 生成された朔閏表定義
|
|
619
|
+
#
|
|
620
|
+
def join(definitions, difference={})
|
|
621
|
+
if definitions.first.kind_of?(Array)
|
|
622
|
+
base = When::CalendarTypes.const_get(definitions.first[0]).dup
|
|
623
|
+
else
|
|
624
|
+
base = []
|
|
625
|
+
base << definitions.shift until definitions.first.kind_of?(Array)
|
|
626
|
+
end
|
|
627
|
+
tables = definitions.map {|definition|
|
|
628
|
+
When.Calendar(definition[0]).lunar_table(definition[1])
|
|
629
|
+
}
|
|
630
|
+
hash = base.pop.merge({
|
|
631
|
+
'origin_of_MSC' => tables.first['origin_of_MSC'],
|
|
632
|
+
'origin_of_LSC' => tables.first['origin_of_LSC'],
|
|
633
|
+
'rule_table' => tables.inject([]) {|rules, table| rules += table['rule_table']}
|
|
634
|
+
})
|
|
635
|
+
difference.each_pair do |year, pattern|
|
|
636
|
+
offset = year - hash['origin_of_MSC']
|
|
637
|
+
hash['rule_table'][offset] =
|
|
638
|
+
if pattern.kind_of?(Hash)
|
|
639
|
+
rule = hash['rule_table'][offset].dup
|
|
640
|
+
pattern.each_pair do |key,value|
|
|
641
|
+
raise ArgumentError, "Can't patch \"#{rule}\" by {#{key}=>#{value}} at #{year}" unless rule.sub!(key,value)
|
|
642
|
+
end
|
|
643
|
+
rule
|
|
644
|
+
else
|
|
645
|
+
pattern
|
|
646
|
+
end
|
|
647
|
+
end
|
|
648
|
+
base << hash
|
|
649
|
+
end
|
|
650
|
+
end
|
|
651
|
+
|
|
652
|
+
# 朔閏表を生成する
|
|
653
|
+
#
|
|
654
|
+
# @param [Range] sub_range 生成範囲(西暦年) デフォルトは self.range
|
|
655
|
+
# @param [Integer] length 大の月の日数(ダミー)
|
|
656
|
+
# @param [When::TM::Duration] duration チェックする月の間隔(ダミー)
|
|
657
|
+
#
|
|
658
|
+
# @return [Hash] 朔閏表
|
|
659
|
+
#
|
|
660
|
+
def lunar_table(sub_range=nil, length=nil, duration=nil)
|
|
661
|
+
sub_range ||= range
|
|
662
|
+
last = sub_range.last
|
|
663
|
+
last -= 1 if sub_range.exclude_end?
|
|
664
|
+
[sub_range.first, last].each do |edge|
|
|
665
|
+
raise RangeError, 'Range exceeded: ' + sub_range.to_s unless range.include?(edge)
|
|
666
|
+
end
|
|
667
|
+
{
|
|
668
|
+
'origin_of_MSC' => sub_range.first,
|
|
669
|
+
'origin_of_LSC' => @origin_of_LSC + @rule_table['T']['Rule'][sub_range.first-@origin_of_MSC][1],
|
|
670
|
+
'rule_table' => sub_range.to_a.map {|year|
|
|
671
|
+
@rule_table['T']['Rule'][year-@origin_of_MSC][0]
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
end
|
|
675
|
+
|
|
676
|
+
# 朔閏表の有効範囲
|
|
677
|
+
#
|
|
678
|
+
# @return [Range] 有効範囲(西暦年)
|
|
679
|
+
#
|
|
680
|
+
def range
|
|
681
|
+
@origin_of_MSC...(@origin_of_MSC+@rule_table['T']['Rule'].length)
|
|
682
|
+
end
|
|
683
|
+
|
|
684
|
+
private
|
|
685
|
+
|
|
686
|
+
# new で指定された月日配当規則をプログラムで利用可能にします。
|
|
687
|
+
#
|
|
688
|
+
# key 年月日配当規則のハッシュキー
|
|
689
|
+
# rule 年月日配当規則
|
|
690
|
+
#
|
|
691
|
+
# インスタンス変数 ハッシュのハッシュ@rule_table の要素
|
|
692
|
+
# Years => the period length / year
|
|
693
|
+
# Months => the period length / month
|
|
694
|
+
# Days => the period length / day
|
|
695
|
+
# Rule => Array of sub rules' key and offset
|
|
696
|
+
def _make_rule(key, rule, unit=nil)
|
|
697
|
+
|
|
698
|
+
offsets = [0, 0]
|
|
699
|
+
rule['Rule'].each_index do |k|
|
|
700
|
+
subkey = rule['Rule'][k]
|
|
701
|
+
if subkey.kind_of?(Array)
|
|
702
|
+
subkey, *offsets = rule['Rule'][k]
|
|
703
|
+
else
|
|
704
|
+
subkey = _make_subkey(subkey)
|
|
705
|
+
rule['Rule'][k] = [subkey] + offsets
|
|
706
|
+
end
|
|
707
|
+
_increment_offsets(offsets, subkey)
|
|
708
|
+
end
|
|
709
|
+
|
|
710
|
+
rule['Years'] ||= rule['Rule'].length # 年数
|
|
711
|
+
rule['Months'] ||= offsets[1] # 月数
|
|
712
|
+
rule['Days'] ||= offsets[0] # 日数
|
|
713
|
+
|
|
714
|
+
@entry_key ||= key
|
|
715
|
+
end
|
|
716
|
+
|
|
717
|
+
# 恒等変換
|
|
718
|
+
alias :_make_subkey :_do_nothing
|
|
719
|
+
|
|
720
|
+
# オフセットの更新
|
|
721
|
+
def _increment_offsets(offsets, subkey)
|
|
722
|
+
offsets[1] += subkey.length # 月のオフセットを月数分進める
|
|
723
|
+
offsets[0] += _year_length(subkey) # 日のオフセットを日数分進める
|
|
724
|
+
end
|
|
725
|
+
|
|
726
|
+
# 年初の通日によるセットアップ
|
|
727
|
+
def _sdn_setup(c_key, c_date)
|
|
728
|
+
root_rule = @rule_table[@entry_key]
|
|
729
|
+
count, year = c_date[0].divmod(root_rule['Years'])
|
|
730
|
+
key, dd, mm = root_rule['Rule'][year]
|
|
731
|
+
rule = (@_m_cash_["_rule"][key] ||= _rule_(key))
|
|
732
|
+
@_m_cash_["_key"] ||= {}
|
|
733
|
+
@_m_cash_["_ids"] ||= {}
|
|
734
|
+
@_m_cash_["_key"][c_key] ||= key
|
|
735
|
+
@_m_cash_["_ids"][c_key] ||= rule['IDs']
|
|
736
|
+
@_m_cash_["_sdn"][c_key] ||= @origin_of_LSC + dd + count * root_rule['Days']
|
|
737
|
+
end
|
|
738
|
+
|
|
739
|
+
# 年初の通日
|
|
740
|
+
#
|
|
741
|
+
# @param [Array<Numeric>] date ( y )
|
|
742
|
+
#
|
|
743
|
+
# y 年
|
|
744
|
+
#
|
|
745
|
+
# @return [Integer] 年初の通日
|
|
746
|
+
#
|
|
747
|
+
def _sdn_(date)
|
|
748
|
+
rule = @rule_table[@entry_key]
|
|
749
|
+
count, year = date[0].divmod(rule['Years'])
|
|
750
|
+
return @origin_of_LSC + rule['Rule'][year][1] + count * rule['Days']
|
|
751
|
+
end
|
|
752
|
+
|
|
753
|
+
# 暦日表のキー取得
|
|
754
|
+
#
|
|
755
|
+
# @param [Array<Numeric>] date ( y )
|
|
756
|
+
#
|
|
757
|
+
# y 年
|
|
758
|
+
#
|
|
759
|
+
# @return [Integer] 暦日表のキー
|
|
760
|
+
#
|
|
761
|
+
def _key_(date)
|
|
762
|
+
rule = @rule_table[@entry_key]
|
|
763
|
+
count, year = date[0].divmod(rule['Years'])
|
|
764
|
+
return rule['Rule'][year][0]
|
|
765
|
+
end
|
|
766
|
+
|
|
767
|
+
# 朔閏パターン -> 日数/年
|
|
768
|
+
#
|
|
769
|
+
# @param [String] key 朔閏パターン
|
|
770
|
+
#
|
|
771
|
+
# @return [Integer] 日数/年
|
|
772
|
+
#
|
|
773
|
+
def _year_length(key)
|
|
774
|
+
key.length * 29 + key.gsub(/[a-z]/,'').length
|
|
775
|
+
end
|
|
776
|
+
|
|
777
|
+
# 朔閏パターン -> 日数/年
|
|
778
|
+
#
|
|
779
|
+
# @param [String] key 朔閏パターン
|
|
780
|
+
# @param [Integer] m 月番号(0始まり)
|
|
781
|
+
#
|
|
782
|
+
# @return [Integer] 日数/月
|
|
783
|
+
#
|
|
784
|
+
def _month_length(key, m)
|
|
785
|
+
key[m,1] =~ /[a-z]/ ? 29 : 30
|
|
786
|
+
end
|
|
787
|
+
|
|
788
|
+
# 朔閏パターン -> 月のID
|
|
789
|
+
#
|
|
790
|
+
# @param [String] key 朔閏パターン
|
|
791
|
+
# @param [Integer] m 月番号(0始まり)
|
|
792
|
+
#
|
|
793
|
+
# @return [Integer] 月のID
|
|
794
|
+
#
|
|
795
|
+
def _month_id(key, m)
|
|
796
|
+
trunk = key.upcase[m]
|
|
797
|
+
branch = trunk == key.upcase[m-1] ? 1 : 0
|
|
798
|
+
trunk = trunk.ord if trunk.kind_of?(String)
|
|
799
|
+
trunk -= 64
|
|
800
|
+
branch == 0 ? trunk : When::Coordinates::Pair.new(trunk, branch)
|
|
801
|
+
end
|
|
802
|
+
end
|
|
803
|
+
|
|
804
|
+
# 表引きにより実現する太陰太陽暦(29,30日以外の月がある場合)
|
|
805
|
+
#
|
|
806
|
+
# Luni-Solar calendar which has months with irregular length
|
|
807
|
+
#
|
|
808
|
+
class PatternTableBasedLuniSolarExtended < PatternTableBasedLuniSolar
|
|
809
|
+
|
|
810
|
+
private
|
|
811
|
+
|
|
812
|
+
# rule の遅延生成
|
|
813
|
+
def _rule_(key)
|
|
814
|
+
key.kind_of?(Hash) ? key : super
|
|
815
|
+
end
|
|
816
|
+
|
|
817
|
+
# オフセットの更新
|
|
818
|
+
def _increment_offsets(offsets, subkey)
|
|
819
|
+
return super unless subkey.kind_of?(Hash)
|
|
820
|
+
offsets[1] += subkey['Months'] # 月のオフセットを月数分進める
|
|
821
|
+
offsets[0] += subkey['Days'] # 日のオフセットを日数分進める
|
|
822
|
+
end
|
|
823
|
+
end
|
|
824
|
+
|
|
825
|
+
# 表引きにより実現する太陰太陽暦(Ephemerisにより朔を決定する)
|
|
826
|
+
#
|
|
827
|
+
# Luni-Solar calendar whose new moon is determined by 'engine' calendar
|
|
828
|
+
#
|
|
829
|
+
class PatternTableBasedLuniSolarWithEphemeris < PatternTableBasedLuniSolar
|
|
830
|
+
|
|
831
|
+
private
|
|
832
|
+
|
|
833
|
+
# subkeyの生成
|
|
834
|
+
def _make_subkey(key)
|
|
835
|
+
pattern = @subkey_table[key]
|
|
836
|
+
subkey = ''
|
|
837
|
+
pattern.length.times do |i|
|
|
838
|
+
@month_no += 1
|
|
839
|
+
next_new_moon = @engine._new_month(@month_no)
|
|
840
|
+
subkey += next_new_moon - @new_moon >= 30 ? pattern[i..i].upcase : pattern[i..i].downcase
|
|
841
|
+
@new_moon = next_new_moon
|
|
842
|
+
end
|
|
843
|
+
subkey
|
|
844
|
+
end
|
|
845
|
+
|
|
846
|
+
# オブジェクトの正規化
|
|
847
|
+
#
|
|
848
|
+
# YearLengthTableBased+オブジェクトの性質定義を初期設定します。
|
|
849
|
+
#
|
|
850
|
+
def _normalize(args=[], options={})
|
|
851
|
+
@engine = When.Calendar(@engine)
|
|
852
|
+
divmod = When::Coordinates::Residue.mod(@origin_of_LSC.to_i+3) {|cn| @engine.formula[-1].cn_to_time(cn)}
|
|
853
|
+
@month_no = divmod[0]
|
|
854
|
+
@new_moon = @origin_of_LSC.to_i+3 - divmod[1]
|
|
855
|
+
super
|
|
856
|
+
end
|
|
857
|
+
end
|
|
858
|
+
|
|
859
|
+
# 表引きにより実現する太陽暦(閏月なし, 5,6,27~34日の月に対応)
|
|
860
|
+
#
|
|
861
|
+
# Solar calendar which uses year / month /day table
|
|
862
|
+
#
|
|
863
|
+
class PatternTableBasedSolar < PatternTableBasedLuniSolar
|
|
864
|
+
|
|
865
|
+
private
|
|
866
|
+
|
|
867
|
+
# 朔閏パターン -> 日数/年
|
|
868
|
+
#
|
|
869
|
+
# @param [String] key 朔閏パターン
|
|
870
|
+
#
|
|
871
|
+
# @return [Integer] 日数/年
|
|
872
|
+
#
|
|
873
|
+
def _year_length(key)
|
|
874
|
+
length = 0
|
|
875
|
+
key.length.times do |m|
|
|
876
|
+
length += _month_length(key, m)
|
|
877
|
+
end
|
|
878
|
+
length
|
|
879
|
+
end
|
|
880
|
+
|
|
881
|
+
# 朔閏パターン -> 日数/年
|
|
882
|
+
#
|
|
883
|
+
# @param [String] key 朔閏パターン
|
|
884
|
+
# @param [Integer] m 月番号(0始まり)
|
|
885
|
+
#
|
|
886
|
+
# @return [Integer] 日数/月
|
|
887
|
+
#
|
|
888
|
+
def _month_length(key, m)
|
|
889
|
+
trunk = key.upcase[m]
|
|
890
|
+
trunk = trunk.ord if trunk.kind_of?(String)
|
|
891
|
+
trunk -= 48
|
|
892
|
+
case trunk
|
|
893
|
+
when 5, 6 ; trunk
|
|
894
|
+
when 7..9 ; trunk + 20
|
|
895
|
+
else ; trunk + 30
|
|
896
|
+
end
|
|
897
|
+
end
|
|
898
|
+
|
|
899
|
+
# 朔閏パターン -> 月のID
|
|
900
|
+
#
|
|
901
|
+
# @param [String] key 朔閏パターン
|
|
902
|
+
# @param [Integer] m 月番号(0始まり)
|
|
903
|
+
#
|
|
904
|
+
# @return [Integer] 月のID
|
|
905
|
+
#
|
|
906
|
+
def _month_id(key, m)
|
|
907
|
+
m + 1
|
|
908
|
+
end
|
|
909
|
+
end
|
|
910
|
+
|
|
911
|
+
# 年の配当パターンが限定されている暦
|
|
912
|
+
#
|
|
913
|
+
# Calendar which has some fixed arrangement rules of year pattern
|
|
914
|
+
#
|
|
915
|
+
class CyclicTableBased < TableBased
|
|
916
|
+
|
|
917
|
+
# 通日 - > 年月日
|
|
918
|
+
#
|
|
919
|
+
# @param [Integer] sdn 通日
|
|
920
|
+
#
|
|
921
|
+
# @return [Array<Integer>] [ y, m, d ]
|
|
922
|
+
# y 年
|
|
923
|
+
# m 月 (0 始まり)
|
|
924
|
+
# d 日 (0 始まり)
|
|
925
|
+
#
|
|
926
|
+
def _number_to_coordinates(sdn)
|
|
927
|
+
root_rule = @rule_table[@entry_key]
|
|
928
|
+
count, value = (sdn-@origin_of_LSC).divmod(root_rule['Days'])
|
|
929
|
+
y, d, key = _read_period(@entry_key,
|
|
930
|
+
'Days', value,
|
|
931
|
+
'Years', count * root_rule['Years'])
|
|
932
|
+
rule = _rule(key)
|
|
933
|
+
(rule['Months']-1).downto(0) do |m|
|
|
934
|
+
if d >=rule['Offset'][m]
|
|
935
|
+
d -= rule['Offset'][m]
|
|
936
|
+
return [y, m, d]
|
|
937
|
+
end
|
|
938
|
+
end
|
|
939
|
+
return nil
|
|
940
|
+
end
|
|
941
|
+
|
|
942
|
+
private
|
|
943
|
+
|
|
944
|
+
#
|
|
945
|
+
# new で指定された月日配当規則をプログラムで利用可能にします。
|
|
946
|
+
#
|
|
947
|
+
# key 年月日配当規則のハッシュキー
|
|
948
|
+
# rule 年月日配当規則
|
|
949
|
+
#
|
|
950
|
+
# インスタンス変数 ハッシュのハッシュ@rule_table の要素
|
|
951
|
+
# Years => the period length / year
|
|
952
|
+
# Months => the period length / month
|
|
953
|
+
# Days => the period length / day
|
|
954
|
+
# Rule => Array of sub rules' key
|
|
955
|
+
#
|
|
956
|
+
def _make_rule(key, rule, unit=nil)
|
|
957
|
+
if rule.key?('Rule') # Table of Many Years
|
|
958
|
+
['Years', 'Months', 'Days'].each do |u|
|
|
959
|
+
rule[u] ||=
|
|
960
|
+
begin
|
|
961
|
+
s = 0
|
|
962
|
+
rule['Rule'].each do |part|
|
|
963
|
+
subkey, count = part
|
|
964
|
+
subrule = @rule_table[subkey]
|
|
965
|
+
_make_rule(subkey, subrule, unit) unless subrule[u]
|
|
966
|
+
s += (count||1) * subrule[u]
|
|
967
|
+
end
|
|
968
|
+
s
|
|
969
|
+
end
|
|
970
|
+
end
|
|
971
|
+
if !@entry_key ||
|
|
972
|
+
@rule_table[@entry_key]['Days'] < rule['Days']
|
|
973
|
+
@entry_key = key
|
|
974
|
+
end
|
|
975
|
+
else # Table of One Year
|
|
976
|
+
super
|
|
977
|
+
end
|
|
978
|
+
end
|
|
979
|
+
|
|
980
|
+
# 年初の通日によるセットアップ
|
|
981
|
+
def _sdn_setup(c_key, c_date)
|
|
982
|
+
root_rule = @rule_table[@entry_key]
|
|
983
|
+
count, value = c_date[0].divmod(root_rule['Years'])
|
|
984
|
+
sdn, y, key = _read_period(@entry_key,
|
|
985
|
+
'Years', value,
|
|
986
|
+
'Days', @origin_of_LSC + count * root_rule['Days'])
|
|
987
|
+
@_m_cash_["_key"] ||= {}
|
|
988
|
+
@_m_cash_["_ids"] ||= {}
|
|
989
|
+
@_m_cash_["_key"][c_key] ||= key
|
|
990
|
+
@_m_cash_["_ids"][c_key] ||= @_m_cash_["_rule"][key]['IDs']
|
|
991
|
+
@_m_cash_["_sdn"][c_key] ||= sdn
|
|
992
|
+
end
|
|
993
|
+
|
|
994
|
+
# 年初の通日
|
|
995
|
+
#
|
|
996
|
+
# @param [Array<Numeric>] date ( y )
|
|
997
|
+
#
|
|
998
|
+
# y 年
|
|
999
|
+
#
|
|
1000
|
+
# @return [Integer] 年初の通日
|
|
1001
|
+
#
|
|
1002
|
+
def _sdn_(date)
|
|
1003
|
+
root_rule = @rule_table[@entry_key]
|
|
1004
|
+
count, value = date[0].divmod(root_rule['Years'])
|
|
1005
|
+
sdn, y, key = _read_period(@entry_key,
|
|
1006
|
+
'Years', value,
|
|
1007
|
+
'Days', @origin_of_LSC + count * root_rule['Days'])
|
|
1008
|
+
return sdn
|
|
1009
|
+
end
|
|
1010
|
+
|
|
1011
|
+
# 暦日表のキー取得
|
|
1012
|
+
#
|
|
1013
|
+
# @param [Array<Numeric>] date ( y )
|
|
1014
|
+
#
|
|
1015
|
+
# y 年
|
|
1016
|
+
#
|
|
1017
|
+
# @return [Integer] 暦日表のキー
|
|
1018
|
+
#
|
|
1019
|
+
def _key_(date)
|
|
1020
|
+
root_rule = @rule_table[@entry_key]
|
|
1021
|
+
count, value = date[0].divmod(root_rule['Years'])
|
|
1022
|
+
sdn, y, key = _read_period(@entry_key,
|
|
1023
|
+
'Years', value,
|
|
1024
|
+
'Days', @origin_of_LSC + count * root_rule['Days'])
|
|
1025
|
+
return key
|
|
1026
|
+
end
|
|
1027
|
+
|
|
1028
|
+
# 年の配当規則を読み出します。
|
|
1029
|
+
#
|
|
1030
|
+
# key 年の配当規則のキー
|
|
1031
|
+
# akey 入力が'Days'か'Years'かを指定
|
|
1032
|
+
# avalue 入力の'Days'または'Years'の値
|
|
1033
|
+
# zkey 出力が'Years'か'Days'かを指定
|
|
1034
|
+
# zvalue 出力の'Years'または'Days'の値
|
|
1035
|
+
def _read_period(key, akey, avalue, zkey, zvalue)
|
|
1036
|
+
rule = @rule_table
|
|
1037
|
+
rule[key]['Rule'].each do |part|
|
|
1038
|
+
subkey, count, = [*part] << 1
|
|
1039
|
+
if avalue >= count * rule[subkey][akey]
|
|
1040
|
+
avalue -= count * rule[subkey][akey]
|
|
1041
|
+
zvalue += count * rule[subkey][zkey]
|
|
1042
|
+
else
|
|
1043
|
+
count, avalue = avalue.divmod(rule[subkey][akey])
|
|
1044
|
+
zvalue += count * rule[subkey][zkey]
|
|
1045
|
+
return zvalue, avalue, subkey unless rule[subkey].key?('Rule')
|
|
1046
|
+
return _read_period(subkey, akey, avalue, zkey, zvalue)
|
|
1047
|
+
end
|
|
1048
|
+
end
|
|
1049
|
+
end
|
|
1050
|
+
end
|
|
1051
|
+
|
|
1052
|
+
#
|
|
1053
|
+
# 年初を太陽黄経で決定する暦
|
|
1054
|
+
#
|
|
1055
|
+
class YearLengthTableBased < TableBased
|
|
1056
|
+
|
|
1057
|
+
# 天体暦アルゴリズム
|
|
1058
|
+
#
|
|
1059
|
+
# @return [Array<When::Ephemeris::Formula>]
|
|
1060
|
+
#
|
|
1061
|
+
attr_reader :formula
|
|
1062
|
+
|
|
1063
|
+
#protected
|
|
1064
|
+
|
|
1065
|
+
private
|
|
1066
|
+
|
|
1067
|
+
# 年初の通日
|
|
1068
|
+
#
|
|
1069
|
+
# @param [Array<Numeric>] date ( y )
|
|
1070
|
+
#
|
|
1071
|
+
# y 年
|
|
1072
|
+
#
|
|
1073
|
+
# @return [Integer] 年初の通日
|
|
1074
|
+
#
|
|
1075
|
+
def _sdn_(date)
|
|
1076
|
+
y = +date[0]
|
|
1077
|
+
t = @formula[0].cn_to_time(y.to_f + @cycle_offset)
|
|
1078
|
+
return solar_sdn(t + @day_offset)
|
|
1079
|
+
end
|
|
1080
|
+
|
|
1081
|
+
# オブジェクトの正規化
|
|
1082
|
+
#
|
|
1083
|
+
# YearLengthTableBased+オブジェクトの性質定義を初期設定します。
|
|
1084
|
+
#
|
|
1085
|
+
def _normalize(args=[], options={})
|
|
1086
|
+
|
|
1087
|
+
Rational
|
|
1088
|
+
@cycle_offset = (@cycle_offset||0).to_r
|
|
1089
|
+
@day_offset = (@day_offset||0).to_r
|
|
1090
|
+
@formula = 'Formula?formula=1S'
|
|
1091
|
+
|
|
1092
|
+
super
|
|
1093
|
+
end
|
|
1094
|
+
end
|
|
1095
|
+
|
|
1096
|
+
# 月日の配当が太陽または月の位置によって決定される暦
|
|
1097
|
+
#
|
|
1098
|
+
# Calendar based on the ephemeris of the Sun or the Moon
|
|
1099
|
+
#
|
|
1100
|
+
class EphemerisBased < When::TM::Calendar
|
|
1101
|
+
|
|
1102
|
+
# 天体暦
|
|
1103
|
+
#
|
|
1104
|
+
# @return [When::Ephmeris::Formula]
|
|
1105
|
+
#
|
|
1106
|
+
attr_reader :formula
|
|
1107
|
+
|
|
1108
|
+
#protected
|
|
1109
|
+
|
|
1110
|
+
# 年月日 -> 通日
|
|
1111
|
+
#
|
|
1112
|
+
# @param [Numeric] y 年
|
|
1113
|
+
# @param [Integer] m 月 (0 始まり)
|
|
1114
|
+
# @param [Integer] d 日 (0 始まり)
|
|
1115
|
+
#
|
|
1116
|
+
# @return [Integer] 通日
|
|
1117
|
+
#
|
|
1118
|
+
def _coordinates_to_number(y, m, d)
|
|
1119
|
+
_new_month(@months_in_year * (+y) + m) + d
|
|
1120
|
+
end
|
|
1121
|
+
|
|
1122
|
+
# 通日 - > 年月日
|
|
1123
|
+
#
|
|
1124
|
+
# @param [Integer] sdn 通日
|
|
1125
|
+
#
|
|
1126
|
+
# @return [Array<Integer>] [ y, m, d ]
|
|
1127
|
+
# y 年
|
|
1128
|
+
# m 月 (0 始まり)
|
|
1129
|
+
# d 日 (0 始まり)
|
|
1130
|
+
#
|
|
1131
|
+
def _number_to_coordinates(sdn)
|
|
1132
|
+
m, d = Residue.mod(sdn) {|m| _new_month(m)}
|
|
1133
|
+
y, m = m.divmod(@months_in_year)
|
|
1134
|
+
return y, m, d
|
|
1135
|
+
end
|
|
1136
|
+
|
|
1137
|
+
# 暦要素数
|
|
1138
|
+
#
|
|
1139
|
+
# @overload _length(date)
|
|
1140
|
+
# @param [Array<Integer>] date ( y )
|
|
1141
|
+
#
|
|
1142
|
+
# y 年
|
|
1143
|
+
#
|
|
1144
|
+
# @return [Integer] その年の月数
|
|
1145
|
+
#
|
|
1146
|
+
# @overload _length(date)
|
|
1147
|
+
# @param [Array<Integer>] date ( y, m )
|
|
1148
|
+
#
|
|
1149
|
+
# y 年
|
|
1150
|
+
#
|
|
1151
|
+
# m 月 (0 始まり)
|
|
1152
|
+
#
|
|
1153
|
+
# @return [Integer] その年月の日数
|
|
1154
|
+
#
|
|
1155
|
+
def _length(date)
|
|
1156
|
+
y, m = date
|
|
1157
|
+
if (m)
|
|
1158
|
+
# 指定した月に含まれる日の数を返します。
|
|
1159
|
+
m += @months_in_year * +y
|
|
1160
|
+
return _new_month(m+1) - _new_month(m)
|
|
1161
|
+
else
|
|
1162
|
+
# 指定した年に含まれる月の数を返します。
|
|
1163
|
+
return @months_in_year
|
|
1164
|
+
end
|
|
1165
|
+
end
|
|
1166
|
+
|
|
1167
|
+
# 暦要素数
|
|
1168
|
+
#
|
|
1169
|
+
# @param [Array<Numeric>] date ( y )
|
|
1170
|
+
#
|
|
1171
|
+
# y 年
|
|
1172
|
+
#
|
|
1173
|
+
# @return [Integer] その年の日数
|
|
1174
|
+
#
|
|
1175
|
+
def _sum_(date)
|
|
1176
|
+
y, = date
|
|
1177
|
+
m = @months_in_year * +y
|
|
1178
|
+
return _new_month(m+@months_in_year) - _new_month(m)
|
|
1179
|
+
end
|
|
1180
|
+
|
|
1181
|
+
private
|
|
1182
|
+
|
|
1183
|
+
# オブジェクトの正規化
|
|
1184
|
+
#
|
|
1185
|
+
# @months_in_year = 1年の月の数
|
|
1186
|
+
#
|
|
1187
|
+
def _normalize(args=[], options={})
|
|
1188
|
+
@months_in_year ||= 12
|
|
1189
|
+
@formula = When::Parts::Resource._instantiate(@formula)
|
|
1190
|
+
super
|
|
1191
|
+
end
|
|
1192
|
+
end
|
|
1193
|
+
|
|
1194
|
+
# 月日の配当が太陽の位置によって決定される太陽暦
|
|
1195
|
+
#
|
|
1196
|
+
# Calendar based on the ephemeris of the Sun
|
|
1197
|
+
#
|
|
1198
|
+
class EphemerisBasedSolar < EphemerisBased
|
|
1199
|
+
|
|
1200
|
+
#protected
|
|
1201
|
+
|
|
1202
|
+
# 月初の通日
|
|
1203
|
+
#
|
|
1204
|
+
# @param [Integer] m 通月
|
|
1205
|
+
#
|
|
1206
|
+
# @return [Integer] 月初の通日
|
|
1207
|
+
#
|
|
1208
|
+
def _new_month_(m)
|
|
1209
|
+
return solar_sdn(@formula[0].cn_to_time(m + @cycle_offset))
|
|
1210
|
+
end
|
|
1211
|
+
|
|
1212
|
+
private
|
|
1213
|
+
|
|
1214
|
+
# オブジェクトの正規化
|
|
1215
|
+
# cycle_offset = 位相のオフセット / 1か月分の角度
|
|
1216
|
+
# formula = 位相の計算に用いる太陽の Formula
|
|
1217
|
+
#
|
|
1218
|
+
def _normalize(args=[], options={})
|
|
1219
|
+
@cycle_offset ||= -1.5
|
|
1220
|
+
@formula ||= "Formula?formula=#{@months_in_year||12}S"
|
|
1221
|
+
super
|
|
1222
|
+
end
|
|
1223
|
+
end
|
|
1224
|
+
|
|
1225
|
+
# 月日の配当が月の位相によって決定される純太陰暦
|
|
1226
|
+
#
|
|
1227
|
+
# Calendar based on the ephemeris of the Moon
|
|
1228
|
+
#
|
|
1229
|
+
class EphemerisBasedLunar < EphemerisBased
|
|
1230
|
+
|
|
1231
|
+
include Lunar
|
|
1232
|
+
|
|
1233
|
+
#protected
|
|
1234
|
+
|
|
1235
|
+
# 月初の通日
|
|
1236
|
+
#
|
|
1237
|
+
# @param [Integer] m 通月
|
|
1238
|
+
#
|
|
1239
|
+
# @return [Integer] 月初の通日
|
|
1240
|
+
#
|
|
1241
|
+
def _new_month_(m)
|
|
1242
|
+
return lunar_sdn(@formula[-1].cn_to_time(m + @cycle_offset))
|
|
1243
|
+
end
|
|
1244
|
+
|
|
1245
|
+
private
|
|
1246
|
+
|
|
1247
|
+
# オブジェクトの正規化
|
|
1248
|
+
# cycle_offset = Goldstein Number に対する暦元の補正
|
|
1249
|
+
#
|
|
1250
|
+
def _normalize(args=[], options={})
|
|
1251
|
+
@cycle_offset ||= 1671 * 12 + 4
|
|
1252
|
+
super
|
|
1253
|
+
end
|
|
1254
|
+
end
|
|
1255
|
+
|
|
1256
|
+
# 月日の配当が太陽および月の位置によって決定される太陰太陽暦
|
|
1257
|
+
#
|
|
1258
|
+
# Calendar based on the ephemeris of the Sun and the Moon
|
|
1259
|
+
#
|
|
1260
|
+
class EphemerisBasedLuniSolar < EphemerisBasedSolar
|
|
1261
|
+
|
|
1262
|
+
include Lunar
|
|
1263
|
+
|
|
1264
|
+
# 計算方法
|
|
1265
|
+
# @return [Array<When::Ephemeris::Formula>]
|
|
1266
|
+
attr_reader :formula
|
|
1267
|
+
|
|
1268
|
+
#protected
|
|
1269
|
+
|
|
1270
|
+
# 年月日 -> 通日
|
|
1271
|
+
#
|
|
1272
|
+
# @param [Numeric] yy 年
|
|
1273
|
+
# @param [Integer] mm 月 (0 始まり)
|
|
1274
|
+
# @param [Integer] dd 日 (0 始まり)
|
|
1275
|
+
#
|
|
1276
|
+
# @return [Integer] 通日
|
|
1277
|
+
#
|
|
1278
|
+
def _coordinates_to_number(yy, mm, dd)
|
|
1279
|
+
_new_month(_new_year_month(+yy) + mm) + dd
|
|
1280
|
+
end
|
|
1281
|
+
|
|
1282
|
+
# 通日 - > 年月日
|
|
1283
|
+
#
|
|
1284
|
+
# @param [Integer] sdn 通日
|
|
1285
|
+
#
|
|
1286
|
+
# @return [Array<Integer>] ( y, m, d )
|
|
1287
|
+
# [ y 年 ]
|
|
1288
|
+
# [ m 月 (0 始まり) ]
|
|
1289
|
+
# [ d 日 (0 始まり) ]
|
|
1290
|
+
#
|
|
1291
|
+
def _number_to_coordinates(sdn)
|
|
1292
|
+
nn, dd = Residue.mod(sdn) {|m| _new_month(m)}
|
|
1293
|
+
yy, mm = Residue.mod(nn) {|y| _new_year_month(y)}
|
|
1294
|
+
[yy, mm, dd]
|
|
1295
|
+
end
|
|
1296
|
+
|
|
1297
|
+
# 暦要素数
|
|
1298
|
+
#
|
|
1299
|
+
# @overload _length(date)
|
|
1300
|
+
# @param [Array<Integer>] date ( 年 )
|
|
1301
|
+
# @return [Integer] その年の月数
|
|
1302
|
+
#
|
|
1303
|
+
# @overload _length(date)
|
|
1304
|
+
# @param [Array<Integer>] date ( 年, 月 )
|
|
1305
|
+
# @note 月は 0 始まり
|
|
1306
|
+
# @return [Integer] その年月の日数
|
|
1307
|
+
#
|
|
1308
|
+
def _length(date)
|
|
1309
|
+
y, m = date
|
|
1310
|
+
if (m)
|
|
1311
|
+
# 指定した月に含まれる日の数を返します。
|
|
1312
|
+
m += _new_year_month(+y)
|
|
1313
|
+
return _new_month(m+1) - _new_month(m)
|
|
1314
|
+
else
|
|
1315
|
+
# 指定した年に含まれる月の数を返します。
|
|
1316
|
+
return _ids([y]).length
|
|
1317
|
+
end
|
|
1318
|
+
end
|
|
1319
|
+
|
|
1320
|
+
private
|
|
1321
|
+
|
|
1322
|
+
# 暦要素数
|
|
1323
|
+
#
|
|
1324
|
+
# @param [Array<Numeric>] date ( y )
|
|
1325
|
+
#
|
|
1326
|
+
# y 年
|
|
1327
|
+
#
|
|
1328
|
+
# @return [Integer] その年の日数
|
|
1329
|
+
#
|
|
1330
|
+
def _sum_(date)
|
|
1331
|
+
y = +date[0]
|
|
1332
|
+
return _new_month(_new_year_month(y+1)) - _new_month(_new_year_month(y))
|
|
1333
|
+
end
|
|
1334
|
+
|
|
1335
|
+
# 太陽月初の通日
|
|
1336
|
+
#
|
|
1337
|
+
#
|
|
1338
|
+
alias :_new_epoch_ :_new_month_
|
|
1339
|
+
|
|
1340
|
+
# 太陰月初の通日
|
|
1341
|
+
#
|
|
1342
|
+
# @param [Integer] m 通月
|
|
1343
|
+
#
|
|
1344
|
+
# @return [Integer] 月初の通日
|
|
1345
|
+
#
|
|
1346
|
+
def _new_month_(m)
|
|
1347
|
+
lunar_sdn(@formula[-1].cn_to_time(m))
|
|
1348
|
+
end
|
|
1349
|
+
|
|
1350
|
+
# 年初の通月
|
|
1351
|
+
#
|
|
1352
|
+
# @param [Integer] y 年
|
|
1353
|
+
#
|
|
1354
|
+
# @return [Integer] 年初の通月
|
|
1355
|
+
#
|
|
1356
|
+
def _new_year_month_(y)
|
|
1357
|
+
raise TypeError, 'EphemerisBasedLuniSolar is abstract class'
|
|
1358
|
+
end
|
|
1359
|
+
|
|
1360
|
+
# オブジェクトの正規化
|
|
1361
|
+
#
|
|
1362
|
+
# cycle_offset = 雨水の場合 -1
|
|
1363
|
+
# formula = 位相の計算に用いる太陽と月の Formula
|
|
1364
|
+
# notes = to_a でデフォルトとして用いる暦注
|
|
1365
|
+
#
|
|
1366
|
+
def _normalize(args=[], options={})
|
|
1367
|
+
@formula ||= ['Formula?formula=12S', 'Formula?formula=1L']
|
|
1368
|
+
super
|
|
1369
|
+
end
|
|
1370
|
+
end
|
|
1371
|
+
|
|
1372
|
+
#
|
|
1373
|
+
# 日時要素の境界 - Border
|
|
1374
|
+
#
|
|
1375
|
+
class Border < When::TM::ReferenceSystem
|
|
1376
|
+
#
|
|
1377
|
+
# 境界の振舞
|
|
1378
|
+
#
|
|
1379
|
+
# @return [Numeric]
|
|
1380
|
+
#
|
|
1381
|
+
# Pair(-1,+1) - 暦年/暦日が進む(境界が前年/日にあり、境界後が当年/日の扱いになる)
|
|
1382
|
+
#
|
|
1383
|
+
# Pair( 0, 0) - 暦年/暦日が戻る(境界が当年/日にあり、境界前が前年/日の扱いになる)
|
|
1384
|
+
#
|
|
1385
|
+
def behavior
|
|
1386
|
+
@border[0]
|
|
1387
|
+
end
|
|
1388
|
+
|
|
1389
|
+
# 境界の取得
|
|
1390
|
+
#
|
|
1391
|
+
# @param [Array<Numeric>] date 境界を計算する年/日
|
|
1392
|
+
# @param [When::TM::ReferenceSystem] frame 使用する暦法/時法
|
|
1393
|
+
#
|
|
1394
|
+
# @return [Array<Numeric>] その年/日の境界
|
|
1395
|
+
#
|
|
1396
|
+
def border(date=[], frame=nil)
|
|
1397
|
+
last = date.length-1
|
|
1398
|
+
return @border if last<0
|
|
1399
|
+
bDate = date[0..last] + @border[(last+1)..-1]
|
|
1400
|
+
branch = @border[last] * 0
|
|
1401
|
+
bDate[last] = When::Coordinates::Pair.new(date[last] * 1, branch)
|
|
1402
|
+
return bDate
|
|
1403
|
+
end
|
|
1404
|
+
|
|
1405
|
+
# 境界の正規化
|
|
1406
|
+
#
|
|
1407
|
+
# @param [Array<Numeric>] date 境界を計算する年/日
|
|
1408
|
+
# @param [When::TM::ReferenceSystem] frame 使用する暦法/時法
|
|
1409
|
+
#
|
|
1410
|
+
# @return [Array<Numeric>] その年/日の境界
|
|
1411
|
+
#
|
|
1412
|
+
def _adjust_epoch(date, frame=nil)
|
|
1413
|
+
s_date = date.dup
|
|
1414
|
+
e_date = border([+date[0]], frame)
|
|
1415
|
+
branch = behavior * 0
|
|
1416
|
+
branch += 1 if (s_date[1..-1] <=> e_date[1..-1]) < 0
|
|
1417
|
+
s_date[0] = When::Coordinates::Pair.new(+s_date[0]-branch, branch)
|
|
1418
|
+
return s_date
|
|
1419
|
+
end
|
|
1420
|
+
|
|
1421
|
+
# 日付の補正
|
|
1422
|
+
# @private
|
|
1423
|
+
def _date_adjust(source)
|
|
1424
|
+
source
|
|
1425
|
+
end
|
|
1426
|
+
|
|
1427
|
+
private
|
|
1428
|
+
|
|
1429
|
+
# 要素の正規化
|
|
1430
|
+
def _normalize(args=[], options={})
|
|
1431
|
+
@border = When::Coordinates::Pair._en_pair_date_time(@border) if (@border.kind_of?(String))
|
|
1432
|
+
end
|
|
1433
|
+
end
|
|
1434
|
+
|
|
1435
|
+
#
|
|
1436
|
+
# 日時要素の境界 - 年/日によって、異なる境界を使用する場合
|
|
1437
|
+
#
|
|
1438
|
+
class MultiBorder < Border
|
|
1439
|
+
|
|
1440
|
+
#
|
|
1441
|
+
# 境界の配列
|
|
1442
|
+
# @return [Array<When::CalendarTypes::Border>]
|
|
1443
|
+
attr_reader :borders
|
|
1444
|
+
|
|
1445
|
+
#
|
|
1446
|
+
# 境界の振舞
|
|
1447
|
+
#
|
|
1448
|
+
# @return [Numeric]
|
|
1449
|
+
#
|
|
1450
|
+
# Pair(-1,+1) - 暦年/暦日が進む(境界が前年/日にあり、境界後が当年/日の扱いになる)
|
|
1451
|
+
#
|
|
1452
|
+
# Pair( 0, 0) - 暦年/暦日が戻る(境界が当年/日にあり、境界前が前年/日の扱いになる)
|
|
1453
|
+
#
|
|
1454
|
+
def behavior
|
|
1455
|
+
@borders[0][:border].behavior
|
|
1456
|
+
end
|
|
1457
|
+
|
|
1458
|
+
# 境界の取得
|
|
1459
|
+
#
|
|
1460
|
+
# @param [Array<Numeric>] date 境界を計算する年/日
|
|
1461
|
+
# @param [When::TM::ReferenceSystem] frame 使用する暦法/時法
|
|
1462
|
+
#
|
|
1463
|
+
# @return [Array<Numeric>] その年/日の境界
|
|
1464
|
+
#
|
|
1465
|
+
def border(date=[], frame=nil)
|
|
1466
|
+
last = date.length-1
|
|
1467
|
+
return @borders[0][:boder] if (last<0)
|
|
1468
|
+
@borders.each do |border|
|
|
1469
|
+
return border[:border].border(date, frame) if date[0] >= border[:key]
|
|
1470
|
+
end
|
|
1471
|
+
date[0..last]
|
|
1472
|
+
end
|
|
1473
|
+
|
|
1474
|
+
# 境界の正規化
|
|
1475
|
+
#
|
|
1476
|
+
# @param [Array<Numeric>] date 境界を計算する年/日
|
|
1477
|
+
# @param [When::TM::ReferenceSystem] frame 使用する暦法/時法
|
|
1478
|
+
#
|
|
1479
|
+
# @return [Array<Numeric>] その年/日の境界
|
|
1480
|
+
#
|
|
1481
|
+
def _adjust_epoch(date, frame=nil)
|
|
1482
|
+
@borders.each do |border|
|
|
1483
|
+
next unless date[0] >= border[:key]
|
|
1484
|
+
s_date = date.dup
|
|
1485
|
+
e_date = border[:border].border(date[0..0], frame)
|
|
1486
|
+
branch = border[:border].behavior * 0
|
|
1487
|
+
branch += 1 if ((s_date[1..-1] <=> e_date[1..-1]) < 0)
|
|
1488
|
+
s_date[0] = When::Coordinates::Pair.new(+s_date[0]-branch, branch)
|
|
1489
|
+
return s_date
|
|
1490
|
+
end
|
|
1491
|
+
date
|
|
1492
|
+
end
|
|
1493
|
+
|
|
1494
|
+
private
|
|
1495
|
+
|
|
1496
|
+
# 要素の正規化
|
|
1497
|
+
def _normalize(args=[], options={})
|
|
1498
|
+
if @borders.kind_of?(String)
|
|
1499
|
+
list = @borders.split(/(\(.+?\))/)
|
|
1500
|
+
list.shift if list[0]==''
|
|
1501
|
+
list.unshift(-Float::MAX) unless list[0] =~ /\(/
|
|
1502
|
+
list.push('0-1-1') if list[-1] =~ /\(/
|
|
1503
|
+
@borders = []
|
|
1504
|
+
loop do
|
|
1505
|
+
key, border, *list = list
|
|
1506
|
+
break unless key
|
|
1507
|
+
key = $1.to_i if key.kind_of?(String) && /\((.+?)\)/ =~ key
|
|
1508
|
+
border = "_c:Border?border=#{border}" unless border =~ /\A[A-Z_]/i
|
|
1509
|
+
border = When.Calendar(border)
|
|
1510
|
+
@borders << {:key=>key, :border=>border}
|
|
1511
|
+
end
|
|
1512
|
+
end
|
|
1513
|
+
@borders = @borders.sort_by {|border| -border[:key]}
|
|
1514
|
+
end
|
|
1515
|
+
end
|
|
1516
|
+
|
|
1517
|
+
#
|
|
1518
|
+
# 日時要素の境界 - 日の出,日の入り
|
|
1519
|
+
#
|
|
1520
|
+
class DayBorder < Border
|
|
1521
|
+
|
|
1522
|
+
# 境界の取得
|
|
1523
|
+
#
|
|
1524
|
+
# @param [Array<Numeric>] date 境界を計算する日
|
|
1525
|
+
# @param [When::TM::ReferenceSystem] clock 使用する時法
|
|
1526
|
+
#
|
|
1527
|
+
# @return [Array<Numeric>] その日の境界
|
|
1528
|
+
#
|
|
1529
|
+
# @note 属性 @event によって境界を計算する (see {When::Ephemeris::Formula#day_event})
|
|
1530
|
+
#
|
|
1531
|
+
def border(date=[], clock=When::UTC)
|
|
1532
|
+
return @border unless date[0] && clock.formula
|
|
1533
|
+
|
|
1534
|
+
time =
|
|
1535
|
+
clock._number_to_coordinates(clock.second *
|
|
1536
|
+
clock.time_standard.from_dynamical_time(
|
|
1537
|
+
When::TM::JulianDate._d_to_t(
|
|
1538
|
+
clock.formula.first.day_event(
|
|
1539
|
+
clock.time_standard.to_dynamical_date(date[0] + @border[0]*0), @event, When.Resource('_ep:Sun'), @height
|
|
1540
|
+
))))
|
|
1541
|
+
|
|
1542
|
+
time[0] += When::TM::JulianDate::JD19700101
|
|
1543
|
+
time[0] = When::Coordinates::Pair.new(time[0]-@border[0]*0, @border[0]*0) unless @border[0]*0 == 0
|
|
1544
|
+
clock._encode(time, false)
|
|
1545
|
+
end
|
|
1546
|
+
|
|
1547
|
+
# 日付の補正
|
|
1548
|
+
# @private
|
|
1549
|
+
def _date_adjust(source)
|
|
1550
|
+
source * 1 + @border[0] * 0
|
|
1551
|
+
end
|
|
1552
|
+
end
|
|
1553
|
+
|
|
1554
|
+
#
|
|
1555
|
+
# 日時要素の境界 - 日の出
|
|
1556
|
+
#
|
|
1557
|
+
class Sunrise < DayBorder
|
|
1558
|
+
|
|
1559
|
+
private
|
|
1560
|
+
|
|
1561
|
+
# 要素の正規化
|
|
1562
|
+
def _normalize(args=[], options={})
|
|
1563
|
+
@border = [0,0,0,0]
|
|
1564
|
+
@event = -1
|
|
1565
|
+
@height ||= '0'
|
|
1566
|
+
end
|
|
1567
|
+
end
|
|
1568
|
+
|
|
1569
|
+
#
|
|
1570
|
+
# 日時要素の境界 - 日の入り
|
|
1571
|
+
#
|
|
1572
|
+
class Sunset < DayBorder
|
|
1573
|
+
|
|
1574
|
+
private
|
|
1575
|
+
|
|
1576
|
+
# 要素の正規化
|
|
1577
|
+
def _normalize(args=[], options={})
|
|
1578
|
+
@border = [When::Coordinates::Pair.new(+1,-1),0,0,0]
|
|
1579
|
+
@event = +1
|
|
1580
|
+
@height ||= '0'
|
|
1581
|
+
end
|
|
1582
|
+
end
|
|
1583
|
+
end
|