when_exe 0.3.1 → 0.3.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.
- data/lib/when_exe.rb +98 -64
- data/lib/when_exe/basictypes.rb +2 -2
- data/lib/when_exe/calendartypes.rb +5 -2
- data/lib/when_exe/coordinates.rb +11 -1
- data/lib/when_exe/core/duration.rb +38 -0
- data/lib/when_exe/core/extension.rb +17 -4
- data/lib/when_exe/ephemeris.rb +49 -17
- data/lib/when_exe/icalendar.rb +19 -17
- data/lib/when_exe/inspect.rb +16 -4
- data/lib/when_exe/mini_application.rb +42 -4
- data/lib/when_exe/parts/locale.rb +30 -13
- data/lib/when_exe/parts/resource.rb +59 -36
- data/lib/when_exe/parts/timezone.rb +19 -13
- data/lib/when_exe/region/bahai.rb +5 -4
- data/lib/when_exe/region/balinese.rb +2 -2
- data/lib/when_exe/region/chinese.rb +11 -11
- data/lib/when_exe/region/chinese_calendar.rb +37 -79
- data/lib/when_exe/region/chinese_epoch.rb +832 -831
- data/lib/when_exe/region/christian.rb +6 -6
- data/lib/when_exe/region/far_east.rb +104 -104
- data/lib/when_exe/region/french.rb +4 -4
- data/lib/when_exe/region/geologicalage.rb +9 -8
- data/lib/when_exe/region/indian.rb +10 -10
- data/lib/when_exe/region/iranian.rb +3 -3
- data/lib/when_exe/region/islamic.rb +3 -3
- data/lib/when_exe/region/japanese.rb +376 -376
- data/lib/when_exe/region/japanese_notes.rb +60 -60
- data/lib/when_exe/region/javanese.rb +4 -4
- data/lib/when_exe/region/jewish.rb +2 -2
- data/lib/when_exe/region/korean.rb +204 -204
- data/lib/when_exe/region/m17n.rb +1 -1
- data/lib/when_exe/region/martian.rb +2 -2
- data/lib/when_exe/region/mayan.rb +1 -1
- data/lib/when_exe/region/nihon_shoki.rb +43 -43
- data/lib/when_exe/region/pope.rb +271 -271
- data/lib/when_exe/region/roman.rb +13 -12
- data/lib/when_exe/region/ryukyu.rb +47 -47
- data/lib/when_exe/region/shire.rb +4 -4
- data/lib/when_exe/region/thai.rb +2 -2
- data/lib/when_exe/region/tibetan.rb +3 -3
- data/lib/when_exe/region/vietnamese.rb +122 -122
- data/lib/when_exe/region/world.rb +2 -2
- data/lib/when_exe/timestandard.rb +112 -67
- data/lib/when_exe/tmobjects.rb +4 -0
- data/lib/when_exe/tmposition.rb +63 -10
- data/lib/when_exe/tmreference.rb +34 -13
- data/lib/when_exe/version.rb +1 -1
- data/test/test/icalendar.rb +29 -29
- data/test/test/region/m17n.rb +4 -4
- data/test/test/tmobjects.rb +9 -0
- data/test/test/tmposition.rb +3 -3
- data/when_exe.gemspec +1 -1
- metadata +4 -2
@@ -13,7 +13,7 @@ module When
|
|
13
13
|
"namespace:[en=http://en.wikipedia.org/wiki/, ja=http://ja.wikipedia.org/wiki/]",
|
14
14
|
"locale:[=en:, ja=ja:, alias]",
|
15
15
|
"names:[WorldTerms]",
|
16
|
-
"[World=en:The_World_Calendar,
|
16
|
+
"[World=en:The_World_Calendar, 世界暦]"
|
17
17
|
]]
|
18
18
|
end
|
19
19
|
|
@@ -182,7 +182,7 @@ module When
|
|
182
182
|
'origin_of_LSC' => 1721060,
|
183
183
|
'indices' => [
|
184
184
|
Coordinates::Index.new({:unit =>12, :trunk=>When.Resource('_m:CalendarTerms::Month::*')}),
|
185
|
-
Coordinates::
|
185
|
+
Coordinates::DefaultDayIndex
|
186
186
|
],
|
187
187
|
'rule_table' => {
|
188
188
|
'T' => {'Rule' =>['LC', 'SC', 'SC', 'SC']},
|
@@ -54,52 +54,7 @@ module When::TimeStandard
|
|
54
54
|
[2454832.5, 34.0],
|
55
55
|
[2456109.5, 35.0]]
|
56
56
|
|
57
|
-
DeltaT = [
|
58
|
-
|
59
|
-
141.00,140.00,139.00,139.00,139.00,139.00,139.00,140.00,140.00,141.00, # 1600-
|
60
|
-
141.00,141.00,141.00,140.00,139.00,138.00,137.00,134.00,132.00,128.00, # 1610-
|
61
|
-
124.00,119.00,115.00,110.00,106.00,102.00, 98.00, 95.00, 91.00, 88.00, # 1620-
|
62
|
-
85.00, 82.00, 79.00, 77.00, 74.00, 72.00, 70.00, 67.00, 65.00, 63.00, # 1630-
|
63
|
-
62.00, 60.00, 58.00, 57.00, 55.00, 54.00, 53.00, 51.00, 50.00, 49.00, # 1640-
|
64
|
-
48.00, 47.00, 46.00, 45.00, 44.00, 43.00, 42.00, 41.00, 40.00, 38.00, # 1650-
|
65
|
-
37.00, 36.00, 35.00, 34.00, 33.00, 32.00, 31.00, 30.00, 28.00, 27.00, # 1660-
|
66
|
-
26.00, 25.00, 24.00, 23.00, 22.00, 21.00, 20.00, 19.00, 18.00, 17.00, # 1670-
|
67
|
-
16.00, 15.00, 14.00, 14.00, 13.00, 12.00, 12.00, 11.00, 11.00, 10.00, # 1680-
|
68
|
-
10.00, 10.00, 9.00, 9.00, 9.00, 9.00, 9.00, 9.00, 9.00, 9.00, # 1690-
|
69
|
-
|
70
|
-
9.00, 9.00, 9.00, 9.00, 9.00, 9.00, 9.00, 9.00, 10.00, 10.00, # 1700-
|
71
|
-
10.00, 10.00, 10.00, 10.00, 10.00, 10.00, 10.00, 11.00, 11.00, 11.00, # 1710-
|
72
|
-
11.00, 11.00, 11.00, 11.00, 11.00, 11.00, 11.00, 11.00, 11.00, 11.00, # 1720-
|
73
|
-
11.00, 11.00, 11.00, 11.00, 12.00, 12.00, 12.00, 12.00, 12.00, 12.00, # 1730-
|
74
|
-
12.00, 12.00, 12.00, 12.00, 13.00, 13.00, 13.00, 13.00, 13.00, 13.00, # 1740-
|
75
|
-
13.00, 14.00, 14.00, 14.00, 14.00, 14.00, 14.00, 14.00, 15.00, 15.00, # 1750-
|
76
|
-
15.00, 15.00, 15.00, 15.00, 15.00, 16.00, 16.00, 16.00, 16.00, 16.00, # 1760-
|
77
|
-
16.00, 16.00, 16.00, 16.00, 16.00, 17.00, 17.00, 17.00, 17.00, 17.00, # 1770-
|
78
|
-
17.00, 17.00, 17.00, 17.00, 17.00, 17.00, 17.00, 17.00, 17.00, 17.00, # 1780-
|
79
|
-
17.00, 17.00, 16.00, 16.00, 16.00, 16.00, 15.00, 15.00, 14.00, 14.00, # 1790-
|
80
|
-
|
81
|
-
13.70, 13.40, 13.10, 12.90, 12.70, 12.60, 12.50, 12.50, 12.50, 12.50, # 1800-
|
82
|
-
12.50, 12.50, 12.50, 12.50, 12.50, 12.50, 12.50, 12.40, 12.30, 12.20, # 1810-
|
83
|
-
12.00, 11.70, 11.40, 11.10, 10.60, 10.20, 9.60, 9.10, 8.60, 8.00, # 1820-
|
84
|
-
7.50, 7.00, 6.60, 6.30, 6.00, 5.80, 5.70, 5.60, 5.60, 5.60, # 1830-
|
85
|
-
5.70, 5.80, 5.90, 6.10, 6.20, 6.30, 6.50, 6.60, 6.80, 6.90, # 1840-
|
86
|
-
7.10, 7.20, 7.30, 7.40, 7.50, 7.60, 7.70, 7.70, 7.80, 7.80, # 1850-
|
87
|
-
7.88, 7.82, 7.54, 6.97, 6.40, 6.02, 5.41, 4.10, 2.92, 1.82, # 1860-
|
88
|
-
1.61, 0.10, -1.02, -1.28, -2.69, -3.24, -3.64, -4.54, -4.71, -5.11, # 1870-
|
89
|
-
-5.40, -5.42, -5.20, -5.46, -5.46, -5.79, -5.63, -5.64, -5.80, -5.66, # 1880-
|
90
|
-
-5.87, -6.01, -6.19, -6.64, -6.44, -6.47, -6.09, -5.76, -4.66, -3.74, # 1890-
|
91
|
-
|
92
|
-
-2.72, -1.54, -0.02, 1.24, 2.64, 3.86, 5.37, 6.14, 7.75, 9.13, # 1900-
|
93
|
-
10.46, 11.53, 13.36, 14.65, 16.01, 17.20, 18.24, 19.06, 20.25, 20.95, # 1910-
|
94
|
-
21.16, 22.25, 22.41, 23.03, 23.49, 23.62, 23.86, 24.49, 24.34, 24.08, # 1920-
|
95
|
-
24.02, 24.00, 23.87, 23.95, 23.86, 23.93, 23.73, 23.92, 23.96, 24.02, # 1930-
|
96
|
-
24.33, 24.83, 25.30, 25.70, 26.24, 26.77, 27.28, 27.78, 28.25, 28.71, # 1940-
|
97
|
-
29.15, 29.57, 29.97, 30.36, 30.72, 31.07, 31.35, 31.68, 32.18, 32.68, # 1950-
|
98
|
-
33.15, 33.59, 34.00, 34.47, 35.03, 35.73, 36.54, 37.43, 38.29, 39.20, # 1960-
|
99
|
-
40.18, 41.17, 42.23, 43.37, 44.49, 45.48, 46.46, 47.52, 48.53, 49.59, # 1970-
|
100
|
-
50.54, 51.38, 52.17, 52.96, 53.79, 54.34, 54.87, 55.32, 55.82, 56.30, # 1980-
|
101
|
-
56.86, 57.57, 58.31, 59.12, 59.99, 60.79, 61.63, 62.30, 62.97, 63.47, # 1990-
|
102
|
-
|
57
|
+
DeltaT = [ 63.47, # 1999
|
103
58
|
63.83, 64.09, 64.30, 64.47, 64.57, 64.69, 64.85, 65.15, 65.46, 65.78, # 2000-
|
104
59
|
66.07, 66.32, 66.60 # 2010-
|
105
60
|
]
|
@@ -116,9 +71,12 @@ module When::TimeStandard
|
|
116
71
|
#
|
117
72
|
# @return [void]
|
118
73
|
#
|
74
|
+
# @note
|
75
|
+
# 本メソッドでマルチスレッド対応の管理変数の初期化を行っている。
|
76
|
+
# このため、本メソッド自体はスレッドセーフでない。
|
77
|
+
#
|
119
78
|
def _setup_(leap_seconds=nil)
|
120
79
|
@_lock_ = Mutex.new if When.multi_thread
|
121
|
-
@_lock_.lock if @_lock_
|
122
80
|
leap_seconds ||= TAI_UTC
|
123
81
|
@leap_seconds =
|
124
82
|
if leap_seconds.kind_of?(String)
|
@@ -131,7 +89,6 @@ module When::TimeStandard
|
|
131
89
|
else
|
132
90
|
leap_seconds.reverse
|
133
91
|
end
|
134
|
-
@_lock_.unlock if @_lock_
|
135
92
|
end
|
136
93
|
|
137
94
|
# @private
|
@@ -177,34 +134,116 @@ module When::TimeStandard
|
|
177
134
|
delta_t_observed(jd_utc)
|
178
135
|
end
|
179
136
|
|
180
|
-
# ΔT - 観測による(TT-UT1)
|
137
|
+
# ΔT - 観測による(TT-UT1) mix of Table and NASA
|
181
138
|
#
|
182
139
|
# @param [Numeric] jd_utc ユリウス日(Universal Time, Coordinated)
|
183
140
|
#
|
184
141
|
# @return [Numeric] (Terrestrial Time - Universal Time 1) / second
|
185
142
|
#
|
186
143
|
def delta_t_observed(jd_utc)
|
187
|
-
|
188
|
-
year
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
144
|
+
year = (jd_utc - When::Ephemeris::EPOCH2000)/When::Ephemeris::JYEAR + 2000 # 0年からの経過世紀
|
145
|
+
return delta_t_observed_poly(year) unless 2000 <= year && year < 2050
|
146
|
+
return delta_t_observed_poly(year) + DeltaThreshold * (year - 2050.0) / (YearThreshold - 2050.0) if year >= YearThreshold
|
147
|
+
|
148
|
+
i = (year-1999.0).floor # 1999年からの経過年(整数)
|
149
|
+
n = year % 1
|
150
|
+
d0 = DeltaT[i+0] - DeltaT[i-1]
|
151
|
+
d1 = DeltaT[i+1] - DeltaT[i+0]
|
152
|
+
d2 = DeltaT[i+2] - DeltaT[i+1]
|
153
|
+
d10 = d1 - d0
|
154
|
+
d21 = d2 - d1
|
155
|
+
d210 = d21 - d10
|
156
|
+
DeltaT[i] + n*d1 + n*(n-1.0)/4.0*(d10+d21) + n*(n-1.0)*(n-0.5)/6.0*d210
|
157
|
+
end
|
158
|
+
|
159
|
+
# ΔT - 観測による(TT-UT1) from http://eclipse.gsfc.nasa.gov/SEhelp/deltatpoly2004.html
|
160
|
+
#
|
161
|
+
# @param [Numeric] jd_utc ユリウス日(Universal Time, Coordinated)
|
162
|
+
#
|
163
|
+
# @return [Numeric] (Terrestrial Time - Universal Time 1) / second
|
164
|
+
#
|
165
|
+
def delta_t_observed_nasa(jd_utc)
|
166
|
+
delta_t_observed_poly((jd_utc - When::Ephemeris::EPOCH2000)/When::Ephemeris::JYEAR + 2000.0) # 0年からの経過年
|
167
|
+
end
|
168
|
+
|
169
|
+
# 多項式による近似
|
170
|
+
def delta_t_observed_poly(year)
|
171
|
+
u = (year-1820)/100
|
172
|
+
|
173
|
+
# 2150 ... 3000
|
174
|
+
if year >= 2150
|
175
|
+
-20 + 32 * u**2
|
176
|
+
|
177
|
+
# 2050 ... 2150
|
178
|
+
elsif year >= 2050
|
179
|
+
-20 + 32 * u**2 - 0.5628 * (2150 - year)
|
180
|
+
|
181
|
+
# 2005 ... 2050
|
182
|
+
elsif year >= 2005
|
183
|
+
t = year - 2000
|
184
|
+
62.92 + 0.32217 * t + 0.005589 * t**2
|
185
|
+
|
186
|
+
# 1986 ... 2005
|
187
|
+
elsif year >= 1986
|
188
|
+
t = year - 2000
|
189
|
+
63.86 + 0.3345 * t - 0.060374 * t**2 + 0.0017275 * t**3 + 0.000651814 * t**4 + 0.00002373599 * t**5
|
190
|
+
|
191
|
+
# 1961 ... 1986
|
192
|
+
elsif year >= 1961
|
193
|
+
t = year - 1975
|
194
|
+
45.45 + 1.067*t - t**2/260 - t**3 / 718
|
195
|
+
|
196
|
+
# 1941 ... 1961
|
197
|
+
elsif year >= 1941
|
198
|
+
t = year - 1950
|
199
|
+
29.07 + 0.407*t - t**2/233 + t**3 / 2547
|
200
|
+
|
201
|
+
# 1920 ... 1941
|
202
|
+
elsif year >= 1920
|
203
|
+
t = year - 1920
|
204
|
+
21.20 + 0.84493*t - 0.076100 * t**2 + 0.0020936 * t**3
|
205
|
+
|
206
|
+
# 1900 ... 1920
|
207
|
+
elsif year >= 1900
|
208
|
+
t = year - 1900
|
209
|
+
-2.79 + 1.494119 * t - 0.0598939 * t**2 + 0.0061966 * t**3 - 0.000197 * t**4
|
210
|
+
|
211
|
+
# 1860 ... 1900
|
212
|
+
elsif year >= 1860
|
213
|
+
t = year - 1860
|
214
|
+
7.62 + 0.5737 * t - 0.251754 * t**2 + 0.01680668 * t**3 - 0.0004473624 * t**4 + t**5 / 233174
|
215
|
+
|
216
|
+
# 1800 ... 1860
|
217
|
+
elsif year >= 1800
|
218
|
+
t = year - 1800
|
219
|
+
13.72 - 0.332447 * t + 0.0068612 * t**2 + 0.0041116 * t**3 - 0.00037436 * t**4 + 0.0000121272 * t**5 - 0.0000001699 * t**6 + 0.000000000875 * t**7
|
220
|
+
|
221
|
+
# 1700 ... 1800
|
222
|
+
elsif year >= 1700
|
223
|
+
t = year - 1700
|
224
|
+
8.83 + 0.1603 * t - 0.0059285 * t**2 + 0.00013336 * t**3 - t**4 / 1174000
|
225
|
+
|
226
|
+
# 1600 ... 1700
|
227
|
+
elsif year >= 1600
|
228
|
+
t = year - 1600
|
229
|
+
120 - 0.9808 * t - 0.01532 * t**2 + t**3 / 7129
|
230
|
+
|
231
|
+
# 500 ... 1600
|
232
|
+
elsif year >= 500
|
233
|
+
u = (year - 1000) / 100
|
234
|
+
1574.2 - 556.01 * u + 71.23472 * u**2 + 0.319781 * u**3 - 0.8503463 * u**4 - 0.005050998 * u**5 + 0.0083572073 * u**6
|
235
|
+
|
236
|
+
# -500 ... 500
|
237
|
+
elsif year >= -500
|
238
|
+
u = year / 100
|
239
|
+
10583.6 - 1014.41 * u + 33.78311 * u**2 - 5.952053 * u**3 - 0.1798452 * u**4 + 0.022174192 * u**5 + 0.0090316521 * u**6
|
240
|
+
|
241
|
+
# ... -500
|
203
242
|
else
|
204
|
-
|
243
|
+
-20 + 32 * u**2
|
205
244
|
end
|
206
|
-
return dt
|
207
245
|
end
|
246
|
+
private :delta_t_observed_poly
|
208
247
|
|
209
248
|
# universal time を dynamical time に変換する
|
210
249
|
#
|
@@ -259,6 +298,12 @@ module When::TimeStandard
|
|
259
298
|
end
|
260
299
|
end
|
261
300
|
|
301
|
+
# @private
|
302
|
+
YearThreshold = 1997.0 + DeltaT.size
|
303
|
+
|
304
|
+
# @private
|
305
|
+
DeltaThreshold = DeltaT[-2] - delta_t_observed_poly(YearThreshold)
|
306
|
+
|
262
307
|
#
|
263
308
|
# 時刻系のひながた
|
264
309
|
#
|
data/lib/when_exe/tmobjects.rb
CHANGED
@@ -64,6 +64,8 @@ module When::TM
|
|
64
64
|
#
|
65
65
|
# Allen(1983) が分類した13種類の相対的な時間位置を定義している
|
66
66
|
#
|
67
|
+
# ISO19108では値は Code クラスだが、本実装では値は Symbol である
|
68
|
+
#
|
67
69
|
# see {http://schemas.opengis.net/gml/3.1.1/base/temporal.xsd#RelatedTimeType gml schema}
|
68
70
|
#
|
69
71
|
# see Allen,J.F., Maintaining Knowledge about Temporal Intervals, Communications of the ACM, 1983,vol.26 pp.832-843
|
@@ -592,6 +594,8 @@ module When::TM
|
|
592
594
|
# [ factor [Numeric] - 冪乗 ]
|
593
595
|
# [ radix [Numeric] - 冪乗の基数 ]
|
594
596
|
#
|
597
|
+
# @note value, factor, radix は Numeric
|
598
|
+
#
|
595
599
|
def self._to_array(interval)
|
596
600
|
return nil unless interval =~ /^([-+]?[\d.]+)(?:(E|X|\((\d+)\))([-+]?\d+))?([A-Za-z]+|\*([\d.]+)S)$/
|
597
601
|
value, radix, radix_quantity, factor, unit, unit_quantity = $~[1..6]
|
data/lib/when_exe/tmposition.rb
CHANGED
@@ -212,7 +212,6 @@ module When::TM
|
|
212
212
|
# @return [When::TM::ReferenceSystem]
|
213
213
|
#
|
214
214
|
attr_accessor :frame
|
215
|
-
alias :clock :frame
|
216
215
|
|
217
216
|
# この時間位置と関連付けられたイベント - additional attribute
|
218
217
|
#
|
@@ -225,6 +224,8 @@ module When::TM
|
|
225
224
|
#
|
226
225
|
# @return [Numeric]
|
227
226
|
#
|
227
|
+
# @note precision より resolution の方が分解能の意味にふさわしいが ISO19108 で別の意味に用いられているため resolution とした。
|
228
|
+
#
|
228
229
|
attr_accessor :precision
|
229
230
|
|
230
231
|
# その他の属性 - additional attribute
|
@@ -261,8 +262,8 @@ module When::TM
|
|
261
262
|
# @param [String] specification When.exe Standard Representation
|
262
263
|
# @param [Hash] options 下記の通り
|
263
264
|
# @option options [When::TM::ReferenceSystem] :frame 暦法の指定
|
264
|
-
# @option options [When::TM::Clock] :clock 時法の指定
|
265
|
-
# @option options [
|
265
|
+
# @option options [When::TM::Clock, When::V::Timezone, When::Parts::Timezone, String] :clock 時法の指定
|
266
|
+
# @option options [String] :tz 時法の指定(時間帯を指定する場合 :clock の替わりに用いることができる)
|
266
267
|
# @option options [Array<Numeric>] :abbr ISO8601上位省略形式のためのデフォルト日付(省略時 指定なし)
|
267
268
|
# @option options [String] :wkst ISO8601週日形式のための暦週開始曜日(省略時 'MO')
|
268
269
|
# @option options [Integer] :precision 生成するオブジェクトの分解能
|
@@ -282,6 +283,12 @@ module When::TM
|
|
282
283
|
# - :period => period による暦年代絞込み
|
283
284
|
# - :name => name による暦年代絞込み(epoch の attribute使用可)
|
284
285
|
#
|
286
|
+
# @note options の中身は本メソッドによって更新されることがある。
|
287
|
+
#
|
288
|
+
# @note :tz は 'Asia/Tokyo'など時間帯を表す文字列をキーにして、登録済みのWhen::V::Timezone, When::Parts::Timezoneを検索して使用する。
|
289
|
+
# :clock はWhen::TM::Clock, When::V::Timezone, When::Parts::Timezoneオブジェクトをそのまま使用するか '+09:00'などの文字列をWhen::TM::Clock化して使用する。
|
290
|
+
# :tz の方が :clock よりも優先される。
|
291
|
+
#
|
285
292
|
# @return [When::TM::TemporalPosition] ISO8601 time point
|
286
293
|
# @return [When::TM::Duration] ISO8601 duration
|
287
294
|
# @return [When::Parts::GeometricComplex] ISO8601 repeating interval
|
@@ -426,6 +433,9 @@ module When::TM
|
|
426
433
|
:era_name, :era, :abbr, :wkst, :time_standard, :location].each do |key|
|
427
434
|
main[key] = query.delete(key) if (query.key?(key))
|
428
435
|
end
|
436
|
+
long = query.delete(:long)
|
437
|
+
lat = query.delete(:lat)
|
438
|
+
main[:location] ||= "_l:long=#{long}&lat=#{lat}" if long && lat
|
429
439
|
trans = query.delete(:trans) || {}
|
430
440
|
[:lower, :upper, :count].each do |key|
|
431
441
|
trans[key] = query.delete(key) if (query.key?(key))
|
@@ -494,7 +504,6 @@ module When::TM
|
|
494
504
|
def time_standard
|
495
505
|
return @time_standard if @time_standard.kind_of?(When::TimeStandard)
|
496
506
|
@time_standard = When.Resource(@time_standard ||
|
497
|
-
(clock ? clock.time_standard : nil) ||
|
498
507
|
(frame ? frame.time_standard : nil) ||
|
499
508
|
'UniversalTime', '_t:')
|
500
509
|
end
|
@@ -605,7 +614,7 @@ module When::TM
|
|
605
614
|
# @return [::DateTime]
|
606
615
|
#
|
607
616
|
def to_date_time(option={:frame=>When.utc})
|
608
|
-
return JulianDate.dynamical_time(dynamical_time, option).to_date_time unless rate_of_clock == 1.0
|
617
|
+
return JulianDate.dynamical_time(dynamical_time, option).to_date_time unless time_standard.rate_of_clock == 1.0
|
609
618
|
raise TypeError, "Clock not assigned" unless clock
|
610
619
|
Rational
|
611
620
|
offset = Rational(-(clock.universal_time/Duration::SECOND).to_i, (Duration::DAY/Duration::SECOND).to_i)
|
@@ -621,7 +630,7 @@ module When::TM
|
|
621
630
|
# @return [::Date]
|
622
631
|
#
|
623
632
|
def to_date(option={})
|
624
|
-
return JulianDate.dynamical_time(dynamical_time, option).to_date unless rate_of_clock == 1.0
|
633
|
+
return JulianDate.dynamical_time(dynamical_time, option).to_date unless time_standard.rate_of_clock == 1.0
|
625
634
|
::Date.jd(to_i, ::Date::GREGORIAN)
|
626
635
|
end
|
627
636
|
|
@@ -671,7 +680,7 @@ module When::TM
|
|
671
680
|
#
|
672
681
|
def -(other)
|
673
682
|
case other
|
674
|
-
when TimeValue ; self.rate_of_clock == other.rate_of_clock && [@precision, other.precision].min <= When::DAY ?
|
683
|
+
when TimeValue ; self.time_standard.rate_of_clock == other.time_standard.rate_of_clock && [@precision, other.precision].min <= When::DAY ?
|
675
684
|
PeriodDuration.new(self.to_i - other.to_i, When::DAY) :
|
676
685
|
IntervalLength.new((self.dynamical_time - other.dynamical_time) / Duration::SECOND, 'second')
|
677
686
|
when Integer ; self - PeriodDuration.new(other, When::DAY)
|
@@ -1033,6 +1042,14 @@ module When::TM
|
|
1033
1042
|
end
|
1034
1043
|
end
|
1035
1044
|
|
1045
|
+
# この時間位置と関連付けられた時間参照系 (relation - Reference)
|
1046
|
+
#
|
1047
|
+
# The time reference system associated with the temporal position being described
|
1048
|
+
#
|
1049
|
+
# @return [When::TM::ReferenceSystem]
|
1050
|
+
#
|
1051
|
+
alias :clock :frame
|
1052
|
+
|
1036
1053
|
# 内部時間による時間座標値
|
1037
1054
|
#
|
1038
1055
|
# @return [Numeric]
|
@@ -1223,9 +1240,19 @@ module When::TM
|
|
1223
1240
|
#
|
1224
1241
|
# @return [Array<Numeric>]
|
1225
1242
|
#
|
1243
|
+
# @note ISO19108 では sequence<Integer> だが、閏時・閏秒などが表現可能なよう Numeric としている。
|
1244
|
+
#
|
1226
1245
|
attr_reader :clk_time
|
1227
1246
|
alias :clkTime :clk_time
|
1228
1247
|
|
1248
|
+
# この時間位置と関連付けられた時間参照系 (relation - Reference)
|
1249
|
+
#
|
1250
|
+
# The time reference system associated with the temporal position being described
|
1251
|
+
#
|
1252
|
+
# @return [When::TM::ReferenceSystem]
|
1253
|
+
#
|
1254
|
+
alias :clock :frame
|
1255
|
+
|
1229
1256
|
# 内部時間
|
1230
1257
|
#
|
1231
1258
|
# @return [Numeric]
|
@@ -1346,9 +1373,19 @@ module When::TM
|
|
1346
1373
|
#
|
1347
1374
|
# @return [Array<Numeric>]
|
1348
1375
|
#
|
1376
|
+
# @note ISO19108 では sequence<Integer> だが、閏月などが表現可能なよう Numeric としている。
|
1377
|
+
#
|
1349
1378
|
attr_reader :cal_date
|
1350
1379
|
alias :calDate :cal_date
|
1351
1380
|
|
1381
|
+
# この時間位置と関連付けられた時間参照系 (relation - Reference)
|
1382
|
+
#
|
1383
|
+
# The time reference system associated with the temporal position being described
|
1384
|
+
#
|
1385
|
+
# @return [When::TM::ReferenceSystem]
|
1386
|
+
#
|
1387
|
+
alias :calendar :frame
|
1388
|
+
|
1352
1389
|
# 暦年代名
|
1353
1390
|
#
|
1354
1391
|
# @return [Array] ( name, epoch, reverse, go back )
|
@@ -1790,7 +1827,6 @@ module When::TM
|
|
1790
1827
|
|
1791
1828
|
# 下位桁の切り上げ
|
1792
1829
|
#
|
1793
|
-
# digit : Integer
|
1794
1830
|
# @param [Integer] digit 切り上げずに残す、最下位の桁
|
1795
1831
|
#
|
1796
1832
|
# @param [Integer] precision 切り上げ結果の分解能
|
@@ -1806,6 +1842,17 @@ module When::TM
|
|
1806
1842
|
return result
|
1807
1843
|
end
|
1808
1844
|
|
1845
|
+
# 位置情報
|
1846
|
+
#
|
1847
|
+
# @return [When::Coordinates::Spatial]
|
1848
|
+
#
|
1849
|
+
def location
|
1850
|
+
return @location if @location
|
1851
|
+
timezone = @clk_time.frame.tz_prop
|
1852
|
+
return nil unless timezone.kind_of?(When::Parts::Timezone)
|
1853
|
+
@location = When.Resource("_l:long=#{timezone.longitude.to_f}&lat=#{timezone.latitude.to_f}")
|
1854
|
+
end
|
1855
|
+
|
1809
1856
|
# 時刻情報のない When::TM::CalDate を返す
|
1810
1857
|
#
|
1811
1858
|
# @return [When::TM::CalDate]
|
@@ -1833,7 +1880,7 @@ module When::TM
|
|
1833
1880
|
case options[:time]
|
1834
1881
|
when Array
|
1835
1882
|
if clock._need_validate
|
1836
|
-
new_clock = clock._daylight { |c| self.class.new(options[:date], options[:time], {:frame=>@frame, :clock=>c}) }
|
1883
|
+
new_clock = clock._daylight { |c| self.class.new(options[:date], options[:time], {:frame=>@frame, :clock=>c}) }
|
1837
1884
|
options[:time] = options[:time].map {|t| t * 1}
|
1838
1885
|
else
|
1839
1886
|
new_clock = clock
|
@@ -1911,7 +1958,13 @@ module When::TM
|
|
1911
1958
|
|
1912
1959
|
# 夏時間の調整
|
1913
1960
|
if clock._need_validate
|
1914
|
-
|
1961
|
+
if @calendar_era_name
|
1962
|
+
cal_date = @cal_date.dup
|
1963
|
+
cal_date[0] += @calendar_era_name[1]
|
1964
|
+
else
|
1965
|
+
cal_date = @cal_date
|
1966
|
+
end
|
1967
|
+
clock = clock._daylight {|clock| self.class.new(cal_date, time, {:frame=>@frame, :clock=>clock}) }
|
1915
1968
|
end
|
1916
1969
|
time = time.map {|t| t * 1}
|
1917
1970
|
@clk_time = ClockTime.new(time, {:frame=>clock, :precision=>precision, :validate=>:done}) if clock_is_timezone
|
data/lib/when_exe/tmreference.rb
CHANGED
@@ -26,6 +26,11 @@ module When::TM
|
|
26
26
|
# @return [When::EX::Extent]
|
27
27
|
#
|
28
28
|
# @note
|
29
|
+
# domain の最小・最大から範囲を決定して domain_of_validity としている
|
30
|
+
# domain_of_validity は ISO19108との互換性を確保するため提供しているが、
|
31
|
+
# 有効期間が複数に断片化していることがあるので、より正確な情報を含む
|
32
|
+
# domain の使用を推奨する
|
33
|
+
#
|
29
34
|
# マルチスレッド動作時 CalendarEra の生成で Calendar の本属性が更新される
|
30
35
|
# 参照・更新処理は synchronize { ... } の ... の部分に書く必要がある
|
31
36
|
#
|
@@ -80,6 +85,11 @@ module When::TM
|
|
80
85
|
#
|
81
86
|
alias :component :child
|
82
87
|
|
88
|
+
private
|
89
|
+
|
90
|
+
# オブジェクトの正規化
|
91
|
+
def _normalize(args=[], options={})
|
92
|
+
end
|
83
93
|
end
|
84
94
|
|
85
95
|
# 暦
|
@@ -95,11 +105,13 @@ module When::TM
|
|
95
105
|
#
|
96
106
|
# @return [void]
|
97
107
|
#
|
108
|
+
# @note
|
109
|
+
# 本メソッドでマルチスレッド対応の管理変数の初期化を行っている。
|
110
|
+
# このため、本メソッド自体はスレッドセーフでない。
|
111
|
+
#
|
98
112
|
def self._setup_
|
99
113
|
@_lock_ = Mutex.new if When.multi_thread
|
100
|
-
@_lock_.lock if @_lock_
|
101
114
|
@_pool = {}
|
102
|
-
@_lock_.unlock if @_lock_
|
103
115
|
end
|
104
116
|
|
105
117
|
# この暦と関連付けられた暦年代 (relation - Basis)
|
@@ -172,7 +184,7 @@ module When::TM
|
|
172
184
|
cal_options = jdt._attr
|
173
185
|
cal_options.delete(:era_name)
|
174
186
|
cal_options.delete(:era)
|
175
|
-
unless rate_of_clock == jdt.rate_of_clock
|
187
|
+
unless rate_of_clock == jdt.time_standard.rate_of_clock
|
176
188
|
cal_options.delete(:time_standard)
|
177
189
|
cal_options[:clock] = @time_basis || When.utc
|
178
190
|
jdt = JulianDate.dynamical_time(jdt.dynamical_time, {:time_standard=>time_standard})
|
@@ -253,7 +265,7 @@ module When::TM
|
|
253
265
|
# オブジェクトの正規化
|
254
266
|
def _normalize(args=[], options={})
|
255
267
|
@time_basis = When.Calendar(@time_basis) if @time_basis.kind_of?(String)
|
256
|
-
@indices ||=
|
268
|
+
@indices ||= DefaultDateIndices
|
257
269
|
_normalize_temporal
|
258
270
|
@reference_frame ||= []
|
259
271
|
end
|
@@ -292,12 +304,14 @@ module When::TM
|
|
292
304
|
#
|
293
305
|
# @return [void]
|
294
306
|
#
|
307
|
+
# @note
|
308
|
+
# 本メソッドでマルチスレッド対応の管理変数の初期化を行っている。
|
309
|
+
# このため、本メソッド自体はスレッドセーフでない。
|
310
|
+
#
|
295
311
|
def _setup_(local=nil)
|
296
312
|
@_lock_ = Mutex.new if When.multi_thread
|
297
|
-
@_lock_.lock if @_lock_
|
298
313
|
@_pool = {}
|
299
314
|
@local_time = local
|
300
|
-
@_lock_.unlock if @_lock_
|
301
315
|
end
|
302
316
|
|
303
317
|
# @private
|
@@ -643,7 +657,7 @@ module When::TM
|
|
643
657
|
|
644
658
|
# オブジェクトの正規化
|
645
659
|
def _normalize(args=[], options={})
|
646
|
-
@indices ||=
|
660
|
+
@indices ||= DefaultTimeIndices
|
647
661
|
|
648
662
|
# note
|
649
663
|
@note ||= 'JulianDayNotes'
|
@@ -868,12 +882,14 @@ module When::TM
|
|
868
882
|
#
|
869
883
|
# @return [void]
|
870
884
|
#
|
885
|
+
# @note
|
886
|
+
# 本メソッドでマルチスレッド対応の管理変数の初期化を行っている。
|
887
|
+
# このため、本メソッド自体はスレッドセーフでない。
|
888
|
+
#
|
871
889
|
def _setup_(order=nil)
|
872
890
|
@_lock_ = Mutex.new if When.multi_thread
|
873
|
-
@_lock_.lock if @_lock_
|
874
891
|
@_pool = {}
|
875
892
|
@order = order || DefaultEpochs
|
876
|
-
@_lock_.unlock if @_lock_
|
877
893
|
end
|
878
894
|
|
879
895
|
# When::TM::CalendarEra オブジェクトを検索し取得する
|
@@ -889,6 +905,9 @@ module When::TM
|
|
889
905
|
# @option options [String] the_others 例えば When::TM::CalendarEra オブジェクトの epoch_of_use に 'name' などの
|
890
906
|
# 指定がある場合、:name に指定しておけば、検索での絞り込みに使用できる。
|
891
907
|
#
|
908
|
+
# @note 検索用のインデクスはインスタンスの生成時に作成する。
|
909
|
+
# 作成後にキーワードとなる年号(M17nクラス)にローケールが追加されても反映されない。
|
910
|
+
#
|
892
911
|
def _instance(*args)
|
893
912
|
# パラメータ
|
894
913
|
args = args.dup
|
@@ -1030,6 +1049,7 @@ module When::TM
|
|
1030
1049
|
# @note
|
1031
1050
|
# 途中の改暦を指定するために要素が必要になることがあり、要素数が2を超えることがある。
|
1032
1051
|
# 最初の要素が When::TimeValue::MIN(-Infinity)の場合、年数を降順にカウントする。
|
1052
|
+
# 暦年代の分解能を“日”より細かくすることはできない。
|
1033
1053
|
#
|
1034
1054
|
attr_reader :epoch
|
1035
1055
|
|
@@ -1109,7 +1129,7 @@ module When::TM
|
|
1109
1129
|
# @return [Numeric]
|
1110
1130
|
#
|
1111
1131
|
def rate_of_clock
|
1112
|
-
_typical_epoch.rate_of_clock
|
1132
|
+
_typical_epoch.time_standard.rate_of_clock
|
1113
1133
|
end
|
1114
1134
|
|
1115
1135
|
# 当該の暦年代の日付に変換する
|
@@ -1313,8 +1333,8 @@ module When::TM
|
|
1313
1333
|
f.reference_frame << self
|
1314
1334
|
f.reference_frame.uniq!
|
1315
1335
|
f.reference_frame.sort!
|
1316
|
-
first = f.domain.first(When
|
1317
|
-
last = f.domain.last(When
|
1336
|
+
first = f.domain.first(When::MinusInfinity)
|
1337
|
+
last = f.domain.last(When::PlusInfinity)
|
1318
1338
|
f.domain_of_validity = When::EX::Extent.new(
|
1319
1339
|
When::TM::Period.new(
|
1320
1340
|
When::TM::Instant.new(first),
|
@@ -1405,6 +1425,7 @@ module When::TM
|
|
1405
1425
|
# reference_event
|
1406
1426
|
@reference_event = reference_event if reference_event
|
1407
1427
|
@reference_event ||= ""
|
1428
|
+
@reference_event = DefaultEvents[@reference_event] if DefaultEvents[@reference_event]
|
1408
1429
|
@reference_event = m17n(@reference_event, nil, nil, term_options) if @reference_event.instance_of?(String)
|
1409
1430
|
@reference_event._pool['..'] ||= self
|
1410
1431
|
@_pool[@reference_event.to_s] = @reference_event
|
@@ -1505,7 +1526,7 @@ module When::TM
|
|
1505
1526
|
end
|
1506
1527
|
|
1507
1528
|
def _trans_date(date, clock=nil)
|
1508
|
-
unless rate_of_clock == date.rate_of_clock
|
1529
|
+
unless rate_of_clock == date.time_standard.rate_of_clock
|
1509
1530
|
date = JulianDate.dynamical_time(date.dynamical_time, {:time_standard=>_typical_epoch.time_standard})
|
1510
1531
|
clock = _typical_epoch.clock
|
1511
1532
|
end
|