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
data/lib/when_exe/region/m17n.rb
CHANGED
|
@@ -1,113 +1,114 @@
|
|
|
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
|
-
module BasicTypes
|
|
10
|
-
class M17n
|
|
11
|
-
#
|
|
12
|
-
# 月名
|
|
13
|
-
#
|
|
14
|
-
# @param [Numeric] name 指定の月番号の月名を返します
|
|
15
|
-
# @param [When::BasicTypes::M17n] name name 自身をそのまま返します
|
|
16
|
-
# @param [String] name 最初の3文字から決定した月名を返します。
|
|
17
|
-
# 一致する月名がない場合、名前の一致するその他のM17nを探して返します。
|
|
18
|
-
#
|
|
19
|
-
# @return [When::BasicTypes::M17n] 月名
|
|
20
|
-
#
|
|
21
|
-
def self.month_name(name)
|
|
22
|
-
return name if name.kind_of?(self)
|
|
23
|
-
|
|
24
|
-
months = When.Resource('_m:Calendar::Month').child
|
|
25
|
-
abbrs = When.Resource('_m:Calendar::Abbr_Month').child
|
|
26
|
-
return name > 0 ? months[name-1] : abbrs[-name-1] if name.kind_of?(Numeric)
|
|
27
|
-
|
|
28
|
-
name = When::EncodingConversion.to_internal_encoding(name)
|
|
29
|
-
match = name[
|
|
30
|
-
if match
|
|
31
|
-
(months+abbrs).each do |month|
|
|
32
|
-
return month if month.=~(
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
ObjectSpace.each_object(self) do |object|
|
|
37
|
-
return object if object.registered? && object.=~(
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
return nil
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
#
|
|
44
|
-
# 共通的な暦用語
|
|
45
|
-
#
|
|
46
|
-
Calendar = [M17n, [
|
|
47
|
-
"locale:[=en:, ja=ja:, alias]",
|
|
48
|
-
"names:[Calendar=]",
|
|
49
|
-
|
|
50
|
-
"[Intercalary %s=, *閏]",
|
|
51
|
-
|
|
52
|
-
[M17n,
|
|
53
|
-
"names:[Month, 月=ja:%%<月_(暦)>, /datetime/prompts/month]",
|
|
54
|
-
"[January, 1月, /date/month_names/1] ",
|
|
55
|
-
"[February, 2月, /date/month_names/2] ",
|
|
56
|
-
"[March, 3月, /date/month_names/3] ",
|
|
57
|
-
"[April, 4月, /date/month_names/4] ",
|
|
58
|
-
"[May, 5月, /date/month_names/5] ",
|
|
59
|
-
"[June, 6月, /date/month_names/6] ",
|
|
60
|
-
"[July, 7月, /date/month_names/7] ",
|
|
61
|
-
"[August, 8月, /date/month_names/8] ",
|
|
62
|
-
"[September, 9月, /date/month_names/9] ",
|
|
63
|
-
"[October, 10月, /date/month_names/10]",
|
|
64
|
-
"[November, 11月, /date/month_names/11]",
|
|
65
|
-
"[December, 12月, /date/month_names/12]"
|
|
66
|
-
],
|
|
67
|
-
|
|
68
|
-
[M17n,
|
|
69
|
-
"names:[Abbr_Month, 月略称)]",
|
|
70
|
-
"[Jan, 1月, /date/abbr_month_names/1] ",
|
|
71
|
-
"[Feb, 2月, /date/abbr_month_names/2] ",
|
|
72
|
-
"[Mar, 3月, /date/abbr_month_names/3] ",
|
|
73
|
-
"[Apr, 4月, /date/abbr_month_names/4] ",
|
|
74
|
-
"[May, 5月, /date/abbr_month_names/5] ",
|
|
75
|
-
"[Jun, 6月, /date/abbr_month_names/6] ",
|
|
76
|
-
"[Jul, 7月, /date/abbr_month_names/7] ",
|
|
77
|
-
"[Aug, 8月, /date/abbr_month_names/8] ",
|
|
78
|
-
"[Sep, 9月, /date/abbr_month_names/9] ",
|
|
79
|
-
"[Oct, 10月, /date/abbr_month_names/10]",
|
|
80
|
-
"[Nov, 11月, /date/abbr_month_names/11]",
|
|
81
|
-
"[Dec, 12月, /date/abbr_month_names/12]"
|
|
82
|
-
]
|
|
83
|
-
]]
|
|
84
|
-
|
|
85
|
-
# Events
|
|
86
|
-
EpochEvents = [M17n, [
|
|
87
|
-
"locale:[=en:, ja=ja:, alias]",
|
|
88
|
-
"names:[EpochEvents=]",
|
|
89
|
-
"[Accession=, 代始]",
|
|
90
|
-
"[FelicitousEvent=, 祥瑞]",
|
|
91
|
-
"[NaturalDisaster=, 災異]",
|
|
92
|
-
"[InauspiciousYear=, 革年]",
|
|
93
|
-
"[Foundation=, 創業]",
|
|
94
|
-
"[CalendarReform=, 改暦]"
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
"
|
|
101
|
-
"[
|
|
102
|
-
"[
|
|
103
|
-
"[
|
|
104
|
-
"[
|
|
105
|
-
"[
|
|
106
|
-
"[
|
|
107
|
-
"[
|
|
108
|
-
"[
|
|
109
|
-
"[
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
end
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
=begin
|
|
3
|
+
Copyright (C) 2011-2014 Takashi SUGA
|
|
4
|
+
|
|
5
|
+
You may use and/or modify this file according to the license described in the LICENSE.txt file included in this archive.
|
|
6
|
+
=end
|
|
7
|
+
|
|
8
|
+
module When
|
|
9
|
+
module BasicTypes
|
|
10
|
+
class M17n
|
|
11
|
+
#
|
|
12
|
+
# 月名
|
|
13
|
+
#
|
|
14
|
+
# @param [Numeric] name 指定の月番号の月名を返します
|
|
15
|
+
# @param [When::BasicTypes::M17n] name name 自身をそのまま返します
|
|
16
|
+
# @param [String] name 最初の3文字から決定した月名を返します。
|
|
17
|
+
# 一致する月名がない場合、名前の一致するその他のM17nを探して返します。
|
|
18
|
+
#
|
|
19
|
+
# @return [When::BasicTypes::M17n] 月名
|
|
20
|
+
#
|
|
21
|
+
def self.month_name(name)
|
|
22
|
+
return name if name.kind_of?(self)
|
|
23
|
+
|
|
24
|
+
months = When.Resource('_m:Calendar::Month').child
|
|
25
|
+
abbrs = When.Resource('_m:Calendar::Abbr_Month').child
|
|
26
|
+
return name > 0 ? months[name-1] : abbrs[-name-1] if name.kind_of?(Numeric)
|
|
27
|
+
|
|
28
|
+
name = When::EncodingConversion.to_internal_encoding(name)
|
|
29
|
+
match = name[/\A...|^..\z/]
|
|
30
|
+
if match
|
|
31
|
+
(months+abbrs).each do |month|
|
|
32
|
+
return month if month.=~(/\A#{match}/i)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
ObjectSpace.each_object(self) do |object|
|
|
37
|
+
return object if object.registered? && object.=~(/\A#{name}\z/)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
return nil
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
#
|
|
44
|
+
# 共通的な暦用語
|
|
45
|
+
#
|
|
46
|
+
Calendar = [M17n, [
|
|
47
|
+
"locale:[=en:, ja=ja:, alias]",
|
|
48
|
+
"names:[Calendar=]",
|
|
49
|
+
|
|
50
|
+
"[Intercalary %s=, *閏]",
|
|
51
|
+
|
|
52
|
+
[M17n,
|
|
53
|
+
"names:[Month, 月=ja:%%<月_(暦)>, /datetime/prompts/month]",
|
|
54
|
+
"[January, 1月, /date/month_names/1] ",
|
|
55
|
+
"[February, 2月, /date/month_names/2] ",
|
|
56
|
+
"[March, 3月, /date/month_names/3] ",
|
|
57
|
+
"[April, 4月, /date/month_names/4] ",
|
|
58
|
+
"[May, 5月, /date/month_names/5] ",
|
|
59
|
+
"[June, 6月, /date/month_names/6] ",
|
|
60
|
+
"[July, 7月, /date/month_names/7] ",
|
|
61
|
+
"[August, 8月, /date/month_names/8] ",
|
|
62
|
+
"[September, 9月, /date/month_names/9] ",
|
|
63
|
+
"[October, 10月, /date/month_names/10]",
|
|
64
|
+
"[November, 11月, /date/month_names/11]",
|
|
65
|
+
"[December, 12月, /date/month_names/12]"
|
|
66
|
+
],
|
|
67
|
+
|
|
68
|
+
[M17n,
|
|
69
|
+
"names:[Abbr_Month, 月略称)]",
|
|
70
|
+
"[Jan, 1月, /date/abbr_month_names/1] ",
|
|
71
|
+
"[Feb, 2月, /date/abbr_month_names/2] ",
|
|
72
|
+
"[Mar, 3月, /date/abbr_month_names/3] ",
|
|
73
|
+
"[Apr, 4月, /date/abbr_month_names/4] ",
|
|
74
|
+
"[May, 5月, /date/abbr_month_names/5] ",
|
|
75
|
+
"[Jun, 6月, /date/abbr_month_names/6] ",
|
|
76
|
+
"[Jul, 7月, /date/abbr_month_names/7] ",
|
|
77
|
+
"[Aug, 8月, /date/abbr_month_names/8] ",
|
|
78
|
+
"[Sep, 9月, /date/abbr_month_names/9] ",
|
|
79
|
+
"[Oct, 10月, /date/abbr_month_names/10]",
|
|
80
|
+
"[Nov, 11月, /date/abbr_month_names/11]",
|
|
81
|
+
"[Dec, 12月, /date/abbr_month_names/12]"
|
|
82
|
+
]
|
|
83
|
+
]]
|
|
84
|
+
|
|
85
|
+
# Events
|
|
86
|
+
EpochEvents = [M17n, [
|
|
87
|
+
"locale:[=en:, ja=ja:, alias]",
|
|
88
|
+
"names:[EpochEvents=]",
|
|
89
|
+
"[Accession=, 代始]",
|
|
90
|
+
"[FelicitousEvent=, 祥瑞]",
|
|
91
|
+
"[NaturalDisaster=, 災異]",
|
|
92
|
+
"[InauspiciousYear=, 革年]",
|
|
93
|
+
"[Foundation=, 創業]",
|
|
94
|
+
"[CalendarReform=, 改暦]",
|
|
95
|
+
"[CalendarEpoch=, 暦元]"
|
|
96
|
+
]]
|
|
97
|
+
|
|
98
|
+
# Formats
|
|
99
|
+
CalendarFormats = [M17n, [
|
|
100
|
+
"locale:[=]",
|
|
101
|
+
"names:[CalendarFormats=]",
|
|
102
|
+
"[Date=, /date/formats/default]",
|
|
103
|
+
"[DateLong=, /date/formats/long ]",
|
|
104
|
+
"[DateShort=, /date/formats/short ]",
|
|
105
|
+
"[DateTime=, /time/formats/default]",
|
|
106
|
+
"[DateTimeLong=, /time/formats/long ]",
|
|
107
|
+
"[DateTimeShort=, /time/formats/short ]",
|
|
108
|
+
"[Time=, /time/formats/time ]",
|
|
109
|
+
"[AM=, /time/am ]",
|
|
110
|
+
"[PM=, /time/pm ]"
|
|
111
|
+
]]
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
end
|
|
@@ -1,255 +1,258 @@
|
|
|
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
|
-
|
|
10
|
-
class BasicTypes::M17n
|
|
11
|
-
|
|
12
|
-
Martian = [self, [
|
|
13
|
-
"locale:[=en:, ja=ja:, alias]",
|
|
14
|
-
"names:[Martian=]",
|
|
15
|
-
"[Darian=en:Darian_calendar, ダリアン暦]",
|
|
16
|
-
|
|
17
|
-
[self,
|
|
18
|
-
"names:[DarianMonth=, 月=ja:%%<月_(暦)>]",
|
|
19
|
-
"[Sagittarius, いて= ]",
|
|
20
|
-
"[Dhanus=, 人馬= ]",
|
|
21
|
-
"[Capricornus, やぎ= ]",
|
|
22
|
-
"[Makara=, 磨羯= ]",
|
|
23
|
-
"[Aquarius, みずがめ=]",
|
|
24
|
-
"[Kumbha=, 宝瓶= ]",
|
|
25
|
-
"[Pisces, うお= ]",
|
|
26
|
-
"[Mina=, 双魚= ]",
|
|
27
|
-
"[Aries, おひつじ=]",
|
|
28
|
-
"[Mesha=, 白羊= ]",
|
|
29
|
-
"[Taurus, おうし= ]",
|
|
30
|
-
"[Rishabha=, 金牛= ]",
|
|
31
|
-
"[Gemini, ふたご= ]",
|
|
32
|
-
"[Mithuna=, 双児= ]",
|
|
33
|
-
"[Cancer, かに= ]",
|
|
34
|
-
"[Karka=, 巨蟹= ]",
|
|
35
|
-
"[Leo, しし= ]",
|
|
36
|
-
"[Simha=, 獅子= ]",
|
|
37
|
-
"[Virgo, おとめ= ]",
|
|
38
|
-
"[Kanya=, 処女= ]",
|
|
39
|
-
"[Libra, てんびん=]",
|
|
40
|
-
"[Tula=, 天秤= ]",
|
|
41
|
-
"[Scorpius, さそり= ]",
|
|
42
|
-
"[Vrishika=, 天蠍= ]"
|
|
43
|
-
]
|
|
44
|
-
]]
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
module TimeStandard
|
|
48
|
-
|
|
49
|
-
#
|
|
50
|
-
# Martian Time, Coordinated
|
|
51
|
-
#
|
|
52
|
-
class MartianTimeCoordinated < TimeStandard
|
|
53
|
-
|
|
54
|
-
J2000Jan6 = 2451549.5
|
|
55
|
-
Ratio = 1.02749125
|
|
56
|
-
MTC0 = 44796.0 - 0.0002 - 0.5
|
|
57
|
-
|
|
58
|
-
# 当該時刻系の日付を dynamical date に変換する
|
|
59
|
-
#
|
|
60
|
-
# @param [Numeric] date 当該時刻系の日付
|
|
61
|
-
#
|
|
62
|
-
# @return [Numeric] dynamical date
|
|
63
|
-
#
|
|
64
|
-
def to_dynamical_date(date)
|
|
65
|
-
(date - @mtc0) * Ratio + J2000Jan6
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
# dynamical date を当該時刻系の日付に変換する
|
|
69
|
-
#
|
|
70
|
-
# @param [Numeric] date dynamical date
|
|
71
|
-
#
|
|
72
|
-
# @return [Numeric] 当該時刻系の日付
|
|
73
|
-
#
|
|
74
|
-
def from_dynamical_date(date)
|
|
75
|
-
(date - J2000Jan6) / Ratio + @mtc0
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
# universal time を dynamical time に変換する
|
|
79
|
-
#
|
|
80
|
-
# @param [Numeric] time universal time
|
|
81
|
-
#
|
|
82
|
-
# @return [Numeric] dynamical time
|
|
83
|
-
#
|
|
84
|
-
def to_dynamical_time(time)
|
|
85
|
-
When::TM::JulianDate._d_to_t(
|
|
86
|
-
to_dynamical_date(
|
|
87
|
-
When::TM::JulianDate._t_to_d(time)))
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
# dynamical time を universal time に変換する
|
|
91
|
-
#
|
|
92
|
-
# @param [Numeric] time dynamical time
|
|
93
|
-
#
|
|
94
|
-
# @return [Numeric] universal time
|
|
95
|
-
#
|
|
96
|
-
def from_dynamical_time(time)
|
|
97
|
-
When::TM::JulianDate._d_to_t(
|
|
98
|
-
from_dynamical_date(
|
|
99
|
-
When::TM::JulianDate._t_to_d(time)))
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
private
|
|
103
|
-
|
|
104
|
-
# オブジェクトの正規化
|
|
105
|
-
def _normalize(args=[], options={})
|
|
106
|
-
@location = When.Resource(@location || '_l:long=0&lat=0&datum=Mars')
|
|
107
|
-
@mtc0 = MTC0 + @location.long / (360.0 * When::Coordinates::Spatial::DEGREE)
|
|
108
|
-
super
|
|
109
|
-
end
|
|
110
|
-
end
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
class CalendarNote
|
|
114
|
-
|
|
115
|
-
#
|
|
116
|
-
# Darian Week
|
|
117
|
-
#
|
|
118
|
-
class DarianWeek < WorldWeek
|
|
119
|
-
|
|
120
|
-
Notes = [When::BasicTypes::M17n, [
|
|
121
|
-
"locale:[=en:, ja=ja:, alias]",
|
|
122
|
-
"names:[Darian]",
|
|
123
|
-
|
|
124
|
-
# 年の暦注 ----------------------------
|
|
125
|
-
[When::BasicTypes::M17n,
|
|
126
|
-
"names:[year]"
|
|
127
|
-
],
|
|
128
|
-
|
|
129
|
-
# 月の暦注 ----------------------------
|
|
130
|
-
[When::BasicTypes::M17n,
|
|
131
|
-
"names:[month]",
|
|
132
|
-
[When::BasicTypes::M17n,
|
|
133
|
-
"names:[Month]"
|
|
134
|
-
]
|
|
135
|
-
],
|
|
136
|
-
|
|
137
|
-
# 日の暦注 ----------------------------
|
|
138
|
-
[When::BasicTypes::M17n,
|
|
139
|
-
"names:[day]",
|
|
140
|
-
[When::BasicTypes::M17n,
|
|
141
|
-
"names:[Week]",
|
|
142
|
-
[DayOfWeek, "label:[Solis=, 日曜日]", {'delta'=>7}],
|
|
143
|
-
[DayOfWeek, "label:[Lunae=, 月曜日]", {'delta'=>7}],
|
|
144
|
-
[DayOfWeek, "label:[Martis=, 火曜日]", {'delta'=>7}],
|
|
145
|
-
[DayOfWeek, "label:[Mercurii=, 水曜日]", {'delta'=>7}],
|
|
146
|
-
[DayOfWeek, "label:[Jovis=, 木曜日]", {'delta'=>7}],
|
|
147
|
-
[DayOfWeek, "label:[Veneris=, 金曜日]", {'delta'=>7}],
|
|
148
|
-
[DayOfWeek, "label:[Saturni=, 土曜日]", {'delta'=>7}]
|
|
149
|
-
]
|
|
150
|
-
]
|
|
151
|
-
]]
|
|
152
|
-
|
|
153
|
-
#
|
|
154
|
-
# 当日または直前の solis の日
|
|
155
|
-
#
|
|
156
|
-
# @param date [When::TM::TemporalPosition]
|
|
157
|
-
# @param parameter [nil] 未使用
|
|
158
|
-
#
|
|
159
|
-
# @return [When::TM::TemporalPosition]
|
|
160
|
-
#
|
|
161
|
-
def solis(date, parameter=nil)
|
|
162
|
-
date = When.Calendar('Darian').jul_trans(date, {:events=>['from_solis']})
|
|
163
|
-
y,m,d = date.cal_date
|
|
164
|
-
dow = (d-1) % 7
|
|
165
|
-
return date if dow == 0
|
|
166
|
-
date += When::TM::PeriodDuration.new([0,0,-dow])
|
|
167
|
-
date.events = ['from_solis']
|
|
168
|
-
date
|
|
169
|
-
end
|
|
170
|
-
|
|
171
|
-
#
|
|
172
|
-
# この日は何曜?
|
|
173
|
-
#
|
|
174
|
-
# @param [When::TM::TemporalPosition] date
|
|
175
|
-
# @param [When::TM::CalDate] base (not used)
|
|
176
|
-
#
|
|
177
|
-
# @return [
|
|
178
|
-
#
|
|
179
|
-
def week(date, base=nil)
|
|
180
|
-
date = _to_date_for_note(date)
|
|
181
|
-
index = (date.cal_date.last - 1) % 7
|
|
182
|
-
|
|
183
|
-
end
|
|
184
|
-
|
|
185
|
-
#
|
|
186
|
-
# 曜日の名前の一覧
|
|
187
|
-
#
|
|
188
|
-
# @param [When::TM::TemporalPosition] date (ダミー)
|
|
189
|
-
#
|
|
190
|
-
# @return [Array<When::CalendarNote::Week::DayOfWeek>]
|
|
191
|
-
#
|
|
192
|
-
def week_labels(date)
|
|
193
|
-
@days_of_week.child
|
|
194
|
-
end
|
|
195
|
-
|
|
196
|
-
#
|
|
197
|
-
# 暦日を当該暦注計算用クラスに変換
|
|
198
|
-
#
|
|
199
|
-
# @private
|
|
200
|
-
def _to_date_for_note(date)
|
|
201
|
-
date = When::Darian ^ date unless date.frame.label.to_s == 'Darian'
|
|
202
|
-
date
|
|
203
|
-
end
|
|
204
|
-
|
|
205
|
-
private
|
|
206
|
-
|
|
207
|
-
# オブジェクトの正規化
|
|
208
|
-
def _normalize(args=[], options={})
|
|
209
|
-
@event ||= 'solis'
|
|
210
|
-
super
|
|
211
|
-
end
|
|
212
|
-
end
|
|
213
|
-
end
|
|
214
|
-
|
|
215
|
-
module CalendarTypes
|
|
216
|
-
|
|
217
|
-
#
|
|
218
|
-
# Martian Time, Coordinated
|
|
219
|
-
#
|
|
220
|
-
class MTC <
|
|
221
|
-
|
|
222
|
-
private
|
|
223
|
-
|
|
224
|
-
# オブジェクトの正規化
|
|
225
|
-
def _normalize(args=[], options={})
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
'
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
'
|
|
248
|
-
'
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
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
|
+
|
|
10
|
+
class BasicTypes::M17n
|
|
11
|
+
|
|
12
|
+
Martian = [self, [
|
|
13
|
+
"locale:[=en:, ja=ja:, alias]",
|
|
14
|
+
"names:[Martian=]",
|
|
15
|
+
"[Darian=en:Darian_calendar, ダリアン暦]",
|
|
16
|
+
|
|
17
|
+
[self,
|
|
18
|
+
"names:[DarianMonth=, 月=ja:%%<月_(暦)>]",
|
|
19
|
+
"[Sagittarius, いて= ]",
|
|
20
|
+
"[Dhanus=, 人馬= ]",
|
|
21
|
+
"[Capricornus, やぎ= ]",
|
|
22
|
+
"[Makara=, 磨羯= ]",
|
|
23
|
+
"[Aquarius, みずがめ=]",
|
|
24
|
+
"[Kumbha=, 宝瓶= ]",
|
|
25
|
+
"[Pisces, うお= ]",
|
|
26
|
+
"[Mina=, 双魚= ]",
|
|
27
|
+
"[Aries, おひつじ=]",
|
|
28
|
+
"[Mesha=, 白羊= ]",
|
|
29
|
+
"[Taurus, おうし= ]",
|
|
30
|
+
"[Rishabha=, 金牛= ]",
|
|
31
|
+
"[Gemini, ふたご= ]",
|
|
32
|
+
"[Mithuna=, 双児= ]",
|
|
33
|
+
"[Cancer, かに= ]",
|
|
34
|
+
"[Karka=, 巨蟹= ]",
|
|
35
|
+
"[Leo, しし= ]",
|
|
36
|
+
"[Simha=, 獅子= ]",
|
|
37
|
+
"[Virgo, おとめ= ]",
|
|
38
|
+
"[Kanya=, 処女= ]",
|
|
39
|
+
"[Libra, てんびん=]",
|
|
40
|
+
"[Tula=, 天秤= ]",
|
|
41
|
+
"[Scorpius, さそり= ]",
|
|
42
|
+
"[Vrishika=, 天蠍= ]"
|
|
43
|
+
]
|
|
44
|
+
]]
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
module TimeStandard
|
|
48
|
+
|
|
49
|
+
#
|
|
50
|
+
# Martian Time, Coordinated
|
|
51
|
+
#
|
|
52
|
+
class MartianTimeCoordinated < TimeStandard
|
|
53
|
+
|
|
54
|
+
J2000Jan6 = 2451549.5
|
|
55
|
+
Ratio = 1.02749125
|
|
56
|
+
MTC0 = 44796.0 - 0.0002 - 0.5
|
|
57
|
+
|
|
58
|
+
# 当該時刻系の日付を dynamical date に変換する
|
|
59
|
+
#
|
|
60
|
+
# @param [Numeric] date 当該時刻系の日付
|
|
61
|
+
#
|
|
62
|
+
# @return [Numeric] dynamical date
|
|
63
|
+
#
|
|
64
|
+
def to_dynamical_date(date)
|
|
65
|
+
(date - @mtc0) * Ratio + J2000Jan6
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# dynamical date を当該時刻系の日付に変換する
|
|
69
|
+
#
|
|
70
|
+
# @param [Numeric] date dynamical date
|
|
71
|
+
#
|
|
72
|
+
# @return [Numeric] 当該時刻系の日付
|
|
73
|
+
#
|
|
74
|
+
def from_dynamical_date(date)
|
|
75
|
+
(date - J2000Jan6) / Ratio + @mtc0
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# universal time を dynamical time に変換する
|
|
79
|
+
#
|
|
80
|
+
# @param [Numeric] time universal time
|
|
81
|
+
#
|
|
82
|
+
# @return [Numeric] dynamical time
|
|
83
|
+
#
|
|
84
|
+
def to_dynamical_time(time)
|
|
85
|
+
When::TM::JulianDate._d_to_t(
|
|
86
|
+
to_dynamical_date(
|
|
87
|
+
When::TM::JulianDate._t_to_d(time)))
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
# dynamical time を universal time に変換する
|
|
91
|
+
#
|
|
92
|
+
# @param [Numeric] time dynamical time
|
|
93
|
+
#
|
|
94
|
+
# @return [Numeric] universal time
|
|
95
|
+
#
|
|
96
|
+
def from_dynamical_time(time)
|
|
97
|
+
When::TM::JulianDate._d_to_t(
|
|
98
|
+
from_dynamical_date(
|
|
99
|
+
When::TM::JulianDate._t_to_d(time)))
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
private
|
|
103
|
+
|
|
104
|
+
# オブジェクトの正規化
|
|
105
|
+
def _normalize(args=[], options={})
|
|
106
|
+
@location = When.Resource(@location || '_l:long=0&lat=0&datum=Mars')
|
|
107
|
+
@mtc0 = MTC0 + @location.long / (360.0 * When::Coordinates::Spatial::DEGREE)
|
|
108
|
+
super
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
class CalendarNote
|
|
114
|
+
|
|
115
|
+
#
|
|
116
|
+
# Darian Week
|
|
117
|
+
#
|
|
118
|
+
class DarianWeek < WorldWeek
|
|
119
|
+
|
|
120
|
+
Notes = [When::BasicTypes::M17n, [
|
|
121
|
+
"locale:[=en:, ja=ja:, alias]",
|
|
122
|
+
"names:[Darian]",
|
|
123
|
+
|
|
124
|
+
# 年の暦注 ----------------------------
|
|
125
|
+
[When::BasicTypes::M17n,
|
|
126
|
+
"names:[year]"
|
|
127
|
+
],
|
|
128
|
+
|
|
129
|
+
# 月の暦注 ----------------------------
|
|
130
|
+
[When::BasicTypes::M17n,
|
|
131
|
+
"names:[month]",
|
|
132
|
+
[When::BasicTypes::M17n,
|
|
133
|
+
"names:[Month]"
|
|
134
|
+
]
|
|
135
|
+
],
|
|
136
|
+
|
|
137
|
+
# 日の暦注 ----------------------------
|
|
138
|
+
[When::BasicTypes::M17n,
|
|
139
|
+
"names:[day]",
|
|
140
|
+
[When::BasicTypes::M17n,
|
|
141
|
+
"names:[Week]",
|
|
142
|
+
[DayOfWeek, "label:[Solis=, 日曜日]", {'delta'=>7}],
|
|
143
|
+
[DayOfWeek, "label:[Lunae=, 月曜日]", {'delta'=>7}],
|
|
144
|
+
[DayOfWeek, "label:[Martis=, 火曜日]", {'delta'=>7}],
|
|
145
|
+
[DayOfWeek, "label:[Mercurii=, 水曜日]", {'delta'=>7}],
|
|
146
|
+
[DayOfWeek, "label:[Jovis=, 木曜日]", {'delta'=>7}],
|
|
147
|
+
[DayOfWeek, "label:[Veneris=, 金曜日]", {'delta'=>7}],
|
|
148
|
+
[DayOfWeek, "label:[Saturni=, 土曜日]", {'delta'=>7}]
|
|
149
|
+
]
|
|
150
|
+
]
|
|
151
|
+
]]
|
|
152
|
+
|
|
153
|
+
#
|
|
154
|
+
# 当日または直前の solis の日
|
|
155
|
+
#
|
|
156
|
+
# @param date [When::TM::TemporalPosition]
|
|
157
|
+
# @param parameter [nil] 未使用
|
|
158
|
+
#
|
|
159
|
+
# @return [When::TM::TemporalPosition]
|
|
160
|
+
#
|
|
161
|
+
def solis(date, parameter=nil)
|
|
162
|
+
date = When.Calendar('Darian').jul_trans(date, {:events=>['from_solis']})
|
|
163
|
+
y,m,d = date.cal_date
|
|
164
|
+
dow = (d-1) % 7
|
|
165
|
+
return date if dow == 0
|
|
166
|
+
date += When::TM::PeriodDuration.new([0,0,-dow])
|
|
167
|
+
date.events = ['from_solis']
|
|
168
|
+
date
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
#
|
|
172
|
+
# この日は何曜?
|
|
173
|
+
#
|
|
174
|
+
# @param [When::TM::TemporalPosition] date
|
|
175
|
+
# @param [When::TM::CalDate] base (not used)
|
|
176
|
+
#
|
|
177
|
+
# @return [Hash<:value=>When::CalendarNote::Week::DayOfWeek, :position=>Array<Integer>>]
|
|
178
|
+
#
|
|
179
|
+
def week(date, base=nil)
|
|
180
|
+
date = _to_date_for_note(date)
|
|
181
|
+
index = (date.cal_date.last - 1) % 7
|
|
182
|
+
{:value=>@days_of_week[index], :position=>[index, 7]}
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
#
|
|
186
|
+
# 曜日の名前の一覧
|
|
187
|
+
#
|
|
188
|
+
# @param [When::TM::TemporalPosition] date (ダミー)
|
|
189
|
+
#
|
|
190
|
+
# @return [Array<When::CalendarNote::Week::DayOfWeek>]
|
|
191
|
+
#
|
|
192
|
+
def week_labels(date)
|
|
193
|
+
@days_of_week.child
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
#
|
|
197
|
+
# 暦日を当該暦注計算用クラスに変換
|
|
198
|
+
#
|
|
199
|
+
# @private
|
|
200
|
+
def _to_date_for_note(date)
|
|
201
|
+
date = When::Darian ^ date unless date.frame.label.to_s == 'Darian'
|
|
202
|
+
date
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
private
|
|
206
|
+
|
|
207
|
+
# オブジェクトの正規化
|
|
208
|
+
def _normalize(args=[], options={})
|
|
209
|
+
@event ||= 'solis'
|
|
210
|
+
super
|
|
211
|
+
end
|
|
212
|
+
end
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
module CalendarTypes
|
|
216
|
+
|
|
217
|
+
#
|
|
218
|
+
# Martian Time, Coordinated
|
|
219
|
+
#
|
|
220
|
+
class MTC < UTC
|
|
221
|
+
|
|
222
|
+
private
|
|
223
|
+
|
|
224
|
+
# オブジェクトの正規化
|
|
225
|
+
def _normalize(args=[], options={})
|
|
226
|
+
label = 'MTC'
|
|
227
|
+
long = @long||0
|
|
228
|
+
label += "?long=#{long}" unless long.to_f == 0
|
|
229
|
+
@label = m17n(label)
|
|
230
|
+
@time_standard = When.Resource("_t:MartianTimeCoordinated?location=(_l:long=#{long}&datum=Mars)")
|
|
231
|
+
super
|
|
232
|
+
end
|
|
233
|
+
end
|
|
234
|
+
|
|
235
|
+
#
|
|
236
|
+
# Darian Calendar
|
|
237
|
+
#
|
|
238
|
+
Darian = [CyclicTableBased, {
|
|
239
|
+
'label' => 'Martian::Darian',
|
|
240
|
+
'time_basis' => 'MTC',
|
|
241
|
+
'origin_of_LSC' => -94798,
|
|
242
|
+
'indices' => [
|
|
243
|
+
When.Index('Martian::DarianMonth', {:unit =>24}),
|
|
244
|
+
When::Coordinates::DefaultDayIndex
|
|
245
|
+
],
|
|
246
|
+
'rule_table' => {
|
|
247
|
+
'T' => {'Rule' =>['LongCentury', ['ShortCentury', 4]]},
|
|
248
|
+
'LongCentury' => {'Rule' =>[ ['LongDecade', 10]]},
|
|
249
|
+
'ShortCentury' => {'Rule' =>['ShortDecade', ['LongDecade', 9]]},
|
|
250
|
+
'LongDecade' => {'Rule' =>[669] * 2 + [668, 669] * 4 },
|
|
251
|
+
'ShortDecade' => {'Rule' => [668, 669] * 5 },
|
|
252
|
+
668 => {'Length'=>[28, 28, 28, 28, 28, 27] * 4 },
|
|
253
|
+
669 => {'Length'=>[28, 28, 28, 28, 28, 27] * 3 + [28] * 6}
|
|
254
|
+
},
|
|
255
|
+
'note' => 'DarianWeek'
|
|
256
|
+
}]
|
|
257
|
+
end
|
|
258
|
+
end
|