when_exe 0.4.1 → 0.4.2

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.
Files changed (96) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +36 -33
  3. data/bin/locales.rb +1 -1
  4. data/bin/make_ttl.rb.config +1 -1
  5. data/lib/when_exe.rb +27 -16
  6. data/lib/when_exe/basictypes.rb +772 -771
  7. data/lib/when_exe/calendartypes.rb +1485 -1453
  8. data/lib/when_exe/coordinates.rb +5 -0
  9. data/lib/when_exe/core/compatibility.rb +1 -1
  10. data/lib/when_exe/core/duration.rb +147 -116
  11. data/lib/when_exe/core/extension.rb +499 -497
  12. data/lib/when_exe/ephemeris.rb +1952 -1951
  13. data/lib/when_exe/ephemeris/eclipse.rb +5 -4
  14. data/lib/when_exe/ephemeris/notes.rb +457 -421
  15. data/lib/when_exe/ephemeris/planets.rb +585 -585
  16. data/lib/when_exe/ephemeris/sun.rb +214 -214
  17. data/lib/when_exe/google_api.rb +153 -0
  18. data/lib/when_exe/icalendar.rb +1640 -1632
  19. data/lib/when_exe/inspect.rb +42 -20
  20. data/lib/when_exe/linkeddata.rb +28 -7
  21. data/lib/when_exe/locales/autoload.rb +2 -1
  22. data/lib/when_exe/locales/locale.rb +35 -15
  23. data/lib/when_exe/locales/zh.rb +77 -0
  24. data/lib/when_exe/mini_application.rb +3 -1
  25. data/lib/when_exe/{googlecalendar.rb → obsolete/googlecalendar.rb} +144 -144
  26. data/lib/when_exe/parts/enumerator.rb +498 -486
  27. data/lib/when_exe/parts/geometric_complex.rb +397 -397
  28. data/lib/when_exe/parts/timezone.rb +246 -241
  29. data/lib/when_exe/region/armenian.rb +55 -56
  30. data/lib/when_exe/region/babylonian.rb +406 -405
  31. data/lib/when_exe/region/bahai.rb +107 -106
  32. data/lib/when_exe/region/balinese.rb +624 -622
  33. data/lib/when_exe/region/chinese.rb +1071 -1026
  34. data/lib/when_exe/region/chinese/epochs.rb +28 -28
  35. data/lib/when_exe/region/chinese/notes.rb +219 -0
  36. data/lib/when_exe/region/chinese/twins.rb +803 -803
  37. data/lib/when_exe/region/christian.rb +21 -15
  38. data/lib/when_exe/region/coptic.rb +107 -106
  39. data/lib/when_exe/region/discordian.rb +218 -218
  40. data/lib/when_exe/region/east_asian.rb +1 -1
  41. data/lib/when_exe/region/french.rb +126 -56
  42. data/lib/when_exe/region/geologicalage.rb +639 -639
  43. data/lib/when_exe/region/goddess.rb +60 -58
  44. data/lib/when_exe/region/hanke_henry.rb +2 -2
  45. data/lib/when_exe/region/indian.rb +1225 -1222
  46. data/lib/when_exe/region/international_fixed.rb +96 -97
  47. data/lib/when_exe/region/iranian.rb +206 -203
  48. data/lib/when_exe/region/islamic.rb +102 -102
  49. data/lib/when_exe/region/japanese.rb +126 -71
  50. data/lib/when_exe/region/japanese/epochs.rb +426 -426
  51. data/lib/when_exe/region/japanese/notes.rb +101 -81
  52. data/lib/when_exe/region/japanese/residues.rb +1345 -1311
  53. data/lib/when_exe/region/japanese/twins.rb +225 -225
  54. data/lib/when_exe/region/japanese/weeks.rb +112 -112
  55. data/lib/when_exe/region/javanese.rb +230 -230
  56. data/lib/when_exe/region/jewish.rb +130 -131
  57. data/lib/when_exe/region/m17n.rb +114 -114
  58. data/lib/when_exe/region/martian.rb +258 -258
  59. data/lib/when_exe/region/mayan.rb +11 -8
  60. data/lib/when_exe/region/pax.rb +4 -5
  61. data/lib/when_exe/region/pope.rb +1 -1
  62. data/lib/when_exe/region/positivist.rb +100 -100
  63. data/lib/when_exe/region/residue.rb +162 -162
  64. data/lib/when_exe/region/roman.rb +333 -333
  65. data/lib/when_exe/region/{soviet.rb → russian.rb} +221 -209
  66. data/lib/when_exe/region/shire.rb +222 -223
  67. data/lib/when_exe/region/symmetry.rb +50 -50
  68. data/lib/when_exe/region/thai.rb +336 -336
  69. data/lib/when_exe/region/tibetan.rb +315 -316
  70. data/lib/when_exe/region/tranquility.rb +207 -208
  71. data/lib/when_exe/region/vanishing_leprechaun.rb +3 -1
  72. data/lib/when_exe/region/vietnamese.rb +449 -440
  73. data/lib/when_exe/region/weekdate.rb +80 -80
  74. data/lib/when_exe/region/world.rb +170 -171
  75. data/lib/when_exe/region/world_season.rb +89 -89
  76. data/lib/when_exe/region/yerm.rb +3 -3
  77. data/lib/when_exe/region/zoroastrian.rb +205 -205
  78. data/lib/when_exe/timestandard.rb +708 -707
  79. data/lib/when_exe/tmduration.rb +338 -338
  80. data/lib/when_exe/tmobjects.rb +1356 -1356
  81. data/lib/when_exe/tmposition.rb +66 -31
  82. data/lib/when_exe/version.rb +16 -2
  83. data/test/examples/Residue.m17n +83 -83
  84. data/test/examples/Terms.m17n +2 -2
  85. data/test/test.rb +2 -2
  86. data/test/test/google_api.rb +65 -0
  87. data/test/test/linkeddata.rb +1 -1
  88. data/test/test/{googlecalendar.rb → obsolete/googlecalendar.rb} +194 -194
  89. data/test/test/region/indian.rb +90 -85
  90. data/test/test/region/m17n.rb +7 -7
  91. data/test/test/region/mayan.rb +195 -195
  92. data/test/test/region/residue.rb +153 -153
  93. data/test/test/tmposition.rb +11 -1
  94. data/when_exe.gemspec +2 -2
  95. metadata +95 -8
  96. data/test/test.rb.config +0 -1
