when_exe 0.3.6 → 0.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/README.md +171 -0
- data/lib/when_exe.rb +78 -47
- data/lib/when_exe/basictypes.rb +752 -747
- data/lib/when_exe/calendarnote.rb +805 -801
- data/lib/when_exe/calendartypes.rb +1583 -1531
- data/lib/when_exe/coordinates.rb +16 -15
- data/lib/when_exe/core/duration.rb +114 -110
- data/lib/when_exe/core/extension.rb +504 -504
- data/lib/when_exe/ephemeris.rb +1917 -1913
- data/lib/when_exe/ephemeris/moon.rb +333 -333
- data/lib/when_exe/ephemeris/notes.rb +389 -387
- data/lib/when_exe/ephemeris/planets.rb +585 -585
- data/lib/when_exe/ephemeris/sun.rb +214 -214
- data/lib/when_exe/googlecalendar.rb +144 -140
- data/lib/when_exe/icalendar.rb +1636 -1636
- data/lib/when_exe/inspect.rb +46 -22
- data/lib/when_exe/locales/akt.rb +176 -176
- data/lib/when_exe/locales/encoding_conversion.rb +134 -126
- data/lib/when_exe/locales/iast.rb +90 -90
- data/lib/when_exe/locales/locale.rb +750 -746
- data/lib/when_exe/locales/transliteration_table.rb +62 -62
- data/lib/when_exe/mini_application.rb +307 -305
- data/lib/when_exe/parts/enumerator.rb +2 -2
- data/lib/when_exe/parts/geometric_complex.rb +397 -397
- data/lib/when_exe/parts/method_cash.rb +224 -224
- data/lib/when_exe/parts/resource.rb +1069 -1071
- data/lib/when_exe/parts/timezone.rb +240 -230
- data/lib/when_exe/region/armenian.rb +56 -56
- data/lib/when_exe/region/babylonian.rb +405 -0
- data/lib/when_exe/region/bahai.rb +146 -146
- data/lib/when_exe/region/balinese.rb +622 -622
- data/lib/when_exe/region/chinese.rb +95 -25
- data/lib/when_exe/region/chinese/calendars.rb +1016 -1016
- data/lib/when_exe/region/chinese/epochs.rb +1 -1
- data/lib/when_exe/region/chinese/twins.rb +803 -795
- data/lib/when_exe/region/christian.rb +824 -824
- data/lib/when_exe/region/coptic.rb +106 -87
- data/lib/when_exe/region/discordian.rb +225 -225
- data/lib/when_exe/region/far_east.rb +188 -188
- data/lib/when_exe/region/french.rb +56 -56
- data/lib/when_exe/region/geologicalage.rb +639 -639
- data/lib/when_exe/region/goddess.rb +58 -58
- data/lib/when_exe/region/indian.rb +1254 -1251
- data/lib/when_exe/region/iranian.rb +8 -8
- data/lib/when_exe/region/islamic.rb +3 -3
- data/lib/when_exe/region/japanese.rb +93 -99
- data/lib/when_exe/region/japanese/calendars.rb +396 -397
- data/lib/when_exe/region/japanese/epochs.rb +26 -26
- data/lib/when_exe/region/japanese/nihon_shoki.rb +71 -71
- data/lib/when_exe/region/japanese/notes.rb +1383 -1386
- data/lib/when_exe/region/japanese/residues.rb +1306 -1306
- data/lib/when_exe/region/japanese/twins.rb +225 -225
- data/lib/when_exe/region/japanese/weeks.rb +112 -0
- data/lib/when_exe/region/javanese.rb +230 -230
- data/lib/when_exe/region/jewish.rb +126 -126
- data/lib/when_exe/region/korean.rb +378 -378
- data/lib/when_exe/region/m17n.rb +114 -113
- data/lib/when_exe/region/martian.rb +258 -255
- data/lib/when_exe/region/mayan.rb +32 -32
- data/lib/when_exe/region/residue.rb +89 -89
- data/lib/when_exe/region/roman.rb +36 -24
- data/lib/when_exe/region/ryukyu.rb +97 -97
- data/lib/when_exe/region/shire.rb +240 -240
- data/lib/when_exe/region/soviet.rb +209 -0
- data/lib/when_exe/region/symmetry.rb +50 -50
- data/lib/when_exe/region/thai.rb +336 -335
- data/lib/when_exe/region/tibetan.rb +316 -315
- data/lib/when_exe/region/vietnamese.rb +440 -439
- data/lib/when_exe/region/weekdate.rb +80 -80
- data/lib/when_exe/region/world.rb +175 -175
- data/lib/when_exe/region/yerm.rb +14 -14
- data/lib/when_exe/region/zoroastrian.rb +203 -203
- data/lib/when_exe/timestandard.rb +707 -681
- data/lib/when_exe/tmduration.rb +338 -330
- data/lib/when_exe/tmobjects.rb +1346 -1325
- data/lib/when_exe/tmposition.rb +2115 -2072
- data/lib/when_exe/tmreference.rb +1693 -1669
- data/lib/when_exe/version.rb +1 -1
- data/link_to_online_documents +1 -1
- data/test/examples/JapanHolidaysRFC6350.ics +1 -1
- data/test/test.rb +67 -61
- data/test/test/basictypes.rb +409 -409
- data/test/test/calendarnote.rb +86 -69
- data/test/test/calendartypes.rb +97 -97
- data/test/test/coordinates.rb +396 -396
- data/test/test/ephemeris.rb +83 -74
- data/test/test/ephemeris/moon.rb +14 -14
- data/test/test/ephemeris/planets.rb +14 -14
- data/test/test/ephemeris/sun.rb +14 -14
- data/test/test/googlecalendar.rb +194 -176
- data/test/test/icalendar.rb +867 -858
- data/test/test/inspect.rb +117 -117
- data/test/test/parts.rb +487 -487
- data/test/test/region/balinese.rb +34 -0
- data/test/test/region/chinese.rb +218 -206
- data/test/test/region/christian.rb +245 -245
- data/test/test/region/coptic.rb +27 -27
- data/test/test/region/french.rb +33 -33
- data/test/test/region/geologicalage.rb +17 -17
- data/test/test/region/indian.rb +57 -57
- data/test/test/region/iran.rb +54 -54
- data/test/test/region/islamic.rb +18 -18
- data/test/test/region/japanese.rb +237 -219
- data/test/test/region/jewish.rb +61 -61
- data/test/test/region/m17n.rb +184 -184
- data/test/test/region/mayan.rb +195 -195
- data/test/test/region/residue.rb +147 -139
- data/test/test/region/thai.rb +116 -116
- data/test/test/region/tibetan.rb +30 -30
- data/test/test/region/vietnamese.rb +102 -102
- data/test/test/region/yerm.rb +146 -146
- data/test/test/timestandard.rb +81 -81
- data/test/test/tmobjects.rb +328 -328
- data/test/test/tmposition.rb +397 -284
- data/test/test/tmreference.rb +157 -157
- metadata +13 -10
|
@@ -1,214 +1,214 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
=begin
|
|
3
|
-
Copyright (C) 2011-2013 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
|
-
module Ephemeris
|
|
10
|
-
|
|
11
|
-
#------------------------------------------
|
|
12
|
-
# 太陽・地球 位置計算用データ
|
|
13
|
-
#------------------------------------------
|
|
14
|
-
|
|
15
|
-
# 太陽の地心黄経
|
|
16
|
-
# @private
|
|
17
|
-
P3L =
|
|
18
|
-
[[LIN , 279.0357964 , 360.007693787, 3.02500E-8],
|
|
19
|
-
[SIN , 353.06 , 719.981008 , 0.02009 ,-2.98832E-8],
|
|
20
|
-
[SIN , 248.64 , -19.34136 , -0.0048 ],
|
|
21
|
-
[SIN , 285.0 , 329.6446699, 0.0020 ,+8.0E-9 ],
|
|
22
|
-
[SIN , 334.2 , -4452.671109 , 0.0018 ,-0.1634E-6 ],
|
|
23
|
-
|
|
24
|
-
[SIN , 293.7 , -0.2020 , 0.00178 ],
|
|
25
|
-
[SIN , 242.4 , 450.3688 , 0.0015 ,+1.4E-9 ],
|
|
26
|
-
[SIN , 211.1 , 225.1844 , 0.0013 ,+0.7E-9 ],
|
|
27
|
-
[SIN , 208.0 , 659.2893 , 0.0008 ,+1.6E-8 ],
|
|
28
|
-
[SIN , 53.5 , 90.3783 , 0.0007 ],
|
|
29
|
-
|
|
30
|
-
[SIN , 12.1 , -30.35 , 0.0007 ],
|
|
31
|
-
[SIN , 239.1 , 337.18 , 0.0006 ],
|
|
32
|
-
[SIN , 10.1 , -1.50 , 0.0005 ],
|
|
33
|
-
[SIN , 99.1 , -22.81 , 0.0005 ],
|
|
34
|
-
[SIN , 264.8 , 315.56 , 0.0004 ],
|
|
35
|
-
|
|
36
|
-
[SIN , 233.8 , 299.30 , 0.0004 ],
|
|
37
|
-
[SIN , 198.1 , 720.02 , -0.0004 ],
|
|
38
|
-
[SIN , 349.6 , 1079.97 , 0.0003 ],
|
|
39
|
-
[SIN , 241.2 , -44.43 , 0.0003 ]]
|
|
40
|
-
# [SIN , 65.0 , -44.43 , 0.0003 ]], 旧版
|
|
41
|
-
# 太陽の動径の対数
|
|
42
|
-
# @private
|
|
43
|
-
P3Q =
|
|
44
|
-
[[COS , 356.53 , 359.990504 , -0.007261 ,-1.49416E-8],
|
|
45
|
-
[COST , 356.53 , 359.990504 , 0.0000002,-1.49416E-8],
|
|
46
|
-
[COS , 353.1 , 719.981008 , -0.000091 ,-2.98832E-8],
|
|
47
|
-
[COS , 205.8 , 4452.671109 , 0.000013 ,-0.1634E-6 ],
|
|
48
|
-
[COS , 62.0 , 450.4 , 0.000007 ,+1.4E-9 ],
|
|
49
|
-
[COS , 105.0 , 329.6 , 0.000007 ,+8.0E-9 ]]
|
|
50
|
-
|
|
51
|
-
#
|
|
52
|
-
# The Sun
|
|
53
|
-
#
|
|
54
|
-
class Sun < Datum
|
|
55
|
-
|
|
56
|
-
# @private
|
|
57
|
-
Radius = 696000.0
|
|
58
|
-
|
|
59
|
-
class << self
|
|
60
|
-
|
|
61
|
-
include Ephemeris
|
|
62
|
-
|
|
63
|
-
S0=[356.531, 359.990504, -1.49416E-8] # 太陽の中心差の位相
|
|
64
|
-
S1=[ 1.9159, -4.8E-5 , -1.44444E-9] # 太陽の中心差の振幅
|
|
65
|
-
|
|
66
|
-
# 視黄経 / CIRCLE
|
|
67
|
-
#
|
|
68
|
-
# @param [Numeric] t ユリウス日(Terrestrial Time)
|
|
69
|
-
# @param [When::TM::TemporalPosition] t
|
|
70
|
-
#
|
|
71
|
-
# @return [Numeric]
|
|
72
|
-
#
|
|
73
|
-
def true_longitude(t)
|
|
74
|
-
y = julian_year_from_1975(+t)
|
|
75
|
-
return (sind(S0[0]+y*(S0[1]+y*S0[2]))*(S1[0]+y*(S1[1]+y*S1[2])) +
|
|
76
|
-
trigonometric(y, P3L)) / 360.0 + 1974.0
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
# 距離 / AU
|
|
80
|
-
#
|
|
81
|
-
# @param [Numeric] t ユリウス日(Terrestrial Time)
|
|
82
|
-
# @param [When::TM::TemporalPosition] t
|
|
83
|
-
#
|
|
84
|
-
# @return [Numeric]
|
|
85
|
-
#
|
|
86
|
-
def pi(t)
|
|
87
|
-
return 10.0**(0.000030+trigonometric(julian_year_from_1975(+t), P3Q))
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
# 平均黄経 / CIRCLE
|
|
91
|
-
#
|
|
92
|
-
# @param [Numeric] t ユリウス日(Terrestrial Time)
|
|
93
|
-
# @param [When::TM::TemporalPosition] t
|
|
94
|
-
#
|
|
95
|
-
# @return [Numeric]
|
|
96
|
-
#
|
|
97
|
-
def mean_longitude(t)
|
|
98
|
-
return trigonometric(julian_year_from_1975(+t), P3L, 0.0, 1) / 360.0 + 1974.0
|
|
99
|
-
end
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
# 位置 (黄道座標)
|
|
103
|
-
#
|
|
104
|
-
# @param [Numeric] t ユリウス日(Terrestrial Time)
|
|
105
|
-
# @param [When::TM::TemporalPosition] t
|
|
106
|
-
#
|
|
107
|
-
# @return [When::Ephemeris::Coords]
|
|
108
|
-
#
|
|
109
|
-
def _coords(t)
|
|
110
|
-
Coords.polar(0, 0, 0, 0)
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
# 視黄経 / CIRCLE
|
|
114
|
-
#
|
|
115
|
-
# @param [Numeric] t ユリウス日(Terrestrial Time)
|
|
116
|
-
# @param [When::TM::TemporalPosition] t
|
|
117
|
-
#
|
|
118
|
-
# @return [0]
|
|
119
|
-
#
|
|
120
|
-
def true_longitude(t)
|
|
121
|
-
0
|
|
122
|
-
end
|
|
123
|
-
|
|
124
|
-
# 平均黄経 / CIRCLE
|
|
125
|
-
#
|
|
126
|
-
# @param [Numeric] t ユリウス日(Terrestrial Time)
|
|
127
|
-
# @param [When::TM::TemporalPosition] t
|
|
128
|
-
#
|
|
129
|
-
# @return [0]
|
|
130
|
-
#
|
|
131
|
-
def mean_longitude(t)
|
|
132
|
-
0
|
|
133
|
-
end
|
|
134
|
-
|
|
135
|
-
# 平均運動 / (DEG/YEAR)
|
|
136
|
-
#
|
|
137
|
-
# @param [Numeric] t ユリウス日(Terrestrial Time)
|
|
138
|
-
# @param [When::TM::TemporalPosition] t
|
|
139
|
-
#
|
|
140
|
-
# @return [0]
|
|
141
|
-
#
|
|
142
|
-
def mean_motion
|
|
143
|
-
0
|
|
144
|
-
end
|
|
145
|
-
|
|
146
|
-
# オブジェクトの生成
|
|
147
|
-
# @private
|
|
148
|
-
def initialize(*args)
|
|
149
|
-
options = [args.pop] if args[-1].kind_of?(Hash)
|
|
150
|
-
surface_radius, aberration, luminosity, *rest = args
|
|
151
|
-
surface_radius ||= Radius
|
|
152
|
-
aberration ||= 0.00000
|
|
153
|
-
luminosity ||= 4.58
|
|
154
|
-
args = [surface_radius, aberration, luminosity] + rest
|
|
155
|
-
args += options if options
|
|
156
|
-
super(*args)
|
|
157
|
-
end
|
|
158
|
-
end
|
|
159
|
-
|
|
160
|
-
#
|
|
161
|
-
# The Earth
|
|
162
|
-
#
|
|
163
|
-
class Earth < Datum
|
|
164
|
-
|
|
165
|
-
# 地球の位置 (黄道座標)
|
|
166
|
-
#
|
|
167
|
-
# @param [Numeric] t ユリウス日(Terrestrial Time)
|
|
168
|
-
# @param [When::TM::TemporalPosition] t
|
|
169
|
-
#
|
|
170
|
-
# @return [When::Ephemeris::Coords]
|
|
171
|
-
#
|
|
172
|
-
def _coords(t)
|
|
173
|
-
t = +t
|
|
174
|
-
radius = Sun.pi(t)
|
|
175
|
-
dl = 0.5 + @aberration / radius / 360 # 略算式に含まれる光行差をキャンセルする
|
|
176
|
-
Coords.polar(Sun.true_longitude(t)+dl, 0, radius, Sun.mean_longitude(t)+dl)
|
|
177
|
-
end
|
|
178
|
-
|
|
179
|
-
# 地球の平均運動 / (DEG/YEAR)
|
|
180
|
-
#
|
|
181
|
-
# @return [Numeric]
|
|
182
|
-
#
|
|
183
|
-
def mean_motion
|
|
184
|
-
P3L[0][2]
|
|
185
|
-
end
|
|
186
|
-
|
|
187
|
-
# オブジェクトの生成
|
|
188
|
-
# @private
|
|
189
|
-
def initialize(*args)
|
|
190
|
-
options = {
|
|
191
|
-
'shape' => [0.998327112, +0.001676399, -0.000003519, -11.514/60.0],
|
|
192
|
-
'sid' => [6.697375, 2400.0513369, 0.0000259],
|
|
193
|
-
'zeros' => {'Z'=>0, 'A'=>-0.58555, '0'=>-0.85255, 'T'=>-7.36111},
|
|
194
|
-
'air' => [10.0, 0.40, 20.0]
|
|
195
|
-
}
|
|
196
|
-
options.update(args.pop) if args[-1].kind_of?(Hash)
|
|
197
|
-
surface_radius, aberration, luminosity, *rest = args
|
|
198
|
-
surface_radius ||= 6378.14
|
|
199
|
-
aberration ||= 0.0056932
|
|
200
|
-
luminosity ||= -3.50
|
|
201
|
-
args = [surface_radius, aberration, luminosity] + rest + [options]
|
|
202
|
-
super(*args)
|
|
203
|
-
end
|
|
204
|
-
end
|
|
205
|
-
|
|
206
|
-
#
|
|
207
|
-
# Typical Geometrical Datum
|
|
208
|
-
#
|
|
209
|
-
# provisionally same as When::Ephemeris::Earth
|
|
210
|
-
#
|
|
211
|
-
class JGD2000 < Earth # TODO
|
|
212
|
-
end
|
|
213
|
-
end
|
|
214
|
-
end
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
=begin
|
|
3
|
+
Copyright (C) 2011-2013 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
|
+
module Ephemeris
|
|
10
|
+
|
|
11
|
+
#------------------------------------------
|
|
12
|
+
# 太陽・地球 位置計算用データ
|
|
13
|
+
#------------------------------------------
|
|
14
|
+
|
|
15
|
+
# 太陽の地心黄経
|
|
16
|
+
# @private
|
|
17
|
+
P3L =
|
|
18
|
+
[[LIN , 279.0357964 , 360.007693787, 3.02500E-8],
|
|
19
|
+
[SIN , 353.06 , 719.981008 , 0.02009 ,-2.98832E-8],
|
|
20
|
+
[SIN , 248.64 , -19.34136 , -0.0048 ],
|
|
21
|
+
[SIN , 285.0 , 329.6446699, 0.0020 ,+8.0E-9 ],
|
|
22
|
+
[SIN , 334.2 , -4452.671109 , 0.0018 ,-0.1634E-6 ],
|
|
23
|
+
|
|
24
|
+
[SIN , 293.7 , -0.2020 , 0.00178 ],
|
|
25
|
+
[SIN , 242.4 , 450.3688 , 0.0015 ,+1.4E-9 ],
|
|
26
|
+
[SIN , 211.1 , 225.1844 , 0.0013 ,+0.7E-9 ],
|
|
27
|
+
[SIN , 208.0 , 659.2893 , 0.0008 ,+1.6E-8 ],
|
|
28
|
+
[SIN , 53.5 , 90.3783 , 0.0007 ],
|
|
29
|
+
|
|
30
|
+
[SIN , 12.1 , -30.35 , 0.0007 ],
|
|
31
|
+
[SIN , 239.1 , 337.18 , 0.0006 ],
|
|
32
|
+
[SIN , 10.1 , -1.50 , 0.0005 ],
|
|
33
|
+
[SIN , 99.1 , -22.81 , 0.0005 ],
|
|
34
|
+
[SIN , 264.8 , 315.56 , 0.0004 ],
|
|
35
|
+
|
|
36
|
+
[SIN , 233.8 , 299.30 , 0.0004 ],
|
|
37
|
+
[SIN , 198.1 , 720.02 , -0.0004 ],
|
|
38
|
+
[SIN , 349.6 , 1079.97 , 0.0003 ],
|
|
39
|
+
[SIN , 241.2 , -44.43 , 0.0003 ]]
|
|
40
|
+
# [SIN , 65.0 , -44.43 , 0.0003 ]], 旧版
|
|
41
|
+
# 太陽の動径の対数
|
|
42
|
+
# @private
|
|
43
|
+
P3Q =
|
|
44
|
+
[[COS , 356.53 , 359.990504 , -0.007261 ,-1.49416E-8],
|
|
45
|
+
[COST , 356.53 , 359.990504 , 0.0000002,-1.49416E-8],
|
|
46
|
+
[COS , 353.1 , 719.981008 , -0.000091 ,-2.98832E-8],
|
|
47
|
+
[COS , 205.8 , 4452.671109 , 0.000013 ,-0.1634E-6 ],
|
|
48
|
+
[COS , 62.0 , 450.4 , 0.000007 ,+1.4E-9 ],
|
|
49
|
+
[COS , 105.0 , 329.6 , 0.000007 ,+8.0E-9 ]]
|
|
50
|
+
|
|
51
|
+
#
|
|
52
|
+
# The Sun
|
|
53
|
+
#
|
|
54
|
+
class Sun < Datum
|
|
55
|
+
|
|
56
|
+
# @private
|
|
57
|
+
Radius = 696000.0
|
|
58
|
+
|
|
59
|
+
class << self
|
|
60
|
+
|
|
61
|
+
include Ephemeris
|
|
62
|
+
|
|
63
|
+
S0=[356.531, 359.990504, -1.49416E-8] # 太陽の中心差の位相
|
|
64
|
+
S1=[ 1.9159, -4.8E-5 , -1.44444E-9] # 太陽の中心差の振幅
|
|
65
|
+
|
|
66
|
+
# 視黄経 / CIRCLE
|
|
67
|
+
#
|
|
68
|
+
# @param [Numeric] t ユリウス日(Terrestrial Time)
|
|
69
|
+
# @param [When::TM::TemporalPosition] t
|
|
70
|
+
#
|
|
71
|
+
# @return [Numeric]
|
|
72
|
+
#
|
|
73
|
+
def true_longitude(t)
|
|
74
|
+
y = julian_year_from_1975(+t)
|
|
75
|
+
return (sind(S0[0]+y*(S0[1]+y*S0[2]))*(S1[0]+y*(S1[1]+y*S1[2])) +
|
|
76
|
+
trigonometric(y, P3L)) / 360.0 + 1974.0
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# 距離 / AU
|
|
80
|
+
#
|
|
81
|
+
# @param [Numeric] t ユリウス日(Terrestrial Time)
|
|
82
|
+
# @param [When::TM::TemporalPosition] t
|
|
83
|
+
#
|
|
84
|
+
# @return [Numeric]
|
|
85
|
+
#
|
|
86
|
+
def pi(t)
|
|
87
|
+
return 10.0**(0.000030+trigonometric(julian_year_from_1975(+t), P3Q))
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
# 平均黄経 / CIRCLE
|
|
91
|
+
#
|
|
92
|
+
# @param [Numeric] t ユリウス日(Terrestrial Time)
|
|
93
|
+
# @param [When::TM::TemporalPosition] t
|
|
94
|
+
#
|
|
95
|
+
# @return [Numeric]
|
|
96
|
+
#
|
|
97
|
+
def mean_longitude(t)
|
|
98
|
+
return trigonometric(julian_year_from_1975(+t), P3L, 0.0, 1) / 360.0 + 1974.0
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
# 位置 (黄道座標)
|
|
103
|
+
#
|
|
104
|
+
# @param [Numeric] t ユリウス日(Terrestrial Time)
|
|
105
|
+
# @param [When::TM::TemporalPosition] t
|
|
106
|
+
#
|
|
107
|
+
# @return [When::Ephemeris::Coords]
|
|
108
|
+
#
|
|
109
|
+
def _coords(t)
|
|
110
|
+
Coords.polar(0, 0, 0, 0)
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
# 視黄経 / CIRCLE
|
|
114
|
+
#
|
|
115
|
+
# @param [Numeric] t ユリウス日(Terrestrial Time)
|
|
116
|
+
# @param [When::TM::TemporalPosition] t
|
|
117
|
+
#
|
|
118
|
+
# @return [0]
|
|
119
|
+
#
|
|
120
|
+
def true_longitude(t)
|
|
121
|
+
0
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
# 平均黄経 / CIRCLE
|
|
125
|
+
#
|
|
126
|
+
# @param [Numeric] t ユリウス日(Terrestrial Time)
|
|
127
|
+
# @param [When::TM::TemporalPosition] t
|
|
128
|
+
#
|
|
129
|
+
# @return [0]
|
|
130
|
+
#
|
|
131
|
+
def mean_longitude(t)
|
|
132
|
+
0
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
# 平均運動 / (DEG/YEAR)
|
|
136
|
+
#
|
|
137
|
+
# @param [Numeric] t ユリウス日(Terrestrial Time)
|
|
138
|
+
# @param [When::TM::TemporalPosition] t
|
|
139
|
+
#
|
|
140
|
+
# @return [0]
|
|
141
|
+
#
|
|
142
|
+
def mean_motion
|
|
143
|
+
0
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
# オブジェクトの生成
|
|
147
|
+
# @private
|
|
148
|
+
def initialize(*args)
|
|
149
|
+
options = [args.pop] if args[-1].kind_of?(Hash)
|
|
150
|
+
surface_radius, aberration, luminosity, *rest = args
|
|
151
|
+
surface_radius ||= Radius
|
|
152
|
+
aberration ||= 0.00000
|
|
153
|
+
luminosity ||= 4.58
|
|
154
|
+
args = [surface_radius, aberration, luminosity] + rest
|
|
155
|
+
args += options if options
|
|
156
|
+
super(*args)
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
#
|
|
161
|
+
# The Earth
|
|
162
|
+
#
|
|
163
|
+
class Earth < Datum
|
|
164
|
+
|
|
165
|
+
# 地球の位置 (黄道座標)
|
|
166
|
+
#
|
|
167
|
+
# @param [Numeric] t ユリウス日(Terrestrial Time)
|
|
168
|
+
# @param [When::TM::TemporalPosition] t
|
|
169
|
+
#
|
|
170
|
+
# @return [When::Ephemeris::Coords]
|
|
171
|
+
#
|
|
172
|
+
def _coords(t)
|
|
173
|
+
t = +t
|
|
174
|
+
radius = Sun.pi(t)
|
|
175
|
+
dl = 0.5 + @aberration / radius / 360 # 略算式に含まれる光行差をキャンセルする
|
|
176
|
+
Coords.polar(Sun.true_longitude(t)+dl, 0, radius, Sun.mean_longitude(t)+dl)
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
# 地球の平均運動 / (DEG/YEAR)
|
|
180
|
+
#
|
|
181
|
+
# @return [Numeric]
|
|
182
|
+
#
|
|
183
|
+
def mean_motion
|
|
184
|
+
P3L[0][2]
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
# オブジェクトの生成
|
|
188
|
+
# @private
|
|
189
|
+
def initialize(*args)
|
|
190
|
+
options = {
|
|
191
|
+
'shape' => [0.998327112, +0.001676399, -0.000003519, -11.514/60.0],
|
|
192
|
+
'sid' => [6.697375, 2400.0513369, 0.0000259],
|
|
193
|
+
'zeros' => {'Z'=>0, 'A'=>-0.58555, '0'=>-0.85255, 'T'=>-7.36111},
|
|
194
|
+
'air' => [10.0, 0.40, 20.0]
|
|
195
|
+
}
|
|
196
|
+
options.update(args.pop) if args[-1].kind_of?(Hash)
|
|
197
|
+
surface_radius, aberration, luminosity, *rest = args
|
|
198
|
+
surface_radius ||= 6378.14
|
|
199
|
+
aberration ||= 0.0056932
|
|
200
|
+
luminosity ||= -3.50
|
|
201
|
+
args = [surface_radius, aberration, luminosity] + rest + [options]
|
|
202
|
+
super(*args)
|
|
203
|
+
end
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
#
|
|
207
|
+
# Typical Geometrical Datum
|
|
208
|
+
#
|
|
209
|
+
# provisionally same as When::Ephemeris::Earth
|
|
210
|
+
#
|
|
211
|
+
class JGD2000 < Earth # TODO
|
|
212
|
+
end
|
|
213
|
+
end
|
|
214
|
+
end
|
|
@@ -1,140 +1,144 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
=begin
|
|
3
|
-
Copyright (C) 2012-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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
#
|
|
56
|
-
#
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
#
|
|
71
|
-
#
|
|
72
|
-
#
|
|
73
|
-
#
|
|
74
|
-
#
|
|
75
|
-
# @
|
|
76
|
-
#
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
conditions['
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
#
|
|
119
|
-
#
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
=begin
|
|
3
|
+
Copyright (C) 2012-2014 Takashi SUGA
|
|
4
|
+
|
|
5
|
+
You may use and/or modify this file according to the license described in the LICENSE.txt file included in this archive.
|
|
6
|
+
=end
|
|
7
|
+
|
|
8
|
+
begin
|
|
9
|
+
require 'gcalapi'
|
|
10
|
+
rescue LoadError
|
|
11
|
+
raise LoadError, "Please install gcalapi from https://github.com/suchowan/gcalapi"
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
#
|
|
15
|
+
# gcalapi の GoogleCalendar モジュールへの機能追加
|
|
16
|
+
#
|
|
17
|
+
module GoogleCalendar
|
|
18
|
+
|
|
19
|
+
#
|
|
20
|
+
# gcalapi の GoogleCalendar::Event クラスへの機能追加
|
|
21
|
+
#
|
|
22
|
+
class Event
|
|
23
|
+
# 繰り返しイベントの定義
|
|
24
|
+
# @return [Array<String>]
|
|
25
|
+
attr_accessor :recurrence
|
|
26
|
+
|
|
27
|
+
Event::ATTRIBUTES_MAP["recurrence"] = { "element" => "gd:recurrence"}
|
|
28
|
+
|
|
29
|
+
# @private
|
|
30
|
+
alias :_instance_to_xml :instance_to_xml
|
|
31
|
+
|
|
32
|
+
# @private
|
|
33
|
+
def instance_to_xml
|
|
34
|
+
_instance_to_xml
|
|
35
|
+
@xml.root.elements[recurrence ? "gd:when" : "gd:recurrence"].remove
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# When::V::Event オブジェクトへの変換
|
|
39
|
+
#
|
|
40
|
+
# @return [When::V::Event]
|
|
41
|
+
#
|
|
42
|
+
def to_vevent
|
|
43
|
+
options = {'summary'=>@title, 'description'=>@desc, 'location'=>@where}
|
|
44
|
+
if @recurrence
|
|
45
|
+
@recurrence.each_line do |line|
|
|
46
|
+
options[$1.downcase] ||= $2 if line =~ /^(DTSTART|DTEND|RRULE).(.+)$/i
|
|
47
|
+
end
|
|
48
|
+
else
|
|
49
|
+
options.update({'dtstart'=>When.when?(@st), 'dtend'=>When.when?(@en)})
|
|
50
|
+
end
|
|
51
|
+
When::V::Event.new(options)
|
|
52
|
+
end
|
|
53
|
+
alias :vevent :to_vevent
|
|
54
|
+
|
|
55
|
+
# イベントのステータス
|
|
56
|
+
#
|
|
57
|
+
# @return [String]
|
|
58
|
+
# [ 'confirmed' - 有効 ]
|
|
59
|
+
# [ 'canceled' - 無効 ]
|
|
60
|
+
#
|
|
61
|
+
def event_status
|
|
62
|
+
@xml.root.elements['gd:eventStatus'].attributes['value'][/[^.]+$/]
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
#
|
|
67
|
+
# gcalapi の GoogleCalendar::Calendar クラスへの機能追加
|
|
68
|
+
#
|
|
69
|
+
class Calendar
|
|
70
|
+
# イベントを順に取り出す enumerator
|
|
71
|
+
#
|
|
72
|
+
# @param [Hash] conditions
|
|
73
|
+
# @option conditions [String, When::TM::TemporalPosition] 'start-min' 最初のイベント開始日時(省略時は現在時刻)
|
|
74
|
+
# @option conditions [String, When::TM::TemporalPosition] 'start-max' 最後のイベント開始日時(省略時は制限なし)
|
|
75
|
+
# @option conditions [String] 'sortorder'
|
|
76
|
+
# [ 'a' - asend(省略時) ]
|
|
77
|
+
# [ 'd' - desend ]
|
|
78
|
+
#
|
|
79
|
+
# @return [Enumerator]
|
|
80
|
+
#
|
|
81
|
+
def enum_for(conditions={})
|
|
82
|
+
conditions['start-min'] ||= When.now
|
|
83
|
+
conditions['sortorder'] ||= 'a'
|
|
84
|
+
conditions['orderby'] = 'starttime'
|
|
85
|
+
direction = (conditions['sortorder'] == 'd') ? :reverse : :forward
|
|
86
|
+
first = When.when?(conditions['start-min'])
|
|
87
|
+
conditions['start-min'] = (When::Gregorian ^ first).to_s
|
|
88
|
+
if conditions['start-max']
|
|
89
|
+
last = When.when?(conditions['start-max'])
|
|
90
|
+
inner_args = [first...last]
|
|
91
|
+
conditions['start-max'] = (When::Gregorian ^ last).to_s
|
|
92
|
+
else
|
|
93
|
+
inner_args = [first, direction]
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
confirmed = []
|
|
97
|
+
canceled = []
|
|
98
|
+
self.events(conditions).each do |event|
|
|
99
|
+
case event.event_status
|
|
100
|
+
when 'canceled' ; canceled << event
|
|
101
|
+
else ; confirmed << event
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
outer_args = [first, direction]
|
|
105
|
+
outer_args << {:exevent => canceled.map {|event| event.to_vevent}} if canceled.length > 0
|
|
106
|
+
|
|
107
|
+
When::Parts::Enumerator::Integrated.new(self, confirmed.map {|event|
|
|
108
|
+
event.to_vevent.enum_for(*inner_args)
|
|
109
|
+
}, *outer_args)
|
|
110
|
+
end
|
|
111
|
+
alias :to_enum :enum_for
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
module When::V
|
|
116
|
+
class Event
|
|
117
|
+
|
|
118
|
+
# GoogleCalendar::Event オブジェクトへの変換
|
|
119
|
+
#
|
|
120
|
+
# @param [GoogleCalendar::Calendar] cal
|
|
121
|
+
#
|
|
122
|
+
# @return [GoogleCalendar::Event]
|
|
123
|
+
#
|
|
124
|
+
def to_gcalevent(cal)
|
|
125
|
+
event = cal.create_event
|
|
126
|
+
event.title = summary if respond_to?(:summary)
|
|
127
|
+
event.desc = description if respond_to?(:description)
|
|
128
|
+
event.where = location if respond_to?(:location)
|
|
129
|
+
if rrule.size == 0
|
|
130
|
+
event.st = dtstart.to_time
|
|
131
|
+
event.en = dtend.to_time
|
|
132
|
+
else
|
|
133
|
+
event.recurrence =
|
|
134
|
+
(['RRULE:' + property['rrule'][0].object] +
|
|
135
|
+
['dtstart', 'dtend'].map {|key|
|
|
136
|
+
value = property[key].attribute['.']
|
|
137
|
+
key.upcase + (value =~ /=/ ? ';' : ':') + value
|
|
138
|
+
}).join("\n") + "\n"
|
|
139
|
+
end
|
|
140
|
+
event
|
|
141
|
+
end
|
|
142
|
+
alias :gcalevent :to_gcalevent
|
|
143
|
+
end
|
|
144
|
+
end
|