when_exe 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +36 -33
- data/bin/locales.rb +1 -1
- data/bin/make_ttl.rb.config +1 -1
- data/lib/when_exe.rb +27 -16
- data/lib/when_exe/basictypes.rb +772 -771
- data/lib/when_exe/calendartypes.rb +1485 -1453
- data/lib/when_exe/coordinates.rb +5 -0
- data/lib/when_exe/core/compatibility.rb +1 -1
- data/lib/when_exe/core/duration.rb +147 -116
- data/lib/when_exe/core/extension.rb +499 -497
- data/lib/when_exe/ephemeris.rb +1952 -1951
- data/lib/when_exe/ephemeris/eclipse.rb +5 -4
- data/lib/when_exe/ephemeris/notes.rb +457 -421
- data/lib/when_exe/ephemeris/planets.rb +585 -585
- data/lib/when_exe/ephemeris/sun.rb +214 -214
- data/lib/when_exe/google_api.rb +153 -0
- data/lib/when_exe/icalendar.rb +1640 -1632
- data/lib/when_exe/inspect.rb +42 -20
- data/lib/when_exe/linkeddata.rb +28 -7
- data/lib/when_exe/locales/autoload.rb +2 -1
- data/lib/when_exe/locales/locale.rb +35 -15
- data/lib/when_exe/locales/zh.rb +77 -0
- data/lib/when_exe/mini_application.rb +3 -1
- data/lib/when_exe/{googlecalendar.rb → obsolete/googlecalendar.rb} +144 -144
- data/lib/when_exe/parts/enumerator.rb +498 -486
- data/lib/when_exe/parts/geometric_complex.rb +397 -397
- data/lib/when_exe/parts/timezone.rb +246 -241
- data/lib/when_exe/region/armenian.rb +55 -56
- data/lib/when_exe/region/babylonian.rb +406 -405
- data/lib/when_exe/region/bahai.rb +107 -106
- data/lib/when_exe/region/balinese.rb +624 -622
- data/lib/when_exe/region/chinese.rb +1071 -1026
- data/lib/when_exe/region/chinese/epochs.rb +28 -28
- data/lib/when_exe/region/chinese/notes.rb +219 -0
- data/lib/when_exe/region/chinese/twins.rb +803 -803
- data/lib/when_exe/region/christian.rb +21 -15
- data/lib/when_exe/region/coptic.rb +107 -106
- data/lib/when_exe/region/discordian.rb +218 -218
- data/lib/when_exe/region/east_asian.rb +1 -1
- data/lib/when_exe/region/french.rb +126 -56
- data/lib/when_exe/region/geologicalage.rb +639 -639
- data/lib/when_exe/region/goddess.rb +60 -58
- data/lib/when_exe/region/hanke_henry.rb +2 -2
- data/lib/when_exe/region/indian.rb +1225 -1222
- data/lib/when_exe/region/international_fixed.rb +96 -97
- data/lib/when_exe/region/iranian.rb +206 -203
- data/lib/when_exe/region/islamic.rb +102 -102
- data/lib/when_exe/region/japanese.rb +126 -71
- data/lib/when_exe/region/japanese/epochs.rb +426 -426
- data/lib/when_exe/region/japanese/notes.rb +101 -81
- data/lib/when_exe/region/japanese/residues.rb +1345 -1311
- data/lib/when_exe/region/japanese/twins.rb +225 -225
- data/lib/when_exe/region/japanese/weeks.rb +112 -112
- data/lib/when_exe/region/javanese.rb +230 -230
- data/lib/when_exe/region/jewish.rb +130 -131
- data/lib/when_exe/region/m17n.rb +114 -114
- data/lib/when_exe/region/martian.rb +258 -258
- data/lib/when_exe/region/mayan.rb +11 -8
- data/lib/when_exe/region/pax.rb +4 -5
- data/lib/when_exe/region/pope.rb +1 -1
- data/lib/when_exe/region/positivist.rb +100 -100
- data/lib/when_exe/region/residue.rb +162 -162
- data/lib/when_exe/region/roman.rb +333 -333
- data/lib/when_exe/region/{soviet.rb → russian.rb} +221 -209
- data/lib/when_exe/region/shire.rb +222 -223
- data/lib/when_exe/region/symmetry.rb +50 -50
- data/lib/when_exe/region/thai.rb +336 -336
- data/lib/when_exe/region/tibetan.rb +315 -316
- data/lib/when_exe/region/tranquility.rb +207 -208
- data/lib/when_exe/region/vanishing_leprechaun.rb +3 -1
- data/lib/when_exe/region/vietnamese.rb +449 -440
- data/lib/when_exe/region/weekdate.rb +80 -80
- data/lib/when_exe/region/world.rb +170 -171
- data/lib/when_exe/region/world_season.rb +89 -89
- data/lib/when_exe/region/yerm.rb +3 -3
- data/lib/when_exe/region/zoroastrian.rb +205 -205
- data/lib/when_exe/timestandard.rb +708 -707
- data/lib/when_exe/tmduration.rb +338 -338
- data/lib/when_exe/tmobjects.rb +1356 -1356
- data/lib/when_exe/tmposition.rb +66 -31
- data/lib/when_exe/version.rb +16 -2
- data/test/examples/Residue.m17n +83 -83
- data/test/examples/Terms.m17n +2 -2
- data/test/test.rb +2 -2
- data/test/test/google_api.rb +65 -0
- data/test/test/linkeddata.rb +1 -1
- data/test/test/{googlecalendar.rb → obsolete/googlecalendar.rb} +194 -194
- data/test/test/region/indian.rb +90 -85
- data/test/test/region/m17n.rb +7 -7
- data/test/test/region/mayan.rb +195 -195
- data/test/test/region/residue.rb +153 -153
- data/test/test/tmposition.rb +11 -1
- data/when_exe.gemspec +2 -2
- metadata +95 -8
- data/test/test.rb.config +0 -1
@@ -1,333 +1,333 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
=begin
|
3
|
-
Copyright (C) 2011-
|
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
|
-
|
10
|
-
class BasicTypes::M17n
|
11
|
-
|
12
|
-
Roman = [self, [
|
13
|
-
"locale:[=en:, ja=ja:, alias]",
|
14
|
-
"names:[Roman=]",
|
15
|
-
|
16
|
-
# Remarks
|
17
|
-
'[based on Chris Bennett "Roman Dates" (Retrieved 2013-05-13)=http://www.tyndalehouse.com/Egypt/ptolemies/chron/roman/chron_rom_intro_fr.htm,' +
|
18
|
-
'典拠 - Chris Bennett "Roman Dates" (2013-05-13 閲覧)=]',
|
19
|
-
|
20
|
-
[self, # ..CE-44 / ..BCE45
|
21
|
-
"names:[
|
22
|
-
"[Ianuarius, 1月]",
|
23
|
-
"[Februarius, 2月]",
|
24
|
-
"[Martius, 3月]",
|
25
|
-
"[Aprilis, 4月]",
|
26
|
-
"[Maius, 5月]",
|
27
|
-
"[Iunius, 6月]",
|
28
|
-
"[Quintilis, 旧7月=]",
|
29
|
-
"[Sextilis, 旧8月=]",
|
30
|
-
"[September, 9月]",
|
31
|
-
"[October, 10月]",
|
32
|
-
"[November, 11月]",
|
33
|
-
"[December, 12月]"
|
34
|
-
],
|
35
|
-
|
36
|
-
[self, # CE-43..CE-8 / BCE44..BCE9
|
37
|
-
"names:[
|
38
|
-
"[Ianuarius, 1月]",
|
39
|
-
"[Februarius, 2月]",
|
40
|
-
"[Martius, 3月]",
|
41
|
-
"[Aprilis, 4月]",
|
42
|
-
"[Maius, 5月]",
|
43
|
-
"[Iunius, 6月]",
|
44
|
-
"[Iulius, 7月]",
|
45
|
-
"[Sextilis, 旧8月=]",
|
46
|
-
"[September, 9月]",
|
47
|
-
"[October, 10月]",
|
48
|
-
"[November, 11月]",
|
49
|
-
"[December, 12月]"
|
50
|
-
],
|
51
|
-
|
52
|
-
[self, # CE-7..CE36, CE41.. / BCE8..CE36, CE41..
|
53
|
-
"names:[Month,
|
54
|
-
"[Ianuarius, 1月]",
|
55
|
-
"[Februarius, 2月]",
|
56
|
-
"[Martius, 3月]",
|
57
|
-
"[Aprilis, 4月]",
|
58
|
-
"[Maius, 5月]",
|
59
|
-
"[Iunius, 6月]",
|
60
|
-
"[Iulius, 7月]",
|
61
|
-
"[Augustus, 8月]",
|
62
|
-
"[September, 9月]",
|
63
|
-
"[October, 10月]",
|
64
|
-
"[November, 11月]",
|
65
|
-
"[December, 12月]"
|
66
|
-
],
|
67
|
-
|
68
|
-
[self, # CE37..CE40
|
69
|
-
"names:[
|
70
|
-
"[Ianuarius, 1月]",
|
71
|
-
"[Februarius, 2月]",
|
72
|
-
"[Martius, 3月]",
|
73
|
-
"[Aprilis, 4月]",
|
74
|
-
"[Maius, 5月]",
|
75
|
-
"[Iunius, 6月]",
|
76
|
-
"[Iulius, 7月]",
|
77
|
-
"[Augustus, 8月]",
|
78
|
-
"[Germanicus, 新9月=]",
|
79
|
-
"[October, 10月]",
|
80
|
-
"[November, 11月]",
|
81
|
-
"[December, 12月]"
|
82
|
-
],
|
83
|
-
|
84
|
-
# %0s は“閏”の表記を抑制する指定となっている
|
85
|
-
[self, # Intercalary Months
|
86
|
-
"names:[IntercalaryMonth=en:Intercalation, 閏月]",
|
87
|
-
"[%0sIntercalaris=en:Roman_calendar#Calendar_of_Numa," +
|
88
|
-
"閏月%0s=ja:%%<ローマ暦>#%.<末期のローマ暦>]",
|
89
|
-
"[%0sIntercalaris Prior=en:Julian_calendar#Realignment_of_the_year," +
|
90
|
-
"第1閏月%0s=ja:%%<ローマ暦>#%.<末期のローマ暦>]",
|
91
|
-
"[%0sIntercalaris Posterior=en:Julian_calendar#Realignment_of_the_year," +
|
92
|
-
"第2閏月%0s=ja:%%<ローマ暦>#%.<末期のローマ暦>]",
|
93
|
-
]
|
94
|
-
]]
|
95
|
-
end
|
96
|
-
|
97
|
-
class TM::CalendarEra
|
98
|
-
|
99
|
-
# From http://en.wikipedia.org/wiki/Julian_calendar#Sacrobosco.27s_theory_on_month_lengths
|
100
|
-
|
101
|
-
"locale:[=en:, ja=ja:, alias]",
|
102
|
-
"period:[Roman=en:Roman_calendar,
|
103
|
-
["[AUC=en:Ab_urbe_condita, 建国紀元=ja:%%<ローマ建国紀元>, alias:Ab_urbe_condita]709.1.1",
|
104
|
-
'@CE', "-44-01-01^JulianA",
|
105
|
-
"-7-03-01^JulianB",
|
106
|
-
"8-01-01^JulianC", "476-09-04"]
|
107
|
-
]]
|
108
|
-
|
109
|
-
# From Chris Bennett, http://www.tyndalehouse.com/Egypt/ptolemies/chron/roman/chron_rom_intro_fr.htm
|
110
|
-
Roman = [self, [
|
111
|
-
"locale:[=en:, ja=ja:, alias]",
|
112
|
-
"period:[Roman=en:Roman_calendar,
|
113
|
-
["[AUC=en:Ab_urbe_condita, 建国紀元=ja:%%<ローマ建国紀元>, alias:Ab_urbe_condita]492.5.1",
|
114
|
-
'@CE', "-261-05-01^RomanA?border=0-5-1",
|
115
|
-
"-221-03-01^RomanA?border=0-3-1",
|
116
|
-
"-152-01-01^RomanA",
|
117
|
-
"-43-01-01^RomanB",
|
118
|
-
"-7-01-01^RomanC",
|
119
|
-
"37-01-01^RomanD",
|
120
|
-
"41-01-01^Roman", "476-09-04"]
|
121
|
-
]]
|
122
|
-
|
123
|
-
end
|
124
|
-
|
125
|
-
module CalendarTypes
|
126
|
-
|
127
|
-
# From http://en.wikipedia.org/wiki/Julian_calendar#Sacrobosco.27s_theory_on_month_lengths
|
128
|
-
_Index0 = When::Coordinates::DefaultDayIndex
|
129
|
-
_IndicesB12 = [When.Index('Roman::MonthB', {:unit=>12}), _Index0]
|
130
|
-
_Indices12 = [When.Index('Roman::Month', {:unit=>12}), _Index0]
|
131
|
-
|
132
|
-
#
|
133
|
-
# Julian Calendar A : BCE45-BCE8
|
134
|
-
#
|
135
|
-
JulianA = [CyclicTableBased, {
|
136
|
-
'origin_of_LSC' => 1704987,
|
137
|
-
'origin_of_MSC' => -44,
|
138
|
-
'indices' => _IndicesB12,
|
139
|
-
'rule_table' => {
|
140
|
-
'T' => {'Rule' =>[365,366,365]},
|
141
|
-
365 => {'Length'=>[31,29] + [31,30]*5},
|
142
|
-
366 => {'Length'=>[31,30] + [31,30]*5}
|
143
|
-
},
|
144
|
-
'note' => 'Roman'
|
145
|
-
}]
|
146
|
-
|
147
|
-
#
|
148
|
-
# Julian Calendar B : BCE8-CE7
|
149
|
-
#
|
150
|
-
JulianB = [CyclicTableBased, {
|
151
|
-
'origin_of_LSC' => 1704987+13,
|
152
|
-
'origin_of_MSC' => -44,
|
153
|
-
'indices' => _IndicesB12,
|
154
|
-
'rule_table' => {
|
155
|
-
'T' => {'Rule' =>[365]},
|
156
|
-
365 => {'Length'=>[31,28] + [31,30,31,30,31]*2}
|
157
|
-
},
|
158
|
-
'note' => 'Roman'
|
159
|
-
}]
|
160
|
-
|
161
|
-
#
|
162
|
-
# Julian Calendar C : CE8-
|
163
|
-
#
|
164
|
-
JulianC = [Julian, {
|
165
|
-
'indices' => _Indices12,
|
166
|
-
'note' => 'Roman'
|
167
|
-
}]
|
168
|
-
|
169
|
-
# From Chris Bennett, http://www.tyndalehouse.com/Egypt/ptolemies/chron/roman/chron_rom_intro_fr.htm
|
170
|
-
#
|
171
|
-
# Roman Calendar BCE262-(CE60)-CE480
|
172
|
-
#
|
173
|
-
# _ID_N = '1,2,3,4,5,6,7,8,9,10,11,12'
|
174
|
-
_ID_L = '1,2,2=,3,4,5,6,7,8,9,10,11,12'
|
175
|
-
_ID_J = '1,2,2=,3,4,5,6,7,8,9,10,11,11<,11>,12'
|
176
|
-
_Branch = {
|
177
|
-
1=>When.Resource('_m:Roman::IntercalaryMonth::*')[0],
|
178
|
-
0.5=>When.Resource('_m:Roman::IntercalaryMonth::*')[1],
|
179
|
-
1.5=>When.Resource('_m:Roman::IntercalaryMonth::*')[2]
|
180
|
-
}
|
181
|
-
_IndicesA = [When.Index('Roman::MonthA', {:branch=>_Branch}), _Index0]
|
182
|
-
_IndicesB = [When.Index('Roman::MonthB', {:branch=>_Branch}), _Index0]
|
183
|
-
_Indices = [When.Index('Roman::Month', {:branch=>_Branch}), _Index0]
|
184
|
-
_IndicesD = [When.Index('Roman::MonthD', {:branch=>_Branch}), _Index0]
|
185
|
-
_remarks = When.M17n('Roman::based on Chris Bennett "Roman Dates" (Retrieved 2013-05-13)')
|
186
|
-
_options = {
|
187
|
-
'origin_of_LSC' => 1625698,
|
188
|
-
'origin_of_MSC' => -261,
|
189
|
-
'indices' => _Indices,
|
190
|
-
'rule_table' => {
|
191
|
-
'T' => {'Rule' => %w( A C A B A C A B A C A B
|
192
|
-
A C A B A C A B A C A B A C A B A C A B A C A B A C A B A C A B A A C B A A A A C A A A B A C A A B
|
193
|
-
A A A A A A A A A A C A C A B C A C A B C A C A C A B C A C A C A A B C A B C A B C A B C A C A C A
|
194
|
-
C A C A C A C A C A C A A C A C A C A C A C A C A C A C A C A C A C A C A A C A A C A A C A A C A A
|
195
|
-
C A C A C A C A C A C A C A A C A C A C A C A C A C A C A C A C A C A A C A A C A A C A A B A A C A
|
196
|
-
A A A A J N L N N L N N L N N L N N L N N L N N L N N L N N L N N L N N L N N L N N L N N N N N N N) +
|
197
|
-
%w(N N N L) * 120
|
198
|
-
},
|
199
|
-
'A' => {'Length'=>[29, 28, 31, 29, 31, 29, 31, 29, 29, 31, 29, 29]},
|
200
|
-
'B' => {'Length'=>[29, 23, 27, 31, 29, 31, 29, 31, 29, 29, 31, 29, 29], 'IDs'=>_ID_L},
|
201
|
-
'C' => {'Length'=>[29, 24, 27, 31, 29, 31, 29, 31, 29, 29, 31, 29, 29], 'IDs'=>_ID_L},
|
202
|
-
'J' => {'Length'=>[29, 24, 27, 31, 29, 31, 29, 31, 29, 29, 31, 34, 31, 31, 29], 'IDs'=>_ID_J},
|
203
|
-
'N' => {'Length'=>[31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]},
|
204
|
-
'L' => {'Length'=>[31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]},
|
205
|
-
},
|
206
|
-
'note' => 'Roman'
|
207
|
-
}
|
208
|
-
# @private
|
209
|
-
RomanA = [CyclicTableBased, _options.merge({'remarks'=>_remarks, 'indices' => _IndicesA})]
|
210
|
-
# @private
|
211
|
-
RomanB = [CyclicTableBased, _options.merge({'remarks'=>_remarks, 'indices' => _IndicesB})]
|
212
|
-
# @private
|
213
|
-
RomanC = [CyclicTableBased, _options.merge({'remarks'=>_remarks })]
|
214
|
-
# @private
|
215
|
-
RomanD = [CyclicTableBased, _options.merge({'remarks'=>_remarks, 'indices' => _IndicesD})]
|
216
|
-
# @private
|
217
|
-
Roman = [CyclicTableBased, _options]
|
218
|
-
end
|
219
|
-
|
220
|
-
#
|
221
|
-
# 古代ローマの暦注
|
222
|
-
#
|
223
|
-
class CalendarNote::Roman < CalendarNote
|
224
|
-
|
225
|
-
Notes = [When::BasicTypes::M17n, [
|
226
|
-
"locale:[=en:, ja=ja:, alias]",
|
227
|
-
"names:[Roman]",
|
228
|
-
|
229
|
-
# 年の暦注 ----------------------------
|
230
|
-
[When::BasicTypes::M17n,
|
231
|
-
"names:[year]",
|
232
|
-
|
233
|
-
[When::Coordinates::Residue,
|
234
|
-
"label:[Solar=en:Solar_cycle_(calendar), 太陽章=]", "divisor:28", "year:-8",
|
235
|
-
],
|
236
|
-
|
237
|
-
[When::Coordinates::Residue,
|
238
|
-
"label:[Metonic=en:Metonic_cycle, 太陰章=]", "divisor:19", "year:0",
|
239
|
-
],
|
240
|
-
|
241
|
-
[When::Coordinates::Residue,
|
242
|
-
"label:[Indiction, インディクティオ]", "divisor:15", "year:-2", "format:[%s=en:Indiction, %s=ja:インディクティオ]",
|
243
|
-
[When::Coordinates::Residue, "label:[I= ]", "remainder: 0"],
|
244
|
-
[When::Coordinates::Residue, "label:[II= ]", "remainder: 1"],
|
245
|
-
[When::Coordinates::Residue, "label:[III= ]", "remainder: 2"],
|
246
|
-
[When::Coordinates::Residue, "label:[IV= ]", "remainder: 3"],
|
247
|
-
[When::Coordinates::Residue, "label:[V= ]", "remainder: 4"],
|
248
|
-
[When::Coordinates::Residue, "label:[VI= ]", "remainder: 5"],
|
249
|
-
[When::Coordinates::Residue, "label:[VII= ]", "remainder: 6"],
|
250
|
-
[When::Coordinates::Residue, "label:[VIII=]", "remainder: 7"],
|
251
|
-
[When::Coordinates::Residue, "label:[IX= ]", "remainder: 8"],
|
252
|
-
[When::Coordinates::Residue, "label:[X= ]", "remainder: 9"],
|
253
|
-
[When::Coordinates::Residue, "label:[XI= ]", "remainder: 10"],
|
254
|
-
[When::Coordinates::Residue, "label:[XII= ]", "remainder: 11"],
|
255
|
-
[When::Coordinates::Residue, "label:[XIII=]", "remainder: 12"],
|
256
|
-
[When::Coordinates::Residue, "label:[XIV= ]", "remainder: 13"],
|
257
|
-
[When::Coordinates::Residue, "label:[XV= ]", "remainder: 14"],
|
258
|
-
]
|
259
|
-
],
|
260
|
-
|
261
|
-
# 月の暦注 ----------------------------
|
262
|
-
[When::BasicTypes::M17n,
|
263
|
-
"names:[month]",
|
264
|
-
[When::BasicTypes::M17n,
|
265
|
-
"names:[Month]"
|
266
|
-
]
|
267
|
-
],
|
268
|
-
|
269
|
-
# 日の暦注 ----------------------------
|
270
|
-
[When::BasicTypes::M17n,
|
271
|
-
"names:[day]",
|
272
|
-
|
273
|
-
[When::BasicTypes::M17n,
|
274
|
-
"names:[Nomen]"
|
275
|
-
]
|
276
|
-
]
|
277
|
-
]]
|
278
|
-
|
279
|
-
Order = [
|
280
|
-
'a.d. bis VI',
|
281
|
-
'prid.', 'a.d. III', 'a.d. IV', 'a.d. V', 'a.d. VI', 'a.d. VII', 'a.d. VIII',
|
282
|
-
'a.d. IX', 'a.d. X', 'a.d. XI', 'a.d. XII', 'a.d. XIII', 'a.d. XIV', 'a.d. XV',
|
283
|
-
'a.d. XVI', 'a.d. XVII', 'a.d. XVIII', 'a.d. XIX', 'a.d. XX', 'a.d. XXI', 'a.d. XXII'
|
284
|
-
]
|
285
|
-
|
286
|
-
LongMonths = [3, 5, 7, 10, When.Pair(11,0.5), When.Pair(11,1.5)]
|
287
|
-
LongType = [1, 2..6, 7, 8..14, 15]
|
288
|
-
ShortType = [1, 2..4, 5, 6..12, 13]
|
289
|
-
|
290
|
-
# 暦注 - 日の名前
|
291
|
-
#
|
292
|
-
# @param [When::TM::CalDate] date
|
293
|
-
#
|
294
|
-
# @return [String]
|
295
|
-
#
|
296
|
-
def nomen(date)
|
297
|
-
y, m, d = date.cal_date
|
298
|
-
month_name = _abbr_of_month(date)
|
299
|
-
kal, to_nonae, nonae, to_idus, idus = LongMonths.include?(m) ? LongType : ShortType
|
300
|
-
case d
|
301
|
-
when kal ; return 'Kal. ' + month_name
|
302
|
-
when to_nonae ; return Order[nonae - d] + ' Non. ' + month_name
|
303
|
-
when nonae ; return 'Non. ' + month_name
|
304
|
-
when to_idus ; return Order[idus - d] + ' Id. ' + month_name
|
305
|
-
when idus ; return 'Id. ' + month_name
|
306
|
-
end
|
307
|
-
this_month = date.floor(When::MONTH)
|
308
|
-
next_month = this_month.succ
|
309
|
-
month_name = _abbr_of_month(next_month)
|
310
|
-
rest = next_month.to_i - date.to_i
|
311
|
-
if m == 2 && next_month.to_i - this_month.to_i == 29
|
312
|
-
return Order[0] + ' Kal. ' + month_name if rest == 5
|
313
|
-
rest -= 1 if rest > 5
|
314
|
-
end
|
315
|
-
return Order[rest] + ' Kal. ' + month_name
|
316
|
-
end
|
317
|
-
|
318
|
-
private
|
319
|
-
|
320
|
-
# オブジェクトの正規化
|
321
|
-
def _normalize(args=[], options={})
|
322
|
-
@event = 'nomen'
|
323
|
-
super
|
324
|
-
end
|
325
|
-
|
326
|
-
# 日の省略名
|
327
|
-
def _abbr_of_month(month)
|
328
|
-
name = month.name('month').to_s
|
329
|
-
return name.sub(/ (..).*/, ' \1.') if name.sub!(/Intercalaris(.*)?/, 'Int.\1')
|
330
|
-
name.size <= 3 ? name : name[/\A...[^caeiou]*/] + '.'
|
331
|
-
end
|
332
|
-
end
|
333
|
-
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
|
+
|
10
|
+
class BasicTypes::M17n
|
11
|
+
|
12
|
+
Roman = [self, [
|
13
|
+
"locale:[=en:, ja=ja:, zh=zh:, alias]",
|
14
|
+
"names:[Roman=en:Roman_calendar, ローマ暦, 羅馬曆]",
|
15
|
+
|
16
|
+
# Remarks
|
17
|
+
'[based on Chris Bennett "Roman Dates" (Retrieved 2013-05-13)=http://www.tyndalehouse.com/Egypt/ptolemies/chron/roman/chron_rom_intro_fr.htm,' +
|
18
|
+
'典拠 - Chris Bennett "Roman Dates" (2013-05-13 閲覧)=]',
|
19
|
+
|
20
|
+
[self, # ..CE-44 / ..BCE45
|
21
|
+
"names:[month name=en:Month, 月の名前=ja:%%<月_(暦)>, 該月的名稱=, *alias:MonthA=]",
|
22
|
+
"[Ianuarius, 1月]",
|
23
|
+
"[Februarius, 2月]",
|
24
|
+
"[Martius, 3月]",
|
25
|
+
"[Aprilis, 4月]",
|
26
|
+
"[Maius, 5月]",
|
27
|
+
"[Iunius, 6月]",
|
28
|
+
"[Quintilis, 旧7月=]",
|
29
|
+
"[Sextilis, 旧8月=]",
|
30
|
+
"[September, 9月]",
|
31
|
+
"[October, 10月]",
|
32
|
+
"[November, 11月]",
|
33
|
+
"[December, 12月]"
|
34
|
+
],
|
35
|
+
|
36
|
+
[self, # CE-43..CE-8 / BCE44..BCE9
|
37
|
+
"names:[month name=en:Month, 月の名前=ja:%%<月_(暦)>, 該月的名稱=, *alias:MonthB=]",
|
38
|
+
"[Ianuarius, 1月]",
|
39
|
+
"[Februarius, 2月]",
|
40
|
+
"[Martius, 3月]",
|
41
|
+
"[Aprilis, 4月]",
|
42
|
+
"[Maius, 5月]",
|
43
|
+
"[Iunius, 6月]",
|
44
|
+
"[Iulius, 7月]",
|
45
|
+
"[Sextilis, 旧8月=]",
|
46
|
+
"[September, 9月]",
|
47
|
+
"[October, 10月]",
|
48
|
+
"[November, 11月]",
|
49
|
+
"[December, 12月]"
|
50
|
+
],
|
51
|
+
|
52
|
+
[self, # CE-7..CE36, CE41.. / BCE8..CE36, CE41..
|
53
|
+
"names:[month name=en:Month, 月の名前=ja:%%<月_(暦)>, 該月的名稱=, *alias:Month=]",
|
54
|
+
"[Ianuarius, 1月]",
|
55
|
+
"[Februarius, 2月]",
|
56
|
+
"[Martius, 3月]",
|
57
|
+
"[Aprilis, 4月]",
|
58
|
+
"[Maius, 5月]",
|
59
|
+
"[Iunius, 6月]",
|
60
|
+
"[Iulius, 7月]",
|
61
|
+
"[Augustus, 8月]",
|
62
|
+
"[September, 9月]",
|
63
|
+
"[October, 10月]",
|
64
|
+
"[November, 11月]",
|
65
|
+
"[December, 12月]"
|
66
|
+
],
|
67
|
+
|
68
|
+
[self, # CE37..CE40
|
69
|
+
"names:[month name=en:Month, 月の名前=ja:%%<月_(暦)>, 該月的名稱=, *alias:MonthD=]",
|
70
|
+
"[Ianuarius, 1月]",
|
71
|
+
"[Februarius, 2月]",
|
72
|
+
"[Martius, 3月]",
|
73
|
+
"[Aprilis, 4月]",
|
74
|
+
"[Maius, 5月]",
|
75
|
+
"[Iunius, 6月]",
|
76
|
+
"[Iulius, 7月]",
|
77
|
+
"[Augustus, 8月]",
|
78
|
+
"[Germanicus, 新9月=]",
|
79
|
+
"[October, 10月]",
|
80
|
+
"[November, 11月]",
|
81
|
+
"[December, 12月]"
|
82
|
+
],
|
83
|
+
|
84
|
+
# %0s は“閏”の表記を抑制する指定となっている
|
85
|
+
[self, # Intercalary Months
|
86
|
+
"names:[IntercalaryMonth=en:Intercalation, 閏月]",
|
87
|
+
"[%0sIntercalaris=en:Roman_calendar#Calendar_of_Numa," +
|
88
|
+
"閏月%0s=ja:%%<ローマ暦>#%.<末期のローマ暦>]",
|
89
|
+
"[%0sIntercalaris Prior=en:Julian_calendar#Realignment_of_the_year," +
|
90
|
+
"第1閏月%0s=ja:%%<ローマ暦>#%.<末期のローマ暦>]",
|
91
|
+
"[%0sIntercalaris Posterior=en:Julian_calendar#Realignment_of_the_year," +
|
92
|
+
"第2閏月%0s=ja:%%<ローマ暦>#%.<末期のローマ暦>]",
|
93
|
+
]
|
94
|
+
]]
|
95
|
+
end
|
96
|
+
|
97
|
+
class TM::CalendarEra
|
98
|
+
|
99
|
+
# From http://en.wikipedia.org/wiki/Julian_calendar#Sacrobosco.27s_theory_on_month_lengths
|
100
|
+
Julians = [self, [
|
101
|
+
"locale:[=en:, ja=ja:, zh=zh:, alias]",
|
102
|
+
"period:[Roman=en:Roman_calendar, ローマ暦, 羅馬曆]",
|
103
|
+
["[AUC=en:Ab_urbe_condita, 建国紀元=ja:%%<ローマ建国紀元>, 建城紀年=zh:%%<羅馬建城紀年>, alias:Ab_urbe_condita]709.1.1",
|
104
|
+
'@CE', "-44-01-01^JulianA",
|
105
|
+
"-7-03-01^JulianB",
|
106
|
+
"8-01-01^JulianC", "476-09-04"]
|
107
|
+
]]
|
108
|
+
|
109
|
+
# From Chris Bennett, http://www.tyndalehouse.com/Egypt/ptolemies/chron/roman/chron_rom_intro_fr.htm
|
110
|
+
Roman = [self, [
|
111
|
+
"locale:[=en:, ja=ja:, zh=zh:, alias]",
|
112
|
+
"period:[Roman=en:Roman_calendar, ローマ暦, 羅馬曆]",
|
113
|
+
["[AUC=en:Ab_urbe_condita, 建国紀元=ja:%%<ローマ建国紀元>, 建城紀年=zh:%%<羅馬建城紀年>, alias:Ab_urbe_condita]492.5.1",
|
114
|
+
'@CE', "-261-05-01^RomanA?border=0-5-1",
|
115
|
+
"-221-03-01^RomanA?border=0-3-1",
|
116
|
+
"-152-01-01^RomanA",
|
117
|
+
"-43-01-01^RomanB",
|
118
|
+
"-7-01-01^RomanC",
|
119
|
+
"37-01-01^RomanD",
|
120
|
+
"41-01-01^Roman", "476-09-04"]
|
121
|
+
]]
|
122
|
+
|
123
|
+
end
|
124
|
+
|
125
|
+
module CalendarTypes
|
126
|
+
|
127
|
+
# From http://en.wikipedia.org/wiki/Julian_calendar#Sacrobosco.27s_theory_on_month_lengths
|
128
|
+
_Index0 = When::Coordinates::DefaultDayIndex
|
129
|
+
_IndicesB12 = [When.Index('Roman::MonthB', {:unit=>12}), _Index0]
|
130
|
+
_Indices12 = [When.Index('Roman::Month', {:unit=>12}), _Index0]
|
131
|
+
|
132
|
+
#
|
133
|
+
# Julian Calendar A : BCE45-BCE8
|
134
|
+
#
|
135
|
+
JulianA = [CyclicTableBased, {
|
136
|
+
'origin_of_LSC' => 1704987,
|
137
|
+
'origin_of_MSC' => -44,
|
138
|
+
'indices' => _IndicesB12,
|
139
|
+
'rule_table' => {
|
140
|
+
'T' => {'Rule' =>[365,366,365]},
|
141
|
+
365 => {'Length'=>[31,29] + [31,30]*5},
|
142
|
+
366 => {'Length'=>[31,30] + [31,30]*5}
|
143
|
+
},
|
144
|
+
'note' => 'Roman'
|
145
|
+
}]
|
146
|
+
|
147
|
+
#
|
148
|
+
# Julian Calendar B : BCE8-CE7
|
149
|
+
#
|
150
|
+
JulianB = [CyclicTableBased, {
|
151
|
+
'origin_of_LSC' => 1704987+13,
|
152
|
+
'origin_of_MSC' => -44,
|
153
|
+
'indices' => _IndicesB12,
|
154
|
+
'rule_table' => {
|
155
|
+
'T' => {'Rule' =>[365]},
|
156
|
+
365 => {'Length'=>[31,28] + [31,30,31,30,31]*2}
|
157
|
+
},
|
158
|
+
'note' => 'Roman'
|
159
|
+
}]
|
160
|
+
|
161
|
+
#
|
162
|
+
# Julian Calendar C : CE8-
|
163
|
+
#
|
164
|
+
JulianC = [Julian, {
|
165
|
+
'indices' => _Indices12,
|
166
|
+
'note' => 'Roman'
|
167
|
+
}]
|
168
|
+
|
169
|
+
# From Chris Bennett, http://www.tyndalehouse.com/Egypt/ptolemies/chron/roman/chron_rom_intro_fr.htm
|
170
|
+
#
|
171
|
+
# Roman Calendar BCE262-(CE60)-CE480
|
172
|
+
#
|
173
|
+
# _ID_N = '1,2,3,4,5,6,7,8,9,10,11,12'
|
174
|
+
_ID_L = '1,2,2=,3,4,5,6,7,8,9,10,11,12'
|
175
|
+
_ID_J = '1,2,2=,3,4,5,6,7,8,9,10,11,11<,11>,12'
|
176
|
+
_Branch = {
|
177
|
+
1=>When.Resource('_m:Roman::IntercalaryMonth::*')[0],
|
178
|
+
0.5=>When.Resource('_m:Roman::IntercalaryMonth::*')[1],
|
179
|
+
1.5=>When.Resource('_m:Roman::IntercalaryMonth::*')[2]
|
180
|
+
}
|
181
|
+
_IndicesA = [When.Index('Roman::MonthA', {:branch=>_Branch}), _Index0]
|
182
|
+
_IndicesB = [When.Index('Roman::MonthB', {:branch=>_Branch}), _Index0]
|
183
|
+
_Indices = [When.Index('Roman::Month', {:branch=>_Branch}), _Index0]
|
184
|
+
_IndicesD = [When.Index('Roman::MonthD', {:branch=>_Branch}), _Index0]
|
185
|
+
_remarks = When.M17n('Roman::based on Chris Bennett "Roman Dates" (Retrieved 2013-05-13)')
|
186
|
+
_options = {
|
187
|
+
'origin_of_LSC' => 1625698,
|
188
|
+
'origin_of_MSC' => -261,
|
189
|
+
'indices' => _Indices,
|
190
|
+
'rule_table' => {
|
191
|
+
'T' => {'Rule' => %w( A C A B A C A B A C A B
|
192
|
+
A C A B A C A B A C A B A C A B A C A B A C A B A C A B A C A B A A C B A A A A C A A A B A C A A B
|
193
|
+
A A A A A A A A A A C A C A B C A C A B C A C A C A B C A C A C A A B C A B C A B C A B C A C A C A
|
194
|
+
C A C A C A C A C A C A A C A C A C A C A C A C A C A C A C A C A C A C A A C A A C A A C A A C A A
|
195
|
+
C A C A C A C A C A C A C A A C A C A C A C A C A C A C A C A C A C A A C A A C A A C A A B A A C A
|
196
|
+
A A A A J N L N N L N N L N N L N N L N N L N N L N N L N N L N N L N N L N N L N N L N N N N N N N) +
|
197
|
+
%w(N N N L) * 120
|
198
|
+
},
|
199
|
+
'A' => {'Length'=>[29, 28, 31, 29, 31, 29, 31, 29, 29, 31, 29, 29]},
|
200
|
+
'B' => {'Length'=>[29, 23, 27, 31, 29, 31, 29, 31, 29, 29, 31, 29, 29], 'IDs'=>_ID_L},
|
201
|
+
'C' => {'Length'=>[29, 24, 27, 31, 29, 31, 29, 31, 29, 29, 31, 29, 29], 'IDs'=>_ID_L},
|
202
|
+
'J' => {'Length'=>[29, 24, 27, 31, 29, 31, 29, 31, 29, 29, 31, 34, 31, 31, 29], 'IDs'=>_ID_J},
|
203
|
+
'N' => {'Length'=>[31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]},
|
204
|
+
'L' => {'Length'=>[31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]},
|
205
|
+
},
|
206
|
+
'note' => 'Roman'
|
207
|
+
}
|
208
|
+
# @private
|
209
|
+
RomanA = [CyclicTableBased, _options.merge({'remarks'=>_remarks, 'indices' => _IndicesA})]
|
210
|
+
# @private
|
211
|
+
RomanB = [CyclicTableBased, _options.merge({'remarks'=>_remarks, 'indices' => _IndicesB})]
|
212
|
+
# @private
|
213
|
+
RomanC = [CyclicTableBased, _options.merge({'remarks'=>_remarks })]
|
214
|
+
# @private
|
215
|
+
RomanD = [CyclicTableBased, _options.merge({'remarks'=>_remarks, 'indices' => _IndicesD})]
|
216
|
+
# @private
|
217
|
+
Roman = [CyclicTableBased, _options]
|
218
|
+
end
|
219
|
+
|
220
|
+
#
|
221
|
+
# 古代ローマの暦注
|
222
|
+
#
|
223
|
+
class CalendarNote::Roman < CalendarNote
|
224
|
+
|
225
|
+
Notes = [When::BasicTypes::M17n, [
|
226
|
+
"locale:[=en:, ja=ja:, alias]",
|
227
|
+
"names:[Roman]",
|
228
|
+
|
229
|
+
# 年の暦注 ----------------------------
|
230
|
+
[When::BasicTypes::M17n,
|
231
|
+
"names:[note for year=, 年の暦注=, *year]",
|
232
|
+
|
233
|
+
[When::Coordinates::Residue,
|
234
|
+
"label:[Solar=en:Solar_cycle_(calendar), 太陽章=]", "divisor:28", "year:-8",
|
235
|
+
],
|
236
|
+
|
237
|
+
[When::Coordinates::Residue,
|
238
|
+
"label:[Metonic=en:Metonic_cycle, 太陰章=]", "divisor:19", "year:0",
|
239
|
+
],
|
240
|
+
|
241
|
+
[When::Coordinates::Residue,
|
242
|
+
"label:[Indiction, インディクティオ]", "divisor:15", "year:-2", "format:[%s=en:Indiction, %s=ja:インディクティオ]",
|
243
|
+
[When::Coordinates::Residue, "label:[I= ]", "remainder: 0"],
|
244
|
+
[When::Coordinates::Residue, "label:[II= ]", "remainder: 1"],
|
245
|
+
[When::Coordinates::Residue, "label:[III= ]", "remainder: 2"],
|
246
|
+
[When::Coordinates::Residue, "label:[IV= ]", "remainder: 3"],
|
247
|
+
[When::Coordinates::Residue, "label:[V= ]", "remainder: 4"],
|
248
|
+
[When::Coordinates::Residue, "label:[VI= ]", "remainder: 5"],
|
249
|
+
[When::Coordinates::Residue, "label:[VII= ]", "remainder: 6"],
|
250
|
+
[When::Coordinates::Residue, "label:[VIII=]", "remainder: 7"],
|
251
|
+
[When::Coordinates::Residue, "label:[IX= ]", "remainder: 8"],
|
252
|
+
[When::Coordinates::Residue, "label:[X= ]", "remainder: 9"],
|
253
|
+
[When::Coordinates::Residue, "label:[XI= ]", "remainder: 10"],
|
254
|
+
[When::Coordinates::Residue, "label:[XII= ]", "remainder: 11"],
|
255
|
+
[When::Coordinates::Residue, "label:[XIII=]", "remainder: 12"],
|
256
|
+
[When::Coordinates::Residue, "label:[XIV= ]", "remainder: 13"],
|
257
|
+
[When::Coordinates::Residue, "label:[XV= ]", "remainder: 14"],
|
258
|
+
]
|
259
|
+
],
|
260
|
+
|
261
|
+
# 月の暦注 ----------------------------
|
262
|
+
[When::BasicTypes::M17n,
|
263
|
+
"names:[note for month=, 月の暦注=, *month]",
|
264
|
+
[When::BasicTypes::M17n,
|
265
|
+
"names:[month name=en:Month, 月の名前=ja:%%<月_(暦)>, zh:該月的名稱=, *alias:Month=]"
|
266
|
+
]
|
267
|
+
],
|
268
|
+
|
269
|
+
# 日の暦注 ----------------------------
|
270
|
+
[When::BasicTypes::M17n,
|
271
|
+
"names:[note for day=, 日の暦注=, *day]",
|
272
|
+
|
273
|
+
[When::BasicTypes::M17n,
|
274
|
+
"names:[Nomen]"
|
275
|
+
]
|
276
|
+
]
|
277
|
+
]]
|
278
|
+
|
279
|
+
Order = [
|
280
|
+
'a.d. bis VI',
|
281
|
+
'prid.', 'a.d. III', 'a.d. IV', 'a.d. V', 'a.d. VI', 'a.d. VII', 'a.d. VIII',
|
282
|
+
'a.d. IX', 'a.d. X', 'a.d. XI', 'a.d. XII', 'a.d. XIII', 'a.d. XIV', 'a.d. XV',
|
283
|
+
'a.d. XVI', 'a.d. XVII', 'a.d. XVIII', 'a.d. XIX', 'a.d. XX', 'a.d. XXI', 'a.d. XXII'
|
284
|
+
]
|
285
|
+
|
286
|
+
LongMonths = [3, 5, 7, 10, When.Pair(11,0.5), When.Pair(11,1.5)]
|
287
|
+
LongType = [1, 2..6, 7, 8..14, 15]
|
288
|
+
ShortType = [1, 2..4, 5, 6..12, 13]
|
289
|
+
|
290
|
+
# 暦注 - 日の名前
|
291
|
+
#
|
292
|
+
# @param [When::TM::CalDate] date
|
293
|
+
#
|
294
|
+
# @return [String]
|
295
|
+
#
|
296
|
+
def nomen(date)
|
297
|
+
y, m, d = date.cal_date
|
298
|
+
month_name = _abbr_of_month(date)
|
299
|
+
kal, to_nonae, nonae, to_idus, idus = LongMonths.include?(m) ? LongType : ShortType
|
300
|
+
case d
|
301
|
+
when kal ; return 'Kal. ' + month_name
|
302
|
+
when to_nonae ; return Order[nonae - d] + ' Non. ' + month_name
|
303
|
+
when nonae ; return 'Non. ' + month_name
|
304
|
+
when to_idus ; return Order[idus - d] + ' Id. ' + month_name
|
305
|
+
when idus ; return 'Id. ' + month_name
|
306
|
+
end
|
307
|
+
this_month = date.floor(When::MONTH)
|
308
|
+
next_month = this_month.succ
|
309
|
+
month_name = _abbr_of_month(next_month)
|
310
|
+
rest = next_month.to_i - date.to_i
|
311
|
+
if m == 2 && next_month.to_i - this_month.to_i == 29
|
312
|
+
return Order[0] + ' Kal. ' + month_name if rest == 5
|
313
|
+
rest -= 1 if rest > 5
|
314
|
+
end
|
315
|
+
return Order[rest] + ' Kal. ' + month_name
|
316
|
+
end
|
317
|
+
|
318
|
+
private
|
319
|
+
|
320
|
+
# オブジェクトの正規化
|
321
|
+
def _normalize(args=[], options={})
|
322
|
+
@event = 'nomen'
|
323
|
+
super
|
324
|
+
end
|
325
|
+
|
326
|
+
# 日の省略名
|
327
|
+
def _abbr_of_month(month)
|
328
|
+
name = month.name('month').to_s
|
329
|
+
return name.sub(/ (..).*/, ' \1.') if name.sub!(/Intercalaris(.*)?/, 'Int.\1')
|
330
|
+
name.size <= 3 ? name : name[/\A...[^caeiou]*/] + '.'
|
331
|
+
end
|
332
|
+
end
|
333
|
+
end
|