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,58 +1,58 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
=begin
|
|
3
|
-
Copyright (C) 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
|
-
=begin
|
|
9
|
-
|
|
10
|
-
References
|
|
11
|
-
|
|
12
|
-
(1) http://calendars.wikia.com/wiki/Goddess_Lunar_Calendar
|
|
13
|
-
(2) http://www.fractal-timewave.com/mmgc/mmgc.htm
|
|
14
|
-
|
|
15
|
-
=end
|
|
16
|
-
|
|
17
|
-
module When
|
|
18
|
-
|
|
19
|
-
class BasicTypes::M17n
|
|
20
|
-
|
|
21
|
-
Goddess = [self, [
|
|
22
|
-
"locale:[=en:, ja]",
|
|
23
|
-
"names:[Goddess=]",
|
|
24
|
-
"[Goddess(MMG)=http://calendars.wikia.com/wiki/Goddess_Lunar_Calendar, ゴッデス暦, *alias:Goddess]",
|
|
25
|
-
|
|
26
|
-
[self,
|
|
27
|
-
"names:[Month]",
|
|
28
|
-
"[Athena]", "[Brigid]", "[Cerridwen]", "[Diana ]",
|
|
29
|
-
"[Epona ]", "[Freya ]", "[Gaea ]", "[Hathor]",
|
|
30
|
-
"[Inanna]", "[Juno ]", "[Kore ]", "[Lilith]",
|
|
31
|
-
"[Maria ]"
|
|
32
|
-
]
|
|
33
|
-
]]
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
module CalendarTypes
|
|
37
|
-
|
|
38
|
-
#
|
|
39
|
-
# Goddess Calendar
|
|
40
|
-
#
|
|
41
|
-
Goddess = [CyclicTableBased, {
|
|
42
|
-
'label' => 'Goddess::Goddess',
|
|
43
|
-
'origin_of_LSC' => 2415611 - 180432, # 1901-08-14 Base Cycle = No.1
|
|
44
|
-
'indices' => [
|
|
45
|
-
When.Index({:unit=>470}),
|
|
46
|
-
When.Index('Goddess::Month'),
|
|
47
|
-
When::Coordinates::DefaultDayIndex,
|
|
48
|
-
],
|
|
49
|
-
'rule_table' => {
|
|
50
|
-
'T' => {'Rule' =>(['L'] * 9 + ['S']) * 23 +
|
|
51
|
-
(['L'] * 4 + ['S']) * 2 +
|
|
52
|
-
(['L'] * 9 + ['S']) * 23},
|
|
53
|
-
'L' => {'Length'=>[30, 29] * 6 + [30]},
|
|
54
|
-
'S' => {'Length'=>[30, 29] * 6 + [29]}
|
|
55
|
-
}
|
|
56
|
-
}]
|
|
57
|
-
end
|
|
58
|
-
end
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
=begin
|
|
3
|
+
Copyright (C) 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
|
+
=begin
|
|
9
|
+
|
|
10
|
+
References
|
|
11
|
+
|
|
12
|
+
(1) http://calendars.wikia.com/wiki/Goddess_Lunar_Calendar
|
|
13
|
+
(2) http://www.fractal-timewave.com/mmgc/mmgc.htm
|
|
14
|
+
|
|
15
|
+
=end
|
|
16
|
+
|
|
17
|
+
module When
|
|
18
|
+
|
|
19
|
+
class BasicTypes::M17n
|
|
20
|
+
|
|
21
|
+
Goddess = [self, [
|
|
22
|
+
"locale:[=en:, ja]",
|
|
23
|
+
"names:[Goddess=]",
|
|
24
|
+
"[Goddess(MMG)=http://calendars.wikia.com/wiki/Goddess_Lunar_Calendar, ゴッデス暦, *alias:Goddess]",
|
|
25
|
+
|
|
26
|
+
[self,
|
|
27
|
+
"names:[Month]",
|
|
28
|
+
"[Athena]", "[Brigid]", "[Cerridwen]", "[Diana ]",
|
|
29
|
+
"[Epona ]", "[Freya ]", "[Gaea ]", "[Hathor]",
|
|
30
|
+
"[Inanna]", "[Juno ]", "[Kore ]", "[Lilith]",
|
|
31
|
+
"[Maria ]"
|
|
32
|
+
]
|
|
33
|
+
]]
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
module CalendarTypes
|
|
37
|
+
|
|
38
|
+
#
|
|
39
|
+
# Goddess Calendar
|
|
40
|
+
#
|
|
41
|
+
Goddess = [CyclicTableBased, {
|
|
42
|
+
'label' => 'Goddess::Goddess',
|
|
43
|
+
'origin_of_LSC' => 2415611 - 180432, # 1901-08-14 Base Cycle = No.1
|
|
44
|
+
'indices' => [
|
|
45
|
+
When.Index({:unit=>470}),
|
|
46
|
+
When.Index('Goddess::Month'),
|
|
47
|
+
When::Coordinates::DefaultDayIndex,
|
|
48
|
+
],
|
|
49
|
+
'rule_table' => {
|
|
50
|
+
'T' => {'Rule' =>(['L'] * 9 + ['S']) * 23 +
|
|
51
|
+
(['L'] * 4 + ['S']) * 2 +
|
|
52
|
+
(['L'] * 9 + ['S']) * 23},
|
|
53
|
+
'L' => {'Length'=>[30, 29] * 6 + [30]},
|
|
54
|
+
'S' => {'Length'=>[30, 29] * 6 + [29]}
|
|
55
|
+
}
|
|
56
|
+
}]
|
|
57
|
+
end
|
|
58
|
+
end
|
|
@@ -1,1251 +1,1254 @@
|
|
|
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
|
-
require 'when_exe/locales/iast'
|
|
9
|
-
|
|
10
|
-
module When
|
|
11
|
-
class BasicTypes::M17n
|
|
12
|
-
|
|
13
|
-
Indian = [self, [
|
|
14
|
-
"locale:[=en:, ja=ja:, hi=hi:, alias]",
|
|
15
|
-
"names:[Indian=]",
|
|
16
|
-
"[IndianNationalSolar=en:Indian_national_calendar,
|
|
17
|
-
"[Nanakshahi=en:Nanakshahi_calendar, ナーナク暦=]",
|
|
18
|
-
"[RevisedBengali=en:Bengali_calendar, 改訂ベンガル暦=]",
|
|
19
|
-
"[HinduSolar=en:Hindu_calendar, インド太陽暦=ja:%%<ヒンドゥー暦>]",
|
|
20
|
-
"[HinduLuniSolar=en:Hindu_calendar, インド太陰太陽暦=ja:%%<ヒンドゥー暦>]",
|
|
21
|
-
|
|
22
|
-
[self,
|
|
23
|
-
"names:[IntercalaryMonth=en:Intercalation, 閏月]",
|
|
24
|
-
"[%s Śuklapakṣa=, %s 白分=, _IAST_=]",
|
|
25
|
-
"[%s Kṛṣṇapakṣa=, %s 黒分=, _IAST_=]",
|
|
26
|
-
"[adhika %s Śuklapakṣa=, 閏%s 白分=, _IAST_=]",
|
|
27
|
-
"[adhika %s Kṛṣṇapakṣa=, 閏%s 黒分=, _IAST_=]"
|
|
28
|
-
],
|
|
29
|
-
|
|
30
|
-
[self,
|
|
31
|
-
"names:[IntercalaryDay=en:Intercalation, 閏日=ja:%%<閏>]",
|
|
32
|
-
"[
|
|
33
|
-
"[Intercalary %s=,
|
|
34
|
-
],
|
|
35
|
-
|
|
36
|
-
[self,
|
|
37
|
-
"names:[LunarMonth=, 太陰月=ja:%%<月_(暦)>]",
|
|
38
|
-
"[Mārgaśīra=en:Margashirsha, マールガシールシャ=, _IAST_=]",
|
|
39
|
-
"[Pauṣa=en:Pausha, パウシャ=, _IAST_=]",
|
|
40
|
-
"[Māgha=en:Maagha, マーガ=, _IAST_=]",
|
|
41
|
-
"[Phālguna=en:Phalguna, パールグナ=, _IAST_=]",
|
|
42
|
-
"[Caitra=en:Chaitra, チャイトラ=, _IAST_=]",
|
|
43
|
-
"[Vaiśākha=en:Vaisakha, ヴァイシャーカ=, _IAST_=]",
|
|
44
|
-
"[Jyaiṣṭha=en:Jyeshta, ジャイシュタ=, _IAST_=]",
|
|
45
|
-
"[Āṣāḍha=en:Aashaadha, アーシャーダ=, _IAST_=]",
|
|
46
|
-
"[Śrāvaṇa=en:Shraavana, シュラーヴァナ=, _IAST_=]",
|
|
47
|
-
"[Bhādrapada=en:Bhadrapada, バードラパダ=, _IAST_=]",
|
|
48
|
-
"[Āśvina=en:Ashwin, アーシュヴィナ=, _IAST_=]",
|
|
49
|
-
"[Kārttika=en:Kartika_(month), カールッティカ=, _IAST_=]"
|
|
50
|
-
],
|
|
51
|
-
|
|
52
|
-
[self,
|
|
53
|
-
"names:[SolarMonth=, 太陽月=ja:%%<月_(暦)>]",
|
|
54
|
-
"[Maysha=, 白羊宮, _IAST_=]",
|
|
55
|
-
"[Vrushabha=, 金牛宮, _IAST_=]",
|
|
56
|
-
"[Mithuna=, 双児宮, _IAST_=]",
|
|
57
|
-
"[Karka=, 巨蟹宮, _IAST_=]",
|
|
58
|
-
"[Simha=, 獅子宮, _IAST_=]",
|
|
59
|
-
"[Kanya=, 処女宮, _IAST_=]",
|
|
60
|
-
"[Tula=, 天秤宮, _IAST_=]",
|
|
61
|
-
"[Vrushchika=, 天蝎宮, _IAST_=]",
|
|
62
|
-
"[Dhanu=, 人馬宮, _IAST_=]",
|
|
63
|
-
"[Makar=, 磨羯宮, _IAST_=]",
|
|
64
|
-
"[Kumbha=, 宝瓶宮, _IAST_=]",
|
|
65
|
-
"[Meena=, 双魚宮, _IAST_=]"
|
|
66
|
-
],
|
|
67
|
-
|
|
68
|
-
[self,
|
|
69
|
-
"names:[NanakshahiMonth=, 太陽月=ja:%%<月_(暦)>]",
|
|
70
|
-
"[Maghar=en:Maghar_(month) ]",
|
|
71
|
-
"[Poh ]",
|
|
72
|
-
"[Magh=en:Magh_(Sikh_calendar)]",
|
|
73
|
-
"[Phagun ]",
|
|
74
|
-
"[Chet=en:Chet_(month) ]",
|
|
75
|
-
"[Vaisakh ]",
|
|
76
|
-
"[Jeth ]",
|
|
77
|
-
"[Harh ]",
|
|
78
|
-
"[Sawan ]",
|
|
79
|
-
"[Bhadon ]",
|
|
80
|
-
"[Assu ]",
|
|
81
|
-
"[Katak ]"
|
|
82
|
-
],
|
|
83
|
-
|
|
84
|
-
[self,
|
|
85
|
-
"names:[BengaliMonth=, 太陽月=ja:%%<月_(暦)>]",
|
|
86
|
-
"[Ogrôhayôn=]",
|
|
87
|
-
"[Poush= ]",
|
|
88
|
-
"[Magh= ]",
|
|
89
|
-
"[Falgun= ]",
|
|
90
|
-
"[Chôitrô= ]",
|
|
91
|
-
"[Bôishakh= ]",
|
|
92
|
-
"[Jyôishţhô=]",
|
|
93
|
-
"[Ashaŗh= ]",
|
|
94
|
-
"[Shrabôn= ]",
|
|
95
|
-
"[Bhadrô= ]",
|
|
96
|
-
"[Ashbin= ]",
|
|
97
|
-
"[Kartik= ]"
|
|
98
|
-
]
|
|
99
|
-
]]
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
module Coordinates
|
|
103
|
-
|
|
104
|
-
# Location of cities in India
|
|
105
|
-
Indian = [When::BasicTypes::M17n, [
|
|
106
|
-
"locale:[=en:, ja=ja:, alias]",
|
|
107
|
-
"names:[Indian]",
|
|
108
|
-
[Spatial, "long:+82.5", "lat:N23.11", "label:[CentralIndia, インド中部]" ],
|
|
109
|
-
[Spatial, "long:+82.5", "lat:+29.0", "label:[NorthIndia, インド北部]" ],
|
|
110
|
-
[Spatial, "long:+78.0", "lat:+27.2", "label:[Agra, アーグラ]" ],
|
|
111
|
-
[Spatial, "long:+72.6", "lat:+23.0", "label:[Ahmedabad, アフマダーバード]" ],
|
|
112
|
-
[Spatial, "long:+74.6", "lat:+26.5", "label:[Ajmer, アジメール]" ],
|
|
113
|
-
[Spatial, "long:+78.1", "lat:+27.9", "label:[Aligarh, アリーガル]" ],
|
|
114
|
-
[Spatial, "long:+74.9", "lat:+31.6", "label:[Amritsar, アムリトサル]" ],
|
|
115
|
-
[Spatial, "long:+77.6", "lat:+13.0", "label:[Bangalore, バンガロール]" ],
|
|
116
|
-
[Spatial, "long:+85.8", "lat:+20.2", "label:[Bhuvaneswar, ブヴァネーシュヴァル]"],
|
|
117
|
-
[Spatial, "long:+80.3", "lat:+13.1", "label:[Chennai, チェンナイ, Madras]" ],
|
|
118
|
-
[Spatial, "long:+79.9", "lat: +6.9", "label:[Colombo, コロンボ]" ],
|
|
119
|
-
[Spatial, "long:+90.4", "lat:+23.7", "label:[Dacca, ダッカ]" ],
|
|
120
|
-
[Spatial, "long:+77.2", "lat:+28.6", "label:[Delhi, デリー]" ],
|
|
121
|
-
[Spatial, "long:+78.5", "lat:+17.4", "label:[Hyderabad, ハイデラバード]" ],
|
|
122
|
-
[Spatial, "long:+75.8", "lat:+26.9", "label:[Jaipur, ジャイプル]" ],
|
|
123
|
-
[Spatial, "long:+85.2", "lat:+27.7", "label:[Kathmandu, カトマンズ]" ],
|
|
124
|
-
[Spatial, "long:+76.2", "lat:+10.0", "label:[Kochi, コーチ, Cochin]" ],
|
|
125
|
-
[Spatial, "long:+88.4", "lat:+22.6", "label:[Kolkata, コルカタ, Calcutta]" ],
|
|
126
|
-
[Spatial, "long:+74.3", "lat:+31.6", "label:[Lahor, ラホール]" ],
|
|
127
|
-
[Spatial, "long:+77.7", "lat:+27.5", "label:[Mathura, マトゥラー]" ],
|
|
128
|
-
[Spatial, "long:+72.8", "lat:+19.0", "label:[Mumbai, ムンバイ, Bombay]" ],
|
|
129
|
-
[Spatial, "long:+76.6", "lat:+12.3", "label:[Mysore, マイソール]" ],
|
|
130
|
-
[Spatial, "long:+85.1", "lat:+25.6", "label:[Patna, パトナ]" ],
|
|
131
|
-
[Spatial, "long:+73.9", "lat:+18.5", "label:[Pune, プネー]" ],
|
|
132
|
-
[Spatial, "long:+74.8", "lat:+34.1", "label:[Srinagar, シュリーナガル]" ],
|
|
133
|
-
[Spatial, "long:+77.0", "lat: +8.5", "label:[Thiruvananthapuram, ティルヴァナンタプラム, Trivandrum]"],
|
|
134
|
-
[Spatial, "long:+83.0", "lat:+25.3", "label:[Varanasi, ワーラーナシー]" ],
|
|
135
|
-
[Spatial, "long:+75.8", "lat:+23.2", "label:[Ujjain, ウッジャイン]" ]
|
|
136
|
-
]]
|
|
137
|
-
end
|
|
138
|
-
|
|
139
|
-
module Ephemeris
|
|
140
|
-
|
|
141
|
-
#
|
|
142
|
-
# Hindu Luni-Solar Calendar Formula
|
|
143
|
-
#
|
|
144
|
-
class Hindu < Formula
|
|
145
|
-
|
|
146
|
-
# Basic Astronomical Constants for Surya-Siddhanta
|
|
147
|
-
Tz = 0.5+75.8/360 # time difference between JulianDayNumber and Ujjain
|
|
148
|
-
E = 588_466 - Tz # Yuga Epoch -3101-02-18T00:00:00
|
|
149
|
-
P = 180 # Precession cycles in yuga
|
|
150
|
-
Ep = 1_903_318 - Tz # Precession Epoch 499-01-01
|
|
151
|
-
Ob = 24.0 / 360.0 # Obliquity of the ecliptic
|
|
152
|
-
|
|
153
|
-
Grahas = {
|
|
154
|
-
'SS' => { # Previous / Newest
|
|
155
|
-
:Star => 1_582_237_800.0, # 1_582_237_500 / 1_582_237_800
|
|
156
|
-
:Sun => 4_320_000.0,
|
|
157
|
-
:Moon => 57_753_336.0,
|
|
158
|
-
:Mercury => 17_937_000.0,
|
|
159
|
-
:Venus => 7_022_388.0,
|
|
160
|
-
:Mars => 2_296_824.0,
|
|
161
|
-
:Jupiter => 364_220.0,
|
|
162
|
-
:Saturn => 146_564.0,
|
|
163
|
-
:Candrocca => 488_219.0, # 488_203 / 488_219
|
|
164
|
-
:Rahu => -232_226.0
|
|
165
|
-
},
|
|
166
|
-
'SB' => {
|
|
167
|
-
:Star => 1_582_237_828.0,
|
|
168
|
-
:Sun => 4_320_000.0,
|
|
169
|
-
:Moon => 57_753_336.0,
|
|
170
|
-
:Mercury => 17_937_060.0,
|
|
171
|
-
:Venus => 7_022_376.0,
|
|
172
|
-
:Mars => 2_296_832.0,
|
|
173
|
-
:Jupiter => 364_220.0,
|
|
174
|
-
:Saturn => 146_568.0,
|
|
175
|
-
:Candrocca => 488_203.0, # 488_199 / 488_203
|
|
176
|
-
:Rahu => -232_238.0
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
#
|
|
181
|
-
# 日月五惑星とラーフおよびケートゥ
|
|
182
|
-
#
|
|
183
|
-
# @abstract
|
|
184
|
-
class Graha
|
|
185
|
-
include When::Ephemeris
|
|
186
|
-
end
|
|
187
|
-
|
|
188
|
-
#
|
|
189
|
-
# 現代的“惑星”
|
|
190
|
-
#
|
|
191
|
-
class ModernGraha < Graha
|
|
192
|
-
|
|
193
|
-
# 真黄経
|
|
194
|
-
#
|
|
195
|
-
# @param [Numeric] t ユリウス日
|
|
196
|
-
#
|
|
197
|
-
# @return [Numeric]
|
|
198
|
-
#
|
|
199
|
-
def true_longitude(t)
|
|
200
|
-
@target.coords(t, @base).phi
|
|
201
|
-
end
|
|
202
|
-
|
|
203
|
-
# オブジェクトの生成
|
|
204
|
-
#
|
|
205
|
-
# @param [When::Ephemeris::Datum] target 天体
|
|
206
|
-
# @param [When::Coordinates::Spatial] base 観測地
|
|
207
|
-
#
|
|
208
|
-
def initialize(target, base)
|
|
209
|
-
@target = target
|
|
210
|
-
@base = base
|
|
211
|
-
end
|
|
212
|
-
end
|
|
213
|
-
|
|
214
|
-
#
|
|
215
|
-
# 古典的“惑星”
|
|
216
|
-
#
|
|
217
|
-
# @abstract
|
|
218
|
-
class ClassicGraha < Graha
|
|
219
|
-
|
|
220
|
-
# 平均黄経
|
|
221
|
-
#
|
|
222
|
-
# @param [Numeric] t ユリウス日
|
|
223
|
-
#
|
|
224
|
-
# @return [Numeric]
|
|
225
|
-
#
|
|
226
|
-
def mean_longitude(t)
|
|
227
|
-
_mean_rotation(t - E)
|
|
228
|
-
end
|
|
229
|
-
|
|
230
|
-
# 真黄経
|
|
231
|
-
#
|
|
232
|
-
# @param [Numeric] t ユリウス日
|
|
233
|
-
#
|
|
234
|
-
# @return [Numeric]
|
|
235
|
-
#
|
|
236
|
-
def true_longitude(t)
|
|
237
|
-
_true_rotation(t - E)
|
|
238
|
-
end
|
|
239
|
-
|
|
240
|
-
# 平均黄経
|
|
241
|
-
#
|
|
242
|
-
# @param [Numeric] ahar カリユガ暦元からの経過日数
|
|
243
|
-
#
|
|
244
|
-
# @return [Numeric]
|
|
245
|
-
#
|
|
246
|
-
def _mean_rotation(ahar)
|
|
247
|
-
@rotation * ahar / @formula.civil_days
|
|
248
|
-
end
|
|
249
|
-
|
|
250
|
-
# オブジェクトの生成
|
|
251
|
-
#
|
|
252
|
-
# @param [When::Ephemeris::Formula] formula 親オブジェクト
|
|
253
|
-
# @param [Numeric] rotation ユガあたりの回転数
|
|
254
|
-
#
|
|
255
|
-
def initialize(formula, rotation)
|
|
256
|
-
@formula = formula
|
|
257
|
-
@rotation = rotation
|
|
258
|
-
end
|
|
259
|
-
end
|
|
260
|
-
|
|
261
|
-
# 架空の“惑星” - ラーフ / 月軌道の遠地点としてのケートゥ
|
|
262
|
-
class VirtualGraha < ClassicGraha
|
|
263
|
-
|
|
264
|
-
# 平均黄経
|
|
265
|
-
#
|
|
266
|
-
# @param [Numeric] ahar カリユガ暦元からの経過日数
|
|
267
|
-
#
|
|
268
|
-
# @return [Numeric]
|
|
269
|
-
#
|
|
270
|
-
def _mean_rotation(ahar)
|
|
271
|
-
super + @rotation0
|
|
272
|
-
end
|
|
273
|
-
alias :_true_rotation :_mean_rotation
|
|
274
|
-
|
|
275
|
-
# オブジェクトの生成
|
|
276
|
-
#
|
|
277
|
-
# @param [When::Ephemeris::Formula] formula 親オブジェクト
|
|
278
|
-
# @param [Numeric] rotation ユガあたりの回転数
|
|
279
|
-
# @param [Numeric] rotation0 カリユガ暦元での回転量
|
|
280
|
-
#
|
|
281
|
-
def initialize(formula, rotation, rotation0)
|
|
282
|
-
@rotation0 = rotation0 / 360.0
|
|
283
|
-
super(formula, rotation)
|
|
284
|
-
end
|
|
285
|
-
end
|
|
286
|
-
|
|
287
|
-
# 実在の“惑星”
|
|
288
|
-
# @abstract
|
|
289
|
-
class RealGraha < ClassicGraha
|
|
290
|
-
|
|
291
|
-
# マンダ補正
|
|
292
|
-
#
|
|
293
|
-
# @param [Numeric] rot 平均近点角など / CIRCLE
|
|
294
|
-
#
|
|
295
|
-
# @return [Numeric]
|
|
296
|
-
#
|
|
297
|
-
def _manda_equation(rot)
|
|
298
|
-
asin(@circumm * sinc(rot)) / CIRCLE
|
|
299
|
-
end
|
|
300
|
-
|
|
301
|
-
# オブジェクトの生成
|
|
302
|
-
#
|
|
303
|
-
# @param [When::Ephemeris::Formula] formula 親オブジェクト
|
|
304
|
-
# @param [Numeric] rotation ユガあたりの回転数
|
|
305
|
-
# @param [Numeric] circumm マンダ円の半径
|
|
306
|
-
# @param [Numeric] apogee 近点黄経 / CIRCLE
|
|
307
|
-
#
|
|
308
|
-
def initialize(formula, rotation, circumm, apogee)
|
|
309
|
-
@circumm = circumm / 360.0
|
|
310
|
-
@apogee = apogee / 360.0
|
|
311
|
-
super(formula, rotation)
|
|
312
|
-
end
|
|
313
|
-
end
|
|
314
|
-
|
|
315
|
-
# 太陽と月 - 逆行しない“惑星”
|
|
316
|
-
# @abstract
|
|
317
|
-
class ConcentricGraha < RealGraha
|
|
318
|
-
|
|
319
|
-
# 平均黄経
|
|
320
|
-
#
|
|
321
|
-
# @param [Numeric] ahar カリユガ暦元からの経過日数
|
|
322
|
-
#
|
|
323
|
-
# @return [Numeric]
|
|
324
|
-
#
|
|
325
|
-
def _mean_rotation(ahar)
|
|
326
|
-
super + @epoch
|
|
327
|
-
end
|
|
328
|
-
|
|
329
|
-
# オブジェクトの生成
|
|
330
|
-
#
|
|
331
|
-
# @param [When::Ephemeris::Formula] formula 親オブジェクト
|
|
332
|
-
# @param [Numeric] rotation ユガあたりの回転数
|
|
333
|
-
# @param [Numeric] circumm マンダ円の半径
|
|
334
|
-
# @param [Numeric] apogee 近点黄経 / CIRCLE
|
|
335
|
-
# @param [Numeric] epoch カリユガ暦元での黄経 / CIRCLE
|
|
336
|
-
#
|
|
337
|
-
def initialize(formula, rotation, circumm, apogee, epoch)
|
|
338
|
-
@epoch = epoch
|
|
339
|
-
super(formula, rotation, circumm, apogee)
|
|
340
|
-
end
|
|
341
|
-
end
|
|
342
|
-
|
|
343
|
-
# 太陽
|
|
344
|
-
class Sun < ConcentricGraha
|
|
345
|
-
|
|
346
|
-
# 真黄経
|
|
347
|
-
#
|
|
348
|
-
# @param [Numeric] ahar カリユガ暦元からの経過日数
|
|
349
|
-
#
|
|
350
|
-
# @return [Numeric]
|
|
351
|
-
#
|
|
352
|
-
def _true_rotation(ahar)
|
|
353
|
-
mean = _mean_rotation(ahar)
|
|
354
|
-
mean - _manda_equation(mean - @apogee)
|
|
355
|
-
end
|
|
356
|
-
end
|
|
357
|
-
|
|
358
|
-
# 月
|
|
359
|
-
class Moon < ConcentricGraha
|
|
360
|
-
|
|
361
|
-
# 真黄経
|
|
362
|
-
#
|
|
363
|
-
# @param [Numeric] ahar カリユガ暦元からの経過日数
|
|
364
|
-
#
|
|
365
|
-
# @return [Numeric]
|
|
366
|
-
#
|
|
367
|
-
def _true_rotation(ahar)
|
|
368
|
-
mean = _mean_rotation(ahar)
|
|
369
|
-
mean - _manda_equation(mean - @formula.graha[:Candrocca]._mean_rotation(ahar))
|
|
370
|
-
end
|
|
371
|
-
end
|
|
372
|
-
|
|
373
|
-
# 惑星 - 逆行するもの
|
|
374
|
-
# @abstract
|
|
375
|
-
class Planet < RealGraha
|
|
376
|
-
|
|
377
|
-
# シグラ補正
|
|
378
|
-
#
|
|
379
|
-
# @param [Numeric] anomaly 平均近点角 / CIRCLE
|
|
380
|
-
#
|
|
381
|
-
# @return [Numeric]
|
|
382
|
-
#
|
|
383
|
-
def _sighra_equation(anomaly)
|
|
384
|
-
atan2(@circums * sinc(anomaly), @circums * cosc(anomaly) + 1) / CIRCLE
|
|
385
|
-
end
|
|
386
|
-
|
|
387
|
-
# 平均シグラ
|
|
388
|
-
#
|
|
389
|
-
# @param [Numeric] ahar カリユガ暦元からの経過日数
|
|
390
|
-
#
|
|
391
|
-
# @return [Numeric]
|
|
392
|
-
#
|
|
393
|
-
def _mean_sighra(ahar)
|
|
394
|
-
@sighra * ahar / @formula.civil_days
|
|
395
|
-
end
|
|
396
|
-
|
|
397
|
-
# 真黄経
|
|
398
|
-
#
|
|
399
|
-
# @param [Numeric] ahar カリユガ暦元からの経過日数
|
|
400
|
-
# @param [Numeric] rotation 基準回転量 / CIRCLE
|
|
401
|
-
#
|
|
402
|
-
# @return [Numeric]
|
|
403
|
-
#
|
|
404
|
-
def _true_rotation(ahar, rotation)
|
|
405
|
-
# first sighra correction
|
|
406
|
-
delta = _sighra_equation(_mean_sighra(ahar) - rotation) / 2
|
|
407
|
-
|
|
408
|
-
# first manda correction
|
|
409
|
-
mean = _mean_rotation(ahar) + delta
|
|
410
|
-
delta = _manda_equation(mean - @apogee) / 2
|
|
411
|
-
|
|
412
|
-
# second manda correction
|
|
413
|
-
mean -= delta
|
|
414
|
-
delta = _manda_equation(mean - @apogee)
|
|
415
|
-
|
|
416
|
-
# second sighra correction
|
|
417
|
-
mean = _mean_rotation(ahar) - delta
|
|
418
|
-
delta = _sighra_equation(_mean_sighra(ahar) - mean)
|
|
419
|
-
|
|
420
|
-
# true rotation
|
|
421
|
-
mean + delta
|
|
422
|
-
end
|
|
423
|
-
|
|
424
|
-
# オブジェクトの生成
|
|
425
|
-
#
|
|
426
|
-
# @param [When::Ephemeris::Formula] formula 親オブジェクト
|
|
427
|
-
# @param [Numeric] rotation ユガあたりの回転数
|
|
428
|
-
# @param [Numeric] circumm マンダ円の半径
|
|
429
|
-
# @param [Numeric] apogee 近点黄経 / CIRCLE
|
|
430
|
-
# @param [Numeric] sighra シグラ対象のカリユガあたりの回転数
|
|
431
|
-
# @param [Numeric] circums シグラ円の半径
|
|
432
|
-
#
|
|
433
|
-
def initialize(formula, rotation, circumm, apogee, sighra, circums)
|
|
434
|
-
@sighra = sighra
|
|
435
|
-
@circums = circums / 360.0
|
|
436
|
-
super(formula, rotation, circumm, apogee)
|
|
437
|
-
end
|
|
438
|
-
end
|
|
439
|
-
|
|
440
|
-
# 内惑星 - 水金
|
|
441
|
-
class InferiorPlanet < Planet
|
|
442
|
-
|
|
443
|
-
# 真黄経
|
|
444
|
-
#
|
|
445
|
-
# @param [Numeric] t ユリウス日
|
|
446
|
-
#
|
|
447
|
-
# @return [Numeric]
|
|
448
|
-
#
|
|
449
|
-
def true_longitude(t)
|
|
450
|
-
ahar = t - E
|
|
451
|
-
_true_rotation(ahar, @formula.graha[:Sun]._mean_rotation(ahar))
|
|
452
|
-
end
|
|
453
|
-
end
|
|
454
|
-
|
|
455
|
-
# 外惑星 - 火木土
|
|
456
|
-
class SuperiorPlanet < Planet
|
|
457
|
-
|
|
458
|
-
# 真黄経
|
|
459
|
-
#
|
|
460
|
-
# @param [Numeric] t ユリウス日
|
|
461
|
-
#
|
|
462
|
-
# @return [Numeric]
|
|
463
|
-
#
|
|
464
|
-
def true_longitude(t)
|
|
465
|
-
ahar = t - E
|
|
466
|
-
_true_rotation(ahar, _mean_rotation(ahar))
|
|
467
|
-
end
|
|
468
|
-
end
|
|
469
|
-
|
|
470
|
-
#
|
|
471
|
-
# ユガの太陽日数
|
|
472
|
-
#
|
|
473
|
-
# @return [Numeric]
|
|
474
|
-
#
|
|
475
|
-
attr_reader :civil_days
|
|
476
|
-
|
|
477
|
-
# 日の出の日時
|
|
478
|
-
#
|
|
479
|
-
# @param [Numeric] sdn ユリウス日
|
|
480
|
-
# @param [When::TM::TemporalPosition] sdn
|
|
481
|
-
# @param [nil] height 太陽高度(本クラスでは使用しない)
|
|
482
|
-
#
|
|
483
|
-
# @return [Integer, When::TM::DateAndTime] 日の出の日時
|
|
484
|
-
#
|
|
485
|
-
def sunrise(sdn, height=nil)
|
|
486
|
-
t = sdn.to_i - @long / 360.0 - 0.25
|
|
487
|
-
p = _mean_sun(t) + P * (t - Ep) / @civil_days
|
|
488
|
-
_to_seed_type(t - asin(tand(@lat)*tan(asin(sinc(p)*sinc(Ob)))) / CIRCLE, sdn)
|
|
489
|
-
end
|
|
490
|
-
|
|
491
|
-
# 日の入りの日時
|
|
492
|
-
#
|
|
493
|
-
# @param [Numeric] sdn ユリウス日
|
|
494
|
-
# @param [When::TM::TemporalPosition] sdn
|
|
495
|
-
# @param [nil] height 太陽高度(本クラスでは使用しない)
|
|
496
|
-
#
|
|
497
|
-
# @return [Integer, When::TM::DateAndTime] 日の入りの日時
|
|
498
|
-
#
|
|
499
|
-
def sunset(sdn, height=nil)
|
|
500
|
-
t = sdn.to_i - @long / 360.0 + 0.25
|
|
501
|
-
p = _mean_sun(t) + P * (t - Ep) / @civil_days
|
|
502
|
-
_to_seed_type(t + asin(tand(@lat)*tan(asin(sinc(p)*sinc(Ob)))) / CIRCLE, sdn)
|
|
503
|
-
end
|
|
504
|
-
|
|
505
|
-
# 太陽の南中の日時
|
|
506
|
-
#
|
|
507
|
-
# @param [Numeric] sdn ユリウス日
|
|
508
|
-
# @param [When::TM::TemporalPosition] sdn
|
|
509
|
-
#
|
|
510
|
-
# @return [Integer, When::TM::DateAndTime] 太陽の南中の日時
|
|
511
|
-
#
|
|
512
|
-
def sun_noon(sdn)
|
|
513
|
-
_to_seed_type(sdn.to_i - @long / 360.0, sdn)
|
|
514
|
-
end
|
|
515
|
-
|
|
516
|
-
private
|
|
517
|
-
|
|
518
|
-
# オブジェクトの正規化
|
|
519
|
-
def _normalize(args=[], options={})
|
|
520
|
-
@time_standard ||= 'universal'
|
|
521
|
-
@bija ||= 'SB'
|
|
522
|
-
super
|
|
523
|
-
end
|
|
524
|
-
|
|
525
|
-
# 9惑星オブジェクトの生成
|
|
526
|
-
def _normalize_grahas
|
|
527
|
-
grahas = Grahas[@bija]
|
|
528
|
-
|
|
529
|
-
# ユガあたりの暦定数
|
|
530
|
-
@sidereal_days = grahas[:Star] # 恒星日
|
|
531
|
-
@solar_years = grahas[:Sun] # 太陽年
|
|
532
|
-
@civil_days = @sidereal_days - @solar_years # 太陽日
|
|
533
|
-
@sidereal_months = grahas[:Moon] # 恒星月
|
|
534
|
-
@synodic_months = @sidereal_months - @solar_years # 朔望月
|
|
535
|
-
@adhimasas = @synodic_months - 12 * @solar_years # 閏月
|
|
536
|
-
@tithis = 30 * @sidereal_months # 太陰日
|
|
537
|
-
@ksayadinas = @tithis - @civil_days # 欠日
|
|
538
|
-
|
|
539
|
-
# 9惑星
|
|
540
|
-
@graha = {}
|
|
541
|
-
@graha.update({
|
|
542
|
-
:Sun => Sun.new( self, @solar_years, 13+50/60.0, 77+17/60.0, -3101)
|
|
543
|
-
}) if @formula =~ /[SL]/i
|
|
544
|
-
@graha.update({
|
|
545
|
-
:Moon => Moon.new( self, @sidereal_months, 31+50/60.0, 0, -28086),
|
|
546
|
-
:Candrocca => VirtualGraha.new( self, grahas[:Candrocca], 90.0)
|
|
547
|
-
}) if @formula =~ /[ML]/i
|
|
548
|
-
@graha.update({
|
|
549
|
-
:Mercury => InferiorPlanet.new(self, @solar_years, 29.0, 220+27/60.0, grahas[:Mercury], 131.5),
|
|
550
|
-
:Venus => InferiorPlanet.new(self, @solar_years, 11.5, 79+50/60.0, grahas[:Venus], 261.0),
|
|
551
|
-
:Mars => SuperiorPlanet.new(self, grahas[:Mars], 73.5, 130+02/60.0, @solar_years, 233.5),
|
|
552
|
-
:Jupiter => SuperiorPlanet.new(self, grahas[:Jupiter], 32.5, 171+18/60.0, @solar_years, 71.0),
|
|
553
|
-
:Saturn => SuperiorPlanet.new(self, grahas[:Saturn], 48.5, 236+37/60.0, @solar_years, 39.5),
|
|
554
|
-
:Rahu => VirtualGraha.new( self, grahas[:Rahu], 180.0)
|
|
555
|
-
}) if @formula == '2L'
|
|
556
|
-
end
|
|
557
|
-
end
|
|
558
|
-
end
|
|
559
|
-
|
|
560
|
-
module CalendarTypes
|
|
561
|
-
|
|
562
|
-
#
|
|
563
|
-
# Indian national solar calendar
|
|
564
|
-
#
|
|
565
|
-
IndianNationalSolar = [CyclicTableBased, {
|
|
566
|
-
'label' => 'Indian::IndianNationalSolar',
|
|
567
|
-
'origin_of_LSC' => 1721140,
|
|
568
|
-
'origin_of_MSC' => -78,
|
|
569
|
-
'epoch_in_CE' => 0,
|
|
570
|
-
'indices' => [
|
|
571
|
-
When.Index('Indian::LunarMonth', {:unit =>12, :shift=>4}),
|
|
572
|
-
When::Coordinates::DefaultDayIndex
|
|
573
|
-
],
|
|
574
|
-
'rule_table' => {
|
|
575
|
-
'T' => {'Rule' =>['LC', 'SC', 'SC', 'SC']},
|
|
576
|
-
'SC' => {'Rule' =>[365]*4 + [366, 365, 365, 365]*24},
|
|
577
|
-
'LC' => {'Rule' =>[366, 365, 365, 365]*25},
|
|
578
|
-
365 => {'Length'=>[30] + [31]*5 + [30]*6},
|
|
579
|
-
366 => {'Length'=> [31]*6 + [30]*6}
|
|
580
|
-
},
|
|
581
|
-
}]
|
|
582
|
-
|
|
583
|
-
#
|
|
584
|
-
# Nanakshahi Calendar
|
|
585
|
-
#
|
|
586
|
-
class Nanakshahi < TableBased
|
|
587
|
-
|
|
588
|
-
private
|
|
589
|
-
|
|
590
|
-
#
|
|
591
|
-
# Object Normalization
|
|
592
|
-
#
|
|
593
|
-
def _normalize(args=[], options={})
|
|
594
|
-
@label ||= 'Indian::Nanakshahi'
|
|
595
|
-
@epoch_in_CE ||= 1468
|
|
596
|
-
@engine ||= 'Gregorian'
|
|
597
|
-
@engine = When.Calendar(@engine)
|
|
598
|
-
@indices ||= [
|
|
599
|
-
When.Index('Indian::NanakshahiMonth', {:unit=>12, :shift=>4}),
|
|
600
|
-
When::Coordinates::DefaultDayIndex
|
|
601
|
-
]
|
|
602
|
-
@rule_table ||= {
|
|
603
|
-
365 => {'Length'=> [31]*5 + [30]*7},
|
|
604
|
-
366 => {'Length'=> [31]*5 + [30]*6 + [31]}
|
|
605
|
-
}
|
|
606
|
-
super
|
|
607
|
-
end
|
|
608
|
-
|
|
609
|
-
# first day of year
|
|
610
|
-
#
|
|
611
|
-
def _sdn_(date)
|
|
612
|
-
year = +date[0] + @epoch_in_CE
|
|
613
|
-
@engine._coordinates_to_number(year, 2, 13)
|
|
614
|
-
end
|
|
615
|
-
end
|
|
616
|
-
|
|
617
|
-
#
|
|
618
|
-
# Revised Bengali Calendar
|
|
619
|
-
#
|
|
620
|
-
class RevisedBengali < TableBased
|
|
621
|
-
|
|
622
|
-
private
|
|
623
|
-
|
|
624
|
-
#
|
|
625
|
-
# Object Normalization
|
|
626
|
-
#
|
|
627
|
-
def _normalize(args=[], options={})
|
|
628
|
-
@label ||= 'Indian::RevisedBengali'
|
|
629
|
-
@epoch_in_CE ||= 593
|
|
630
|
-
@engine ||= 'Gregorian'
|
|
631
|
-
@engine = When.Calendar(@engine)
|
|
632
|
-
@indices ||= [
|
|
633
|
-
When.Index('Indian::BengaliMonth', {:unit=>12, :shift=>5}),
|
|
634
|
-
When::Coordinates::DefaultDayIndex
|
|
635
|
-
]
|
|
636
|
-
@rule_table ||= {
|
|
637
|
-
365 => {'Length'=> [31]*5 + [30]*7},
|
|
638
|
-
366 => {'Length'=> [31]*5 + [30]*5 + [31, 30]}
|
|
639
|
-
}
|
|
640
|
-
super
|
|
641
|
-
end
|
|
642
|
-
|
|
643
|
-
# first day of year
|
|
644
|
-
#
|
|
645
|
-
def _sdn_(date)
|
|
646
|
-
year = +date[0] + @epoch_in_CE
|
|
647
|
-
@engine._coordinates_to_number(year, 3, 13)
|
|
648
|
-
end
|
|
649
|
-
end
|
|
650
|
-
|
|
651
|
-
#
|
|
652
|
-
# Hindu Solar Calendar
|
|
653
|
-
#
|
|
654
|
-
class HinduSolar < EphemerisBasedSolar
|
|
655
|
-
|
|
656
|
-
# protected
|
|
657
|
-
|
|
658
|
-
# 月初の通日
|
|
659
|
-
#
|
|
660
|
-
# @param [Integer] m 通月
|
|
661
|
-
#
|
|
662
|
-
# @return [Integer] 月初の通日
|
|
663
|
-
#
|
|
664
|
-
def _new_month_(m)
|
|
665
|
-
new_month_time = @formula[0].cn_to_time(m + @cycle_offset)
|
|
666
|
-
new_month_date = (new_month_time + 0.5 + @formula[0].long/360.0).floor
|
|
667
|
-
sunrise_time = @formula[0].sunrise(new_month_date)
|
|
668
|
-
(sunrise_time <= new_month_time) ? new_month_date : new_month_date-1
|
|
669
|
-
end
|
|
670
|
-
|
|
671
|
-
private
|
|
672
|
-
|
|
673
|
-
# オブジェクトの正規化
|
|
674
|
-
#
|
|
675
|
-
# @formula[0] = 位相の計算に用いる太陽の Formula
|
|
676
|
-
# @cycle_offset = 位相のオフセット
|
|
677
|
-
# @start_month = 暦年の最初の月
|
|
678
|
-
#
|
|
679
|
-
def _normalize(args=[], options={})
|
|
680
|
-
@label ||= 'Indian::HinduSolar'
|
|
681
|
-
@type ||= 'SBS'
|
|
682
|
-
raise ArgumentError, "Irregal formula: #{@formula}" unless @type.upcase =~
|
|
683
|
-
|
|
684
|
-
@location ||= HinduLuniSolar::Location_E[$2] || HinduLuniSolar::Location_F[$1]
|
|
685
|
-
@cycle_offset ||= HinduLuniSolar::CycleOffset[$1]
|
|
686
|
-
@origin_of_MSC ||= -HinduLuniSolar::YearEpoch[$2]
|
|
687
|
-
@epoch_in_CE ||= 0
|
|
688
|
-
@start_month ||= 1 # Maysha
|
|
689
|
-
@start_month = @start_month.to_i
|
|
690
|
-
@cycle_offset = @cycle_offset.to_f + (@start_month - 1)
|
|
691
|
-
formula = @formula || HinduLuniSolar::Formula[$1]
|
|
692
|
-
if formula.kind_of?(String)
|
|
693
|
-
formula += (formula =~ /\?/) ? '&' : '?'
|
|
694
|
-
@formula = [When.Resource("_ep:#{formula}location=(#{@location})&formula=12S")]
|
|
695
|
-
end
|
|
696
|
-
@indices ||= [
|
|
697
|
-
When.Index('Indian::SolarMonth', {:shift=>@start_month-1}),
|
|
698
|
-
When::Coordinates::DefaultDayIndex
|
|
699
|
-
]
|
|
700
|
-
|
|
701
|
-
super
|
|
702
|
-
end
|
|
703
|
-
end
|
|
704
|
-
|
|
705
|
-
#
|
|
706
|
-
# Hindu Luni-Solar Calendar
|
|
707
|
-
#
|
|
708
|
-
class HinduLuniSolar < EphemerisBasedLuniSolar
|
|
709
|
-
|
|
710
|
-
# Calendar Type
|
|
711
|
-
Formula = {'M'=>'Formula', 'SS'=>'Hindu?bija=SS', 'SB'=>'Hindu?bija=SB'}
|
|
712
|
-
Location_F = {'M'=>'_co:Indian::CentralIndia', 'SS'=>'_co:Indian::Ujjain', 'SB'=>'_co:Indian::Ujjain'}
|
|
713
|
-
Location_E = {'B'=>'_co:Indian::Dacca', 'BZ'=>'_co:Indian::Dacca', 'H'=>'_co:Iranian::Tehran', 'HZ'=>'_co:Iranian::Tehran'}
|
|
714
|
-
CycleOffset = {'M'=>+23.25/30, 'SS'=>0.0, 'SB'=>0.0}
|
|
715
|
-
HinduStyle = {'A'=>0, 'P'=>1, 'PX'=>2}
|
|
716
|
-
YearEpoch = {'V'=>-58,'VZ'=>-57,'S'=>78, 'SZ'=>79, 'B'=> 593, 'BZ'=>594, 'H'=> 621, 'HZ'=> 622}
|
|
717
|
-
|
|
718
|
-
# White / black month and leap month identification table
|
|
719
|
-
|
|
720
|
-
#[w]/b [n]/l #0 #1 #2
|
|
721
|
-
LEAP_MAP = {[nil, false] => [ 0, 0, 0 ],
|
|
722
|
-
[nil, true ] => [-1.5, -1.5, -1.5],
|
|
723
|
-
[true, false] => [+0.5, -0.5, -2.5],
|
|
724
|
-
[true, true ] => [-1, -2, -1 ]}
|
|
725
|
-
|
|
726
|
-
# protected
|
|
727
|
-
|
|
728
|
-
# 月初の通日
|
|
729
|
-
#
|
|
730
|
-
# @param [Integer] m 通月
|
|
731
|
-
#
|
|
732
|
-
# @return [Integer] 月初の通日
|
|
733
|
-
#
|
|
734
|
-
def _new_month_(m)
|
|
735
|
-
new_moon_time = @formula[-1].cn_to_time(m)
|
|
736
|
-
new_moon_date = (new_moon_time + 0.5 + @formula[-1].long/360.0).floor
|
|
737
|
-
sunrise_time = @formula[-1].sunrise(new_moon_date)
|
|
738
|
-
(sunrise_time >= new_moon_time) ? new_moon_date : new_moon_date+1
|
|
739
|
-
end
|
|
740
|
-
|
|
741
|
-
# 年初の通月
|
|
742
|
-
#
|
|
743
|
-
# @param [Integer] y 年
|
|
744
|
-
#
|
|
745
|
-
# @return [Integer] 年初の通月
|
|
746
|
-
#
|
|
747
|
-
def _new_year_month_(y)
|
|
748
|
-
(Residue.mod(y-1) {|t| _tithi_to_coordinates(t*15)[0]})[0] + 1
|
|
749
|
-
end
|
|
750
|
-
|
|
751
|
-
# 朔望日 -> 年・月・日
|
|
752
|
-
#
|
|
753
|
-
# tithi : 朔望日(月の位相 / (CIRCLE/30))
|
|
754
|
-
#
|
|
755
|
-
# @return [Array<Numeric>] ( y, m, d )
|
|
756
|
-
# [ y - 年(Integer) ]
|
|
757
|
-
# [ m - 月(When::Coordinates::Pair) ]
|
|
758
|
-
# [ d - 日(Integer) ]
|
|
759
|
-
#
|
|
760
|
-
def _tithi_to_coordinates(tithi)
|
|
761
|
-
m, d = tithi.divmod(30)
|
|
762
|
-
s = [0,1,2].map {|i| (@formula[1].time_to_cn(30*(m+i)) - @cycle_offset).floor + 1 }
|
|
763
|
-
f = s[0]==s[1]
|
|
764
|
-
if (d >= 15.0)
|
|
765
|
-
d -= 15
|
|
766
|
-
b = true
|
|
767
|
-
n = true unless @hindu_style==0
|
|
768
|
-
f = s[1]==s[2] if @hindu_style==1
|
|
769
|
-
end
|
|
770
|
-
y, m = (n ? s[1] : s[0]).divmod(12)
|
|
771
|
-
return [y, Pair._force_pair(m+1, LEAP_MAP[[b,f]][@hindu_style]), d.floor]
|
|
772
|
-
end
|
|
773
|
-
|
|
774
|
-
# 日時要素の翻訳表の取得
|
|
775
|
-
#
|
|
776
|
-
# @overload _ids_(date)
|
|
777
|
-
# @param [Array<Numeric>] date ( 年 )
|
|
778
|
-
# @return [Array<When::Coordinates::Pair>] 1年の月の配置の翻訳表
|
|
779
|
-
#
|
|
780
|
-
# @overload _ids_(date)
|
|
781
|
-
# @param [Array<Numeric>] date ( 年 月 )
|
|
782
|
-
# @return [Array<When::Coordinates::Pair>] 1月の日の配置の翻訳表
|
|
783
|
-
# @note 月は 0 始まりの通番
|
|
784
|
-
#
|
|
785
|
-
def _ids_(date)
|
|
786
|
-
y, m = date
|
|
787
|
-
y = +y
|
|
788
|
-
mm = _new_year_month(y)
|
|
789
|
-
return (_table(_new_month_(mm+m.to_i)) {|i| _new_month(mm+m+i/15.0)}) if m
|
|
790
|
-
table = (0...26).to_a.map {|i| _tithi_to_coordinates((mm+i)*15)[1]}
|
|
791
|
-
table.pop while table[-1].trunk < 11
|
|
792
|
-
return table
|
|
793
|
-
end
|
|
794
|
-
|
|
795
|
-
private
|
|
796
|
-
|
|
797
|
-
# 日時要素の翻訳表の作成
|
|
798
|
-
def _table(b0)
|
|
799
|
-
table = [Pair._force_pair(0,0)]
|
|
800
|
-
(1..16).each do |i|
|
|
801
|
-
b1 = yield(i)
|
|
802
|
-
case b1-b0
|
|
803
|
-
when 0 ; table[-1] = Pair._force_pair(i-1, -2)
|
|
804
|
-
when 1 ; table << Pair._force_pair(i, 0)
|
|
805
|
-
when 2 ; table << Pair._force_pair(i, 0) << Pair._force_pair(i, 1)
|
|
806
|
-
else ; raise ArgumentError, "Irregal date span: #{b1-b0}"
|
|
807
|
-
end
|
|
808
|
-
b0 = b1
|
|
809
|
-
end
|
|
810
|
-
table.pop while table[-1].trunk >= 16
|
|
811
|
-
table.shift
|
|
812
|
-
return table
|
|
813
|
-
end
|
|
814
|
-
|
|
815
|
-
# オブジェクトの正規化
|
|
816
|
-
#
|
|
817
|
-
# @formula = 位相の計算に用いる太陽・変換・月の Formula
|
|
818
|
-
# @cycle_offset = 位相のオフセット
|
|
819
|
-
# @hindu_style = 閏月の表現方法
|
|
820
|
-
# @start_month = 暦年の最初の月
|
|
821
|
-
#
|
|
822
|
-
def _normalize(args=[], options={})
|
|
823
|
-
@label ||= 'Indian::HinduLuniSolar'
|
|
824
|
-
@type ||= 'SBSA'
|
|
825
|
-
raise ArgumentError, "Irregal formula: #{@formula}" unless @type.upcase =~
|
|
826
|
-
|
|
827
|
-
@location ||= Location_E[$2] || Location_F[$1]
|
|
828
|
-
@cycle_offset ||= CycleOffset[$1]
|
|
829
|
-
@origin_of_MSC ||= -YearEpoch[$2]
|
|
830
|
-
@hindu_style ||= HinduStyle[$3]
|
|
831
|
-
@epoch_in_CE ||= 0
|
|
832
|
-
@start_month ||= 5 # Chaitra
|
|
833
|
-
@start_month = @start_month.to_i
|
|
834
|
-
@cycle_offset = @cycle_offset.to_f + (@start_month - 5)
|
|
835
|
-
@hindu_style = @hindu_style.to_i
|
|
836
|
-
@origin_of_MSC = @origin_of_MSC.to_i
|
|
837
|
-
formula = @formula || Formula[$1]
|
|
838
|
-
if formula.kind_of?(String)
|
|
839
|
-
formula += (formula =~ /\?/) ? '&' : '?'
|
|
840
|
-
@formula = When.Resource(["_ep:#{formula}formula=12S",
|
|
841
|
-
"_ep:#{formula}formula=30L->12S",
|
|
842
|
-
"_ep:#{formula}location=(#{@location})&formula=2L"])
|
|
843
|
-
end
|
|
844
|
-
intercalary_month = When.Resource('_m:Indian::IntercalaryMonth::*')
|
|
845
|
-
intercalary_day = When.Resource('_m:Indian::IntercalaryDay::*')
|
|
846
|
-
@indices ||= [
|
|
847
|
-
When.Index('Indian::LunarMonth', {:branch=>{-2.5 => intercalary_month[1], # 黒分
|
|
848
|
-
-2 => intercalary_month[3], # 閏黒分
|
|
849
|
-
-1.5 => intercalary_month[2], # 閏白分
|
|
850
|
-
-1 => intercalary_month[3], # 閏黒分
|
|
851
|
-
-0.5 => intercalary_month[1], # 黒分
|
|
852
|
-
0 => intercalary_month[0], # 白分
|
|
853
|
-
+0.5 => intercalary_month[1]}, # 黒分
|
|
854
|
-
:shift=>@start_month-1}),
|
|
855
|
-
When.Index({:branch=>{-2=>intercalary_day[0],
|
|
856
|
-
]
|
|
857
|
-
|
|
858
|
-
super
|
|
859
|
-
end
|
|
860
|
-
end
|
|
861
|
-
end
|
|
862
|
-
|
|
863
|
-
class CalendarNote
|
|
864
|
-
#
|
|
865
|
-
# ヒンドゥー系の暦注
|
|
866
|
-
#
|
|
867
|
-
class HinduNote < self
|
|
868
|
-
|
|
869
|
-
Notes = [When::BasicTypes::M17n, [
|
|
870
|
-
"locale:[=en:, ja=ja:, hi=hi:, alias]",
|
|
871
|
-
"names:[Hindu]",
|
|
872
|
-
|
|
873
|
-
# 年の暦注 ----------------------------
|
|
874
|
-
[When::BasicTypes::M17n,
|
|
875
|
-
"names:[year]",
|
|
876
|
-
[When::BasicTypes::M17n,
|
|
877
|
-
"names:[samvatsara, 木星年=]",
|
|
878
|
-
"[Prabhava=, プラバヴァ=, _IAST_=]", # 1
|
|
879
|
-
"[Vibhava=, ヴィバヴァ=, _IAST_=]", # 2
|
|
880
|
-
"[Sukha=, スカ=, _IAST_=]", # 3
|
|
881
|
-
"[Pramoda=, プラモーダ=, _IAST_=]", # 4
|
|
882
|
-
"[Prajāpati=, プラジャーパティ=, _IAST_=]", # 5
|
|
883
|
-
"[Aṅgiras=, アンギラス=, _IAST_=]", # 6
|
|
884
|
-
"[Śrīmukha=, シュリームカ=, _IAST_=]", # 7
|
|
885
|
-
"[Bhāva=, バーヴァ=, _IAST_=]", # 8
|
|
886
|
-
"[Yuvan=, ユヴァン=, _IAST_=]", # 9
|
|
887
|
-
"[Dhātṛ=, ダートリ=, _IAST_=]", # 10
|
|
888
|
-
"[Īśvara=, イーシュヴァラ=, _IAST_=]", # 11
|
|
889
|
-
"[Bahudhānya=, バフダーニャ=, _IAST_=]", # 12
|
|
890
|
-
"[Pramāthin=, プラマーティン=, _IAST_=]", # 13
|
|
891
|
-
"[Vikrama=, ヴィクラマ=, _IAST_=]", # 14
|
|
892
|
-
"[Vṛṣa=, ヴリシャ=, _IAST_=]", # 15
|
|
893
|
-
"[Chitrabhānu=, チトラバーヌ=, _IAST_=]", # 16
|
|
894
|
-
"[Subhānu=, スバーヌ=, _IAST_=]", # 17
|
|
895
|
-
"[Tāraṇa=, ターラナ=, _IAST_=]", # 18
|
|
896
|
-
"[Pārthiva=, パールティヴァ=, _IAST_=]", # 19
|
|
897
|
-
"[Vyaya=, ヴヤヤ=, _IAST_=]", # 20
|
|
898
|
-
"[Sarvajit=, サルヴァジト=, _IAST_=]", # 21
|
|
899
|
-
"[Sarvadhārin=, サルヴァダーリン=, _IAST_=]", # 22
|
|
900
|
-
"[Virodhin=, ヴィローディン=, _IAST_=]", # 23
|
|
901
|
-
"[Vikṛta=, ヴィクリタ=, _IAST_=]", # 24
|
|
902
|
-
"[Khara=, カラ=, _IAST_=]", # 25
|
|
903
|
-
"[Nandana=, ナンダナ=, _IAST_=]", # 26
|
|
904
|
-
"[Vijaya=, ヴィジャヤ=, _IAST_=]", # 27
|
|
905
|
-
"[Jaya=, ジャヤ=, _IAST_=]", # 28
|
|
906
|
-
"[Manmatha=, マンマタ=, _IAST_=]", # 29
|
|
907
|
-
"[Durmukha=, ドゥルムカ=, _IAST_=]", # 30
|
|
908
|
-
"[Hemalamba=, ヘマラムバ=, _IAST_=]", # 31
|
|
909
|
-
"[Vilambin=, ヴィラムビン=, _IAST_=]", # 32
|
|
910
|
-
"[Vikārin=, ヴィカーリン=, _IAST_=]", # 33
|
|
911
|
-
"[Śārvarin=, シャールヴァリン=, _IAST_=]", # 34
|
|
912
|
-
"[Plava=, プラヴァ=, _IAST_=]", # 35
|
|
913
|
-
"[Śubhakṛt=, シュバクリト=, _IAST_=]", # 36
|
|
914
|
-
"[Śobhana=, ショバナ=, _IAST_=]", # 37
|
|
915
|
-
"[Krodhin=, クロディン=, _IAST_=]", # 38
|
|
916
|
-
"[Viśvāvasu=, ヴィシュヴァーヴァス=, _IAST_=]", # 39
|
|
917
|
-
"[Parābhava=, パラーバヴァ=, _IAST_=]", # 40
|
|
918
|
-
"[Plavaṅga=, プラヴァンガ=, _IAST_=]", # 41
|
|
919
|
-
"[Kīlaka=, キーラカ=, _IAST_=]", # 42
|
|
920
|
-
"[Saumya=, サウムヤ=, _IAST_=]", # 43
|
|
921
|
-
"[Sādhāraṇa=, サーダーラナ=, _IAST_=]", # 44
|
|
922
|
-
"[Virodhakṛt=, ヴィローダクリト=, _IAST_=]", # 45
|
|
923
|
-
"[Paridhāvin=, パリダーヴィン=, _IAST_=]", # 46
|
|
924
|
-
"[Pramādin=, プラマーディン=, _IAST_=]", # 47
|
|
925
|
-
"[Ānanda=, アーナンダ=, _IAST_=]", # 48
|
|
926
|
-
"[Rākṣasa=, ラークシャサ=, _IAST_=]", # 49
|
|
927
|
-
"[Anala=, アナラ=, _IAST_=]", # 50
|
|
928
|
-
"[Piṅgala=, ピンガラ=, _IAST_=]", # 51
|
|
929
|
-
"[Kālayukta=, カーラユクタ=, _IAST_=]", # 52
|
|
930
|
-
"[Siddhārthin=, シッダールティン=, _IAST_=]", # 53
|
|
931
|
-
"[Raudra=, ラウドラ=, _IAST_=]", # 54
|
|
932
|
-
"[Durmati=, ドゥルマティ=, _IAST_=]", # 55
|
|
933
|
-
"[Dundubhi=, ドゥンドゥビ=, _IAST_=]", # 56
|
|
934
|
-
"[Rudhirodgārin=, ルディロードガーリン=, _IAST_=]", # 57
|
|
935
|
-
"[Raktākṣin=, ラクタークシン=, _IAST_=]", # 58
|
|
936
|
-
"[Krodhana=, クローダナ=, _IAST_=]", # 59
|
|
937
|
-
"[Kṣaya=, クシャヤ=, _IAST_=]" # 60
|
|
938
|
-
]
|
|
939
|
-
],
|
|
940
|
-
|
|
941
|
-
# 月の暦注 ----------------------------
|
|
942
|
-
[When::BasicTypes::M17n,
|
|
943
|
-
"names:[month]",
|
|
944
|
-
[When::BasicTypes::M17n,
|
|
945
|
-
"names:[Month]"
|
|
946
|
-
]
|
|
947
|
-
],
|
|
948
|
-
|
|
949
|
-
# 日の暦注 ----------------------------
|
|
950
|
-
[When::BasicTypes::M17n,
|
|
951
|
-
"names:[day]",
|
|
952
|
-
|
|
953
|
-
[When::BasicTypes::M17n,
|
|
954
|
-
"names:[tithi=, ティティ=ja:%%<ティティ>]",
|
|
955
|
-
"[Amavasya, 新月, _IAST_=]", # 新月
|
|
956
|
-
"[Pratipad=en:Prathama_(day), 1日=, _IAST_=]", # 1
|
|
957
|
-
"[Dwitiya, 2日=, _IAST_=]", # 2
|
|
958
|
-
"[Tritiya, 3日=, _IAST_=]", # 3
|
|
959
|
-
"[Chaturthi, 4日=, _IAST_=]", # 4
|
|
960
|
-
"[Panchami, 5日=, _IAST_=]", # 5
|
|
961
|
-
"[Ṣaṣṭhī=en:Shashti, 6日=, _IAST_=]", # 6
|
|
962
|
-
"[Saptami, 7日=, _IAST_=]", # 7
|
|
963
|
-
"[Ashtami, 8日=, _IAST_=]", # 8
|
|
964
|
-
"[Navami, 9日=, _IAST_=]", # 9
|
|
965
|
-
"[Dashami, 10日=, _IAST_=]", # 10
|
|
966
|
-
"[Ekadashi, 11日=, _IAST_=]", # 11
|
|
967
|
-
"[Dwadashi, 12日=, _IAST_=]", # 12
|
|
968
|
-
"[Thrayodashi, 13日=, _IAST_=]", # 13
|
|
969
|
-
"[Chaturdashi, 14日=, _IAST_=]", # 14
|
|
970
|
-
"[Purnima, 満月, _IAST_=]" # 満月
|
|
971
|
-
],
|
|
972
|
-
|
|
973
|
-
[When::BasicTypes::M17n,
|
|
974
|
-
"names:[vāra=, ヴァーラ=, _IAST_=, *vara=]",
|
|
975
|
-
"[Ravi=en:S%C5%ABrya, 日曜日, _IAST_=]",
|
|
976
|
-
"[Soma, 月曜日, _IAST_=]",
|
|
977
|
-
"[Maṅgala=en:Mangala, 火曜日, _IAST_=]",
|
|
978
|
-
"[Budha, 水曜日, _IAST_=]",
|
|
979
|
-
"[Guru, 木曜日, _IAST_=]",
|
|
980
|
-
"[Śukra=en:Shukra, 金曜日, _IAST_=]",
|
|
981
|
-
"[Śani=en:Shani, 土曜日, _IAST_=]"
|
|
982
|
-
],
|
|
983
|
-
|
|
984
|
-
[When::BasicTypes::M17n,
|
|
985
|
-
"names:[nakṣatra=, ナクシャトラ=, _IAST_=, *naksatra=]",
|
|
986
|
-
"[Aśvinī=en:Ashvin%C4%AB, アシュヴィニー=, _IAST_=, 婁宿]", # 1
|
|
987
|
-
"[Bharaṇī=en:Bharan%C4%AB, バラニー=, _IAST_=, 胃宿]", # 2
|
|
988
|
-
"[Kṛttikā=en:Krittik%C4%81, クリッティカー=, _IAST_=, 昴宿]", # 3
|
|
989
|
-
"[Rohiṇī=en:Rohini_(nakshatra), ローヒニ―=, _IAST_=, 畢宿]", # 4
|
|
990
|
-
"[Mṛgaśiras=en:Mrigash%C4%ABrsha, ムリガシラス=, _IAST_=, 觜宿]", # 5
|
|
991
|
-
"[Ārdrā=en:Ardra_(nakshatra), アールドラー=, _IAST_=, 參宿]", # 6
|
|
992
|
-
"[Punarvasu=en:Punarvasu, プナルヴァス=, _IAST_=, 井宿]", # 7
|
|
993
|
-
"[Puṣya=en:Pushya, プシュヤ=, _IAST_=, 鬼宿]", # 8
|
|
994
|
-
"[Aśleṣā=en:%C4%80shlesh%C4%81, アーシュレーシャー=, _IAST_=, 柳宿]", # 9
|
|
995
|
-
"[Maghā=en:Magh%C4%81, マガー=, _IAST_=, 星宿]", # 10
|
|
996
|
-
"[Pū. Phalguṇī=en:P%C5%ABrva_Phalgun%C4%AB, P. パールグニー=, _IAST_=, 張宿]", # 11
|
|
997
|
-
"[U. Phalguṇī=en:Uttara_Phalgun%C4%AB, U. パールグニー=, _IAST_=, 翼宿]", # 12
|
|
998
|
-
"[Hasta=en:Nakshatra#Divisions, ハスタ=, _IAST_=, 軫宿]", # 13
|
|
999
|
-
"[Citrā=en:Nakshatra#Divisions, チトラー=, _IAST_=, 角宿]", # 14
|
|
1000
|
-
"[Svāti=en:Sv%C4%81t%C4%AB, スヴァーティー=, _IAST_=, 亢宿]", # 15
|
|
1001
|
-
"[Viśākha=en:Vish%C4%81kh%C4%81, ヴィシャーカー=, _IAST_=, 氐宿]", # 16
|
|
1002
|
-
"[Anurādhā=en:Anur%C4%81dh%C4%81, アヌラーダー=, _IAST_=, 房宿]", # 17
|
|
1003
|
-
"[Jyeṣṭha=en:Jyeshtha, ジェーシュター=, _IAST_=, 心宿]", # 18
|
|
1004
|
-
"[Mūla=en:Mula_(astrology), ムーラ=, _IAST_=, 尾宿]", # 19
|
|
1005
|
-
"[Pū. āṣāḍha=en:P%C5%ABrva_Ash%C4%81dh%C4%81, P. アーシャーダー=, _IAST_=, 箕宿]", # 20
|
|
1006
|
-
"[U. āṣāḍha=en:Uttara_Ash%C4%81dh%C4%81, U. アーシャーダー=, _IAST_=, 斗宿]", # 21
|
|
1007
|
-
"[Śravaṇa=en:Shravana, シュラヴァナ=, _IAST_=, 女宿]", # 22
|
|
1008
|
-
"[Śraviṣṭhā=en:Dhanishta, ダニシュター=, _IAST_=, 虛宿]", # 23
|
|
1009
|
-
"[Śatabhiṣak=en:Shatabhish%C4%81, シャタビシャジュ=, _IAST_=, 危宿]", # 24
|
|
1010
|
-
"[Pū. Bhādrapadā=en:P%C5%ABrva_Bh%C4%81drapad%C4%81,P. バードラパダー=, _IAST_=, 室宿]", # 25
|
|
1011
|
-
"[U. Bhādrapadā=en:Uttara_Bh%C4%81drapad%C4%81, U. バードラパダー=, _IAST_=, 壁宿]", # 26
|
|
1012
|
-
"[Revatī=en:Revati_(nakshatra), レーヴァティー=, _IAST_=, 奎宿]" # 27
|
|
1013
|
-
],
|
|
1014
|
-
|
|
1015
|
-
[When::BasicTypes::M17n,
|
|
1016
|
-
"names:[yoga=, ヨーガ=, _IAST_=]",
|
|
1017
|
-
"[Viṣkambha=, ヴィシュカムバ=, _IAST_=]", # 1
|
|
1018
|
-
"[Prīti=, プリーティ=, _IAST_=]", # 2
|
|
1019
|
-
"[Āyuśmān=, アーユシュマー=, _IAST_=]", # 3
|
|
1020
|
-
"[Saubhāgya=, サウバーギャ=, _IAST_=]", # 4
|
|
1021
|
-
"[Śobhana=, ショーバナ=, _IAST_=]", # 5
|
|
1022
|
-
"[Atigaṇḍa=, アティガンダ=, _IAST_=]", # 6
|
|
1023
|
-
"[Sukarma=, スカルマ=, _IAST_=]", # 7
|
|
1024
|
-
"[Dhṛti, ドゥリティ=, _IAST_=]", # 8
|
|
1025
|
-
"[Śūla=, シューラ=, _IAST_=]", # 9
|
|
1026
|
-
"[Gaṇḍa=, ガンダ=, _IAST_=]", # 10
|
|
1027
|
-
"[Vṛddhi=, ヴリッディ=, _IAST_=]", # 11
|
|
1028
|
-
"[Dhruva=, ドルヴァ=, _IAST_=]", # 12
|
|
1029
|
-
"[Vyāghāta=, ヴヤーガータ=, _IAST_=]", # 13
|
|
1030
|
-
"[Harṣaṇa=, ハルシャナ=, _IAST_=]", # 14
|
|
1031
|
-
"[Vajra=, ヴァジュラ=, _IAST_=]", # 15
|
|
1032
|
-
"[Siddhi=, シッディ=, _IAST_=]", # 16
|
|
1033
|
-
"[Vyatīpāta=, ヴヤティーパータ=, _IAST_=]", # 17
|
|
1034
|
-
"[Varīyas=, ヴァリーヤス=, _IAST_=]", # 18
|
|
1035
|
-
"[Parigha=, パリガ=, _IAST_=]", # 19
|
|
1036
|
-
"[Śiva=, シヴァ=, _IAST_=]", # 20
|
|
1037
|
-
"[Siddha=, シッダ=, _IAST_=]", # 21
|
|
1038
|
-
"[Sādhya=, サーディヤ=, _IAST_=]", # 22
|
|
1039
|
-
"[Śubha=, シュバ=, _IAST_=]", # 23
|
|
1040
|
-
"[Śukla=, シュクラ=, _IAST_=]", # 24
|
|
1041
|
-
"[Brahman=, ブラフマン=, _IAST_=]", # 25
|
|
1042
|
-
"[Māhendra=, マーヘンドラ=, _IAST_=]", # 26
|
|
1043
|
-
"[Vaidhṛti=, ヴァイドリティ=, _IAST_=]" # 27
|
|
1044
|
-
],
|
|
1045
|
-
|
|
1046
|
-
[When::BasicTypes::M17n,
|
|
1047
|
-
"names:[Karaṇa=, カラナ=, _IAST_=, *karana]",
|
|
1048
|
-
"[Bava=, バヴァ=, _IAST_=]", # 1
|
|
1049
|
-
"[Bālava=, バーラヴァ=, _IAST_=]", # 2
|
|
1050
|
-
"[Kaulava=, カウラヴァ=, _IAST_=]", # 3
|
|
1051
|
-
"[Taitila=, タイティラ=, _IAST_=]", # 4
|
|
1052
|
-
"[Gara=, ガラ=, _IAST_=]", # 5
|
|
1053
|
-
"[Vaṇija=, ヴァニジュ=, _IAST_=]", # 6
|
|
1054
|
-
"[Viṣṭi=, ヴィシュティ=, _IAST_=]", # 7
|
|
1055
|
-
"[Kiṃtughna=, キンストゥグナ=, _IAST_=]", # A
|
|
1056
|
-
"[Śakuni=, シャクニ=, _IAST_=]", # B
|
|
1057
|
-
"[Catuṣpāda=, チャトシュパダ=, _IAST_=]", # C
|
|
1058
|
-
"[Nāga=, ナーガ=, _IAST_=]" # D
|
|
1059
|
-
]
|
|
1060
|
-
]
|
|
1061
|
-
]]
|
|
1062
|
-
|
|
1063
|
-
NoteConsts = {
|
|
1064
|
-
'tithi' => {
|
|
1065
|
-
:formula => 15,
|
|
1066
|
-
:range => (-1..2),
|
|
1067
|
-
:index => [ 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,
|
|
1068
|
-
15,1,2,3,4,5,6,7,8,9,10,11,12,13,14]
|
|
1069
|
-
},
|
|
1070
|
-
'naksatra' => {
|
|
1071
|
-
:formula => '27M',
|
|
1072
|
-
:range => (-1..2),
|
|
1073
|
-
:index => (0...27).to_a
|
|
1074
|
-
},
|
|
1075
|
-
'yoga' => {
|
|
1076
|
-
:formula => '27M+27S',
|
|
1077
|
-
:range => (-1..2),
|
|
1078
|
-
:index => (0...27).to_a
|
|
1079
|
-
},
|
|
1080
|
-
'karana' => {
|
|
1081
|
-
:formula => 30,
|
|
1082
|
-
:range => (-2..3),
|
|
1083
|
-
:index => [7] + (0...7).to_a * 8 + [8,9,10]
|
|
1084
|
-
}
|
|
1085
|
-
}
|
|
1086
|
-
|
|
1087
|
-
#
|
|
1088
|
-
# pancanga 計算に必要となる情報をまとめた内部クラス
|
|
1089
|
-
#
|
|
1090
|
-
class Dates
|
|
1091
|
-
|
|
1092
|
-
# @private
|
|
1093
|
-
attr_reader :o_date, :l_date, :root, :formula, :iri, :rises
|
|
1094
|
-
|
|
1095
|
-
# 初期設定
|
|
1096
|
-
# @private
|
|
1097
|
-
def initialize(date)
|
|
1098
|
-
@o_date = date
|
|
1099
|
-
clock = date.clock
|
|
1100
|
-
frame = date.frame if date.frame.kind_of?(When::CalendarTypes::HinduLuniSolar)
|
|
1101
|
-
@l_date = (frame || When.Calendar('HinduLuniSolar?note=HinduNote')).jul_trans(date.to_i, {:clock=>'+05:30'})
|
|
1102
|
-
@root = When.CalendarNote('HinduNote/Notes')['day']
|
|
1103
|
-
@formula = @l_date.frame.formula[-1]
|
|
1104
|
-
@iri = @formula.iri
|
|
1105
|
-
@rises = [@formula.sunrise(@l_date), @formula.sunrise(@l_date+When.Duration('P1D'))]
|
|
1106
|
-
end
|
|
1107
|
-
|
|
1108
|
-
# その他のメソッドは @l_date に移譲する
|
|
1109
|
-
def method_missing(name, *args, &block)
|
|
1110
|
-
self.class.module_eval %Q{
|
|
1111
|
-
def #{name}(*args, &block)
|
|
1112
|
-
@l_date.send("#{name}", *args, &block)
|
|
1113
|
-
end
|
|
1114
|
-
} unless When::Parts::MethodCash.escape(name)
|
|
1115
|
-
@l_date.send(name, *args, &block)
|
|
1116
|
-
end
|
|
1117
|
-
end
|
|
1118
|
-
|
|
1119
|
-
#
|
|
1120
|
-
# 任意の暦をインド太陰太陽暦日に変換
|
|
1121
|
-
# @private
|
|
1122
|
-
def _to_date_for_note(date)
|
|
1123
|
-
Dates.new(date)
|
|
1124
|
-
end
|
|
1125
|
-
|
|
1126
|
-
#
|
|
1127
|
-
# 木星年
|
|
1128
|
-
#
|
|
1129
|
-
# @param [Dates] dates
|
|
1130
|
-
#
|
|
1131
|
-
# @return [When::BasicTypes::M17n] 木星年の名称
|
|
1132
|
-
#
|
|
1133
|
-
# see {http://en.wikipedia.org/wiki/Samvatsara Samvatsara}
|
|
1134
|
-
#
|
|
1135
|
-
def samvatsara(dates)
|
|
1136
|
-
year_kali = dates.l_date.most_significant_coordinate + dates.l_date.frame._diff_to_CE + 3101
|
|
1137
|
-
year_mod = year_kali >= jovian ? (year_kali + 12) % 60 :
|
|
1138
|
-
((year_kali * 211 - 108).div(18000) + year_kali + 26) % 60
|
|
1139
|
-
When.CalendarNote('HinduNote/Notes')['year']['samvatsara'][year_mod]
|
|
1140
|
-
end
|
|
1141
|
-
|
|
1142
|
-
#
|
|
1143
|
-
# 木星年の計算方式に“South”を適用開始する年
|
|
1144
|
-
#
|
|
1145
|
-
# @return [Integer] 年(カリユガ紀元)
|
|
1146
|
-
#
|
|
1147
|
-
def jovian
|
|
1148
|
-
return @jovian if @jovian.kind_of?(Integer)
|
|
1149
|
-
@jovian = @jovian ? @jovian.to_i : 4009
|
|
1150
|
-
end
|
|
1151
|
-
|
|
1152
|
-
#
|
|
1153
|
-
# ヴァーラ (七曜)
|
|
1154
|
-
#
|
|
1155
|
-
# @param [Dates] dates
|
|
1156
|
-
#
|
|
1157
|
-
# @return [Array<When::TM::TemporalPosition>] 日の出の時刻をイベント時刻とする
|
|
1158
|
-
#
|
|
1159
|
-
def vara(dates)
|
|
1160
|
-
rise = dates.rises[0]
|
|
1161
|
-
rise.events = [dates.root['vara'][(rise.to_i+1) % 7]]
|
|
1162
|
-
['V:-', rise]
|
|
1163
|
-
end
|
|
1164
|
-
|
|
1165
|
-
#
|
|
1166
|
-
# ヴァーラ以外
|
|
1167
|
-
#
|
|
1168
|
-
|
|
1169
|
-
# 当該日付中でティティが変わる日時
|
|
1170
|
-
# @method tithi(dates)
|
|
1171
|
-
# @param [Dates] dates
|
|
1172
|
-
# @return [Array<When::TM::TemporalPosition>] イベント日時
|
|
1173
|
-
|
|
1174
|
-
# 当該日付中でナクシャトラが変わる日時
|
|
1175
|
-
# @method naksatra(dates)
|
|
1176
|
-
# @param [Dates] dates
|
|
1177
|
-
# @return [Array<When::TM::TemporalPosition>] イベント日時
|
|
1178
|
-
|
|
1179
|
-
# 当該日付中でヨーガが変わる日時
|
|
1180
|
-
# @method yoga(dates)
|
|
1181
|
-
# @param [Dates] dates
|
|
1182
|
-
# @return [Array<When::TM::TemporalPosition>] イベント日時
|
|
1183
|
-
|
|
1184
|
-
# 当該日付中でカラナが変わる日時
|
|
1185
|
-
# @method karana(dates)
|
|
1186
|
-
# @param [Dates] dates
|
|
1187
|
-
# @return [Array<When::TM::TemporalPosition>] イベント日時
|
|
1188
|
-
#
|
|
1189
|
-
|
|
1190
|
-
# @private
|
|
1191
|
-
NoteConsts.keys.each do |key|
|
|
1192
|
-
module_eval %Q{
|
|
1193
|
-
def #{key}(dates)
|
|
1194
|
-
pancanga(dates, '#{key}').map {|event| ['#{key[0..0].upcase}:-', event]}
|
|
1195
|
-
end
|
|
1196
|
-
}
|
|
1197
|
-
end
|
|
1198
|
-
|
|
1199
|
-
#
|
|
1200
|
-
# ヴァーラ以外のイベント日時
|
|
1201
|
-
#
|
|
1202
|
-
# @param [Dates] dates
|
|
1203
|
-
# @param [String] key 'tithi', 'naksatra', 'yoga', 'karana' のいずれか
|
|
1204
|
-
# @return [Array<When::TM::TemporalPosition>] イベント日時
|
|
1205
|
-
#
|
|
1206
|
-
def pancanga(dates, key)
|
|
1207
|
-
pattern = NoteConsts[key]
|
|
1208
|
-
note = dates.root[key]
|
|
1209
|
-
if pattern[:formula].kind_of?(Numeric)
|
|
1210
|
-
factor = pattern[:formula].to_f
|
|
1211
|
-
formula = dates.formula
|
|
1212
|
-
else
|
|
1213
|
-
factor = 1.0
|
|
1214
|
-
formula = When.Resource(dates.iri.sub(/formula=2L/, "formula=#{pattern[:formula]}"))
|
|
1215
|
-
end
|
|
1216
|
-
cn = (formula.time_to_cn(dates.l_date) * factor).floor
|
|
1217
|
-
events = []
|
|
1218
|
-
pattern[:range].each do |i|
|
|
1219
|
-
event = formula._to_seed_type(formula.cn_to_time((cn+i)/factor), dates.l_date)
|
|
1220
|
-
break if +event >= +dates.rises[1]
|
|
1221
|
-
next if +event < +dates.rises[0]
|
|
1222
|
-
event.events = [note[pattern[:index][(cn+i) % pattern[:index].length]]]
|
|
1223
|
-
events << event
|
|
1224
|
-
end
|
|
1225
|
-
events
|
|
1226
|
-
end
|
|
1227
|
-
end
|
|
1228
|
-
|
|
1229
|
-
#
|
|
1230
|
-
# 日の出の九惑星の位置まで計算
|
|
1231
|
-
#
|
|
1232
|
-
class HinduNoteDetailed < HinduNote
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
#
|
|
1237
|
-
#
|
|
1238
|
-
#
|
|
1239
|
-
#
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
}
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
end
|
|
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
|
+
require 'when_exe/locales/iast'
|
|
9
|
+
|
|
10
|
+
module When
|
|
11
|
+
class BasicTypes::M17n
|
|
12
|
+
|
|
13
|
+
Indian = [self, [
|
|
14
|
+
"locale:[=en:, ja=ja:, hi=hi:, alias]",
|
|
15
|
+
"names:[Indian=]",
|
|
16
|
+
"[IndianNationalSolar=en:Indian_national_calendar, インド国定暦, era:SE=]",
|
|
17
|
+
"[Nanakshahi=en:Nanakshahi_calendar, ナーナク暦=]",
|
|
18
|
+
"[RevisedBengali=en:Bengali_calendar, 改訂ベンガル暦=]",
|
|
19
|
+
"[HinduSolar=en:Hindu_calendar, インド太陽暦=ja:%%<ヒンドゥー暦>]",
|
|
20
|
+
"[HinduLuniSolar=en:Hindu_calendar, インド太陰太陽暦=ja:%%<ヒンドゥー暦>]",
|
|
21
|
+
|
|
22
|
+
[self,
|
|
23
|
+
"names:[IntercalaryMonth=en:Intercalation, 閏月]",
|
|
24
|
+
"[%s Śuklapakṣa=, %s 白分=, _IAST_=]",
|
|
25
|
+
"[%s Kṛṣṇapakṣa=, %s 黒分=, _IAST_=]",
|
|
26
|
+
"[adhika %s Śuklapakṣa=, 閏%s 白分=, _IAST_=]",
|
|
27
|
+
"[adhika %s Kṛṣṇapakṣa=, 閏%s 黒分=, _IAST_=]"
|
|
28
|
+
],
|
|
29
|
+
|
|
30
|
+
[self,
|
|
31
|
+
"names:[IntercalaryDay=en:Intercalation, 閏日=ja:%%<閏>]",
|
|
32
|
+
"[%s and next day=, %sと翌日=]",
|
|
33
|
+
"[Intercalary %s=, 重%s=]"
|
|
34
|
+
],
|
|
35
|
+
|
|
36
|
+
[self,
|
|
37
|
+
"names:[LunarMonth=, 太陰月=ja:%%<月_(暦)>]",
|
|
38
|
+
"[Mārgaśīra=en:Margashirsha, マールガシールシャ=, _IAST_=]",
|
|
39
|
+
"[Pauṣa=en:Pausha, パウシャ=, _IAST_=]",
|
|
40
|
+
"[Māgha=en:Maagha, マーガ=, _IAST_=]",
|
|
41
|
+
"[Phālguna=en:Phalguna, パールグナ=, _IAST_=]",
|
|
42
|
+
"[Caitra=en:Chaitra, チャイトラ=, _IAST_=]",
|
|
43
|
+
"[Vaiśākha=en:Vaisakha, ヴァイシャーカ=, _IAST_=]",
|
|
44
|
+
"[Jyaiṣṭha=en:Jyeshta, ジャイシュタ=, _IAST_=]",
|
|
45
|
+
"[Āṣāḍha=en:Aashaadha, アーシャーダ=, _IAST_=]",
|
|
46
|
+
"[Śrāvaṇa=en:Shraavana, シュラーヴァナ=, _IAST_=]",
|
|
47
|
+
"[Bhādrapada=en:Bhadrapada, バードラパダ=, _IAST_=]",
|
|
48
|
+
"[Āśvina=en:Ashwin, アーシュヴィナ=, _IAST_=]",
|
|
49
|
+
"[Kārttika=en:Kartika_(month), カールッティカ=, _IAST_=]"
|
|
50
|
+
],
|
|
51
|
+
|
|
52
|
+
[self,
|
|
53
|
+
"names:[SolarMonth=, 太陽月=ja:%%<月_(暦)>]",
|
|
54
|
+
"[Maysha=, 白羊宮, _IAST_=]",
|
|
55
|
+
"[Vrushabha=, 金牛宮, _IAST_=]",
|
|
56
|
+
"[Mithuna=, 双児宮, _IAST_=]",
|
|
57
|
+
"[Karka=, 巨蟹宮, _IAST_=]",
|
|
58
|
+
"[Simha=, 獅子宮, _IAST_=]",
|
|
59
|
+
"[Kanya=, 処女宮, _IAST_=]",
|
|
60
|
+
"[Tula=, 天秤宮, _IAST_=]",
|
|
61
|
+
"[Vrushchika=, 天蝎宮, _IAST_=]",
|
|
62
|
+
"[Dhanu=, 人馬宮, _IAST_=]",
|
|
63
|
+
"[Makar=, 磨羯宮, _IAST_=]",
|
|
64
|
+
"[Kumbha=, 宝瓶宮, _IAST_=]",
|
|
65
|
+
"[Meena=, 双魚宮, _IAST_=]"
|
|
66
|
+
],
|
|
67
|
+
|
|
68
|
+
[self,
|
|
69
|
+
"names:[NanakshahiMonth=, 太陽月=ja:%%<月_(暦)>]",
|
|
70
|
+
"[Maghar=en:Maghar_(month) ]",
|
|
71
|
+
"[Poh ]",
|
|
72
|
+
"[Magh=en:Magh_(Sikh_calendar)]",
|
|
73
|
+
"[Phagun ]",
|
|
74
|
+
"[Chet=en:Chet_(month) ]",
|
|
75
|
+
"[Vaisakh ]",
|
|
76
|
+
"[Jeth ]",
|
|
77
|
+
"[Harh ]",
|
|
78
|
+
"[Sawan ]",
|
|
79
|
+
"[Bhadon ]",
|
|
80
|
+
"[Assu ]",
|
|
81
|
+
"[Katak ]"
|
|
82
|
+
],
|
|
83
|
+
|
|
84
|
+
[self,
|
|
85
|
+
"names:[BengaliMonth=, 太陽月=ja:%%<月_(暦)>]",
|
|
86
|
+
"[Ogrôhayôn=]",
|
|
87
|
+
"[Poush= ]",
|
|
88
|
+
"[Magh= ]",
|
|
89
|
+
"[Falgun= ]",
|
|
90
|
+
"[Chôitrô= ]",
|
|
91
|
+
"[Bôishakh= ]",
|
|
92
|
+
"[Jyôishţhô=]",
|
|
93
|
+
"[Ashaŗh= ]",
|
|
94
|
+
"[Shrabôn= ]",
|
|
95
|
+
"[Bhadrô= ]",
|
|
96
|
+
"[Ashbin= ]",
|
|
97
|
+
"[Kartik= ]"
|
|
98
|
+
]
|
|
99
|
+
]]
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
module Coordinates
|
|
103
|
+
|
|
104
|
+
# Location of cities in India
|
|
105
|
+
Indian = [When::BasicTypes::M17n, [
|
|
106
|
+
"locale:[=en:, ja=ja:, alias]",
|
|
107
|
+
"names:[Indian]",
|
|
108
|
+
[Spatial, "long:+82.5", "lat:N23.11", "label:[CentralIndia, インド中部]" ],
|
|
109
|
+
[Spatial, "long:+82.5", "lat:+29.0", "label:[NorthIndia, インド北部]" ],
|
|
110
|
+
[Spatial, "long:+78.0", "lat:+27.2", "label:[Agra, アーグラ]" ],
|
|
111
|
+
[Spatial, "long:+72.6", "lat:+23.0", "label:[Ahmedabad, アフマダーバード]" ],
|
|
112
|
+
[Spatial, "long:+74.6", "lat:+26.5", "label:[Ajmer, アジメール]" ],
|
|
113
|
+
[Spatial, "long:+78.1", "lat:+27.9", "label:[Aligarh, アリーガル]" ],
|
|
114
|
+
[Spatial, "long:+74.9", "lat:+31.6", "label:[Amritsar, アムリトサル]" ],
|
|
115
|
+
[Spatial, "long:+77.6", "lat:+13.0", "label:[Bangalore, バンガロール]" ],
|
|
116
|
+
[Spatial, "long:+85.8", "lat:+20.2", "label:[Bhuvaneswar, ブヴァネーシュヴァル]"],
|
|
117
|
+
[Spatial, "long:+80.3", "lat:+13.1", "label:[Chennai, チェンナイ, Madras]" ],
|
|
118
|
+
[Spatial, "long:+79.9", "lat: +6.9", "label:[Colombo, コロンボ]" ],
|
|
119
|
+
[Spatial, "long:+90.4", "lat:+23.7", "label:[Dacca, ダッカ]" ],
|
|
120
|
+
[Spatial, "long:+77.2", "lat:+28.6", "label:[Delhi, デリー]" ],
|
|
121
|
+
[Spatial, "long:+78.5", "lat:+17.4", "label:[Hyderabad, ハイデラバード]" ],
|
|
122
|
+
[Spatial, "long:+75.8", "lat:+26.9", "label:[Jaipur, ジャイプル]" ],
|
|
123
|
+
[Spatial, "long:+85.2", "lat:+27.7", "label:[Kathmandu, カトマンズ]" ],
|
|
124
|
+
[Spatial, "long:+76.2", "lat:+10.0", "label:[Kochi, コーチ, Cochin]" ],
|
|
125
|
+
[Spatial, "long:+88.4", "lat:+22.6", "label:[Kolkata, コルカタ, Calcutta]" ],
|
|
126
|
+
[Spatial, "long:+74.3", "lat:+31.6", "label:[Lahor, ラホール]" ],
|
|
127
|
+
[Spatial, "long:+77.7", "lat:+27.5", "label:[Mathura, マトゥラー]" ],
|
|
128
|
+
[Spatial, "long:+72.8", "lat:+19.0", "label:[Mumbai, ムンバイ, Bombay]" ],
|
|
129
|
+
[Spatial, "long:+76.6", "lat:+12.3", "label:[Mysore, マイソール]" ],
|
|
130
|
+
[Spatial, "long:+85.1", "lat:+25.6", "label:[Patna, パトナ]" ],
|
|
131
|
+
[Spatial, "long:+73.9", "lat:+18.5", "label:[Pune, プネー]" ],
|
|
132
|
+
[Spatial, "long:+74.8", "lat:+34.1", "label:[Srinagar, シュリーナガル]" ],
|
|
133
|
+
[Spatial, "long:+77.0", "lat: +8.5", "label:[Thiruvananthapuram, ティルヴァナンタプラム, Trivandrum]"],
|
|
134
|
+
[Spatial, "long:+83.0", "lat:+25.3", "label:[Varanasi, ワーラーナシー]" ],
|
|
135
|
+
[Spatial, "long:+75.8", "lat:+23.2", "label:[Ujjain, ウッジャイン]" ]
|
|
136
|
+
]]
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
module Ephemeris
|
|
140
|
+
|
|
141
|
+
#
|
|
142
|
+
# Hindu Luni-Solar Calendar Formula
|
|
143
|
+
#
|
|
144
|
+
class Hindu < Formula
|
|
145
|
+
|
|
146
|
+
# Basic Astronomical Constants for Surya-Siddhanta
|
|
147
|
+
Tz = 0.5+75.8/360 # time difference between JulianDayNumber and Ujjain
|
|
148
|
+
E = 588_466 - Tz # Yuga Epoch -3101-02-18T00:00:00
|
|
149
|
+
P = 180 # Precession cycles in yuga
|
|
150
|
+
Ep = 1_903_318 - Tz # Precession Epoch 499-01-01
|
|
151
|
+
Ob = 24.0 / 360.0 # Obliquity of the ecliptic
|
|
152
|
+
|
|
153
|
+
Grahas = {
|
|
154
|
+
'SS' => { # Previous / Newest
|
|
155
|
+
:Star => 1_582_237_800.0, # 1_582_237_500 / 1_582_237_800
|
|
156
|
+
:Sun => 4_320_000.0,
|
|
157
|
+
:Moon => 57_753_336.0,
|
|
158
|
+
:Mercury => 17_937_000.0,
|
|
159
|
+
:Venus => 7_022_388.0,
|
|
160
|
+
:Mars => 2_296_824.0,
|
|
161
|
+
:Jupiter => 364_220.0,
|
|
162
|
+
:Saturn => 146_564.0,
|
|
163
|
+
:Candrocca => 488_219.0, # 488_203 / 488_219
|
|
164
|
+
:Rahu => -232_226.0
|
|
165
|
+
},
|
|
166
|
+
'SB' => {
|
|
167
|
+
:Star => 1_582_237_828.0,
|
|
168
|
+
:Sun => 4_320_000.0,
|
|
169
|
+
:Moon => 57_753_336.0,
|
|
170
|
+
:Mercury => 17_937_060.0,
|
|
171
|
+
:Venus => 7_022_376.0,
|
|
172
|
+
:Mars => 2_296_832.0,
|
|
173
|
+
:Jupiter => 364_220.0,
|
|
174
|
+
:Saturn => 146_568.0,
|
|
175
|
+
:Candrocca => 488_203.0, # 488_199 / 488_203
|
|
176
|
+
:Rahu => -232_238.0
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
#
|
|
181
|
+
# 日月五惑星とラーフおよびケートゥ
|
|
182
|
+
#
|
|
183
|
+
# @abstract
|
|
184
|
+
class Graha
|
|
185
|
+
include When::Ephemeris
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
#
|
|
189
|
+
# 現代的“惑星”
|
|
190
|
+
#
|
|
191
|
+
class ModernGraha < Graha
|
|
192
|
+
|
|
193
|
+
# 真黄経
|
|
194
|
+
#
|
|
195
|
+
# @param [Numeric] t ユリウス日
|
|
196
|
+
#
|
|
197
|
+
# @return [Numeric]
|
|
198
|
+
#
|
|
199
|
+
def true_longitude(t)
|
|
200
|
+
@target.coords(t, @base).phi
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
# オブジェクトの生成
|
|
204
|
+
#
|
|
205
|
+
# @param [When::Ephemeris::Datum] target 天体
|
|
206
|
+
# @param [When::Coordinates::Spatial] base 観測地
|
|
207
|
+
#
|
|
208
|
+
def initialize(target, base)
|
|
209
|
+
@target = target
|
|
210
|
+
@base = base
|
|
211
|
+
end
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
#
|
|
215
|
+
# 古典的“惑星”
|
|
216
|
+
#
|
|
217
|
+
# @abstract
|
|
218
|
+
class ClassicGraha < Graha
|
|
219
|
+
|
|
220
|
+
# 平均黄経
|
|
221
|
+
#
|
|
222
|
+
# @param [Numeric] t ユリウス日
|
|
223
|
+
#
|
|
224
|
+
# @return [Numeric]
|
|
225
|
+
#
|
|
226
|
+
def mean_longitude(t)
|
|
227
|
+
_mean_rotation(t - E)
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
# 真黄経
|
|
231
|
+
#
|
|
232
|
+
# @param [Numeric] t ユリウス日
|
|
233
|
+
#
|
|
234
|
+
# @return [Numeric]
|
|
235
|
+
#
|
|
236
|
+
def true_longitude(t)
|
|
237
|
+
_true_rotation(t - E)
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
# 平均黄経
|
|
241
|
+
#
|
|
242
|
+
# @param [Numeric] ahar カリユガ暦元からの経過日数
|
|
243
|
+
#
|
|
244
|
+
# @return [Numeric]
|
|
245
|
+
#
|
|
246
|
+
def _mean_rotation(ahar)
|
|
247
|
+
@rotation * ahar / @formula.civil_days
|
|
248
|
+
end
|
|
249
|
+
|
|
250
|
+
# オブジェクトの生成
|
|
251
|
+
#
|
|
252
|
+
# @param [When::Ephemeris::Formula] formula 親オブジェクト
|
|
253
|
+
# @param [Numeric] rotation ユガあたりの回転数
|
|
254
|
+
#
|
|
255
|
+
def initialize(formula, rotation)
|
|
256
|
+
@formula = formula
|
|
257
|
+
@rotation = rotation
|
|
258
|
+
end
|
|
259
|
+
end
|
|
260
|
+
|
|
261
|
+
# 架空の“惑星” - ラーフ / 月軌道の遠地点としてのケートゥ
|
|
262
|
+
class VirtualGraha < ClassicGraha
|
|
263
|
+
|
|
264
|
+
# 平均黄経
|
|
265
|
+
#
|
|
266
|
+
# @param [Numeric] ahar カリユガ暦元からの経過日数
|
|
267
|
+
#
|
|
268
|
+
# @return [Numeric]
|
|
269
|
+
#
|
|
270
|
+
def _mean_rotation(ahar)
|
|
271
|
+
super + @rotation0
|
|
272
|
+
end
|
|
273
|
+
alias :_true_rotation :_mean_rotation
|
|
274
|
+
|
|
275
|
+
# オブジェクトの生成
|
|
276
|
+
#
|
|
277
|
+
# @param [When::Ephemeris::Formula] formula 親オブジェクト
|
|
278
|
+
# @param [Numeric] rotation ユガあたりの回転数
|
|
279
|
+
# @param [Numeric] rotation0 カリユガ暦元での回転量
|
|
280
|
+
#
|
|
281
|
+
def initialize(formula, rotation, rotation0)
|
|
282
|
+
@rotation0 = rotation0 / 360.0
|
|
283
|
+
super(formula, rotation)
|
|
284
|
+
end
|
|
285
|
+
end
|
|
286
|
+
|
|
287
|
+
# 実在の“惑星”
|
|
288
|
+
# @abstract
|
|
289
|
+
class RealGraha < ClassicGraha
|
|
290
|
+
|
|
291
|
+
# マンダ補正
|
|
292
|
+
#
|
|
293
|
+
# @param [Numeric] rot 平均近点角など / CIRCLE
|
|
294
|
+
#
|
|
295
|
+
# @return [Numeric]
|
|
296
|
+
#
|
|
297
|
+
def _manda_equation(rot)
|
|
298
|
+
asin(@circumm * sinc(rot)) / CIRCLE
|
|
299
|
+
end
|
|
300
|
+
|
|
301
|
+
# オブジェクトの生成
|
|
302
|
+
#
|
|
303
|
+
# @param [When::Ephemeris::Formula] formula 親オブジェクト
|
|
304
|
+
# @param [Numeric] rotation ユガあたりの回転数
|
|
305
|
+
# @param [Numeric] circumm マンダ円の半径
|
|
306
|
+
# @param [Numeric] apogee 近点黄経 / CIRCLE
|
|
307
|
+
#
|
|
308
|
+
def initialize(formula, rotation, circumm, apogee)
|
|
309
|
+
@circumm = circumm / 360.0
|
|
310
|
+
@apogee = apogee / 360.0
|
|
311
|
+
super(formula, rotation)
|
|
312
|
+
end
|
|
313
|
+
end
|
|
314
|
+
|
|
315
|
+
# 太陽と月 - 逆行しない“惑星”
|
|
316
|
+
# @abstract
|
|
317
|
+
class ConcentricGraha < RealGraha
|
|
318
|
+
|
|
319
|
+
# 平均黄経
|
|
320
|
+
#
|
|
321
|
+
# @param [Numeric] ahar カリユガ暦元からの経過日数
|
|
322
|
+
#
|
|
323
|
+
# @return [Numeric]
|
|
324
|
+
#
|
|
325
|
+
def _mean_rotation(ahar)
|
|
326
|
+
super + @epoch
|
|
327
|
+
end
|
|
328
|
+
|
|
329
|
+
# オブジェクトの生成
|
|
330
|
+
#
|
|
331
|
+
# @param [When::Ephemeris::Formula] formula 親オブジェクト
|
|
332
|
+
# @param [Numeric] rotation ユガあたりの回転数
|
|
333
|
+
# @param [Numeric] circumm マンダ円の半径
|
|
334
|
+
# @param [Numeric] apogee 近点黄経 / CIRCLE
|
|
335
|
+
# @param [Numeric] epoch カリユガ暦元での黄経 / CIRCLE
|
|
336
|
+
#
|
|
337
|
+
def initialize(formula, rotation, circumm, apogee, epoch)
|
|
338
|
+
@epoch = epoch
|
|
339
|
+
super(formula, rotation, circumm, apogee)
|
|
340
|
+
end
|
|
341
|
+
end
|
|
342
|
+
|
|
343
|
+
# 太陽
|
|
344
|
+
class Sun < ConcentricGraha
|
|
345
|
+
|
|
346
|
+
# 真黄経
|
|
347
|
+
#
|
|
348
|
+
# @param [Numeric] ahar カリユガ暦元からの経過日数
|
|
349
|
+
#
|
|
350
|
+
# @return [Numeric]
|
|
351
|
+
#
|
|
352
|
+
def _true_rotation(ahar)
|
|
353
|
+
mean = _mean_rotation(ahar)
|
|
354
|
+
mean - _manda_equation(mean - @apogee)
|
|
355
|
+
end
|
|
356
|
+
end
|
|
357
|
+
|
|
358
|
+
# 月
|
|
359
|
+
class Moon < ConcentricGraha
|
|
360
|
+
|
|
361
|
+
# 真黄経
|
|
362
|
+
#
|
|
363
|
+
# @param [Numeric] ahar カリユガ暦元からの経過日数
|
|
364
|
+
#
|
|
365
|
+
# @return [Numeric]
|
|
366
|
+
#
|
|
367
|
+
def _true_rotation(ahar)
|
|
368
|
+
mean = _mean_rotation(ahar)
|
|
369
|
+
mean - _manda_equation(mean - @formula.graha[:Candrocca]._mean_rotation(ahar))
|
|
370
|
+
end
|
|
371
|
+
end
|
|
372
|
+
|
|
373
|
+
# 惑星 - 逆行するもの
|
|
374
|
+
# @abstract
|
|
375
|
+
class Planet < RealGraha
|
|
376
|
+
|
|
377
|
+
# シグラ補正
|
|
378
|
+
#
|
|
379
|
+
# @param [Numeric] anomaly 平均近点角 / CIRCLE
|
|
380
|
+
#
|
|
381
|
+
# @return [Numeric]
|
|
382
|
+
#
|
|
383
|
+
def _sighra_equation(anomaly)
|
|
384
|
+
atan2(@circums * sinc(anomaly), @circums * cosc(anomaly) + 1) / CIRCLE
|
|
385
|
+
end
|
|
386
|
+
|
|
387
|
+
# 平均シグラ
|
|
388
|
+
#
|
|
389
|
+
# @param [Numeric] ahar カリユガ暦元からの経過日数
|
|
390
|
+
#
|
|
391
|
+
# @return [Numeric]
|
|
392
|
+
#
|
|
393
|
+
def _mean_sighra(ahar)
|
|
394
|
+
@sighra * ahar / @formula.civil_days
|
|
395
|
+
end
|
|
396
|
+
|
|
397
|
+
# 真黄経
|
|
398
|
+
#
|
|
399
|
+
# @param [Numeric] ahar カリユガ暦元からの経過日数
|
|
400
|
+
# @param [Numeric] rotation 基準回転量 / CIRCLE
|
|
401
|
+
#
|
|
402
|
+
# @return [Numeric]
|
|
403
|
+
#
|
|
404
|
+
def _true_rotation(ahar, rotation)
|
|
405
|
+
# first sighra correction
|
|
406
|
+
delta = _sighra_equation(_mean_sighra(ahar) - rotation) / 2
|
|
407
|
+
|
|
408
|
+
# first manda correction
|
|
409
|
+
mean = _mean_rotation(ahar) + delta
|
|
410
|
+
delta = _manda_equation(mean - @apogee) / 2
|
|
411
|
+
|
|
412
|
+
# second manda correction
|
|
413
|
+
mean -= delta
|
|
414
|
+
delta = _manda_equation(mean - @apogee)
|
|
415
|
+
|
|
416
|
+
# second sighra correction
|
|
417
|
+
mean = _mean_rotation(ahar) - delta
|
|
418
|
+
delta = _sighra_equation(_mean_sighra(ahar) - mean)
|
|
419
|
+
|
|
420
|
+
# true rotation
|
|
421
|
+
mean + delta
|
|
422
|
+
end
|
|
423
|
+
|
|
424
|
+
# オブジェクトの生成
|
|
425
|
+
#
|
|
426
|
+
# @param [When::Ephemeris::Formula] formula 親オブジェクト
|
|
427
|
+
# @param [Numeric] rotation ユガあたりの回転数
|
|
428
|
+
# @param [Numeric] circumm マンダ円の半径
|
|
429
|
+
# @param [Numeric] apogee 近点黄経 / CIRCLE
|
|
430
|
+
# @param [Numeric] sighra シグラ対象のカリユガあたりの回転数
|
|
431
|
+
# @param [Numeric] circums シグラ円の半径
|
|
432
|
+
#
|
|
433
|
+
def initialize(formula, rotation, circumm, apogee, sighra, circums)
|
|
434
|
+
@sighra = sighra
|
|
435
|
+
@circums = circums / 360.0
|
|
436
|
+
super(formula, rotation, circumm, apogee)
|
|
437
|
+
end
|
|
438
|
+
end
|
|
439
|
+
|
|
440
|
+
# 内惑星 - 水金
|
|
441
|
+
class InferiorPlanet < Planet
|
|
442
|
+
|
|
443
|
+
# 真黄経
|
|
444
|
+
#
|
|
445
|
+
# @param [Numeric] t ユリウス日
|
|
446
|
+
#
|
|
447
|
+
# @return [Numeric]
|
|
448
|
+
#
|
|
449
|
+
def true_longitude(t)
|
|
450
|
+
ahar = t - E
|
|
451
|
+
_true_rotation(ahar, @formula.graha[:Sun]._mean_rotation(ahar))
|
|
452
|
+
end
|
|
453
|
+
end
|
|
454
|
+
|
|
455
|
+
# 外惑星 - 火木土
|
|
456
|
+
class SuperiorPlanet < Planet
|
|
457
|
+
|
|
458
|
+
# 真黄経
|
|
459
|
+
#
|
|
460
|
+
# @param [Numeric] t ユリウス日
|
|
461
|
+
#
|
|
462
|
+
# @return [Numeric]
|
|
463
|
+
#
|
|
464
|
+
def true_longitude(t)
|
|
465
|
+
ahar = t - E
|
|
466
|
+
_true_rotation(ahar, _mean_rotation(ahar))
|
|
467
|
+
end
|
|
468
|
+
end
|
|
469
|
+
|
|
470
|
+
#
|
|
471
|
+
# ユガの太陽日数
|
|
472
|
+
#
|
|
473
|
+
# @return [Numeric]
|
|
474
|
+
#
|
|
475
|
+
attr_reader :civil_days
|
|
476
|
+
|
|
477
|
+
# 日の出の日時
|
|
478
|
+
#
|
|
479
|
+
# @param [Numeric] sdn ユリウス日
|
|
480
|
+
# @param [When::TM::TemporalPosition] sdn
|
|
481
|
+
# @param [nil] height 太陽高度(本クラスでは使用しない)
|
|
482
|
+
#
|
|
483
|
+
# @return [Integer, When::TM::DateAndTime] 日の出の日時
|
|
484
|
+
#
|
|
485
|
+
def sunrise(sdn, height=nil)
|
|
486
|
+
t = sdn.to_i - @long / 360.0 - 0.25
|
|
487
|
+
p = _mean_sun(t) + P * (t - Ep) / @civil_days
|
|
488
|
+
_to_seed_type(t - asin(tand(@lat)*tan(asin(sinc(p)*sinc(Ob)))) / CIRCLE, sdn)
|
|
489
|
+
end
|
|
490
|
+
|
|
491
|
+
# 日の入りの日時
|
|
492
|
+
#
|
|
493
|
+
# @param [Numeric] sdn ユリウス日
|
|
494
|
+
# @param [When::TM::TemporalPosition] sdn
|
|
495
|
+
# @param [nil] height 太陽高度(本クラスでは使用しない)
|
|
496
|
+
#
|
|
497
|
+
# @return [Integer, When::TM::DateAndTime] 日の入りの日時
|
|
498
|
+
#
|
|
499
|
+
def sunset(sdn, height=nil)
|
|
500
|
+
t = sdn.to_i - @long / 360.0 + 0.25
|
|
501
|
+
p = _mean_sun(t) + P * (t - Ep) / @civil_days
|
|
502
|
+
_to_seed_type(t + asin(tand(@lat)*tan(asin(sinc(p)*sinc(Ob)))) / CIRCLE, sdn)
|
|
503
|
+
end
|
|
504
|
+
|
|
505
|
+
# 太陽の南中の日時
|
|
506
|
+
#
|
|
507
|
+
# @param [Numeric] sdn ユリウス日
|
|
508
|
+
# @param [When::TM::TemporalPosition] sdn
|
|
509
|
+
#
|
|
510
|
+
# @return [Integer, When::TM::DateAndTime] 太陽の南中の日時
|
|
511
|
+
#
|
|
512
|
+
def sun_noon(sdn)
|
|
513
|
+
_to_seed_type(sdn.to_i - @long / 360.0, sdn)
|
|
514
|
+
end
|
|
515
|
+
|
|
516
|
+
private
|
|
517
|
+
|
|
518
|
+
# オブジェクトの正規化
|
|
519
|
+
def _normalize(args=[], options={})
|
|
520
|
+
@time_standard ||= 'universal'
|
|
521
|
+
@bija ||= 'SB'
|
|
522
|
+
super
|
|
523
|
+
end
|
|
524
|
+
|
|
525
|
+
# 9惑星オブジェクトの生成
|
|
526
|
+
def _normalize_grahas
|
|
527
|
+
grahas = Grahas[@bija]
|
|
528
|
+
|
|
529
|
+
# ユガあたりの暦定数
|
|
530
|
+
@sidereal_days = grahas[:Star] # 恒星日
|
|
531
|
+
@solar_years = grahas[:Sun] # 太陽年
|
|
532
|
+
@civil_days = @sidereal_days - @solar_years # 太陽日
|
|
533
|
+
@sidereal_months = grahas[:Moon] # 恒星月
|
|
534
|
+
@synodic_months = @sidereal_months - @solar_years # 朔望月
|
|
535
|
+
@adhimasas = @synodic_months - 12 * @solar_years # 閏月
|
|
536
|
+
@tithis = 30 * @sidereal_months # 太陰日
|
|
537
|
+
@ksayadinas = @tithis - @civil_days # 欠日
|
|
538
|
+
|
|
539
|
+
# 9惑星
|
|
540
|
+
@graha = {}
|
|
541
|
+
@graha.update({
|
|
542
|
+
:Sun => Sun.new( self, @solar_years, 13+50/60.0, 77+17/60.0, -3101)
|
|
543
|
+
}) if @formula =~ /[SL]/i
|
|
544
|
+
@graha.update({
|
|
545
|
+
:Moon => Moon.new( self, @sidereal_months, 31+50/60.0, 0, -28086),
|
|
546
|
+
:Candrocca => VirtualGraha.new( self, grahas[:Candrocca], 90.0)
|
|
547
|
+
}) if @formula =~ /[ML]/i
|
|
548
|
+
@graha.update({
|
|
549
|
+
:Mercury => InferiorPlanet.new(self, @solar_years, 29.0, 220+27/60.0, grahas[:Mercury], 131.5),
|
|
550
|
+
:Venus => InferiorPlanet.new(self, @solar_years, 11.5, 79+50/60.0, grahas[:Venus], 261.0),
|
|
551
|
+
:Mars => SuperiorPlanet.new(self, grahas[:Mars], 73.5, 130+02/60.0, @solar_years, 233.5),
|
|
552
|
+
:Jupiter => SuperiorPlanet.new(self, grahas[:Jupiter], 32.5, 171+18/60.0, @solar_years, 71.0),
|
|
553
|
+
:Saturn => SuperiorPlanet.new(self, grahas[:Saturn], 48.5, 236+37/60.0, @solar_years, 39.5),
|
|
554
|
+
:Rahu => VirtualGraha.new( self, grahas[:Rahu], 180.0)
|
|
555
|
+
}) if @formula == '2L'
|
|
556
|
+
end
|
|
557
|
+
end
|
|
558
|
+
end
|
|
559
|
+
|
|
560
|
+
module CalendarTypes
|
|
561
|
+
|
|
562
|
+
#
|
|
563
|
+
# Indian national solar calendar
|
|
564
|
+
#
|
|
565
|
+
IndianNationalSolar = [CyclicTableBased, {
|
|
566
|
+
'label' => 'Indian::IndianNationalSolar',
|
|
567
|
+
'origin_of_LSC' => 1721140,
|
|
568
|
+
'origin_of_MSC' => -78,
|
|
569
|
+
'epoch_in_CE' => 0,
|
|
570
|
+
'indices' => [
|
|
571
|
+
When.Index('Indian::LunarMonth', {:unit =>12, :shift=>4}),
|
|
572
|
+
When::Coordinates::DefaultDayIndex
|
|
573
|
+
],
|
|
574
|
+
'rule_table' => {
|
|
575
|
+
'T' => {'Rule' =>['LC', 'SC', 'SC', 'SC']},
|
|
576
|
+
'SC' => {'Rule' =>[365]*4 + [366, 365, 365, 365]*24},
|
|
577
|
+
'LC' => {'Rule' =>[366, 365, 365, 365]*25},
|
|
578
|
+
365 => {'Length'=>[30] + [31]*5 + [30]*6},
|
|
579
|
+
366 => {'Length'=> [31]*6 + [30]*6}
|
|
580
|
+
},
|
|
581
|
+
}]
|
|
582
|
+
|
|
583
|
+
#
|
|
584
|
+
# Nanakshahi Calendar
|
|
585
|
+
#
|
|
586
|
+
class Nanakshahi < TableBased
|
|
587
|
+
|
|
588
|
+
private
|
|
589
|
+
|
|
590
|
+
#
|
|
591
|
+
# Object Normalization
|
|
592
|
+
#
|
|
593
|
+
def _normalize(args=[], options={})
|
|
594
|
+
@label ||= 'Indian::Nanakshahi'
|
|
595
|
+
@epoch_in_CE ||= 1468
|
|
596
|
+
@engine ||= 'Gregorian'
|
|
597
|
+
@engine = When.Calendar(@engine)
|
|
598
|
+
@indices ||= [
|
|
599
|
+
When.Index('Indian::NanakshahiMonth', {:unit=>12, :shift=>4}),
|
|
600
|
+
When::Coordinates::DefaultDayIndex
|
|
601
|
+
]
|
|
602
|
+
@rule_table ||= {
|
|
603
|
+
365 => {'Length'=> [31]*5 + [30]*7},
|
|
604
|
+
366 => {'Length'=> [31]*5 + [30]*6 + [31]}
|
|
605
|
+
}
|
|
606
|
+
super
|
|
607
|
+
end
|
|
608
|
+
|
|
609
|
+
# first day of year
|
|
610
|
+
#
|
|
611
|
+
def _sdn_(date)
|
|
612
|
+
year = +date[0] + @epoch_in_CE
|
|
613
|
+
@engine._coordinates_to_number(year, 2, 13)
|
|
614
|
+
end
|
|
615
|
+
end
|
|
616
|
+
|
|
617
|
+
#
|
|
618
|
+
# Revised Bengali Calendar
|
|
619
|
+
#
|
|
620
|
+
class RevisedBengali < TableBased
|
|
621
|
+
|
|
622
|
+
private
|
|
623
|
+
|
|
624
|
+
#
|
|
625
|
+
# Object Normalization
|
|
626
|
+
#
|
|
627
|
+
def _normalize(args=[], options={})
|
|
628
|
+
@label ||= 'Indian::RevisedBengali'
|
|
629
|
+
@epoch_in_CE ||= 593
|
|
630
|
+
@engine ||= 'Gregorian'
|
|
631
|
+
@engine = When.Calendar(@engine)
|
|
632
|
+
@indices ||= [
|
|
633
|
+
When.Index('Indian::BengaliMonth', {:unit=>12, :shift=>5}),
|
|
634
|
+
When::Coordinates::DefaultDayIndex
|
|
635
|
+
]
|
|
636
|
+
@rule_table ||= {
|
|
637
|
+
365 => {'Length'=> [31]*5 + [30]*7},
|
|
638
|
+
366 => {'Length'=> [31]*5 + [30]*5 + [31, 30]}
|
|
639
|
+
}
|
|
640
|
+
super
|
|
641
|
+
end
|
|
642
|
+
|
|
643
|
+
# first day of year
|
|
644
|
+
#
|
|
645
|
+
def _sdn_(date)
|
|
646
|
+
year = +date[0] + @epoch_in_CE
|
|
647
|
+
@engine._coordinates_to_number(year, 3, 13)
|
|
648
|
+
end
|
|
649
|
+
end
|
|
650
|
+
|
|
651
|
+
#
|
|
652
|
+
# Hindu Solar Calendar
|
|
653
|
+
#
|
|
654
|
+
class HinduSolar < EphemerisBasedSolar
|
|
655
|
+
|
|
656
|
+
# protected
|
|
657
|
+
|
|
658
|
+
# 月初の通日
|
|
659
|
+
#
|
|
660
|
+
# @param [Integer] m 通月
|
|
661
|
+
#
|
|
662
|
+
# @return [Integer] 月初の通日
|
|
663
|
+
#
|
|
664
|
+
def _new_month_(m)
|
|
665
|
+
new_month_time = @formula[0].cn_to_time(m + @cycle_offset)
|
|
666
|
+
new_month_date = (new_month_time + 0.5 + @formula[0].long/360.0).floor
|
|
667
|
+
sunrise_time = @formula[0].sunrise(new_month_date)
|
|
668
|
+
(sunrise_time <= new_month_time) ? new_month_date : new_month_date-1
|
|
669
|
+
end
|
|
670
|
+
|
|
671
|
+
private
|
|
672
|
+
|
|
673
|
+
# オブジェクトの正規化
|
|
674
|
+
#
|
|
675
|
+
# @formula[0] = 位相の計算に用いる太陽の Formula
|
|
676
|
+
# @cycle_offset = 位相のオフセット
|
|
677
|
+
# @start_month = 暦年の最初の月
|
|
678
|
+
#
|
|
679
|
+
def _normalize(args=[], options={})
|
|
680
|
+
@label ||= 'Indian::HinduSolar'
|
|
681
|
+
@type ||= 'SBS'
|
|
682
|
+
raise ArgumentError, "Irregal formula: #{@formula}" unless @type.upcase =~ /\A(M|SS|SB)(V|S||B|H|VZ|SZ|BZ|HZ)\z/
|
|
683
|
+
|
|
684
|
+
@location ||= HinduLuniSolar::Location_E[$2] || HinduLuniSolar::Location_F[$1]
|
|
685
|
+
@cycle_offset ||= HinduLuniSolar::CycleOffset[$1]
|
|
686
|
+
@origin_of_MSC ||= -HinduLuniSolar::YearEpoch[$2]
|
|
687
|
+
@epoch_in_CE ||= 0
|
|
688
|
+
@start_month ||= 1 # Maysha
|
|
689
|
+
@start_month = @start_month.to_i
|
|
690
|
+
@cycle_offset = @cycle_offset.to_f + (@start_month - 1)
|
|
691
|
+
formula = @formula || HinduLuniSolar::Formula[$1]
|
|
692
|
+
if formula.kind_of?(String)
|
|
693
|
+
formula += (formula =~ /\?/) ? '&' : '?'
|
|
694
|
+
@formula = [When.Resource("_ep:#{formula}location=(#{@location})&formula=12S")]
|
|
695
|
+
end
|
|
696
|
+
@indices ||= [
|
|
697
|
+
When.Index('Indian::SolarMonth', {:shift=>@start_month-1}),
|
|
698
|
+
When::Coordinates::DefaultDayIndex
|
|
699
|
+
]
|
|
700
|
+
|
|
701
|
+
super
|
|
702
|
+
end
|
|
703
|
+
end
|
|
704
|
+
|
|
705
|
+
#
|
|
706
|
+
# Hindu Luni-Solar Calendar
|
|
707
|
+
#
|
|
708
|
+
class HinduLuniSolar < EphemerisBasedLuniSolar
|
|
709
|
+
|
|
710
|
+
# Calendar Type
|
|
711
|
+
Formula = {'M'=>'Formula', 'SS'=>'Hindu?bija=SS', 'SB'=>'Hindu?bija=SB'}
|
|
712
|
+
Location_F = {'M'=>'_co:Indian::CentralIndia', 'SS'=>'_co:Indian::Ujjain', 'SB'=>'_co:Indian::Ujjain'}
|
|
713
|
+
Location_E = {'B'=>'_co:Indian::Dacca', 'BZ'=>'_co:Indian::Dacca', 'H'=>'_co:Iranian::Tehran', 'HZ'=>'_co:Iranian::Tehran'}
|
|
714
|
+
CycleOffset = {'M'=>+23.25/30, 'SS'=>0.0, 'SB'=>0.0}
|
|
715
|
+
HinduStyle = {'A'=>0, 'P'=>1, 'PX'=>2}
|
|
716
|
+
YearEpoch = {'V'=>-58,'VZ'=>-57,'S'=>78, 'SZ'=>79, 'B'=> 593, 'BZ'=>594, 'H'=> 621, 'HZ'=> 622}
|
|
717
|
+
|
|
718
|
+
# White / black month and leap month identification table
|
|
719
|
+
|
|
720
|
+
#[w]/b [n]/l #0 #1 #2
|
|
721
|
+
LEAP_MAP = {[nil, false] => [ 0, 0, 0 ],
|
|
722
|
+
[nil, true ] => [-1.5, -1.5, -1.5],
|
|
723
|
+
[true, false] => [+0.5, -0.5, -2.5],
|
|
724
|
+
[true, true ] => [-1, -2, -1 ]}
|
|
725
|
+
|
|
726
|
+
# protected
|
|
727
|
+
|
|
728
|
+
# 月初の通日
|
|
729
|
+
#
|
|
730
|
+
# @param [Integer] m 通月
|
|
731
|
+
#
|
|
732
|
+
# @return [Integer] 月初の通日
|
|
733
|
+
#
|
|
734
|
+
def _new_month_(m)
|
|
735
|
+
new_moon_time = @formula[-1].cn_to_time(m)
|
|
736
|
+
new_moon_date = (new_moon_time + 0.5 + @formula[-1].long/360.0).floor
|
|
737
|
+
sunrise_time = @formula[-1].sunrise(new_moon_date)
|
|
738
|
+
(sunrise_time >= new_moon_time) ? new_moon_date : new_moon_date+1
|
|
739
|
+
end
|
|
740
|
+
|
|
741
|
+
# 年初の通月
|
|
742
|
+
#
|
|
743
|
+
# @param [Integer] y 年
|
|
744
|
+
#
|
|
745
|
+
# @return [Integer] 年初の通月
|
|
746
|
+
#
|
|
747
|
+
def _new_year_month_(y)
|
|
748
|
+
(Residue.mod(y-1) {|t| _tithi_to_coordinates(t*15)[0]})[0] + 1
|
|
749
|
+
end
|
|
750
|
+
|
|
751
|
+
# 朔望日 -> 年・月・日
|
|
752
|
+
#
|
|
753
|
+
# tithi : 朔望日(月の位相 / (CIRCLE/30))
|
|
754
|
+
#
|
|
755
|
+
# @return [Array<Numeric>] ( y, m, d )
|
|
756
|
+
# [ y - 年(Integer) ]
|
|
757
|
+
# [ m - 月(When::Coordinates::Pair) ]
|
|
758
|
+
# [ d - 日(Integer) ]
|
|
759
|
+
#
|
|
760
|
+
def _tithi_to_coordinates(tithi)
|
|
761
|
+
m, d = tithi.divmod(30)
|
|
762
|
+
s = [0,1,2].map {|i| (@formula[1].time_to_cn(30*(m+i)) - @cycle_offset).floor + 1 }
|
|
763
|
+
f = s[0]==s[1]
|
|
764
|
+
if (d >= 15.0)
|
|
765
|
+
d -= 15
|
|
766
|
+
b = true
|
|
767
|
+
n = true unless @hindu_style==0
|
|
768
|
+
f = s[1]==s[2] if @hindu_style==1
|
|
769
|
+
end
|
|
770
|
+
y, m = (n ? s[1] : s[0]).divmod(12)
|
|
771
|
+
return [y, Pair._force_pair(m+1, LEAP_MAP[[b,f]][@hindu_style]), d.floor]
|
|
772
|
+
end
|
|
773
|
+
|
|
774
|
+
# 日時要素の翻訳表の取得
|
|
775
|
+
#
|
|
776
|
+
# @overload _ids_(date)
|
|
777
|
+
# @param [Array<Numeric>] date ( 年 )
|
|
778
|
+
# @return [Array<When::Coordinates::Pair>] 1年の月の配置の翻訳表
|
|
779
|
+
#
|
|
780
|
+
# @overload _ids_(date)
|
|
781
|
+
# @param [Array<Numeric>] date ( 年 月 )
|
|
782
|
+
# @return [Array<When::Coordinates::Pair>] 1月の日の配置の翻訳表
|
|
783
|
+
# @note 月は 0 始まりの通番
|
|
784
|
+
#
|
|
785
|
+
def _ids_(date)
|
|
786
|
+
y, m = date
|
|
787
|
+
y = +y
|
|
788
|
+
mm = _new_year_month(y)
|
|
789
|
+
return (_table(_new_month_(mm+m.to_i)) {|i| _new_month(mm+m+i/15.0)}) if m
|
|
790
|
+
table = (0...26).to_a.map {|i| _tithi_to_coordinates((mm+i)*15)[1]}
|
|
791
|
+
table.pop while table[-1].trunk < 11
|
|
792
|
+
return table
|
|
793
|
+
end
|
|
794
|
+
|
|
795
|
+
private
|
|
796
|
+
|
|
797
|
+
# 日時要素の翻訳表の作成
|
|
798
|
+
def _table(b0)
|
|
799
|
+
table = [Pair._force_pair(0,0)]
|
|
800
|
+
(1..16).each do |i|
|
|
801
|
+
b1 = yield(i)
|
|
802
|
+
case b1-b0
|
|
803
|
+
when 0 ; table[-1] = Pair._force_pair(i-1, -2)
|
|
804
|
+
when 1 ; table << Pair._force_pair(i, 0)
|
|
805
|
+
when 2 ; table << Pair._force_pair(i, 0) << Pair._force_pair(i, 1)
|
|
806
|
+
else ; raise ArgumentError, "Irregal date span: #{b1-b0}"
|
|
807
|
+
end
|
|
808
|
+
b0 = b1
|
|
809
|
+
end
|
|
810
|
+
table.pop while table[-1].trunk >= 16
|
|
811
|
+
table.shift
|
|
812
|
+
return table
|
|
813
|
+
end
|
|
814
|
+
|
|
815
|
+
# オブジェクトの正規化
|
|
816
|
+
#
|
|
817
|
+
# @formula = 位相の計算に用いる太陽・変換・月の Formula
|
|
818
|
+
# @cycle_offset = 位相のオフセット
|
|
819
|
+
# @hindu_style = 閏月の表現方法
|
|
820
|
+
# @start_month = 暦年の最初の月
|
|
821
|
+
#
|
|
822
|
+
def _normalize(args=[], options={})
|
|
823
|
+
@label ||= 'Indian::HinduLuniSolar'
|
|
824
|
+
@type ||= 'SBSA'
|
|
825
|
+
raise ArgumentError, "Irregal formula: #{@formula}" unless @type.upcase =~ /\A(M|SS|SB)(V|S||B|H|VZ|SZ|BZ|HZ)(A|P|PX)\z/
|
|
826
|
+
|
|
827
|
+
@location ||= Location_E[$2] || Location_F[$1]
|
|
828
|
+
@cycle_offset ||= CycleOffset[$1]
|
|
829
|
+
@origin_of_MSC ||= -YearEpoch[$2]
|
|
830
|
+
@hindu_style ||= HinduStyle[$3]
|
|
831
|
+
@epoch_in_CE ||= 0
|
|
832
|
+
@start_month ||= 5 # Chaitra
|
|
833
|
+
@start_month = @start_month.to_i
|
|
834
|
+
@cycle_offset = @cycle_offset.to_f + (@start_month - 5)
|
|
835
|
+
@hindu_style = @hindu_style.to_i
|
|
836
|
+
@origin_of_MSC = @origin_of_MSC.to_i
|
|
837
|
+
formula = @formula || Formula[$1]
|
|
838
|
+
if formula.kind_of?(String)
|
|
839
|
+
formula += (formula =~ /\?/) ? '&' : '?'
|
|
840
|
+
@formula = When.Resource(["_ep:#{formula}formula=12S",
|
|
841
|
+
"_ep:#{formula}formula=30L->12S",
|
|
842
|
+
"_ep:#{formula}location=(#{@location})&formula=2L"])
|
|
843
|
+
end
|
|
844
|
+
intercalary_month = When.Resource('_m:Indian::IntercalaryMonth::*')
|
|
845
|
+
intercalary_day = When.Resource('_m:Indian::IntercalaryDay::*')
|
|
846
|
+
@indices ||= [
|
|
847
|
+
When.Index('Indian::LunarMonth', {:branch=>{-2.5 => intercalary_month[1], # 黒分
|
|
848
|
+
-2 => intercalary_month[3], # 閏黒分
|
|
849
|
+
-1.5 => intercalary_month[2], # 閏白分
|
|
850
|
+
-1 => intercalary_month[3], # 閏黒分
|
|
851
|
+
-0.5 => intercalary_month[1], # 黒分
|
|
852
|
+
0 => intercalary_month[0], # 白分
|
|
853
|
+
+0.5 => intercalary_month[1]}, # 黒分
|
|
854
|
+
:shift=>@start_month-1}),
|
|
855
|
+
When.Index({:branch=>{-2=>intercalary_day[0], +1=>intercalary_day[1]}})
|
|
856
|
+
]
|
|
857
|
+
|
|
858
|
+
super
|
|
859
|
+
end
|
|
860
|
+
end
|
|
861
|
+
end
|
|
862
|
+
|
|
863
|
+
class CalendarNote
|
|
864
|
+
#
|
|
865
|
+
# ヒンドゥー系の暦注
|
|
866
|
+
#
|
|
867
|
+
class HinduNote < self
|
|
868
|
+
|
|
869
|
+
Notes = [When::BasicTypes::M17n, [
|
|
870
|
+
"locale:[=en:, ja=ja:, hi=hi:, alias]",
|
|
871
|
+
"names:[Hindu]",
|
|
872
|
+
|
|
873
|
+
# 年の暦注 ----------------------------
|
|
874
|
+
[When::BasicTypes::M17n,
|
|
875
|
+
"names:[year]",
|
|
876
|
+
[When::BasicTypes::M17n,
|
|
877
|
+
"names:[samvatsara, 木星年=]",
|
|
878
|
+
"[Prabhava=, プラバヴァ=, _IAST_=]", # 1
|
|
879
|
+
"[Vibhava=, ヴィバヴァ=, _IAST_=]", # 2
|
|
880
|
+
"[Sukha=, スカ=, _IAST_=]", # 3
|
|
881
|
+
"[Pramoda=, プラモーダ=, _IAST_=]", # 4
|
|
882
|
+
"[Prajāpati=, プラジャーパティ=, _IAST_=]", # 5
|
|
883
|
+
"[Aṅgiras=, アンギラス=, _IAST_=]", # 6
|
|
884
|
+
"[Śrīmukha=, シュリームカ=, _IAST_=]", # 7
|
|
885
|
+
"[Bhāva=, バーヴァ=, _IAST_=]", # 8
|
|
886
|
+
"[Yuvan=, ユヴァン=, _IAST_=]", # 9
|
|
887
|
+
"[Dhātṛ=, ダートリ=, _IAST_=]", # 10
|
|
888
|
+
"[Īśvara=, イーシュヴァラ=, _IAST_=]", # 11
|
|
889
|
+
"[Bahudhānya=, バフダーニャ=, _IAST_=]", # 12
|
|
890
|
+
"[Pramāthin=, プラマーティン=, _IAST_=]", # 13
|
|
891
|
+
"[Vikrama=, ヴィクラマ=, _IAST_=]", # 14
|
|
892
|
+
"[Vṛṣa=, ヴリシャ=, _IAST_=]", # 15
|
|
893
|
+
"[Chitrabhānu=, チトラバーヌ=, _IAST_=]", # 16
|
|
894
|
+
"[Subhānu=, スバーヌ=, _IAST_=]", # 17
|
|
895
|
+
"[Tāraṇa=, ターラナ=, _IAST_=]", # 18
|
|
896
|
+
"[Pārthiva=, パールティヴァ=, _IAST_=]", # 19
|
|
897
|
+
"[Vyaya=, ヴヤヤ=, _IAST_=]", # 20
|
|
898
|
+
"[Sarvajit=, サルヴァジト=, _IAST_=]", # 21
|
|
899
|
+
"[Sarvadhārin=, サルヴァダーリン=, _IAST_=]", # 22
|
|
900
|
+
"[Virodhin=, ヴィローディン=, _IAST_=]", # 23
|
|
901
|
+
"[Vikṛta=, ヴィクリタ=, _IAST_=]", # 24
|
|
902
|
+
"[Khara=, カラ=, _IAST_=]", # 25
|
|
903
|
+
"[Nandana=, ナンダナ=, _IAST_=]", # 26
|
|
904
|
+
"[Vijaya=, ヴィジャヤ=, _IAST_=]", # 27
|
|
905
|
+
"[Jaya=, ジャヤ=, _IAST_=]", # 28
|
|
906
|
+
"[Manmatha=, マンマタ=, _IAST_=]", # 29
|
|
907
|
+
"[Durmukha=, ドゥルムカ=, _IAST_=]", # 30
|
|
908
|
+
"[Hemalamba=, ヘマラムバ=, _IAST_=]", # 31
|
|
909
|
+
"[Vilambin=, ヴィラムビン=, _IAST_=]", # 32
|
|
910
|
+
"[Vikārin=, ヴィカーリン=, _IAST_=]", # 33
|
|
911
|
+
"[Śārvarin=, シャールヴァリン=, _IAST_=]", # 34
|
|
912
|
+
"[Plava=, プラヴァ=, _IAST_=]", # 35
|
|
913
|
+
"[Śubhakṛt=, シュバクリト=, _IAST_=]", # 36
|
|
914
|
+
"[Śobhana=, ショバナ=, _IAST_=]", # 37
|
|
915
|
+
"[Krodhin=, クロディン=, _IAST_=]", # 38
|
|
916
|
+
"[Viśvāvasu=, ヴィシュヴァーヴァス=, _IAST_=]", # 39
|
|
917
|
+
"[Parābhava=, パラーバヴァ=, _IAST_=]", # 40
|
|
918
|
+
"[Plavaṅga=, プラヴァンガ=, _IAST_=]", # 41
|
|
919
|
+
"[Kīlaka=, キーラカ=, _IAST_=]", # 42
|
|
920
|
+
"[Saumya=, サウムヤ=, _IAST_=]", # 43
|
|
921
|
+
"[Sādhāraṇa=, サーダーラナ=, _IAST_=]", # 44
|
|
922
|
+
"[Virodhakṛt=, ヴィローダクリト=, _IAST_=]", # 45
|
|
923
|
+
"[Paridhāvin=, パリダーヴィン=, _IAST_=]", # 46
|
|
924
|
+
"[Pramādin=, プラマーディン=, _IAST_=]", # 47
|
|
925
|
+
"[Ānanda=, アーナンダ=, _IAST_=]", # 48
|
|
926
|
+
"[Rākṣasa=, ラークシャサ=, _IAST_=]", # 49
|
|
927
|
+
"[Anala=, アナラ=, _IAST_=]", # 50
|
|
928
|
+
"[Piṅgala=, ピンガラ=, _IAST_=]", # 51
|
|
929
|
+
"[Kālayukta=, カーラユクタ=, _IAST_=]", # 52
|
|
930
|
+
"[Siddhārthin=, シッダールティン=, _IAST_=]", # 53
|
|
931
|
+
"[Raudra=, ラウドラ=, _IAST_=]", # 54
|
|
932
|
+
"[Durmati=, ドゥルマティ=, _IAST_=]", # 55
|
|
933
|
+
"[Dundubhi=, ドゥンドゥビ=, _IAST_=]", # 56
|
|
934
|
+
"[Rudhirodgārin=, ルディロードガーリン=, _IAST_=]", # 57
|
|
935
|
+
"[Raktākṣin=, ラクタークシン=, _IAST_=]", # 58
|
|
936
|
+
"[Krodhana=, クローダナ=, _IAST_=]", # 59
|
|
937
|
+
"[Kṣaya=, クシャヤ=, _IAST_=]" # 60
|
|
938
|
+
]
|
|
939
|
+
],
|
|
940
|
+
|
|
941
|
+
# 月の暦注 ----------------------------
|
|
942
|
+
[When::BasicTypes::M17n,
|
|
943
|
+
"names:[month]",
|
|
944
|
+
[When::BasicTypes::M17n,
|
|
945
|
+
"names:[Month]"
|
|
946
|
+
]
|
|
947
|
+
],
|
|
948
|
+
|
|
949
|
+
# 日の暦注 ----------------------------
|
|
950
|
+
[When::BasicTypes::M17n,
|
|
951
|
+
"names:[day]",
|
|
952
|
+
|
|
953
|
+
[When::BasicTypes::M17n,
|
|
954
|
+
"names:[tithi=, ティティ=ja:%%<ティティ>]",
|
|
955
|
+
"[Amavasya, 新月, _IAST_=]", # 新月
|
|
956
|
+
"[Pratipad=en:Prathama_(day), 1日=, _IAST_=]", # 1
|
|
957
|
+
"[Dwitiya, 2日=, _IAST_=]", # 2
|
|
958
|
+
"[Tritiya, 3日=, _IAST_=]", # 3
|
|
959
|
+
"[Chaturthi, 4日=, _IAST_=]", # 4
|
|
960
|
+
"[Panchami, 5日=, _IAST_=]", # 5
|
|
961
|
+
"[Ṣaṣṭhī=en:Shashti, 6日=, _IAST_=]", # 6
|
|
962
|
+
"[Saptami, 7日=, _IAST_=]", # 7
|
|
963
|
+
"[Ashtami, 8日=, _IAST_=]", # 8
|
|
964
|
+
"[Navami, 9日=, _IAST_=]", # 9
|
|
965
|
+
"[Dashami, 10日=, _IAST_=]", # 10
|
|
966
|
+
"[Ekadashi, 11日=, _IAST_=]", # 11
|
|
967
|
+
"[Dwadashi, 12日=, _IAST_=]", # 12
|
|
968
|
+
"[Thrayodashi, 13日=, _IAST_=]", # 13
|
|
969
|
+
"[Chaturdashi, 14日=, _IAST_=]", # 14
|
|
970
|
+
"[Purnima, 満月, _IAST_=]" # 満月
|
|
971
|
+
],
|
|
972
|
+
|
|
973
|
+
[When::BasicTypes::M17n,
|
|
974
|
+
"names:[vāra=, ヴァーラ=, _IAST_=, *vara=]",
|
|
975
|
+
"[Ravi=en:S%C5%ABrya, 日曜日, _IAST_=]",
|
|
976
|
+
"[Soma, 月曜日, _IAST_=]",
|
|
977
|
+
"[Maṅgala=en:Mangala, 火曜日, _IAST_=]",
|
|
978
|
+
"[Budha, 水曜日, _IAST_=]",
|
|
979
|
+
"[Guru, 木曜日, _IAST_=]",
|
|
980
|
+
"[Śukra=en:Shukra, 金曜日, _IAST_=]",
|
|
981
|
+
"[Śani=en:Shani, 土曜日, _IAST_=]"
|
|
982
|
+
],
|
|
983
|
+
|
|
984
|
+
[When::BasicTypes::M17n,
|
|
985
|
+
"names:[nakṣatra=, ナクシャトラ=, _IAST_=, *naksatra=]",
|
|
986
|
+
"[Aśvinī=en:Ashvin%C4%AB, アシュヴィニー=, _IAST_=, 婁宿]", # 1
|
|
987
|
+
"[Bharaṇī=en:Bharan%C4%AB, バラニー=, _IAST_=, 胃宿]", # 2
|
|
988
|
+
"[Kṛttikā=en:Krittik%C4%81, クリッティカー=, _IAST_=, 昴宿]", # 3
|
|
989
|
+
"[Rohiṇī=en:Rohini_(nakshatra), ローヒニ―=, _IAST_=, 畢宿]", # 4
|
|
990
|
+
"[Mṛgaśiras=en:Mrigash%C4%ABrsha, ムリガシラス=, _IAST_=, 觜宿]", # 5
|
|
991
|
+
"[Ārdrā=en:Ardra_(nakshatra), アールドラー=, _IAST_=, 參宿]", # 6
|
|
992
|
+
"[Punarvasu=en:Punarvasu, プナルヴァス=, _IAST_=, 井宿]", # 7
|
|
993
|
+
"[Puṣya=en:Pushya, プシュヤ=, _IAST_=, 鬼宿]", # 8
|
|
994
|
+
"[Aśleṣā=en:%C4%80shlesh%C4%81, アーシュレーシャー=, _IAST_=, 柳宿]", # 9
|
|
995
|
+
"[Maghā=en:Magh%C4%81, マガー=, _IAST_=, 星宿]", # 10
|
|
996
|
+
"[Pū. Phalguṇī=en:P%C5%ABrva_Phalgun%C4%AB, P. パールグニー=, _IAST_=, 張宿]", # 11
|
|
997
|
+
"[U. Phalguṇī=en:Uttara_Phalgun%C4%AB, U. パールグニー=, _IAST_=, 翼宿]", # 12
|
|
998
|
+
"[Hasta=en:Nakshatra#Divisions, ハスタ=, _IAST_=, 軫宿]", # 13
|
|
999
|
+
"[Citrā=en:Nakshatra#Divisions, チトラー=, _IAST_=, 角宿]", # 14
|
|
1000
|
+
"[Svāti=en:Sv%C4%81t%C4%AB, スヴァーティー=, _IAST_=, 亢宿]", # 15
|
|
1001
|
+
"[Viśākha=en:Vish%C4%81kh%C4%81, ヴィシャーカー=, _IAST_=, 氐宿]", # 16
|
|
1002
|
+
"[Anurādhā=en:Anur%C4%81dh%C4%81, アヌラーダー=, _IAST_=, 房宿]", # 17
|
|
1003
|
+
"[Jyeṣṭha=en:Jyeshtha, ジェーシュター=, _IAST_=, 心宿]", # 18
|
|
1004
|
+
"[Mūla=en:Mula_(astrology), ムーラ=, _IAST_=, 尾宿]", # 19
|
|
1005
|
+
"[Pū. āṣāḍha=en:P%C5%ABrva_Ash%C4%81dh%C4%81, P. アーシャーダー=, _IAST_=, 箕宿]", # 20
|
|
1006
|
+
"[U. āṣāḍha=en:Uttara_Ash%C4%81dh%C4%81, U. アーシャーダー=, _IAST_=, 斗宿]", # 21
|
|
1007
|
+
"[Śravaṇa=en:Shravana, シュラヴァナ=, _IAST_=, 女宿]", # 22
|
|
1008
|
+
"[Śraviṣṭhā=en:Dhanishta, ダニシュター=, _IAST_=, 虛宿]", # 23
|
|
1009
|
+
"[Śatabhiṣak=en:Shatabhish%C4%81, シャタビシャジュ=, _IAST_=, 危宿]", # 24
|
|
1010
|
+
"[Pū. Bhādrapadā=en:P%C5%ABrva_Bh%C4%81drapad%C4%81,P. バードラパダー=, _IAST_=, 室宿]", # 25
|
|
1011
|
+
"[U. Bhādrapadā=en:Uttara_Bh%C4%81drapad%C4%81, U. バードラパダー=, _IAST_=, 壁宿]", # 26
|
|
1012
|
+
"[Revatī=en:Revati_(nakshatra), レーヴァティー=, _IAST_=, 奎宿]" # 27
|
|
1013
|
+
],
|
|
1014
|
+
|
|
1015
|
+
[When::BasicTypes::M17n,
|
|
1016
|
+
"names:[yoga=, ヨーガ=, _IAST_=]",
|
|
1017
|
+
"[Viṣkambha=, ヴィシュカムバ=, _IAST_=]", # 1
|
|
1018
|
+
"[Prīti=, プリーティ=, _IAST_=]", # 2
|
|
1019
|
+
"[Āyuśmān=, アーユシュマー=, _IAST_=]", # 3
|
|
1020
|
+
"[Saubhāgya=, サウバーギャ=, _IAST_=]", # 4
|
|
1021
|
+
"[Śobhana=, ショーバナ=, _IAST_=]", # 5
|
|
1022
|
+
"[Atigaṇḍa=, アティガンダ=, _IAST_=]", # 6
|
|
1023
|
+
"[Sukarma=, スカルマ=, _IAST_=]", # 7
|
|
1024
|
+
"[Dhṛti, ドゥリティ=, _IAST_=]", # 8
|
|
1025
|
+
"[Śūla=, シューラ=, _IAST_=]", # 9
|
|
1026
|
+
"[Gaṇḍa=, ガンダ=, _IAST_=]", # 10
|
|
1027
|
+
"[Vṛddhi=, ヴリッディ=, _IAST_=]", # 11
|
|
1028
|
+
"[Dhruva=, ドルヴァ=, _IAST_=]", # 12
|
|
1029
|
+
"[Vyāghāta=, ヴヤーガータ=, _IAST_=]", # 13
|
|
1030
|
+
"[Harṣaṇa=, ハルシャナ=, _IAST_=]", # 14
|
|
1031
|
+
"[Vajra=, ヴァジュラ=, _IAST_=]", # 15
|
|
1032
|
+
"[Siddhi=, シッディ=, _IAST_=]", # 16
|
|
1033
|
+
"[Vyatīpāta=, ヴヤティーパータ=, _IAST_=]", # 17
|
|
1034
|
+
"[Varīyas=, ヴァリーヤス=, _IAST_=]", # 18
|
|
1035
|
+
"[Parigha=, パリガ=, _IAST_=]", # 19
|
|
1036
|
+
"[Śiva=, シヴァ=, _IAST_=]", # 20
|
|
1037
|
+
"[Siddha=, シッダ=, _IAST_=]", # 21
|
|
1038
|
+
"[Sādhya=, サーディヤ=, _IAST_=]", # 22
|
|
1039
|
+
"[Śubha=, シュバ=, _IAST_=]", # 23
|
|
1040
|
+
"[Śukla=, シュクラ=, _IAST_=]", # 24
|
|
1041
|
+
"[Brahman=, ブラフマン=, _IAST_=]", # 25
|
|
1042
|
+
"[Māhendra=, マーヘンドラ=, _IAST_=]", # 26
|
|
1043
|
+
"[Vaidhṛti=, ヴァイドリティ=, _IAST_=]" # 27
|
|
1044
|
+
],
|
|
1045
|
+
|
|
1046
|
+
[When::BasicTypes::M17n,
|
|
1047
|
+
"names:[Karaṇa=, カラナ=, _IAST_=, *karana]",
|
|
1048
|
+
"[Bava=, バヴァ=, _IAST_=]", # 1
|
|
1049
|
+
"[Bālava=, バーラヴァ=, _IAST_=]", # 2
|
|
1050
|
+
"[Kaulava=, カウラヴァ=, _IAST_=]", # 3
|
|
1051
|
+
"[Taitila=, タイティラ=, _IAST_=]", # 4
|
|
1052
|
+
"[Gara=, ガラ=, _IAST_=]", # 5
|
|
1053
|
+
"[Vaṇija=, ヴァニジュ=, _IAST_=]", # 6
|
|
1054
|
+
"[Viṣṭi=, ヴィシュティ=, _IAST_=]", # 7
|
|
1055
|
+
"[Kiṃtughna=, キンストゥグナ=, _IAST_=]", # A
|
|
1056
|
+
"[Śakuni=, シャクニ=, _IAST_=]", # B
|
|
1057
|
+
"[Catuṣpāda=, チャトシュパダ=, _IAST_=]", # C
|
|
1058
|
+
"[Nāga=, ナーガ=, _IAST_=]" # D
|
|
1059
|
+
]
|
|
1060
|
+
]
|
|
1061
|
+
]]
|
|
1062
|
+
|
|
1063
|
+
NoteConsts = {
|
|
1064
|
+
'tithi' => {
|
|
1065
|
+
:formula => 15,
|
|
1066
|
+
:range => (-1..2),
|
|
1067
|
+
:index => [ 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,
|
|
1068
|
+
15,1,2,3,4,5,6,7,8,9,10,11,12,13,14]
|
|
1069
|
+
},
|
|
1070
|
+
'naksatra' => {
|
|
1071
|
+
:formula => '27M',
|
|
1072
|
+
:range => (-1..2),
|
|
1073
|
+
:index => (0...27).to_a
|
|
1074
|
+
},
|
|
1075
|
+
'yoga' => {
|
|
1076
|
+
:formula => '27M+27S',
|
|
1077
|
+
:range => (-1..2),
|
|
1078
|
+
:index => (0...27).to_a
|
|
1079
|
+
},
|
|
1080
|
+
'karana' => {
|
|
1081
|
+
:formula => 30,
|
|
1082
|
+
:range => (-2..3),
|
|
1083
|
+
:index => [7] + (0...7).to_a * 8 + [8,9,10]
|
|
1084
|
+
}
|
|
1085
|
+
}
|
|
1086
|
+
|
|
1087
|
+
#
|
|
1088
|
+
# pancanga 計算に必要となる情報をまとめた内部クラス
|
|
1089
|
+
#
|
|
1090
|
+
class Dates
|
|
1091
|
+
|
|
1092
|
+
# @private
|
|
1093
|
+
attr_reader :o_date, :l_date, :root, :formula, :iri, :rises
|
|
1094
|
+
|
|
1095
|
+
# 初期設定
|
|
1096
|
+
# @private
|
|
1097
|
+
def initialize(date)
|
|
1098
|
+
@o_date = date
|
|
1099
|
+
clock = date.clock
|
|
1100
|
+
frame = date.frame if date.frame.kind_of?(When::CalendarTypes::HinduLuniSolar)
|
|
1101
|
+
@l_date = (frame || When.Calendar('HinduLuniSolar?note=HinduNote')).jul_trans(date.to_i, {:clock=>'+05:30'})
|
|
1102
|
+
@root = When.CalendarNote('HinduNote/Notes')['day']
|
|
1103
|
+
@formula = @l_date.frame.formula[-1]
|
|
1104
|
+
@iri = @formula.iri
|
|
1105
|
+
@rises = [@formula.sunrise(@l_date), @formula.sunrise(@l_date+When.Duration('P1D'))]
|
|
1106
|
+
end
|
|
1107
|
+
|
|
1108
|
+
# その他のメソッドは @l_date に移譲する
|
|
1109
|
+
def method_missing(name, *args, &block)
|
|
1110
|
+
self.class.module_eval %Q{
|
|
1111
|
+
def #{name}(*args, &block)
|
|
1112
|
+
@l_date.send("#{name}", *args, &block)
|
|
1113
|
+
end
|
|
1114
|
+
} unless When::Parts::MethodCash.escape(name)
|
|
1115
|
+
@l_date.send(name, *args, &block)
|
|
1116
|
+
end
|
|
1117
|
+
end
|
|
1118
|
+
|
|
1119
|
+
#
|
|
1120
|
+
# 任意の暦をインド太陰太陽暦日に変換
|
|
1121
|
+
# @private
|
|
1122
|
+
def _to_date_for_note(date)
|
|
1123
|
+
Dates.new(date)
|
|
1124
|
+
end
|
|
1125
|
+
|
|
1126
|
+
#
|
|
1127
|
+
# 木星年
|
|
1128
|
+
#
|
|
1129
|
+
# @param [Dates] dates
|
|
1130
|
+
#
|
|
1131
|
+
# @return [When::BasicTypes::M17n] 木星年の名称
|
|
1132
|
+
#
|
|
1133
|
+
# see {http://en.wikipedia.org/wiki/Samvatsara Samvatsara}
|
|
1134
|
+
#
|
|
1135
|
+
def samvatsara(dates)
|
|
1136
|
+
year_kali = dates.l_date.most_significant_coordinate + dates.l_date.frame._diff_to_CE + 3101
|
|
1137
|
+
year_mod = year_kali >= jovian ? (year_kali + 12) % 60 :
|
|
1138
|
+
((year_kali * 211 - 108).div(18000) + year_kali + 26) % 60
|
|
1139
|
+
When.CalendarNote('HinduNote/Notes')['year']['samvatsara'][year_mod]
|
|
1140
|
+
end
|
|
1141
|
+
|
|
1142
|
+
#
|
|
1143
|
+
# 木星年の計算方式に“South”を適用開始する年
|
|
1144
|
+
#
|
|
1145
|
+
# @return [Integer] 年(カリユガ紀元)
|
|
1146
|
+
#
|
|
1147
|
+
def jovian
|
|
1148
|
+
return @jovian if @jovian.kind_of?(Integer)
|
|
1149
|
+
@jovian = @jovian ? @jovian.to_i : 4009
|
|
1150
|
+
end
|
|
1151
|
+
|
|
1152
|
+
#
|
|
1153
|
+
# ヴァーラ (七曜)
|
|
1154
|
+
#
|
|
1155
|
+
# @param [Dates] dates
|
|
1156
|
+
#
|
|
1157
|
+
# @return [Array<When::TM::TemporalPosition>] 日の出の時刻をイベント時刻とする
|
|
1158
|
+
#
|
|
1159
|
+
def vara(dates)
|
|
1160
|
+
rise = dates.rises[0]
|
|
1161
|
+
rise.events = [dates.root['vara'][(rise.to_i+1) % 7]]
|
|
1162
|
+
['V:-', rise]
|
|
1163
|
+
end
|
|
1164
|
+
|
|
1165
|
+
#
|
|
1166
|
+
# ヴァーラ以外
|
|
1167
|
+
#
|
|
1168
|
+
|
|
1169
|
+
# 当該日付中でティティが変わる日時
|
|
1170
|
+
# @method tithi(dates)
|
|
1171
|
+
# @param [Dates] dates
|
|
1172
|
+
# @return [Array<When::TM::TemporalPosition>] イベント日時
|
|
1173
|
+
|
|
1174
|
+
# 当該日付中でナクシャトラが変わる日時
|
|
1175
|
+
# @method naksatra(dates)
|
|
1176
|
+
# @param [Dates] dates
|
|
1177
|
+
# @return [Array<When::TM::TemporalPosition>] イベント日時
|
|
1178
|
+
|
|
1179
|
+
# 当該日付中でヨーガが変わる日時
|
|
1180
|
+
# @method yoga(dates)
|
|
1181
|
+
# @param [Dates] dates
|
|
1182
|
+
# @return [Array<When::TM::TemporalPosition>] イベント日時
|
|
1183
|
+
|
|
1184
|
+
# 当該日付中でカラナが変わる日時
|
|
1185
|
+
# @method karana(dates)
|
|
1186
|
+
# @param [Dates] dates
|
|
1187
|
+
# @return [Array<When::TM::TemporalPosition>] イベント日時
|
|
1188
|
+
#
|
|
1189
|
+
|
|
1190
|
+
# @private
|
|
1191
|
+
NoteConsts.keys.each do |key|
|
|
1192
|
+
module_eval %Q{
|
|
1193
|
+
def #{key}(dates)
|
|
1194
|
+
pancanga(dates, '#{key}').map {|event| ['#{key[0..0].upcase}:-', event]}
|
|
1195
|
+
end
|
|
1196
|
+
}
|
|
1197
|
+
end
|
|
1198
|
+
|
|
1199
|
+
#
|
|
1200
|
+
# ヴァーラ以外のイベント日時
|
|
1201
|
+
#
|
|
1202
|
+
# @param [Dates] dates
|
|
1203
|
+
# @param [String] key 'tithi', 'naksatra', 'yoga', 'karana' のいずれか
|
|
1204
|
+
# @return [Array<When::TM::TemporalPosition>] イベント日時
|
|
1205
|
+
#
|
|
1206
|
+
def pancanga(dates, key)
|
|
1207
|
+
pattern = NoteConsts[key]
|
|
1208
|
+
note = dates.root[key]
|
|
1209
|
+
if pattern[:formula].kind_of?(Numeric)
|
|
1210
|
+
factor = pattern[:formula].to_f
|
|
1211
|
+
formula = dates.formula
|
|
1212
|
+
else
|
|
1213
|
+
factor = 1.0
|
|
1214
|
+
formula = When.Resource(dates.iri.sub(/formula=2L/, "formula=#{pattern[:formula]}"))
|
|
1215
|
+
end
|
|
1216
|
+
cn = (formula.time_to_cn(dates.l_date) * factor).floor
|
|
1217
|
+
events = []
|
|
1218
|
+
pattern[:range].each do |i|
|
|
1219
|
+
event = formula._to_seed_type(formula.cn_to_time((cn+i)/factor), dates.l_date)
|
|
1220
|
+
break if +event >= +dates.rises[1]
|
|
1221
|
+
next if +event < +dates.rises[0]
|
|
1222
|
+
event.events = [note[pattern[:index][(cn+i) % pattern[:index].length]]]
|
|
1223
|
+
events << event
|
|
1224
|
+
end
|
|
1225
|
+
events
|
|
1226
|
+
end
|
|
1227
|
+
end
|
|
1228
|
+
|
|
1229
|
+
#
|
|
1230
|
+
# 日の出の九惑星の位置まで計算
|
|
1231
|
+
#
|
|
1232
|
+
class HinduNoteDetailed < HinduNote
|
|
1233
|
+
|
|
1234
|
+
Notes = HinduNote::Notes
|
|
1235
|
+
|
|
1236
|
+
#
|
|
1237
|
+
# ヴァーラ (七曜)と九惑星の位置
|
|
1238
|
+
#
|
|
1239
|
+
# @param [Dates] dates
|
|
1240
|
+
# @return [Array<When::TM::TemporalPosition, Hash{ 惑星シンボル=>惑星の真黄経 }>]
|
|
1241
|
+
# 日の出の時刻をイベント時刻とし、その時刻での九惑星の位置を計算
|
|
1242
|
+
#
|
|
1243
|
+
def vara(dates)
|
|
1244
|
+
rise = dates.rises[0]
|
|
1245
|
+
rise.events = [dates.root['vara'][(rise.to_i+1) % 7]]
|
|
1246
|
+
t = dates.formula.is_dynamical ? +rise : rise.to_f
|
|
1247
|
+
[['V:-', rise], dates.formula.graha.keys.inject({}) {|h,p|
|
|
1248
|
+
h.store(p, dates.formula.graha[p].true_longitude(t))
|
|
1249
|
+
h
|
|
1250
|
+
}]
|
|
1251
|
+
end
|
|
1252
|
+
end
|
|
1253
|
+
end
|
|
1254
|
+
end
|