@@ -1,106 +1,107 @@
1
- # -*- coding: utf-8 -*-
2
- =begin
3
- Copyright (C) 2013-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
- module When
9
- class BasicTypes::M17n
10
-
11
- Bahai = [self, [
12
- "locale:[=en:, ar=ar:, alias=en:]",
13
- "names:[Bahai=]",
14
- "[Bahai=en:Bah%C3%A1%27%C3%AD_calendar, ja:バハーイー暦=ja:%%<バハーイー教>]",
15
-
16
- # %0s は“閏”の表記を抑制する指定となっている
17
- [self,
18
- "names:[Month, 月=ja:%%<月_(暦)>]",
19
- "[Bahá=, بهاء=, Splendour= ]", # 1
20
- "[Jalál=, جلال=, Glory= ]", # 2
21
- "[Jamál=, جمال=, Beauty= ]", # 3
22
- "[‘Aẓamat=, عظمة=, Grandeur= ]", # 4
23
- "[Núr=, نور=, Light= ]", # 5
24
- "[Raḥmat=, رحمة=, Mercy= ]", # 6
25
- "[Kalimát=, كلمات=, Words= ]", # 7
26
- "[Kamál=, كمال=, Perfection= ]", # 8
27
- "[Asmá’=, اسماء=, Names= ]", # 9
28
- "[‘Izzat=, عزة=, Might= ]", # 10
29
- "[Mashíyyat=, عزة=, Will= ]", # 11
30
- "[‘Ilm=, علم=, Knowledge= ]", # 12
31
- "[Qudrat=, قدرة=, Power= ]", # 13
32
- "[Qawl=, قول=, Speech= ]", # 14
33
- "[Masá’il=, مسائل=, Questions= ]", # 15
34
- "[Sharaf=, شرف=, Honour= ]", # 16
35
- "[Sulṭán=, سلطان=, Sovereignty=]", # 17
36
- "[Mulk=, ملك=, Dominion= ]", # 18
37
- "[‘Alá’=, علاء=, Loftiness= ]", # 19
38
- "[%0sAyyám-i-Há=en:Ayy%C3%A1m-i-H%C3%A1, %0sايام الهاء=, %0sThe Days of Há=]" # Intercalary days
39
- ]
40
- ]]
41
- end
42
-
43
- class CalendarNote
44
- Bahai = [['Bahai::YearName'], ['_m:Bahai::Month'], ['Common::Week']]
45
- end
46
-
47
- module Coordinates
48
-
49
- # Bahai years
50
- Bahai = [When::BasicTypes::M17n, [
51
- "locale:[=en:, ar=ar:, alias=en:]",
52
- "names:[Bahai]",
53
-
54
- [Residue,
55
- "label:[YearName=]", "divisor:19", "year:0", "format:[%1$s(%3$d)=]",
56
- [Residue, "label:[Alif=, ألف=, A= ]", "remainder: 0"],
57
- [Residue, "label:[Bá=, باء=, B= ]", "remainder: 1"],
58
- [Residue, "label:[Ab=, أب=, Father= ]", "remainder: 2"],
59
- [Residue, "label:[Dál=, دﺍﻝ=, D= ]", "remainder: 3"],
60
- [Residue, "label:[Báb=, باب=, Gate= ]", "remainder: 4"],
61
- [Residue, "label:[Váv=, وﺍو=, V= ]", "remainder: 5"],
62
- [Residue, "label:[Abad=, أبد=, Eternity= ]", "remainder: 6"],
63
- [Residue, "label:[Jád=, جاد=, Generosity= ]", "remainder: 7"],
64
- [Residue, "label:[Bahá'=, بهاء=, Splendour= ]", "remainder: 8"],
65
- [Residue, "label:[Ḥubb=, حب=, Love= ]", "remainder: 9"],
66
- [Residue, "label:[Bahháj=, بهاج=, Delightful= ]", "remainder: 10"],
67
- [Residue, "label:[Javáb=, جواب=, Answer= ]", "remainder: 11"],
68
- [Residue, "label:[Aḥad=, احد=, Single= ]", "remainder: 12"],
69
- [Residue, "label:[Vahháb=, بهاء=, Bountiful= ]", "remainder: 13"],
70
- [Residue, "label:[Vidád=, وداد=, Affection= ]", "remainder: 14"],
71
- [Residue, "label:[Badí‘=, بدیع=, Beginning= ]", "remainder: 15"],
72
- [Residue, "label:[Bahí=, بهي=, Luminous= ]", "remainder: 16"],
73
- [Residue, "label:[Abhá=, ابهى=, Most Luminous=]", "remainder: 17"],
74
- [Residue, "label:[Váḥid=, واحد=, Unity= ]", "remainder: 18"]
75
- ]
76
- ]]
77
- end
78
-
79
- module CalendarTypes
80
-
81
- _ID = '1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,18=,19'
82
- _Indices = [
83
- When.Index({:unit =>19}),
84
- When.Index({:unit =>19}),
85
- When.Index('Bahai::Month', {:branch=>{+1=>When.Resource('_m:Bahai::Month::*')[19]}}),
86
- When::Coordinates::DefaultDayIndex
87
- ]
88
-
89
- #
90
- # Bahá'í Calendar
91
- #
92
- Bahai = [SolarYearTableBasedWithSunset, {
93
- 'label' => 'Bahai::Bahai',
94
- 'indices' => _Indices,
95
- 'origin_of_MSC' => -1844 + 19*19,
96
- 'diff_to_CE' => 0,
97
- 'engine_month' => 3,
98
- 'engine_day' => 21,
99
- 'rule_table' => {
100
- 365 => {'Length'=>[19] * 18 + [4, 19], 'IDs'=>_ID},
101
- 366 => {'Length'=>[19] * 18 + [5, 19], 'IDs'=>_ID}
102
- },
103
- 'note' => 'Bahai'
104
- }]
105
- end
106
- end
1
+ # -*- coding: utf-8 -*-
2
+ =begin
3
+ Copyright (C) 2013-2015 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
+ module When
9
+ class BasicTypes::M17n
10
+
11
+ Bahai = [self, [
12
+ "locale:[=en:, ja=ja:, zh=zh:]",
13
+ "names:[Bahai=en:Bah%C3%A1%27%C3%AD_calendar, バハーイー暦=ja:%%<バハーイー教>, 巴哈伊曆=zh:%%<巴哈伊曆法>]",
14
+
15
+ # %0s は“閏”の表記を抑制する指定となっている
16
+ [self,
17
+ "locale:[=en:, ar=ar:, alias=en:]",
18
+ "names:[month name=en:Month, ja:月の名前=ja:%%<月_(暦)>, zh:該月的名稱=, *alias:Month=]",
19
+ "[Bahá=, بهاء=, Splendour= ]", # 1
20
+ "[Jalál=, جلال=, Glory= ]", # 2
21
+ "[Jamál=, جمال=, Beauty= ]", # 3
22
+ "[‘Aẓamat=, عظمة=, Grandeur= ]", # 4
23
+ "[Núr=, نور=, Light= ]", # 5
24
+ "[Raḥmat=, رحمة=, Mercy= ]", # 6
25
+ "[Kalimát=, كلمات=, Words= ]", # 7
26
+ "[Kamál=, كمال=, Perfection= ]", # 8
27
+ "[Asmá’=, اسماء=, Names= ]", # 9
28
+ "[‘Izzat=, عزة=, Might= ]", # 10
29
+ "[Mashíyyat=, عزة=, Will= ]", # 11
30
+ "[‘Ilm=, علم=, Knowledge= ]", # 12
31
+ "[Qudrat=, قدرة=, Power= ]", # 13
32
+ "[Qawl=, قول=, Speech= ]", # 14
33
+ "[Masá’il=, مسائل=, Questions= ]", # 15
34
+ "[Sharaf=, شرف=, Honour= ]", # 16
35
+ "[Sulṭán=, سلطان=, Sovereignty=]", # 17
36
+ "[Mulk=, ملك=, Dominion= ]", # 18
37
+ "[‘Alá’=, علاء=, Loftiness= ]", # 19
38
+ "[%0sAyyám-i-Há=en:Ayy%C3%A1m-i-H%C3%A1, %0sايام الهاء=, %0sThe Days of Há=]" # Intercalary days
39
+ ]
40
+ ]]
41
+ end
42
+
43
+ class CalendarNote
44
+ Bahai = [['Bahai::YearName'], ['_m:Bahai::Month'], ['Common::Week']]
45
+ end
46
+
47
+ module Coordinates
48
+
49
+ # Bahai years
50
+ Bahai = [When::BasicTypes::M17n, [
51
+ "locale:[=en:, ar=ar:, alias=en:]",
52
+ "names:[Bahá'í Faith, بهائية, ja:バハーイー教, *alias:Bahai=]",
53
+
54
+ [Residue,
55
+ "label:[year name=, ja:年の名前=, zh:該年的名稱=, *alias:YearName=]",
56
+ "divisor:19", "year:1", "format:[%1$s(%3$d)=, (%3$d)%1$s=]",
57
+ [Residue, "label:[Alif=, ألف=, A= ]", "remainder: 0"],
58
+ [Residue, "label:[Bá=, باء=, B= ]", "remainder: 1"],
59
+ [Residue, "label:[Ab=, أب=, Father= ]", "remainder: 2"],
60
+ [Residue, "label:[Dál=, دﺍﻝ=, D= ]", "remainder: 3"],
61
+ [Residue, "label:[Báb=, باب=, Gate= ]", "remainder: 4"],
62
+ [Residue, "label:[Váv=, وﺍو=, V= ]", "remainder: 5"],
63
+ [Residue, "label:[Abad=, أبد=, Eternity= ]", "remainder: 6"],
64
+ [Residue, "label:[Jád=, جاد=, Generosity= ]", "remainder: 7"],
65
+ [Residue, "label:[Bahá'=, بهاء=, Splendour= ]", "remainder: 8"],
66
+ [Residue, "label:[Ḥubb=, حب=, Love= ]", "remainder: 9"],
67
+ [Residue, "label:[Bahháj=, بهاج=, Delightful= ]", "remainder: 10"],
68
+ [Residue, "label:[Javáb=, جواب=, Answer= ]", "remainder: 11"],
69
+ [Residue, "label:[Aḥad=, احد=, Single= ]", "remainder: 12"],
70
+ [Residue, "label:[Vahháb=, بهاء=, Bountiful= ]", "remainder: 13"],
71
+ [Residue, "label:[Vidád=, وداد=, Affection= ]", "remainder: 14"],
72
+ [Residue, "label:[Badí‘=, بدیع=, Beginning= ]", "remainder: 15"],
73
+ [Residue, "label:[Bahí=, بهي=, Luminous= ]", "remainder: 16"],
74
+ [Residue, "label:[Abhá=, ابهى=, Most Luminous=]", "remainder: 17"],
75
+ [Residue, "label:[Váḥid=, واحد=, Unity= ]", "remainder: 18"]
76
+ ]
77
+ ]]
78
+ end
79
+
80
+ module CalendarTypes
81
+
82
+ _ID = '1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,18=,19'
83
+ _Indices = [
84
+ When.Index({:unit =>19}),
85
+ When.Index({:unit =>19}),
86
+ When.Index('Bahai::Month', {:branch=>{+1=>When.Resource('_m:Bahai::Month::*')[19]}}),
87
+ When::Coordinates::DefaultDayIndex
88
+ ]
89
+
90
+ #
91
+ # Bahá'í Calendar
92
+ #
93
+ Bahai = [SolarYearTableBasedWithSunset, {
94
+ 'label' => 'Bahai',
95
+ 'indices' => _Indices,
96
+ 'origin_of_MSC' => -1844 + 19*19,
97
+ 'diff_to_CE' => 0,
98
+ 'engine_month' => 3,
99
+ 'engine_day' => 21,
100
+ 'rule_table' => {
101
+ 365 => {'Length'=>[19] * 18 + [4, 19], 'IDs'=>_ID},
102
+ 366 => {'Length'=>[19] * 18 + [5, 19], 'IDs'=>_ID}
103
+ },
104
+ 'note' => 'Bahai'
105
+ }]
106
+ end
107
+ end
@@ -1,622 +1,624 @@
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
- module When
9
- class BasicTypes::M17n
10
-
11
- Balinese = [self, [
12
- "locale:[=en:, ja=ja:, alias]",
13
- "names:[Balinese=]",
14
- "[BalineseLuniSolar=, バリ・サカ暦=]",
15
- "[Tenganan, テンガナン暦=]",
16
-
17
- [self,
18
- "names:[IntercalaryMonth=en:Intercalation, 閏月]",
19
- "[%s Suklapaksa=, %s 白分= ]",
20
- "[%s Krsnapaksa=, %s 黒分= ]",
21
- "[Mala %s Suklapaksa=, 閏%s 白分=]",
22
- "[Mala %s Krsnapaksa=, 閏%s 黒分=]"
23
- ],
24
-
25
- [self,
26
- "names:[IntercalaryDay=en:Intercalation, 閏日=ja:%%<閏>]",
27
- "[Double %s=, 欠= ]"
28
- ],
29
-
30
- [self,
31
- "names:[HinduMonth=, ヒンドゥ月=]",
32
- "[Kelima=, 5月=]",
33
- "[Kenem=, 6月=]",
34
- "[Kepitu=, 7月=]",
35
- "[Kewulu=, 8月=]",
36
- "[Kesanga=, 9月=]",
37
- "[Kedasa=, 10月=]",
38
- "[Jiyestha=, 11月=]",
39
- "[Sadha=, 12月=]",
40
- "[Kasa=, 1月=]",
41
- "[Karo=, 2月=]",
42
- "[Ketiga=, 3月=]",
43
- "[Kapat=, 4月=]"
44
- ],
45
-
46
- [self,
47
- "names:[TengananMonth=, テンガナン月=]",
48
- "[Kelima=, 5月=]",
49
- "[Kanem=, 6月=]",
50
- "[Kepitu=, 7月=]",
51
- "[Kolu=, 8月=]",
52
- "[Kesanga=, 9月=]",
53
- "[Kedasa=, 10月=]",
54
- "[Desta=, 11月=]",
55
- "[Sadda=, 12月=]",
56
- "[Kasa=, 1月=]",
57
- "[Karo=, 2月=]",
58
- "[Ketiga=, 3月=]",
59
- "[Kapat=, 4月=]",
60
- "[Kapat Sep=, 閏4月=]"
61
- ]
62
- ]]
63
- end
64
-
65
- module Coordinates
66
-
67
- # Balinese Residues
68
-
69
- #
70
- # ウク周期
71
- #
72
- class Wuku < Residue
73
-
74
- # Urip 7
75
- Urip7 = [ 5, 4, 3, 7, 8, 6, 9]
76
-
77
- # Urip 5
78
- Urip5 = [ 9, 7, 4, 8, 5]
79
-
80
- # 2日週
81
- Dwiwara = (0...35).to_a.map {|d| (Urip7[d % 7] + Urip5[d % 5]) % 2}
82
-
83
- # 10日週
84
- Dasawara = (0...35).to_a.map {|d| (Urip7[d % 7] + Urip5[d % 5]) % 10}
85
-
86
- # Watek
87
- Watek = (0...35).to_a.map {|d| Urip7[d % 7] + Urip5[d % 5] - 7 }
88
-
89
- # 2日週
90
- # @return [When::BasicTypes::M17n]
91
- def dwiwara
92
- When.CalendarNote('Balinese/Notes')['day']['Dwiwara'][Dwiwara[@remainder % 35]]
93
- end
94
-
95
- # 4日週
96
- # @return [When::BasicTypes::M17n]
97
- def tjaturwara
98
- index = (@remainder + 137) % 210
99
- When.CalendarNote('Balinese/Notes')['day']['Tjaturwara'][index >= 208 ? 2 : (index-1) % 4]
100
- end
101
-
102
- # 8日週
103
- # @return [When::BasicTypes::M17n]
104
- def astawara
105
- index = (@remainder + 137) % 210
106
- When.CalendarNote('Balinese/Notes')['day']['Astawara'][index >= 208 ? 6 : (index-1) % 8]
107
- end
108
-
109
- # 9日週
110
- # @return [When::BasicTypes::M17n]
111
- def sangawara
112
- index = @remainder - 3
113
- When.CalendarNote('Balinese/Notes')['day']['Sangawara'][index < 0 ? 0 : index % 9]
114
- end
115
-
116
- # 10日週
117
- # @return [When::BasicTypes::M17n]
118
- def dasawara
119
- When.CalendarNote('Balinese/Notes')['day']['Dasawara'][Dasawara[@remainder % 35]]
120
- end
121
-
122
- # Watek
123
- # @return [When::BasicTypes::M17n]
124
- def watek
125
- When.CalendarNote('Balinese/Notes')['day']['Watek'][Watek[@remainder % 35]]
126
- end
127
- end
128
- end
129
-
130
- class TM::CalendarEra
131
-
132
- #
133
- # バリのサカ暦
134
- #
135
- BalineseLuniSolar = [self, [
136
- "locale:[=en:, ja=ja:, alias]",
137
- "period:[BalineseLuniSolar=, バリ・サカ暦=]",
138
- ["[SE=, サカ暦=, alias:Balinese_Saka_Era]1887-07<13", '@CE', "1965-07<13^BalineseLuniSolar1965",
139
- "1971-07-04^BalineseLuniSolar1971",
140
- "1993-07-08^BalineseLuniSolar1993",
141
- "1999-06<10^BalineseLuniSolar2000",
142
- "2003-07<14^BalineseLuniSolar2003", '+Infinity']
143
- ]]
144
- end
145
-
146
- module CalendarTypes
147
-
148
- #
149
- # Balinese Luni-Solar Calendar
150
- #
151
- class BalineseLuniSolar < HinduLuniSolar
152
-
153
- # protected
154
-
155
- # 朔望日 -> 年・月・日
156
- #
157
- # @param [Numeric] tithi 朔望日(月の位相 / (CIRCLE/30))
158
- #
159
- # @return [Array<Numeric>] ( y, m, d )
160
- # [ y - 年(Integer) ]
161
- # [ m - 月(When::Coordinates::Pair) ]
162
- # [ d - 日(Integer) ]
163
- #
164
- def _tithi_to_coordinates(tithi)
165
- @tabular._encode(@tabular._number_to_coordinates(tithi.to_i))
166
- end
167
-
168
- # 日時要素の翻訳表の取得
169
- #
170
- # @overload _ids_(date)
171
- # @param [Array<Numeric>] date ( 年 )
172
- # @return [Array<When::Coordinates::Pair>] 1年の月の配置の翻訳表
173
- #
174
- # @overload _ids_(date)
175
- # @param [Array<Numeric>] date ( 年 月 )
176
- # @return [Array<When::Coordinates::Pair>] 1月の日の配置の翻訳表
177
- # @note 月は 0 始まりの通番
178
- #
179
- def _ids_(date)
180
- y, m = date
181
- m ? super : @tabular._ids(date)
182
- end
183
-
184
- private
185
-
186
- # オブジェクトの正規化
187
- #
188
- # @tabular = 19年7閏のパターンを与える tithi に対する Calendar
189
- # @formula[-1] = 位相の計算に用いる月の Ephemeris
190
- #
191
- def _normalize(args=[], options={})
192
-
193
- intercalary_month = When.Resource('_m:Balinese::IntercalaryMonth::*')
194
- intercalary_day = When.Resource('_m:Balinese::IntercalaryDay::*')
195
- month_index = When.Index('Balinese::HinduMonth', {:branch=>{ 0 => intercalary_month[0], # 白分
196
- +0.5 => intercalary_month[1], # 黒分
197
- +1 => intercalary_month[2], # 閏白分
198
- +1.5 => intercalary_month[3]}, # 閏黒分
199
- :shift=>+8})
200
-
201
- @origin_of_MSC = 0
202
-
203
- @tabular = CyclicTableBased.new({
204
- 'indices' => [month_index, When::Coordinates::DefaultDayIndex],
205
- 'rule_table' => @rule_table
206
- })
207
-
208
- @formula = [Ephemeris::MeanLunation.new(
209
- {
210
- 'day_epoch' => @day_epoch,
211
- 'longitude_shift' => '-1/12', # 雨水
212
- 'long' => 360.0 / 63 * @day_border.to_i,
213
- 'formula' => '2L',
214
- 'year_length' => '222075/608',
215
- 'lunation_length' => '945/32'
216
- })]
217
-
218
- @indices = [month_index, When.Index({:branch=>{-2=>intercalary_day[0]}})]
219
-
220
- @note = When.CalendarNote(@note || 'Balinese')
221
- super
222
- end
223
- end
224
-
225
- intercalary_pattern_1 = {# 17 18 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
226
- 'T' => {'Rule' =>[ 'N','N','D','N','N','S','N','N','D','N','S','N','N','D','N','N','S','N','S']},
227
- 'N' => {'Length' =>[15]*24, 'IDs' => '10,10<,11,11<,12,12<,1,1<,2,2<,3,3<,4,4<,5,5<,6,6<,7,7<,8,8<,9,9<'},
228
- 'D' => {'Length' =>[15]*26, 'IDs' => '10,10<,11,11<,11=,11>,12,12<,1,1<,2,2<,3,3<,4,4<,5,5<,6,6<,7,7<,8,8<,9,9<'},
229
- 'S' => {'Length' =>[15]*26, 'IDs' => '10,10<,11,11<,12,12<,12=,12>,1,1<,2,2<,3,3<,4,4<,5,5<,6,6<,7,7<,8,8<,9,9<'}
230
- }
231
-
232
- intercalary_pattern_2 = {# 17 18 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
233
- 'T' => {'Rule' =>[ 'N','S','N','N','D','N','3','N','N','1','N','N','D','N','N','K','N','2','N']},
234
- 'N' => {'Length' =>[15]*24, 'IDs' => '10,10<,11,11<,12,12<,1,1<,2,2<,3,3<,4,4<,5,5<,6,6<,7,7<,8,8<,9,9<'},
235
- 'K' => {'Length' =>[15]*26, 'IDs' => '10,10<,10=,10>,11,11<,12,12<,1,1<,2,2<,3,3<,4,4<,5,5<,6,6<,7,7<,8,8<,9,9<'},
236
- 'D' => {'Length' =>[15]*26, 'IDs' => '10,10<,11,11<,11=,11>,12,12<,1,1<,2,2<,3,3<,4,4<,5,5<,6,6<,7,7<,8,8<,9,9<'},
237
- 'S' => {'Length' =>[15]*26, 'IDs' => '10,10<,11,11<,12,12<,12=,12>,1,1<,2,2<,3,3<,4,4<,5,5<,6,6<,7,7<,8,8<,9,9<'},
238
- '1' => {'Length' =>[15]*26, 'IDs' => '10,10<,11,11<,12,12<,1,1<,1=,1>,2,2<,3,3<,4,4<,5,5<,6,6<,7,7<,8,8<,9,9<'},
239
- '2' => {'Length' =>[15]*26, 'IDs' => '10,10<,11,11<,12,12<,1,1<,2,2<,2=,2>,3,3<,4,4<,5,5<,6,6<,7,7<,8,8<,9,9<'},
240
- '3' => {'Length' =>[15]*26, 'IDs' => '10,10<,11,11<,12,12<,1,1<,2,2<,3,3<,3=,3>,4,4<,5,5<,6,6<,7,7<,8,8<,9,9<'}
241
- }
242
-
243
- BalineseLuniSolar1965 = [BalineseLuniSolar, {
244
- 'day_epoch' => 1749594, # CE78-02-16
245
- 'day_border' => 0, # Friday
246
- 'rule_table' => intercalary_pattern_1
247
- }]
248
-
249
- BalineseLuniSolar1971 = [BalineseLuniSolar, {
250
- 'day_epoch' => 1749594, # CE78-02-16
251
- 'day_border' => -23, # Wednesday
252
- 'rule_table' => intercalary_pattern_1
253
- }]
254
-
255
- BalineseLuniSolar1993 = [BalineseLuniSolar, {
256
- 'day_epoch' => 1749594, # CE78-02-16
257
- 'day_border' => -23, # Wednesday
258
- 'rule_table' => intercalary_pattern_2
259
- }]
260
-
261
- BalineseLuniSolar2000 = [BalineseLuniSolar, {
262
- 'day_epoch' => 1749593, # CE78-02-15
263
- 'day_border' => -23, # Tuesday
264
- 'rule_table' => intercalary_pattern_2
265
- }]
266
-
267
- BalineseLuniSolar2003 = [BalineseLuniSolar, {
268
- 'day_epoch' => 1749593, # CE78-02-15
269
- 'day_border' => -23, # Tuesday
270
- 'rule_table' => intercalary_pattern_1
271
- }]
272
-
273
- #
274
- # Tenganan Calendar
275
- #
276
- Tenganan = [CyclicTableBased, {
277
- 'label' => 'Balinese::Tenganan',
278
- 'origin_of_LSC' => 1095 * 1573 - 381,
279
- 'origin_of_MSC' => 1,
280
- 'note' => [['_m:Calendar::Month'],
281
- ['_n:Balinese/Notes::day::Triwara', '_n:Balinese/Notes::day::Pantjawara']],
282
- 'indices' => [
283
- When.Index('Balinese::TengananMonth'),
284
- When::Coordinates::DefaultDayIndex
285
- ],
286
- 'rule_table' => {
287
- 'T' => {'Rule' =>[360, 383, 352]},
288
- 360 => {'Length'=>[30] * 12},
289
- 383 => {'Length'=>[30] * 6 + [26] * 2 + [30] * 4 + [27]},
290
- 352 => {'Length'=>[30] * 6 + [28] * 2 + [30] * 4 }
291
- }
292
- }]
293
- end
294
-
295
- #
296
- # バリ暦の暦注
297
- #
298
- class CalendarNote::Balinese < CalendarNote
299
-
300
- Notes = [When::BasicTypes::M17n, [
301
- "locale:[=en:, ja=ja:, alias]",
302
- "names:[Balinese]",
303
-
304
- # 年の暦注 ----------------------------
305
- [When::BasicTypes::M17n,
306
- "names:[year]"
307
- ],
308
-
309
- # 月の暦注 ----------------------------
310
- [When::BasicTypes::M17n,
311
- "names:[month]",
312
- [When::BasicTypes::M17n,
313
- "names:[Month]"
314
- ]
315
- ],
316
-
317
- # 日の暦注 ----------------------------
318
- [When::BasicTypes::M17n,
319
- "names:[day]",
320
-
321
- [When::BasicTypes::M17n,
322
- "names:[Hari=, 日名=]",
323
-
324
- [When::BasicTypes::M17n,
325
- "names:[Suklapaksa=, 白分=]",
326
- "[Lidi= ]",
327
- "[Kuda= ]",
328
- "[Kidang= ]",
329
- "[Macan= ]",
330
- "[Kucing= ]",
331
- "[Sampi= ]",
332
- "[Kerbau= ]",
333
- "[Tikus= ]",
334
- "[Debu= ]",
335
- "[Anjing= ]",
336
- "[Naga= ]",
337
- "[Kambing=]",
338
- "[Mayang= ]",
339
- "[Gajah= ]",
340
- "[Singa= ]"
341
- ],
342
-
343
- [When::BasicTypes::M17n,
344
- "names:[Krsnapaksa=, 黒分=]",
345
- "[Ikan= ]",
346
- "[Lilin= ]",
347
- "[Ulung= ]",
348
- "[Kelapa= ]",
349
- "[Banteng=]",
350
- "[Hantu= ]",
351
- "[Areng= ]",
352
- "[Udang= ]",
353
- "[Semudra=]",
354
- "[Pare= ]",
355
- "[Madu= ]",
356
- "[Kala= ]",
357
- "[Ular= ]",
358
- "[Padi= ]",
359
- "[Ulat= ]"
360
- ]
361
- ],
362
-
363
- [When::BasicTypes::M17n,
364
- "names:[Dwiwara=, 2日週=]",
365
- "[Menga=]", # 0
366
- "[Pepet=]" # 1
367
- ],
368
-
369
- [When::Coordinates::Residue,
370
- "label:[Triwara=, 3日週=]", "divisor:3", "day:2",
371
- [When::Coordinates::Residue, "label:[Pasah= ]", "remainder: 0"],
372
- [When::Coordinates::Residue, "label:[Gelang Tegeh=]", "remainder: 1"],
373
- [When::Coordinates::Residue, "label:[Kajeng= ]", "remainder: 2"]
374
- ],
375
-
376
- [When::BasicTypes::M17n,
377
- "names:[Tjaturwara=, 4日週=]",
378
- "[Sri= ]",
379
- "[Laba= ]",
380
- "[Jaya= ]",
381
- "[Menala=]"
382
- ],
383
-
384
- [When::Coordinates::Residue,
385
- "label:[Pantjawara=, 5日週=]", "divisor:5", "day:1",
386
- [When::Coordinates::Residue, "label:[Paing= ]", "remainder: 0"],
387
- [When::Coordinates::Residue, "label:[Pon= ]", "remainder: 1"],
388
- [When::Coordinates::Residue, "label:[Wage= ]", "remainder: 2"],
389
- [When::Coordinates::Residue, "label:[Kliwon=]", "remainder: 3"],
390
- [When::Coordinates::Residue, "label:[Umanis=]", "remainder: 4"]
391
- ],
392
-
393
- [When::Coordinates::Residue,
394
- "label:[Perinkelan=, 六曜=]", "divisor:6", "day:2",
395
- [When::Coordinates::Residue, "label:[Tungleh=]", "remainder: 0"],
396
- [When::Coordinates::Residue, "label:[Aryang= ]", "remainder: 1"],
397
- [When::Coordinates::Residue, "label:[Urukung=]", "remainder: 2"],
398
- [When::Coordinates::Residue, "label:[Paniron=]", "remainder: 3"],
399
- [When::Coordinates::Residue, "label:[Was= ]", "remainder: 4"],
400
- [When::Coordinates::Residue, "label:[Maulu= ]", "remainder: 5"]
401
- ],
402
-
403
- [When::Coordinates::Residue,
404
- "label:[Sadwara=, 6日週=]", "divisor:6", "day:2",
405
- [When::Coordinates::Residue, "label:[Mina= ]", "remainder: 0"],
406
- [When::Coordinates::Residue, "label:[Taru= ]", "remainder: 1"],
407
- [When::Coordinates::Residue, "label:[Sato= ]", "remainder: 2"],
408
- [When::Coordinates::Residue, "label:[Patra=]", "remainder: 3"],
409
- [When::Coordinates::Residue, "label:[Wong= ]", "remainder: 4"],
410
- [When::Coordinates::Residue, "label:[Paksi=]", "remainder: 5"]
411
- ],
412
-
413
- [When::Coordinates::Residue,
414
- "label:[Septawara=, 7日週=]", "divisor:7", "day:6",
415
- [When::Coordinates::Residue, "label:[Reditē= ]", "remainder: 0"],
416
- [When::Coordinates::Residue, "label:[Coma= ]", "remainder: 1"],
417
- [When::Coordinates::Residue, "label:[Anggara= ]", "remainder: 2"],
418
- [When::Coordinates::Residue, "label:[Buda= ]", "remainder: 3"],
419
- [When::Coordinates::Residue, "label:[Wraspati= ]", "remainder: 4"],
420
- [When::Coordinates::Residue, "label:[Sukra= ]", "remainder: 5"],
421
- [When::Coordinates::Residue, "label:[Saniscara=]", "remainder: 6"]
422
- ],
423
-
424
- [When::BasicTypes::M17n,
425
- "names:[Astawara=, 8日週=]",
426
- "[Sri= ]",
427
- "[Indra= ]",
428
- "[Guru= ]",
429
- "[Yama= ]",
430
- "[Ludra= ]",
431
- "[Brahma=]",
432
- "[Kala= ]",
433
- "[Uma= ]"
434
- ],
435
-
436
- [When::BasicTypes::M17n,
437
- "names:[Sangawara=, 9日週=]",
438
- "[Dangu= ]",
439
- "[Jangur= ]",
440
- "[Gigis= ]",
441
- "[Nohan= ]",
442
- "[Ogan= ]",
443
- "[Erangan=]",
444
- "[Urungan=]",
445
- "[Tulus= ]",
446
- "[Dadi= ]"
447
- ],
448
-
449
- [When::BasicTypes::M17n,
450
- "names:[Dasawara=, 10日週=]",
451
- "[Pandita]", # 0
452
- "[Pati ]", # 1
453
- "[Suka ]", # 2
454
- "[Duka ]", # 3
455
- "[Sri ]", # 4
456
- "[Manuh ]", # 5
457
- "[Manusa ]", # 6
458
- "[Raja ]", # 7
459
- "[Dewa ]", # 8
460
- "[Raksasa]" # 9
461
- ],
462
-
463
- [When::Coordinates::Residue,
464
- "label:[Ingkel=]", "divisor:42", "day:20",
465
- [When::Coordinates::Residue, "label:[Wong= ]", "remainder: 0"],
466
- [When::Coordinates::Residue, "label:[Sato= ]", "remainder: 7"],
467
- [When::Coordinates::Residue, "label:[Mina= ]", "remainder: 14"],
468
- [When::Coordinates::Residue, "label:[Manuk=]", "remainder: 21"],
469
- [When::Coordinates::Residue, "label:[Taru= ]", "remainder: 28"],
470
- [When::Coordinates::Residue, "label:[Buku= ]", "remainder: 35"]
471
- ],
472
-
473
- [When::BasicTypes::M17n,
474
- "names:[Watek=]",
475
- "[Watu-Lembu= ]", # 7
476
- "[Buta-Lintah= ]", # 8
477
- "[Suku-Uler= ]", # 9
478
- "[Wong-Gajah= ]", # 10
479
- "[Gajah-Lembu= ]", # 11
480
- "[Watu-Lintah= ]", # 12
481
- "[Buta-Uler= ]", # 13
482
- "[Suku-Gajah= ]", # 14
483
- "[Wong-Lembu= ]", # 15
484
- "[Gajah-Lintah=]", # 16
485
- "[Watu-Uler= ]", # 17
486
- "[Buta-Gajah= ]" # 18
487
- ],
488
-
489
- [When::Coordinates::Residue,
490
- "label:[Lintang=]", "divisor:35", "day:6",
491
- [When::Coordinates::Residue, "label:[Gajah= ]", "remainder: 0"],
492
- [When::Coordinates::Residue, "label:[Kiriman= ]", "remainder: 1"],
493
- [When::Coordinates::Residue, "label:[Jong Sarat= ]", "remainder: 2"],
494
- [When::Coordinates::Residue, "label:[Tiwa-Tiwa= ]", "remainder: 3"],
495
- [When::Coordinates::Residue, "label:[Sangkatikel= ]", "remainder: 4"],
496
- [When::Coordinates::Residue, "label:[Bubu bolong= ]", "remainder: 5"],
497
- [When::Coordinates::Residue, "label:[Sungenge= ]", "remainder: 6"],
498
- [When::Coordinates::Residue, "label:[Uluku= ]", "remainder: 7"],
499
- [When::Coordinates::Residue, "label:[Pedati= ]", "remainder: 8"],
500
- [When::Coordinates::Residue, "label:[Kuda= ]", "remainder: 9"],
501
- [When::Coordinates::Residue, "label:[Gajah-Mina= ]", "remainder: 10"],
502
- [When::Coordinates::Residue, "label:[Bade= ]", "remainder: 11"],
503
- [When::Coordinates::Residue, "label:[Maglut= ]", "remainder: 12"],
504
- [When::Coordinates::Residue, "label:[Paglangan= ]", "remainder: 13"],
505
- [When::Coordinates::Residue, "label:[Kala Sungsang= ]", "remainder: 14"],
506
- [When::Coordinates::Residue, "label:[Kukus= ]", "remainder: 15"],
507
- [When::Coordinates::Residue, "label:[Asu= ]", "remainder: 16"],
508
- [When::Coordinates::Residue, "label:[Kartika= ]", "remainder: 17"],
509
- [When::Coordinates::Residue, "label:[Naga= ]", "remainder: 18"],
510
- [When::Coordinates::Residue, "label:[Banyakangrem= ]", "remainder: 19"],
511
- [When::Coordinates::Residue, "label:[Ru= ]", "remainder: 20"],
512
- [When::Coordinates::Residue, "label:[Patrem= ]", "remainder: 21"],
513
- [When::Coordinates::Residue, "label:[Lembu= ]", "remainder: 22"],
514
- [When::Coordinates::Residue, "label:[Dpat= ]", "remainder: 23"],
515
- [When::Coordinates::Residue, "label:[Tangis= ]", "remainder: 24"],
516
- [When::Coordinates::Residue, "label:[Salar Ukur= ]", "remainder: 25"],
517
- [When::Coordinates::Residue, "label:[Prahu Pgat= ]", "remainder: 26"],
518
- [When::Coordinates::Residue, "label:[Pwuhu atarung= ]", "remainder: 27"],
519
- [When::Coordinates::Residue, "label:[Lawean= ]", "remainder: 28"],
520
- [When::Coordinates::Residue, "label:[Kelapa= ]", "remainder: 29"],
521
- [When::Coordinates::Residue, "label:[Yuyu= ]", "remainder: 30"],
522
- [When::Coordinates::Residue, "label:[Lumbung= ]", "remainder: 31"],
523
- [When::Coordinates::Residue, "label:[Kumba= ]", "remainder: 32"],
524
- [When::Coordinates::Residue, "label:[Udang= ]", "remainder: 33"],
525
- [When::Coordinates::Residue, "label:[Bgoong= ]", "remainder: 34"]
526
- ],
527
-
528
- [When::Coordinates::Wuku,
529
- "label:[Wuku=]", "divisor:210", "day:146",
530
- [When::Coordinates::Wuku, "label:[Sinta= ]", "remainder: 0"],
531
- [When::Coordinates::Wuku, "label:[Landep= ]", "remainder: 7"],
532
- [When::Coordinates::Wuku, "label:[Ukir= ]", "remainder: 14"],
533
- [When::Coordinates::Wuku, "label:[Kurantir= ]", "remainder: 21"],
534
- [When::Coordinates::Wuku, "label:[Tulu= ]", "remainder: 28"],
535
- [When::Coordinates::Wuku, "label:[Gumbreg= ]", "remainder: 35"],
536
- [When::Coordinates::Wuku, "label:[Wariga= ]", "remainder: 42"],
537
- [When::Coordinates::Wuku, "label:[Warigadian= ]", "remainder: 49"],
538
- [When::Coordinates::Wuku, "label:[Julungwangi= ]", "remainder: 56"],
539
- [When::Coordinates::Wuku, "label:[Sungsang= ]", "remainder: 63"],
540
- [When::Coordinates::Wuku, "label:[Dunggulan= ]", "remainder: 70"],
541
- [When::Coordinates::Wuku, "label:[Kuningan= ]", "remainder: 77"],
542
- [When::Coordinates::Wuku, "label:[Langkir= ]", "remainder: 84"],
543
- [When::Coordinates::Wuku, "label:[Medangsiya= ]", "remainder: 91"],
544
- [When::Coordinates::Wuku, "label:[Pujut= ]", "remainder: 98"],
545
- [When::Coordinates::Wuku, "label:[Pahang= ]", "remainder:105"],
546
- [When::Coordinates::Wuku, "label:[Krulut= ]", "remainder:112"],
547
- [When::Coordinates::Wuku, "label:[Merakih= ]", "remainder:119"],
548
- [When::Coordinates::Wuku, "label:[Tambir= ]", "remainder:126"],
549
- [When::Coordinates::Wuku, "label:[Medangkungan=]", "remainder:133"],
550
- [When::Coordinates::Wuku, "label:[Matal= ]", "remainder:140"],
551
- [When::Coordinates::Wuku, "label:[Uye= ]", "remainder:147"],
552
- [When::Coordinates::Wuku, "label:[Menail= ]", "remainder:154"],
553
- [When::Coordinates::Wuku, "label:[Prangbakat= ]", "remainder:161"],
554
- [When::Coordinates::Wuku, "label:[Bala= ]", "remainder:168"],
555
- [When::Coordinates::Wuku, "label:[Ugu= ]", "remainder:175"],
556
- [When::Coordinates::Wuku, "label:[Wayang= ]", "remainder:182"],
557
- [When::Coordinates::Wuku, "label:[Kelawu= ]", "remainder:189"],
558
- [When::Coordinates::Wuku, "label:[Dukut= ]", "remainder:196"],
559
- [When::Coordinates::Wuku, "label:[Watugunung= ]", "remainder:203"]
560
- ]
561
- ]
562
- ]]
563
-
564
- #
565
- # When::Coordinates::Residue へ処理を委譲する暦注
566
- #
567
- # @private
568
- When.CalendarNote('Balinese/Notes')['day::*'].each do |cood|
569
- case cood
570
- when Coordinates::Residue
571
- module_eval %Q{
572
- def #{cood.label.to_s.downcase}(date, parameter=nil)
573
- When.CalendarNote('Balinese/Notes')['day']['#{cood.label.to_s}'] % date
574
- end
575
- }
576
- when BasicTypes::M17n
577
- module_eval %Q{
578
- def #{cood.to_s.downcase}(date, parameter=nil)
579
- (When.CalendarNote('Balinese/Notes')['day']['Wuku'] % date).#{cood.to_s.downcase}
580
- end
581
- }
582
- end
583
- end
584
-
585
- #
586
- # 任意の暦をバリ暦日に変換
587
- #
588
- # @private
589
- def _to_date_for_note(date)
590
- return date if date.frame.kind_of?(When::CalendarTypes::BalineseLuniSolar)
591
- (date ^ When.era(:period=>'BalineseLuniSolar')).each do |list|
592
- return list[0] if list[0]
593
- end
594
- nil
595
- end
596
-
597
- # バリ暦日の「日名」
598
- #
599
- # @param [When::TM::TemporalPosition] date 「日名」を求める日付
600
- # @param [nil] parameter 未使用
601
- #
602
- # @return [When::BasicTypes::M17n] 「日名」(欠日の場合は2日分を'/'で連結)
603
- #
604
- def hari(date, parameter=nil)
605
- y, m, d = _to_date_for_note(date).cal_date
606
- thiti = [d * 1 - 1]
607
- thiti[0] += 15 unless [0,1,nil].include?(m * 0)
608
- thiti << (thiti[0] + 1) % 30 if d * 0 == -2
609
- table = When.CalendarNote('Balinese/Notes')['day']['Hari']
610
- thiti.map {|t| table[t / 15][t % 15]}.join('/')
611
- end
612
-
613
- private
614
-
615
- # オブジェクトの正規化
616
- def _normalize(args=[], options={})
617
- @event = 'hari'
618
- @prime ||= [%w(Month), %w(Pantjawara Perinkelan Septawara Wuku)]
619
- super
620
- end
621
- end
622
- end
1
+ # -*- coding: utf-8 -*-
2
+ =begin
3
+ Copyright (C) 2011-2015 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
+ module When
9
+ class BasicTypes::M17n
10
+
11
+ Balinese = [self, [
12
+ "locale:[=en:, ja=ja:, alias]",
13
+ "names:[Balinese=]",
14
+ "[BalineseLuniSolar=, バリ・サカ暦=, zh:峇里陰陽曆=]",
15
+ "[Tenganan, テンガナン暦=]",
16
+
17
+ [self,
18
+ "names:[HalfMonth=, 半月=, zh:半月=, *IntercalaryMonth=en:Intercalation]",
19
+ "[%s Suklapaksa=, %s 白分= ]",
20
+ "[%s Krsnapaksa=, %s 黒分= ]",
21
+ "[Mala %s Suklapaksa=, 閏%s 白分=]",
22
+ "[Mala %s Krsnapaksa=, 閏%s 黒分=]"
23
+ ],
24
+
25
+ [self,
26
+ "names:[IntercalaryDay=en:Intercalation, 閏日=ja:%%<閏>]",
27
+ "[Double %s=, 欠= ]"
28
+ ],
29
+
30
+ [self,
31
+ "names:[HinduMonth=, ヒンドゥ月=, zh:印度月=]",
32
+ "[Kelima=, 5月=]",
33
+ "[Kenem=, 6月=]",
34
+ "[Kepitu=, 7月=]",
35
+ "[Kewulu=, 8月=]",
36
+ "[Kesanga=, 9月=]",
37
+ "[Kedasa=, 10月=]",
38
+ "[Jiyestha=, 11月=]",
39
+ "[Sadha=, 12月=]",
40
+ "[Kasa=, 1月=]",
41
+ "[Karo=, 2月=]",
42
+ "[Ketiga=, 3月=]",
43
+ "[Kapat=, 4月=]"
44
+ ],
45
+
46
+ [self,
47
+ "names:[TengananMonth=, テンガナン月=, zh:印度月=]",
48
+ "[Kelima=, 5月=]",
49
+ "[Kanem=, 6月=]",
50
+ "[Kepitu=, 7月=]",
51
+ "[Kolu=, 8月=]",
52
+ "[Kesanga=, 9月=]",
53
+ "[Kedasa=, 10月=]",
54
+ "[Desta=, 11月=]",
55
+ "[Sadda=, 12月=]",
56
+ "[Kasa=, 1月=]",
57
+ "[Karo=, 2月=]",
58
+ "[Ketiga=, 3月=]",
59
+ "[Kapat=, 4月=]",
60
+ "[Kapat Sep=, 閏4月=]"
61
+ ]
62
+ ]]
63
+ end
64
+
65
+ module Coordinates
66
+
67
+ # Balinese Residues
68
+
69
+ #
70
+ # ウク周期
71
+ #
72
+ class Wuku < Residue
73
+
74
+ # Urip 7
75
+ Urip7 = [ 5, 4, 3, 7, 8, 6, 9]
76
+
77
+ # Urip 5
78
+ Urip5 = [ 9, 7, 4, 8, 5]
79
+
80
+ # 2日週
81
+ Dwiwara = (0...35).to_a.map {|d| (Urip7[d % 7] + Urip5[d % 5]) % 2}
82
+
83
+ # 10日週
84
+ Dasawara = (0...35).to_a.map {|d| (Urip7[d % 7] + Urip5[d % 5]) % 10}
85
+
86
+ # Watek
87
+ Watek = (0...35).to_a.map {|d| Urip7[d % 7] + Urip5[d % 5] - 7 }
88
+
89
+ # 2日週
90
+ # @return [When::BasicTypes::M17n]
91
+ def dwiwara
92
+ When.CalendarNote('Balinese/Notes')['day']['Dwiwara'][Dwiwara[@remainder % 35]]
93
+ end
94
+
95
+ # 4日週
96
+ # @return [When::BasicTypes::M17n]
97
+ def tjaturwara
98
+ index = (@remainder + 137) % 210
99
+ When.CalendarNote('Balinese/Notes')['day']['Tjaturwara'][index >= 208 ? 2 : (index-1) % 4]
100
+ end
101
+
102
+ # 8日週
103
+ # @return [When::BasicTypes::M17n]
104
+ def astawara
105
+ index = (@remainder + 137) % 210
106
+ When.CalendarNote('Balinese/Notes')['day']['Astawara'][index >= 208 ? 6 : (index-1) % 8]
107
+ end
108
+
109
+ # 9日週
110
+ # @return [When::BasicTypes::M17n]
111
+ def sangawara
112
+ index = @remainder - 3
113
+ When.CalendarNote('Balinese/Notes')['day']['Sangawara'][index < 0 ? 0 : index % 9]
114
+ end
115
+
116
+ # 10日週
117
+ # @return [When::BasicTypes::M17n]
118
+ def dasawara
119
+ When.CalendarNote('Balinese/Notes')['day']['Dasawara'][Dasawara[@remainder % 35]]
120
+ end
121
+
122
+ # Watek
123
+ # @return [When::BasicTypes::M17n]
124
+ def watek
125
+ When.CalendarNote('Balinese/Notes')['day']['Watek'][Watek[@remainder % 35]]
126
+ end
127
+ end
128
+ end
129
+
130
+ class TM::CalendarEra
131
+
132
+ #
133
+ # バリのサカ暦
134
+ #
135
+ BalineseLuniSolar = [self, [
136
+ "locale:[=en:, ja=ja:, zh=zh:, alias]",
137
+ "period:[BalineseLuniSolar=, バリ・サカ暦=, 峇里陰陽曆=]",
138
+ ["[SE=, サカ暦=, 塞種紀元=, alias:Balinese_Saka_Era]1887-07<13", '@CE', "1965-07<13^BalineseLuniSolar1965",
139
+ "1971-07-04^BalineseLuniSolar1971",
140
+ "1993-07-08^BalineseLuniSolar1993",
141
+ "1999-06<10^BalineseLuniSolar2000",
142
+ "2003-07<14^BalineseLuniSolar2003", '+Infinity']
143
+ ]]
144
+ end
145
+
146
+ module CalendarTypes
147
+
148
+ #
149
+ # Balinese Luni-Solar Calendar
150
+ #
151
+ class BalineseLuniSolar < HinduLuniSolar
152
+
153
+ # protected
154
+
155
+ # 朔望日 -> 年・月・日
156
+ #
157
+ # @param [Numeric] tithi 朔望日(月の位相 / (CIRCLE/30))
158
+ #
159
+ # @return [Array<Numeric>] ( y, m, d )
160
+ # [ y - 年(Integer) ]
161
+ # [ m - 月(When::Coordinates::Pair) ]
162
+ # [ d - 日(Integer) ]
163
+ #
164
+ def _tithi_to_coordinates(tithi)
165
+ @tabular._encode(@tabular._number_to_coordinates(tithi.to_i))
166
+ end
167
+
168
+ # 日時要素の翻訳表の取得
169
+ #
170
+ # @overload _ids_(date)
171
+ # @param [Array<Numeric>] date ( 年 )
172
+ # @return [Array<When::Coordinates::Pair>] 1年の月の配置の翻訳表
173
+ #
174
+ # @overload _ids_(date)
175
+ # @param [Array<Numeric>] date ( 年 月 )
176
+ # @return [Array<When::Coordinates::Pair>] 1月の日の配置の翻訳表
177
+ # @note 月は 0 始まりの通番
178
+ #
179
+ def _ids_(date)
180
+ y, m = date
181
+ m ? super : @tabular._ids(date)
182
+ end
183
+
184
+ private
185
+
186
+ # オブジェクトの正規化
187
+ #
188
+ # @tabular = 19年7閏のパターンを与える tithi に対する Calendar
189
+ # @formula[-1] = 位相の計算に用いる月の Ephemeris
190
+ #
191
+ def _normalize(args=[], options={})
192
+
193
+ intercalary_month = When.Resource('_m:Balinese::IntercalaryMonth::*')
194
+ intercalary_day = When.Resource('_m:Balinese::IntercalaryDay::*')
195
+ month_index = When.Index('Balinese::HinduMonth', {:branch=>{ 0 => intercalary_month[0], # 白分
196
+ +0.5 => intercalary_month[1], # 黒分
197
+ +1 => intercalary_month[2], # 閏白分
198
+ +1.5 => intercalary_month[3]}, # 閏黒分
199
+ :shift=>+8})
200
+
201
+ @origin_of_MSC = 0
202
+
203
+ @tabular = CyclicTableBased.new({
204
+ 'indices' => [month_index, When::Coordinates::DefaultDayIndex],
205
+ 'rule_table' => @rule_table
206
+ })
207
+
208
+ @formula = [Ephemeris::MeanLunation.new(
209
+ {
210
+ 'day_epoch' => @day_epoch,
211
+ 'longitude_shift' => '-1/12', # 雨水
212
+ 'long' => 360.0 / 63 * @day_border.to_i,
213
+ 'formula' => '2L',
214
+ 'year_length' => '222075/608',
215
+ 'lunation_length' => '945/32'
216
+ })]
217
+
218
+ @indices = [month_index, When.Index({:branch=>{-2=>intercalary_day[0]}})]
219
+
220
+ @note = When.CalendarNote(@note || 'Balinese')
221
+ super
222
+ end
223
+ end
224
+
225
+ intercalary_pattern_1 = {# 17 18 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
226
+ 'T' => {'Rule' =>[ 'N','N','D','N','N','S','N','N','D','N','S','N','N','D','N','N','S','N','S']},
227
+ 'N' => {'Length' =>[15]*24, 'IDs' => '10,10<,11,11<,12,12<,1,1<,2,2<,3,3<,4,4<,5,5<,6,6<,7,7<,8,8<,9,9<'},
228
+ 'D' => {'Length' =>[15]*26, 'IDs' => '10,10<,11,11<,11=,11>,12,12<,1,1<,2,2<,3,3<,4,4<,5,5<,6,6<,7,7<,8,8<,9,9<'},
229
+ 'S' => {'Length' =>[15]*26, 'IDs' => '10,10<,11,11<,12,12<,12=,12>,1,1<,2,2<,3,3<,4,4<,5,5<,6,6<,7,7<,8,8<,9,9<'}
230
+ }
231
+
232
+ intercalary_pattern_2 = {# 17 18 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
233
+ 'T' => {'Rule' =>[ 'N','S','N','N','D','N','3','N','N','1','N','N','D','N','N','K','N','2','N']},
234
+ 'N' => {'Length' =>[15]*24, 'IDs' => '10,10<,11,11<,12,12<,1,1<,2,2<,3,3<,4,4<,5,5<,6,6<,7,7<,8,8<,9,9<'},
235
+ 'K' => {'Length' =>[15]*26, 'IDs' => '10,10<,10=,10>,11,11<,12,12<,1,1<,2,2<,3,3<,4,4<,5,5<,6,6<,7,7<,8,8<,9,9<'},
236
+ 'D' => {'Length' =>[15]*26, 'IDs' => '10,10<,11,11<,11=,11>,12,12<,1,1<,2,2<,3,3<,4,4<,5,5<,6,6<,7,7<,8,8<,9,9<'},
237
+ 'S' => {'Length' =>[15]*26, 'IDs' => '10,10<,11,11<,12,12<,12=,12>,1,1<,2,2<,3,3<,4,4<,5,5<,6,6<,7,7<,8,8<,9,9<'},
238
+ '1' => {'Length' =>[15]*26, 'IDs' => '10,10<,11,11<,12,12<,1,1<,1=,1>,2,2<,3,3<,4,4<,5,5<,6,6<,7,7<,8,8<,9,9<'},
239
+ '2' => {'Length' =>[15]*26, 'IDs' => '10,10<,11,11<,12,12<,1,1<,2,2<,2=,2>,3,3<,4,4<,5,5<,6,6<,7,7<,8,8<,9,9<'},
240
+ '3' => {'Length' =>[15]*26, 'IDs' => '10,10<,11,11<,12,12<,1,1<,2,2<,3,3<,3=,3>,4,4<,5,5<,6,6<,7,7<,8,8<,9,9<'}
241
+ }
242
+
243
+ BalineseLuniSolar1965 = [BalineseLuniSolar, {
244
+ 'day_epoch' => 1749594, # CE78-02-16
245
+ 'day_border' => 0, # Friday
246
+ 'rule_table' => intercalary_pattern_1
247
+ }]
248
+
249
+ BalineseLuniSolar1971 = [BalineseLuniSolar, {
250
+ 'day_epoch' => 1749594, # CE78-02-16
251
+ 'day_border' => -23, # Wednesday
252
+ 'rule_table' => intercalary_pattern_1
253
+ }]
254
+
255
+ BalineseLuniSolar1993 = [BalineseLuniSolar, {
256
+ 'day_epoch' => 1749594, # CE78-02-16
257
+ 'day_border' => -23, # Wednesday
258
+ 'rule_table' => intercalary_pattern_2
259
+ }]
260
+
261
+ BalineseLuniSolar2000 = [BalineseLuniSolar, {
262
+ 'day_epoch' => 1749593, # CE78-02-15
263
+ 'day_border' => -23, # Tuesday
264
+ 'rule_table' => intercalary_pattern_2
265
+ }]
266
+
267
+ BalineseLuniSolar2003 = [BalineseLuniSolar, {
268
+ 'day_epoch' => 1749593, # CE78-02-15
269
+ 'day_border' => -23, # Tuesday
270
+ 'rule_table' => intercalary_pattern_1
271
+ }]
272
+
273
+ #
274
+ # Tenganan Calendar
275
+ #
276
+ Tenganan = [CyclicTableBased, {
277
+ 'label' => 'Balinese::Tenganan',
278
+ 'origin_of_LSC' => 1095 * 1573 - 381,
279
+ 'origin_of_MSC' => 1,
280
+ 'note' => [['_m:Calendar::Month'],
281
+ ['_n:Balinese/Notes::day::Triwara', '_n:Balinese/Notes::day::Pantjawara']],
282
+ 'indices' => [
283
+ When.Index('Balinese::TengananMonth'),
284
+ When::Coordinates::DefaultDayIndex
285
+ ],
286
+ 'rule_table' => {
287
+ 'T' => {'Rule' =>[360, 383, 352]},
288
+ 360 => {'Length'=>[30] * 12},
289
+ 383 => {'Length'=>[30] * 6 + [26] * 2 + [30] * 4 + [27]},
290
+ 352 => {'Length'=>[30] * 6 + [28] * 2 + [30] * 4 }
291
+ }
292
+ }]
293
+ end
294
+
295
+ #
296
+ # バリ暦の暦注
297
+ #
298
+ class CalendarNote::Balinese < CalendarNote
299
+
300
+ Notes = [When::BasicTypes::M17n, [
301
+ "locale:[=en:, ja=ja:, alias]",
302
+ "names:[Balinese, バリ暦注=]",
303
+
304
+ # 年の暦注 ----------------------------
305
+ [When::BasicTypes::M17n,
306
+ "names:[note for year=, 年の暦注=, *year]"
307
+ ],
308
+
309
+ # 月の暦注 ----------------------------
310
+ [When::BasicTypes::M17n,
311
+ "names:[note for month=, 月の暦注=, *month]",
312
+ [When::BasicTypes::M17n,
313
+ "names:[month name=en:Month, 月の名前=ja:%%<月_(暦)>, zh:該月的名稱=, *alias:Month=]"
314
+ ]
315
+ ],
316
+
317
+ # 日の暦注 ----------------------------
318
+ [When::BasicTypes::M17n,
319
+ "names:[note for day=, 日の暦注=, *day]",
320
+
321
+ [When::BasicTypes::M17n,
322
+ "names:[Hari=, 日名=]",
323
+
324
+ [When::BasicTypes::M17n,
325
+ "names:[Suklapaksa=, 白分=, zh:上弦月=]",
326
+ "[Lidi= ]",
327
+ "[Kuda= ]",
328
+ "[Kidang= ]",
329
+ "[Macan= ]",
330
+ "[Kucing= ]",
331
+ "[Sampi= ]",
332
+ "[Kerbau= ]",
333
+ "[Tikus= ]",
334
+ "[Debu= ]",
335
+ "[Anjing= ]",
336
+ "[Naga= ]",
337
+ "[Kambing=]",
338
+ "[Mayang= ]",
339
+ "[Gajah= ]",
340
+ "[Singa= ]"
341
+ ],
342
+
343
+ [When::BasicTypes::M17n,
344
+ "names:[Krsnapaksa=, 黒分=, zh:下弦月=]",
345
+ "[Ikan= ]",
346
+ "[Lilin= ]",
347
+ "[Ulung= ]",
348
+ "[Kelapa= ]",
349
+ "[Banteng=]",
350
+ "[Hantu= ]",
351
+ "[Areng= ]",
352
+ "[Udang= ]",
353
+ "[Semudra=]",
354
+ "[Pare= ]",
355
+ "[Madu= ]",
356
+ "[Kala= ]",
357
+ "[Ular= ]",
358
+ "[Padi= ]",
359
+ "[Ulat= ]"
360
+ ]
361
+ ],
362
+
363
+ [When::BasicTypes::M17n,
364
+ "names:[Dwiwara=, 2日週=]",
365
+ "[Menga=]", # 0
366
+ "[Pepet=]" # 1
367
+ ],
368
+
369
+ [When::Coordinates::Residue,
370
+ "label:[Triwara=, 3日週=]", "divisor:3", "day:2",
371
+ [When::Coordinates::Residue, "label:[Pasah= ]", "remainder: 0"],
372
+ [When::Coordinates::Residue, "label:[Gelang Tegeh=]", "remainder: 1"],
373
+ [When::Coordinates::Residue, "label:[Kajeng= ]", "remainder: 2"]
374
+ ],
375
+
376
+ [When::BasicTypes::M17n,
377
+ "names:[Tjaturwara=, 4日週=]",
378
+ "[Sri= ]",
379
+ "[Laba= ]",
380
+ "[Jaya= ]",
381
+ "[Menala=]"
382
+ ],
383
+
384
+ [When::Coordinates::Residue,
385
+ "label:[Pantjawara=, 5日週=]", "divisor:5", "day:1",
386
+ [When::Coordinates::Residue, "label:[Paing= ]", "remainder: 0"],
387
+ [When::Coordinates::Residue, "label:[Pon= ]", "remainder: 1"],
388
+ [When::Coordinates::Residue, "label:[Wage= ]", "remainder: 2"],
389
+ [When::Coordinates::Residue, "label:[Kliwon=]", "remainder: 3"],
390
+ [When::Coordinates::Residue, "label:[Umanis=]", "remainder: 4"]
391
+ ],
392
+
393
+ [When::Coordinates::Residue,
394
+ "label:[Perinkelan=, 六曜=]", "divisor:6", "day:2",
395
+ [When::Coordinates::Residue, "label:[Tungleh=]", "remainder: 0"],
396
+ [When::Coordinates::Residue, "label:[Aryang= ]", "remainder: 1"],
397
+ [When::Coordinates::Residue, "label:[Urukung=]", "remainder: 2"],
398
+ [When::Coordinates::Residue, "label:[Paniron=]", "remainder: 3"],
399
+ [When::Coordinates::Residue, "label:[Was= ]", "remainder: 4"],
400
+ [When::Coordinates::Residue, "label:[Maulu= ]", "remainder: 5"]
401
+ ],
402
+
403
+ [When::Coordinates::Residue,
404
+ "label:[Sadwara=, 6日週=]", "divisor:6", "day:2",
405
+ [When::Coordinates::Residue, "label:[Mina= ]", "remainder: 0"],
406
+ [When::Coordinates::Residue, "label:[Taru= ]", "remainder: 1"],
407
+ [When::Coordinates::Residue, "label:[Sato= ]", "remainder: 2"],
408
+ [When::Coordinates::Residue, "label:[Patra=]", "remainder: 3"],
409
+ [When::Coordinates::Residue, "label:[Wong= ]", "remainder: 4"],
410
+ [When::Coordinates::Residue, "label:[Paksi=]", "remainder: 5"]
411
+ ],
412
+
413
+ [When::Coordinates::Residue,
414
+ "label:[Septawara=, 7日週=]", "divisor:7", "day:6",
415
+ [When::Coordinates::Residue, "label:[Reditē= ]", "remainder: 0"],
416
+ [When::Coordinates::Residue, "label:[Coma= ]", "remainder: 1"],
417
+ [When::Coordinates::Residue, "label:[Anggara= ]", "remainder: 2"],
418
+ [When::Coordinates::Residue, "label:[Buda= ]", "remainder: 3"],
419
+ [When::Coordinates::Residue, "label:[Wraspati= ]", "remainder: 4"],
420
+ [When::Coordinates::Residue, "label:[Sukra= ]", "remainder: 5"],
421
+ [When::Coordinates::Residue, "label:[Saniscara=]", "remainder: 6"]
422
+ ],
423
+
424
+ [When::BasicTypes::M17n,
425
+ "names:[Astawara=, 8日週=]",
426
+ "[Sri= ]",
427
+ "[Indra= ]",
428
+ "[Guru= ]",
429
+ "[Yama= ]",
430
+ "[Ludra= ]",
431
+ "[Brahma=]",
432
+ "[Kala= ]",
433
+ "[Uma= ]"
434
+ ],
435
+
436
+ [When::BasicTypes::M17n,
437
+ "names:[Sangawara=, 9日週=]",
438
+ "[Dangu= ]",
439
+ "[Jangur= ]",
440
+ "[Gigis= ]",
441
+ "[Nohan= ]",
442
+ "[Ogan= ]",
443
+ "[Erangan=]",
444
+ "[Urungan=]",
445
+ "[Tulus= ]",
446
+ "[Dadi= ]"
447
+ ],
448
+
449
+ [When::BasicTypes::M17n,
450
+ "names:[Dasawara=, 10日週=]",
451
+ "[Pandita]", # 0
452
+ "[Pati ]", # 1
453
+ "[Suka ]", # 2
454
+ "[Duka ]", # 3
455
+ "[Sri ]", # 4
456
+ "[Manuh ]", # 5
457
+ "[Manusa ]", # 6
458
+ "[Raja ]", # 7
459
+ "[Dewa ]", # 8
460
+ "[Raksasa]" # 9
461
+ ],
462
+
463
+ [When::Coordinates::Residue,
464
+ "label:[Ingkel=, インゲル=]", "divisor:42", "day:20",
465
+ [When::Coordinates::Residue, "label:[Wong= ]", "remainder: 0"],
466
+ [When::Coordinates::Residue, "label:[Sato= ]", "remainder: 7"],
467
+ [When::Coordinates::Residue, "label:[Mina= ]", "remainder: 14"],
468
+ [When::Coordinates::Residue, "label:[Manuk=]", "remainder: 21"],
469
+ [When::Coordinates::Residue, "label:[Taru= ]", "remainder: 28"],
470
+ [When::Coordinates::Residue, "label:[Buku= ]", "remainder: 35"]
471
+ ],
472
+
473
+ [When::BasicTypes::M17n,
474
+ "names:[Watek=, ワテック=]",
475
+ "[Watu-Lembu= ]", # 7
476
+ "[Buta-Lintah= ]", # 8
477
+ "[Suku-Uler= ]", # 9
478
+ "[Wong-Gajah= ]", # 10
479
+ "[Gajah-Lembu= ]", # 11
480
+ "[Watu-Lintah= ]", # 12
481
+ "[Buta-Uler= ]", # 13
482
+ "[Suku-Gajah= ]", # 14
483
+ "[Wong-Lembu= ]", # 15
484
+ "[Gajah-Lintah=]", # 16
485
+ "[Watu-Uler= ]", # 17
486
+ "[Buta-Gajah= ]" # 18
487
+ ],
488
+
489
+ [When::Coordinates::Residue,
490
+ "label:[Lintang=, リンタン=]", "divisor:35", "day:6",
491
+ [When::Coordinates::Residue, "label:[Gajah= ]", "remainder: 0"],
492
+ [When::Coordinates::Residue, "label:[Kiriman= ]", "remainder: 1"],
493
+ [When::Coordinates::Residue, "label:[Jong Sarat= ]", "remainder: 2"],
494
+ [When::Coordinates::Residue, "label:[Tiwa-Tiwa= ]", "remainder: 3"],
495
+ [When::Coordinates::Residue, "label:[Sangkatikel= ]", "remainder: 4"],
496
+ [When::Coordinates::Residue, "label:[Bubu bolong= ]", "remainder: 5"],
497
+ [When::Coordinates::Residue, "label:[Sungenge= ]", "remainder: 6"],
498
+ [When::Coordinates::Residue, "label:[Uluku= ]", "remainder: 7"],
499
+ [When::Coordinates::Residue, "label:[Pedati= ]", "remainder: 8"],
500
+ [When::Coordinates::Residue, "label:[Kuda= ]", "remainder: 9"],
501
+ [When::Coordinates::Residue, "label:[Gajah-Mina= ]", "remainder: 10"],
502
+ [When::Coordinates::Residue, "label:[Bade= ]", "remainder: 11"],
503
+ [When::Coordinates::Residue, "label:[Maglut= ]", "remainder: 12"],
504
+ [When::Coordinates::Residue, "label:[Paglangan= ]", "remainder: 13"],
505
+ [When::Coordinates::Residue, "label:[Kala Sungsang= ]", "remainder: 14"],
506
+ [When::Coordinates::Residue, "label:[Kukus= ]", "remainder: 15"],
507
+ [When::Coordinates::Residue, "label:[Asu= ]", "remainder: 16"],
508
+ [When::Coordinates::Residue, "label:[Kartika= ]", "remainder: 17"],
509
+ [When::Coordinates::Residue, "label:[Naga= ]", "remainder: 18"],
510
+ [When::Coordinates::Residue, "label:[Banyakangrem= ]", "remainder: 19"],
511
+ [When::Coordinates::Residue, "label:[Ru= ]", "remainder: 20"],
512
+ [When::Coordinates::Residue, "label:[Patrem= ]", "remainder: 21"],
513
+ [When::Coordinates::Residue, "label:[Lembu= ]", "remainder: 22"],
514
+ [When::Coordinates::Residue, "label:[Dpat= ]", "remainder: 23"],
515
+ [When::Coordinates::Residue, "label:[Tangis= ]", "remainder: 24"],
516
+ [When::Coordinates::Residue, "label:[Salar Ukur= ]", "remainder: 25"],
517
+ [When::Coordinates::Residue, "label:[Prahu Pgat= ]", "remainder: 26"],
518
+ [When::Coordinates::Residue, "label:[Pwuhu atarung= ]", "remainder: 27"],
519
+ [When::Coordinates::Residue, "label:[Lawean= ]", "remainder: 28"],
520
+ [When::Coordinates::Residue, "label:[Kelapa= ]", "remainder: 29"],
521
+ [When::Coordinates::Residue, "label:[Yuyu= ]", "remainder: 30"],
522
+ [When::Coordinates::Residue, "label:[Lumbung= ]", "remainder: 31"],
523
+ [When::Coordinates::Residue, "label:[Kumba= ]", "remainder: 32"],
524
+ [When::Coordinates::Residue, "label:[Udang= ]", "remainder: 33"],
525
+ [When::Coordinates::Residue, "label:[Bgoong= ]", "remainder: 34"]
526
+ ],
527
+
528
+ [When::Coordinates::Wuku,
529
+ "label:[Wuku=, ウク週=]", "divisor:210", "day:146",
530
+ [When::Coordinates::Wuku, "label:[Sinta= ]", "remainder: 0"],
531
+ [When::Coordinates::Wuku, "label:[Landep= ]", "remainder: 7"],
532
+ [When::Coordinates::Wuku, "label:[Ukir= ]", "remainder: 14"],
533
+ [When::Coordinates::Wuku, "label:[Kurantir= ]", "remainder: 21"],
534
+ [When::Coordinates::Wuku, "label:[Tulu= ]", "remainder: 28"],
535
+ [When::Coordinates::Wuku, "label:[Gumbreg= ]", "remainder: 35"],
536
+ [When::Coordinates::Wuku, "label:[Wariga= ]", "remainder: 42"],
537
+ [When::Coordinates::Wuku, "label:[Warigadian= ]", "remainder: 49"],
538
+ [When::Coordinates::Wuku, "label:[Julungwangi= ]", "remainder: 56"],
539
+ [When::Coordinates::Wuku, "label:[Sungsang= ]", "remainder: 63"],
540
+ [When::Coordinates::Wuku, "label:[Dunggulan= ]", "remainder: 70"],
541
+ [When::Coordinates::Wuku, "label:[Kuningan= ]", "remainder: 77"],
542
+ [When::Coordinates::Wuku, "label:[Langkir= ]", "remainder: 84"],
543
+ [When::Coordinates::Wuku, "label:[Medangsiya= ]", "remainder: 91"],
544
+ [When::Coordinates::Wuku, "label:[Pujut= ]", "remainder: 98"],
545
+ [When::Coordinates::Wuku, "label:[Pahang= ]", "remainder:105"],
546
+ [When::Coordinates::Wuku, "label:[Krulut= ]", "remainder:112"],
547
+ [When::Coordinates::Wuku, "label:[Merakih= ]", "remainder:119"],
548
+ [When::Coordinates::Wuku, "label:[Tambir= ]", "remainder:126"],
549
+ [When::Coordinates::Wuku, "label:[Medangkungan=]", "remainder:133"],
550
+ [When::Coordinates::Wuku, "label:[Matal= ]", "remainder:140"],
551
+ [When::Coordinates::Wuku, "label:[Uye= ]", "remainder:147"],
552
+ [When::Coordinates::Wuku, "label:[Menail= ]", "remainder:154"],
553
+ [When::Coordinates::Wuku, "label:[Prangbakat= ]", "remainder:161"],
554
+ [When::Coordinates::Wuku, "label:[Bala= ]", "remainder:168"],
555
+ [When::Coordinates::Wuku, "label:[Ugu= ]", "remainder:175"],
556
+ [When::Coordinates::Wuku, "label:[Wayang= ]", "remainder:182"],
557
+ [When::Coordinates::Wuku, "label:[Kelawu= ]", "remainder:189"],
558
+ [When::Coordinates::Wuku, "label:[Dukut= ]", "remainder:196"],
559
+ [When::Coordinates::Wuku, "label:[Watugunung= ]", "remainder:203"]
560
+ ]
561
+ ]
562
+ ]]
563
+
564
+ #
565
+ # When::Coordinates::Residue へ処理を委譲する暦注
566
+ #
567
+ # @private
568
+ When.CalendarNote('Balinese/Notes')['day::*'].each do |cood|
569
+ case cood
570
+ when Coordinates::Residue
571
+ module_eval %Q{
572
+ def #{cood.label.to_s.downcase}(date, parameter=nil)
573
+ When.CalendarNote('Balinese/Notes')['day']['#{cood.label.to_s}'] % date
574
+ end
575
+ }
576
+ when BasicTypes::M17n
577
+ module_eval %Q{
578
+ def #{cood.to_s.downcase}(date, parameter=nil)
579
+ (When.CalendarNote('Balinese/Notes')['day']['Wuku'] % date).#{cood.to_s.downcase}
580
+ end
581
+ }
582
+ end
583
+ end
584
+
585
+ #
586
+ # 任意の暦をバリ暦日に変換
587
+ #
588
+ # @private
589
+ def _to_date_for_note(date)
590
+ return date if date.frame.kind_of?(When::CalendarTypes::BalineseLuniSolar)
591
+ (date ^ When.era(:period=>'BalineseLuniSolar')).each do |list|
592
+ return list[0] if list[0]
593
+ end
594
+ nil
595
+ end
596
+
597
+ # バリ暦日の「日名」
598
+ #
599
+ # @param [When::TM::TemporalPosition] date 「日名」を求める日付
600
+ # @param [nil] parameter 未使用
601
+ #
602
+ # @return [When::BasicTypes::M17n] 「日名」(欠日の場合は2日分を'/'で連結)
603
+ #
604
+ def hari(date, parameter=nil)
605
+ y, m, d = _to_date_for_note(date).cal_date
606
+ tithi = [d * 1 - 1]
607
+ tithi[0] += 15 unless [0,1,nil].include?(m * 0)
608
+ tithi << (tithi[0] + 1) % 30 if d * 0 == -2
609
+ table = When.CalendarNote('Balinese/Notes')['day']['Hari']
610
+ haris = tithi.map {|t| table[t / 15][t % 15]}
611
+ return haris.first + '' if haris.length == 1
612
+ haris.first + '/' + haris.last
613
+ end
614
+
615
+ private
616
+
617
+ # オブジェクトの正規化
618
+ def _normalize(args=[], options={})
619
+ @event = 'hari'
620
+ @prime ||= [%w(Month), %w(Pantjawara Perinkelan Septawara Wuku)]
621
+ super
622
+ end
623
+ end
624
+ end