when_exe 0.3.8 → 0.3.9
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 +4 -4
- data/README.md +210 -210
- data/lib/when_exe.rb +923 -919
- data/lib/when_exe/basictypes.rb +1 -1
- data/lib/when_exe/calendartypes.rb +4 -4
- data/lib/when_exe/coordinates.rb +5 -1
- data/lib/when_exe/ephemeris.rb +1 -1
- data/lib/when_exe/locales/locale.rb +3 -2
- data/lib/when_exe/region/bahai.rb +2 -2
- data/lib/when_exe/region/chinese.rb +1030 -1030
- data/lib/when_exe/region/chinese/epochs.rb +887 -919
- data/lib/when_exe/region/discordian.rb +5 -5
- data/lib/when_exe/region/east_asian.rb +256 -0
- data/lib/when_exe/region/french.rb +1 -1
- data/lib/when_exe/region/indian.rb +7 -7
- data/lib/when_exe/region/international_fixed.rb +2 -2
- data/lib/when_exe/region/iranian.rb +1 -1
- data/lib/when_exe/region/islamic.rb +102 -103
- data/lib/when_exe/region/japanese/epochs.rb +426 -426
- data/lib/when_exe/region/japanese/nihon_shoki.rb +46 -47
- data/lib/when_exe/region/japanese/notes.rb +1482 -1482
- data/lib/when_exe/region/japanese/twins.rb +3 -3
- data/lib/when_exe/region/japanese/weeks.rb +2 -2
- data/lib/when_exe/region/jewish.rb +5 -0
- data/lib/when_exe/region/korean.rb +209 -203
- data/lib/when_exe/region/positivist.rb +2 -2
- data/lib/when_exe/region/roman.rb +1 -1
- data/lib/when_exe/region/ryukyu.rb +50 -48
- data/lib/when_exe/region/shire.rb +2 -2
- data/lib/when_exe/region/thai.rb +1 -1
- data/lib/when_exe/region/tibetan.rb +15 -15
- data/lib/when_exe/region/tranquility.rb +2 -2
- data/lib/when_exe/region/vietnamese.rb +167 -167
- data/lib/when_exe/region/world.rb +3 -3
- data/lib/when_exe/region/world_season.rb +2 -2
- data/lib/when_exe/region/yerm.rb +4 -2
- data/lib/when_exe/region/zoroastrian.rb +1 -1
- data/lib/when_exe/tmreference.rb +140 -128
- data/lib/when_exe/version.rb +1 -1
- data/test/examples/Spatial.m17n +3 -3
- data/test/test.rb +2 -1
- data/test/test/coordinates.rb +2 -2
- data/test/test/region/chinese.rb +2 -2
- data/test/test/region/islamic.rb +38 -2
- data/test/test/region/japanese.rb +2 -2
- data/test/test/region/vietnamese.rb +2 -2
- data/test/test/region/yerm.rb +156 -146
- metadata +3 -3
- data/lib/when_exe/region/far_east.rb +0 -188
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4aa361eea778047e510eff92c02580c2c0a9032c
|
4
|
+
data.tar.gz: 6828e97bdca91d3533a2a8a9832259a2f22c2a38
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76e950b423e1219e64a648826c6cf0de99ff6a738382b227f0f6d93ac9bcdf5b46459a2876d73a515c46a18ba761232ed0510eea2eb4d7063fe2377481fabaae
|
7
|
+
data.tar.gz: 12cd771a12962d12b8972bfa21524d43d537104847c6d5f803133bf795beaa879c7e6a5ee3a229bee09c4662a4de1cef7a4733ca5f60f8ef8a0de55500da8699
|
data/README.md
CHANGED
@@ -1,210 +1,210 @@
|
|
1
|
-
when_exe - A multicultural and multilingualized calendar library
|
2
|
-
================================================================
|
3
|
-
|
4
|
-
[](http://badge.fury.io/rb/when_exe)
|
5
|
-
|
6
|
-
[when_exe](http://rubygems.org/gems/when_exe) is a multicultural and multilingualized calendar library based on [ISO 8601](http://en.wikipedia.org/wiki/ISO_8601), [ISO 19108](http://www.iso.org/iso/home/store/catalogue_tc/catalogue_detail.htm?csnumber=26013), [RFC 5545(iCalendar)](http://tools.ietf.org/html/rfc5545) and [RFC6350](http://tools.ietf.org/html/rfc6350).
|
7
|
-
|
8
|
-
[<img alt='Architecture' title='display this figure at actual size' src='
|
9
|
-
|
10
|
-
Installation
|
11
|
-
------------
|
12
|
-
|
13
|
-
The when_exe gem can be installed by running:
|
14
|
-
|
15
|
-
gem install when_exe
|
16
|
-
|
17
|
-
|
18
|
-
Web Server
|
19
|
-
----------
|
20
|
-
|
21
|
-
Web server for when_exe demonstration is available on [hosi.org](http://hosi.org).
|
22
|
-
|
23
|
-
You can see examples of [When.exe Standard Representation](http://www.asahi-net.or.jp/~dd6t-sg/when_rdoc/when_en.html#label-8) and Reference System IRI at the top-left corner of Date frame.
|
24
|
-
|
25
|
-
Preferences are changeable on [hosi.org/cookies](http://hosi.org/cookies).
|
26
|
-
|
27
|
-
|
28
|
-
Documentation
|
29
|
-
-------------
|
30
|
-
|
31
|
-
API documentation for when_exe is available on [RubyDoc.info](http://rubydoc.info/gems/when_exe
|
32
|
-
|
33
|
-
Available calendars and clocks are defined as subclasses of TM_Calendar and TM_Clock or using definition tables in [CalendarTypes namespace](http://rubydoc.info/gems/when_exe/
|
34
|
-
|
35
|
-
Available calendar eras are defined using definition tables in [CalendarEra namespace](http://rubydoc.info/gems/when_exe/
|
36
|
-
|
37
|
-
License
|
38
|
-
-------
|
39
|
-
|
40
|
-
This beta version's license is limited. Please see [LICENSE.txt](https://github.com/suchowan/when_exe/blob/master/LICENSE.txt) for details.
|
41
|
-
|
42
|
-
|
43
|
-
Source Code
|
44
|
-
-----------
|
45
|
-
|
46
|
-
Source code for when_exe is available on [GitHub](https://github.com/suchowan/when_exe).
|
47
|
-
|
48
|
-
|
49
|
-
Example Usage
|
50
|
-
-------------
|
51
|
-
|
52
|
-
require 'when_exe'
|
53
|
-
|
54
|
-
# When::TM::CalDate ---------------------------
|
55
|
-
|
56
|
-
gregorian_date = When.tm_pos(2014, 8, 1)
|
57
|
-
p gregorian_date #=> 2014-08-01
|
58
|
-
p When.when?('2014-08-01') #=> 2014-08-01, the same date
|
59
|
-
p gregorian_date.to_i #=> 2456871, Julian Day Number(Integer)
|
60
|
-
p gregorian_date.to_f #=> 2456871.0, at noon for UTC
|
61
|
-
p gregorian_date.class #=> When::TM::CalDate
|
62
|
-
p gregorian_date.frame.iri #=> "http://hosi.org/When/CalendarTypes/Gregorian"
|
63
|
-
puts gregorian_date.name(When::MONTH).class #=> When::BasicTypes::M17n
|
64
|
-
puts gregorian_date.name(When::MONTH).iri #=> http://hosi.org/When/BasicTypes/M17n/Calendar::Month::August
|
65
|
-
puts gregorian_date.name(When::MONTH) / 'en' #=> August
|
66
|
-
puts gregorian_date.name(When::MONTH) / 'fr' #=> août
|
67
|
-
puts gregorian_date.name(When::MONTH) / 'ar' #=> اغسطس
|
68
|
-
p gregorian_date.easter #=> 2014-04-20
|
69
|
-
p gregorian_date.is?('Easter') #=> false
|
70
|
-
p When.tm_pos(2014, 4, 20).is?('Easter') #=> true
|
71
|
-
|
72
|
-
islamic_date = When::TabularIslamic ^ gregorian_date
|
73
|
-
p islamic_date #=> 1435-10-04
|
74
|
-
p When.tm_pos(1435, 10, 4, :frame=>'TabularIslamic')
|
75
|
-
#=> 1435-10-04, the same date
|
76
|
-
p When.when?('1435-10-4^TabularIslamic') #=> 1435-10-04, the same date
|
77
|
-
p islamic_date.frame.iri #=> "http://hosi.org/When/CalendarTypes/TabularIslamic"
|
78
|
-
puts islamic_date.name(When::MONTH) / 'en' #=> Shawwal
|
79
|
-
puts islamic_date.name(When::MONTH) / 'ar' #=> شوال
|
80
|
-
|
81
|
-
# When::TM::DateAndTime ------------------------
|
82
|
-
|
83
|
-
gregorian_date = When.tm_pos(2014, 8, 1, 9, 0, 0, :clock=>'+09:00')
|
84
|
-
p gregorian_date #=> 2014-08-01T09:00:00+09:00
|
85
|
-
p When.when?('2014-08-01T09:00:00+09:00') #=> 2014-08-01T09:00:00+09:00, the same date
|
86
|
-
p gregorian_date.to_i #=> 2456871, Julian Day Number(Integer)
|
87
|
-
p gregorian_date.to_f #=> 2456870.5 at 09:00:00 of Timezone +09:00
|
88
|
-
p gregorian_date.class #=> When::TM::DateAndTime
|
89
|
-
p gregorian_date.frame.iri #=> "http://hosi.org/When/CalendarTypes/Gregorian"
|
90
|
-
p gregorian_date.clk_time.class #=> When::TM::ClockTime
|
91
|
-
p gregorian_date.clk_time.frame.iri #=> "http://hosi.org/When/TM/Clock?label=+09:00"
|
92
|
-
|
93
|
-
gregorian_date = When.tm_pos(2014, 8, 1, 9, 0, 0, :clock=>'+09:00',
|
94
|
-
:long=>'139.413012E', :lat=>'35.412222N')
|
95
|
-
p gregorian_date #=> 2014-08-01T09:00:00+09:00
|
96
|
-
p gregorian_date.location.iri #=> "http://hosi.org/When/Coordinates/Spatial?long=139.413012E&lat=35.412222N&alt=0"
|
97
|
-
p gregorian_date.sunrise.floor(When::MINUTE) #=> 2014-08-01T04:48+09:00
|
98
|
-
p gregorian_date.sunset.floor(When::MINUTE) #=> 2014-08-01T18:46+09:00
|
99
|
-
|
100
|
-
darian_date = When::Darian ^ gregorian_date
|
101
|
-
p darian_date #=> 0216-13-23T15:12:11MTC
|
102
|
-
p darian_date.to_i #=> 49974, Serial Day Number(Integer)
|
103
|
-
p darian_date.to_f #=> 49974.13346485421
|
104
|
-
p darian_date.frame.iri #=> "http://hosi.org/When/CalendarTypes/Darian"
|
105
|
-
p darian_date.clk_time.frame.iri #=> "http://hosi.org/When/CalendarTypes/MTC"
|
106
|
-
p darian_date.time_standard.iri #=> "http://hosi.org/When/TimeStandard/MartianTimeCoordinated?location=(_l:long=0&datum=Mars)"
|
107
|
-
|
108
|
-
# When::TM::CalendarEra ------------------------
|
109
|
-
|
110
|
-
babylonian_date = When.tm_pos('NebuchadnezzarII', 1, 1, 1)
|
111
|
-
p babylonian_date #=> NebuchadnezzarII01(-603).01.01
|
112
|
-
p When.when?('NebuchadnezzarII1.1.1') #=> NebuchadnezzarII01(-603).01.01, the same date
|
113
|
-
p babylonian_date.to_i #=> 1500904, Julian Day Number(Integer)
|
114
|
-
p When.era('NebuchadnezzarII') #=> [_e:AncientOrient::Neo-Babylonian::NebuchadnezzarII]
|
115
|
-
p When.era('NebuchadnezzarII')[0] ^ 1500904 #=> NebuchadnezzarII01(-603).01.01, the same date
|
116
|
-
p babylonian_date.to_f #=> 1500904.0, at noon for UTC
|
117
|
-
p babylonian_date.frame.iri #=> "http://hosi.org/When/CalendarTypes/BabylonianPD"
|
118
|
-
p babylonian_date.calendar_era.iri #=> "http://hosi.org/When/TM/CalendarEra/AncientOrient::Neo-Babylonian::NebuchadnezzarII"
|
119
|
-
|
120
|
-
babylonian_date = When.when?('NebuchadnezzarII1.1.1T18:13:00',
|
121
|
-
:clock=>'+03:00?long=45&lat=32&border=Sunset')
|
122
|
-
4.times do
|
123
|
-
p [babylonian_date, babylonian_date.to_i] #=>
|
124
|
-
# [NebuchadnezzarII01(-603).01.01T:18:13:00+03:00, 1500904]
|
125
|
-
# [NebuchadnezzarII01(-603).01.01T:18:14:00+03:00, 1500904]
|
126
|
-
# [NebuchadnezzarII01(-603).01.02T*18:15:00+03:00, 1500905]
|
127
|
-
# [NebuchadnezzarII01(-603).01.02T*18:16:00+03:00, 1500905]
|
128
|
-
babylonian_date += When::PT1M
|
129
|
-
end
|
130
|
-
|
131
|
-
# Web service ----------------------------------
|
132
|
-
# retrieve JSON response from http://hosi.org:3000 (when_exe demonstration web server)
|
133
|
-
require 'open-uri'
|
134
|
-
open('http://hosi.org:3000/Date/2014-04-20.json') do |json|
|
135
|
-
puts json.read #=> newlines and blanks are inserted for readability.
|
136
|
-
# {"frame" : "http://hosi.org/When/CalendarTypes/Gregorian",
|
137
|
-
# "precision": 0,
|
138
|
-
# "location" : "http://hosi.org/When/Coordinates/Spatial?long=139.4441E&lat=35.3916N&alt=0.0",
|
139
|
-
# "sdn" : 2456768,
|
140
|
-
# "calendar" : ["http://hosi.org/When/CalendarTypes/Gregorian"],
|
141
|
-
# "notes" : [[{"note":"Month","value":"April"}],
|
142
|
-
# [{"note":"Week","value":"Sunday(6)"}]],
|
143
|
-
# "clock" : "Asia/Tokyo+09:00",
|
144
|
-
# "clk_time" : [2456768,0,0,0],
|
145
|
-
# "dynamical": 1397919667.184082,
|
146
|
-
# "universal": 1397919600.0,
|
147
|
-
# "cal_date" : [2014,4,20]}
|
148
|
-
end
|
149
|
-
|
150
|
-
# TZInfo --------------------------------------
|
151
|
-
# https://rubygems.org/gems/tzinfo is required for this section's operations.
|
152
|
-
# Please install tzinfo before operation.
|
153
|
-
|
154
|
-
gregorian_date = When.tm_pos(2014, 8, 1, 9, 0, 0, :tz=>'Asia/Tokyo')
|
155
|
-
p gregorian_date #=> 2014-08-01T09:00:00+09:00
|
156
|
-
p gregorian_date.location.iri #=> "http://hosi.org/When/Coordinates/Spatial?long=139.4441E&lat=35.3916N&label=Asia/Tokyo"
|
157
|
-
p gregorian_date.sunrise.floor(When::MINUTE) #=> 2014-08-01T04:48+09:00
|
158
|
-
p gregorian_date.sunset.floor(When::MINUTE) #=> 2014-08-01T18:45+09:00
|
159
|
-
|
160
|
-
jst = When.tm_pos(1997, 4, 6, 15, 30, 00, :tz=>'Asia/Tokyo')
|
161
|
-
p jst #=> 1997-04-06T15:30:00+09:00
|
162
|
-
est = When.Clock('America/New_York') ^ jst
|
163
|
-
p est #=> 1997-04-06T01:30:00-05:00
|
164
|
-
jst = When.tm_pos(1997, 4, 6, 16, 30, 00, :tz=>'Asia/Tokyo')
|
165
|
-
p jst #=> 1997-04-06T16:30:00+09:00
|
166
|
-
edt = When.Clock('America/New_York') ^ jst
|
167
|
-
p edt #=> 1997-04-06T03:30:00-04:00
|
168
|
-
|
169
|
-
p When.when?('TZID=America/New_York:1997-10-26T01:30') #=> 1997-10-26T01:30-04:00
|
170
|
-
p When.when?('TZID=America/New_York:1997-10-26T01=30') #=> 1997-10-26T01:30-05:00, '=' indicates "leep hour"
|
171
|
-
p When.when?('TZID=America/New_York:1997-10-26T02:30') #=> 1997-10-26T02:30-05:00
|
172
|
-
p When.when?('TZID=America/New_York:1997-10-26T03:30') #=> 1997-10-26T03:30-05:00
|
173
|
-
|
174
|
-
# Google Calendar ------------------------------
|
175
|
-
# https://github.com/suchowan/gcalapi is required for this section's operations.
|
176
|
-
# Please install gcalapi before operation.
|
177
|
-
# Please replace xxxxxxxx and ******** to valid id/password pair and access Google Calendar.
|
178
|
-
|
179
|
-
service = GoogleCalendar::Service.new('xxxxxxxx@gmail.com', '********')
|
180
|
-
feed = "http://www.google.com/calendar/feeds/%s__%s%%40holiday.calendar.google.com/public/full" %
|
181
|
-
['japanese', 'ja']
|
182
|
-
gcal = GoogleCalendar::Calendar::new(service, feed)
|
183
|
-
gcal.enum_for({'start-min'=>'2014-01-01', 'start-max'=>'2015-01-01',
|
184
|
-
'orderby'=>'starttime', 'sortorder'=>'a'
|
185
|
-
}).each do |range|
|
186
|
-
puts '%s - %s' % [range, range.events[0].summary] #=>
|
187
|
-
# 2014-01-01T00:00:00.00+09:00...2014-01-02T00:00:00.00+09:00 - 元日
|
188
|
-
# 2014-01-02T00:00:00.00+09:00...2014-01-03T00:00:00.00+09:00 - 銀行休業日
|
189
|
-
# 2014-01-03T00:00:00.00+09:00...2014-01-04T00:00:00.00+09:00 - 銀行休業日
|
190
|
-
# 2014-01-13T00:00:00.00+09:00...2014-01-14T00:00:00.00+09:00 - 成人の日
|
191
|
-
# 2014-02-11T00:00:00.00+09:00...2014-02-12T00:00:00.00+09:00 - 建国記念の日
|
192
|
-
# 2014-03-21T00:00:00.00+09:00...2014-03-22T00:00:00.00+09:00 - 春分の日
|
193
|
-
# 2014-04-29T00:00:00.00+09:00...2014-04-30T00:00:00.00+09:00 - 昭和の日
|
194
|
-
# 2014-05-03T00:00:00.00+09:00...2014-05-04T00:00:00.00+09:00 - 憲法記念日
|
195
|
-
# 2014-05-04T00:00:00.00+09:00...2014-05-05T00:00:00.00+09:00 - みどりの日
|
196
|
-
# 2014-05-05T00:00:00.00+09:00...2014-05-06T00:00:00.00+09:00 - こどもの日
|
197
|
-
# 2014-05-06T00:00:00.00+09:00...2014-05-07T00:00:00.00+09:00 - みどりの日 振替休日
|
198
|
-
# 2014-07-21T00:00:00.00+09:00...2014-07-22T00:00:00.00+09:00 - 海の日
|
199
|
-
# 2014-09-15T00:00:00.00+09:00...2014-09-16T00:00:00.00+09:00 - 敬老の日
|
200
|
-
# 2014-09-23T00:00:00.00+09:00...2014-09-24T00:00:00.00+09:00 - 秋分の日
|
201
|
-
# 2014-10-13T00:00:00.00+09:00...2014-10-14T00:00:00.00+09:00 - 体育の日
|
202
|
-
# 2014-11-03T00:00:00.00+09:00...2014-11-04T00:00:00.00+09:00 - 文化の日
|
203
|
-
# 2014-11-23T00:00:00.00+09:00...2014-11-24T00:00:00.00+09:00 - 勤労感謝の日
|
204
|
-
# 2014-11-24T00:00:00.00+09:00...2014-11-25T00:00:00.00+09:00 - 勤労感謝の日 振替休日
|
205
|
-
# 2014-12-23T00:00:00.00+09:00...2014-12-24T00:00:00.00+09:00 - 天皇誕生日
|
206
|
-
# 2014-12-25T00:00:00.00+09:00...2014-12-26T00:00:00.00+09:00 - クリスマス
|
207
|
-
# 2014-12-31T00:00:00.00+09:00...2015-01-01T00:00:00.00+09:00 - 大晦日
|
208
|
-
end
|
209
|
-
|
210
|
-
For further detail, please refer to the [when_exe Wiki](http://www2u.biglobe.ne.jp/~suchowan/when_exe_wiki.html) pages.
|
1
|
+
when_exe - A multicultural and multilingualized calendar library
|
2
|
+
================================================================
|
3
|
+
|
4
|
+
[](http://badge.fury.io/rb/when_exe)
|
5
|
+
|
6
|
+
[when_exe](http://rubygems.org/gems/when_exe) is a multicultural and multilingualized calendar library based on [ISO 8601](http://en.wikipedia.org/wiki/ISO_8601), [ISO 19108](http://www.iso.org/iso/home/store/catalogue_tc/catalogue_detail.htm?csnumber=26013), [RFC 5545(iCalendar)](http://tools.ietf.org/html/rfc5545) and [RFC6350](http://tools.ietf.org/html/rfc6350).
|
7
|
+
|
8
|
+
[<img alt='Architecture' title='display this figure at actual size' src='https://raw.githubusercontent.com/suchowan/when_exe/f7bb8b51259f0c1653c6c37b3ce20bd2a6ab7914/architecture.png' width='637' height='408'/>](https://raw.githubusercontent.com/suchowan/when_exe/f7bb8b51259f0c1653c6c37b3ce20bd2a6ab7914/architecture.png)
|
9
|
+
|
10
|
+
Installation
|
11
|
+
------------
|
12
|
+
|
13
|
+
The when_exe gem can be installed by running:
|
14
|
+
|
15
|
+
gem install when_exe
|
16
|
+
|
17
|
+
|
18
|
+
Web Server
|
19
|
+
----------
|
20
|
+
|
21
|
+
Web server for when_exe demonstration is available on [hosi.org](http://hosi.org).
|
22
|
+
|
23
|
+
You can see examples of [When.exe Standard Representation](http://www.asahi-net.or.jp/~dd6t-sg/when_rdoc/when_en.html#label-8) and Reference System IRI at the top-left corner of Date frame.
|
24
|
+
|
25
|
+
Preferences are changeable on [hosi.org/cookies](http://hosi.org/cookies).
|
26
|
+
|
27
|
+
|
28
|
+
Documentation
|
29
|
+
-------------
|
30
|
+
|
31
|
+
API documentation for when_exe is available on [RubyDoc.info](http://rubydoc.info/gems/when_exe).
|
32
|
+
|
33
|
+
Available calendars and clocks are defined as subclasses of TM_Calendar and TM_Clock or using definition tables in [CalendarTypes namespace](http://rubydoc.info/gems/when_exe/When/CalendarTypes).
|
34
|
+
|
35
|
+
Available calendar eras are defined using definition tables in [CalendarEra namespace](http://rubydoc.info/gems/when_exe/When/TM/CalendarEra).
|
36
|
+
|
37
|
+
License
|
38
|
+
-------
|
39
|
+
|
40
|
+
This beta version's license is limited. Please see [LICENSE.txt](https://github.com/suchowan/when_exe/blob/master/LICENSE.txt) for details.
|
41
|
+
|
42
|
+
|
43
|
+
Source Code
|
44
|
+
-----------
|
45
|
+
|
46
|
+
Source code for when_exe is available on [GitHub](https://github.com/suchowan/when_exe).
|
47
|
+
|
48
|
+
|
49
|
+
Example Usage
|
50
|
+
-------------
|
51
|
+
|
52
|
+
require 'when_exe'
|
53
|
+
|
54
|
+
# When::TM::CalDate ---------------------------
|
55
|
+
|
56
|
+
gregorian_date = When.tm_pos(2014, 8, 1)
|
57
|
+
p gregorian_date #=> 2014-08-01
|
58
|
+
p When.when?('2014-08-01') #=> 2014-08-01, the same date
|
59
|
+
p gregorian_date.to_i #=> 2456871, Julian Day Number(Integer)
|
60
|
+
p gregorian_date.to_f #=> 2456871.0, at noon for UTC
|
61
|
+
p gregorian_date.class #=> When::TM::CalDate
|
62
|
+
p gregorian_date.frame.iri #=> "http://hosi.org/When/CalendarTypes/Gregorian"
|
63
|
+
puts gregorian_date.name(When::MONTH).class #=> When::BasicTypes::M17n
|
64
|
+
puts gregorian_date.name(When::MONTH).iri #=> http://hosi.org/When/BasicTypes/M17n/Calendar::Month::August
|
65
|
+
puts gregorian_date.name(When::MONTH) / 'en' #=> August
|
66
|
+
puts gregorian_date.name(When::MONTH) / 'fr' #=> août
|
67
|
+
puts gregorian_date.name(When::MONTH) / 'ar' #=> اغسطس
|
68
|
+
p gregorian_date.easter #=> 2014-04-20
|
69
|
+
p gregorian_date.is?('Easter') #=> false
|
70
|
+
p When.tm_pos(2014, 4, 20).is?('Easter') #=> true
|
71
|
+
|
72
|
+
islamic_date = When::TabularIslamic ^ gregorian_date
|
73
|
+
p islamic_date #=> 1435-10-04
|
74
|
+
p When.tm_pos(1435, 10, 4, :frame=>'TabularIslamic')
|
75
|
+
#=> 1435-10-04, the same date
|
76
|
+
p When.when?('1435-10-4^TabularIslamic') #=> 1435-10-04, the same date
|
77
|
+
p islamic_date.frame.iri #=> "http://hosi.org/When/CalendarTypes/TabularIslamic"
|
78
|
+
puts islamic_date.name(When::MONTH) / 'en' #=> Shawwal
|
79
|
+
puts islamic_date.name(When::MONTH) / 'ar' #=> شوال
|
80
|
+
|
81
|
+
# When::TM::DateAndTime ------------------------
|
82
|
+
|
83
|
+
gregorian_date = When.tm_pos(2014, 8, 1, 9, 0, 0, :clock=>'+09:00')
|
84
|
+
p gregorian_date #=> 2014-08-01T09:00:00+09:00
|
85
|
+
p When.when?('2014-08-01T09:00:00+09:00') #=> 2014-08-01T09:00:00+09:00, the same date
|
86
|
+
p gregorian_date.to_i #=> 2456871, Julian Day Number(Integer)
|
87
|
+
p gregorian_date.to_f #=> 2456870.5 at 09:00:00 of Timezone +09:00
|
88
|
+
p gregorian_date.class #=> When::TM::DateAndTime
|
89
|
+
p gregorian_date.frame.iri #=> "http://hosi.org/When/CalendarTypes/Gregorian"
|
90
|
+
p gregorian_date.clk_time.class #=> When::TM::ClockTime
|
91
|
+
p gregorian_date.clk_time.frame.iri #=> "http://hosi.org/When/TM/Clock?label=+09:00"
|
92
|
+
|
93
|
+
gregorian_date = When.tm_pos(2014, 8, 1, 9, 0, 0, :clock=>'+09:00',
|
94
|
+
:long=>'139.413012E', :lat=>'35.412222N')
|
95
|
+
p gregorian_date #=> 2014-08-01T09:00:00+09:00
|
96
|
+
p gregorian_date.location.iri #=> "http://hosi.org/When/Coordinates/Spatial?long=139.413012E&lat=35.412222N&alt=0"
|
97
|
+
p gregorian_date.sunrise.floor(When::MINUTE) #=> 2014-08-01T04:48+09:00
|
98
|
+
p gregorian_date.sunset.floor(When::MINUTE) #=> 2014-08-01T18:46+09:00
|
99
|
+
|
100
|
+
darian_date = When::Darian ^ gregorian_date
|
101
|
+
p darian_date #=> 0216-13-23T15:12:11MTC
|
102
|
+
p darian_date.to_i #=> 49974, Serial Day Number(Integer)
|
103
|
+
p darian_date.to_f #=> 49974.13346485421
|
104
|
+
p darian_date.frame.iri #=> "http://hosi.org/When/CalendarTypes/Darian"
|
105
|
+
p darian_date.clk_time.frame.iri #=> "http://hosi.org/When/CalendarTypes/MTC"
|
106
|
+
p darian_date.time_standard.iri #=> "http://hosi.org/When/TimeStandard/MartianTimeCoordinated?location=(_l:long=0&datum=Mars)"
|
107
|
+
|
108
|
+
# When::TM::CalendarEra ------------------------
|
109
|
+
|
110
|
+
babylonian_date = When.tm_pos('NebuchadnezzarII', 1, 1, 1)
|
111
|
+
p babylonian_date #=> NebuchadnezzarII01(-603).01.01
|
112
|
+
p When.when?('NebuchadnezzarII1.1.1') #=> NebuchadnezzarII01(-603).01.01, the same date
|
113
|
+
p babylonian_date.to_i #=> 1500904, Julian Day Number(Integer)
|
114
|
+
p When.era('NebuchadnezzarII') #=> [_e:AncientOrient::Neo-Babylonian::NebuchadnezzarII]
|
115
|
+
p When.era('NebuchadnezzarII')[0] ^ 1500904 #=> NebuchadnezzarII01(-603).01.01, the same date
|
116
|
+
p babylonian_date.to_f #=> 1500904.0, at noon for UTC
|
117
|
+
p babylonian_date.frame.iri #=> "http://hosi.org/When/CalendarTypes/BabylonianPD"
|
118
|
+
p babylonian_date.calendar_era.iri #=> "http://hosi.org/When/TM/CalendarEra/AncientOrient::Neo-Babylonian::NebuchadnezzarII"
|
119
|
+
|
120
|
+
babylonian_date = When.when?('NebuchadnezzarII1.1.1T18:13:00',
|
121
|
+
:clock=>'+03:00?long=45&lat=32&border=Sunset')
|
122
|
+
4.times do
|
123
|
+
p [babylonian_date, babylonian_date.to_i] #=>
|
124
|
+
# [NebuchadnezzarII01(-603).01.01T:18:13:00+03:00, 1500904]
|
125
|
+
# [NebuchadnezzarII01(-603).01.01T:18:14:00+03:00, 1500904]
|
126
|
+
# [NebuchadnezzarII01(-603).01.02T*18:15:00+03:00, 1500905]
|
127
|
+
# [NebuchadnezzarII01(-603).01.02T*18:16:00+03:00, 1500905]
|
128
|
+
babylonian_date += When::PT1M
|
129
|
+
end
|
130
|
+
|
131
|
+
# Web service ----------------------------------
|
132
|
+
# retrieve JSON response from http://hosi.org:3000 (when_exe demonstration web server)
|
133
|
+
require 'open-uri'
|
134
|
+
open('http://hosi.org:3000/Date/2014-04-20.json') do |json|
|
135
|
+
puts json.read #=> newlines and blanks are inserted for readability.
|
136
|
+
# {"frame" : "http://hosi.org/When/CalendarTypes/Gregorian",
|
137
|
+
# "precision": 0,
|
138
|
+
# "location" : "http://hosi.org/When/Coordinates/Spatial?long=139.4441E&lat=35.3916N&alt=0.0",
|
139
|
+
# "sdn" : 2456768,
|
140
|
+
# "calendar" : ["http://hosi.org/When/CalendarTypes/Gregorian"],
|
141
|
+
# "notes" : [[{"note":"Month","value":"April"}],
|
142
|
+
# [{"note":"Week","value":"Sunday(6)"}]],
|
143
|
+
# "clock" : "Asia/Tokyo+09:00",
|
144
|
+
# "clk_time" : [2456768,0,0,0],
|
145
|
+
# "dynamical": 1397919667.184082,
|
146
|
+
# "universal": 1397919600.0,
|
147
|
+
# "cal_date" : [2014,4,20]}
|
148
|
+
end
|
149
|
+
|
150
|
+
# TZInfo --------------------------------------
|
151
|
+
# https://rubygems.org/gems/tzinfo is required for this section's operations.
|
152
|
+
# Please install tzinfo before operation.
|
153
|
+
|
154
|
+
gregorian_date = When.tm_pos(2014, 8, 1, 9, 0, 0, :tz=>'Asia/Tokyo')
|
155
|
+
p gregorian_date #=> 2014-08-01T09:00:00+09:00
|
156
|
+
p gregorian_date.location.iri #=> "http://hosi.org/When/Coordinates/Spatial?long=139.4441E&lat=35.3916N&label=Asia/Tokyo"
|
157
|
+
p gregorian_date.sunrise.floor(When::MINUTE) #=> 2014-08-01T04:48+09:00
|
158
|
+
p gregorian_date.sunset.floor(When::MINUTE) #=> 2014-08-01T18:45+09:00
|
159
|
+
|
160
|
+
jst = When.tm_pos(1997, 4, 6, 15, 30, 00, :tz=>'Asia/Tokyo')
|
161
|
+
p jst #=> 1997-04-06T15:30:00+09:00
|
162
|
+
est = When.Clock('America/New_York') ^ jst
|
163
|
+
p est #=> 1997-04-06T01:30:00-05:00
|
164
|
+
jst = When.tm_pos(1997, 4, 6, 16, 30, 00, :tz=>'Asia/Tokyo')
|
165
|
+
p jst #=> 1997-04-06T16:30:00+09:00
|
166
|
+
edt = When.Clock('America/New_York') ^ jst
|
167
|
+
p edt #=> 1997-04-06T03:30:00-04:00
|
168
|
+
|
169
|
+
p When.when?('TZID=America/New_York:1997-10-26T01:30') #=> 1997-10-26T01:30-04:00
|
170
|
+
p When.when?('TZID=America/New_York:1997-10-26T01=30') #=> 1997-10-26T01:30-05:00, '=' indicates "leep hour"
|
171
|
+
p When.when?('TZID=America/New_York:1997-10-26T02:30') #=> 1997-10-26T02:30-05:00
|
172
|
+
p When.when?('TZID=America/New_York:1997-10-26T03:30') #=> 1997-10-26T03:30-05:00
|
173
|
+
|
174
|
+
# Google Calendar ------------------------------
|
175
|
+
# https://github.com/suchowan/gcalapi is required for this section's operations.
|
176
|
+
# Please install gcalapi before operation.
|
177
|
+
# Please replace xxxxxxxx and ******** to valid id/password pair and access Google Calendar.
|
178
|
+
|
179
|
+
service = GoogleCalendar::Service.new('xxxxxxxx@gmail.com', '********')
|
180
|
+
feed = "http://www.google.com/calendar/feeds/%s__%s%%40holiday.calendar.google.com/public/full" %
|
181
|
+
['japanese', 'ja']
|
182
|
+
gcal = GoogleCalendar::Calendar::new(service, feed)
|
183
|
+
gcal.enum_for({'start-min'=>'2014-01-01', 'start-max'=>'2015-01-01',
|
184
|
+
'orderby'=>'starttime', 'sortorder'=>'a'
|
185
|
+
}).each do |range|
|
186
|
+
puts '%s - %s' % [range, range.events[0].summary] #=>
|
187
|
+
# 2014-01-01T00:00:00.00+09:00...2014-01-02T00:00:00.00+09:00 - 元日
|
188
|
+
# 2014-01-02T00:00:00.00+09:00...2014-01-03T00:00:00.00+09:00 - 銀行休業日
|
189
|
+
# 2014-01-03T00:00:00.00+09:00...2014-01-04T00:00:00.00+09:00 - 銀行休業日
|
190
|
+
# 2014-01-13T00:00:00.00+09:00...2014-01-14T00:00:00.00+09:00 - 成人の日
|
191
|
+
# 2014-02-11T00:00:00.00+09:00...2014-02-12T00:00:00.00+09:00 - 建国記念の日
|
192
|
+
# 2014-03-21T00:00:00.00+09:00...2014-03-22T00:00:00.00+09:00 - 春分の日
|
193
|
+
# 2014-04-29T00:00:00.00+09:00...2014-04-30T00:00:00.00+09:00 - 昭和の日
|
194
|
+
# 2014-05-03T00:00:00.00+09:00...2014-05-04T00:00:00.00+09:00 - 憲法記念日
|
195
|
+
# 2014-05-04T00:00:00.00+09:00...2014-05-05T00:00:00.00+09:00 - みどりの日
|
196
|
+
# 2014-05-05T00:00:00.00+09:00...2014-05-06T00:00:00.00+09:00 - こどもの日
|
197
|
+
# 2014-05-06T00:00:00.00+09:00...2014-05-07T00:00:00.00+09:00 - みどりの日 振替休日
|
198
|
+
# 2014-07-21T00:00:00.00+09:00...2014-07-22T00:00:00.00+09:00 - 海の日
|
199
|
+
# 2014-09-15T00:00:00.00+09:00...2014-09-16T00:00:00.00+09:00 - 敬老の日
|
200
|
+
# 2014-09-23T00:00:00.00+09:00...2014-09-24T00:00:00.00+09:00 - 秋分の日
|
201
|
+
# 2014-10-13T00:00:00.00+09:00...2014-10-14T00:00:00.00+09:00 - 体育の日
|
202
|
+
# 2014-11-03T00:00:00.00+09:00...2014-11-04T00:00:00.00+09:00 - 文化の日
|
203
|
+
# 2014-11-23T00:00:00.00+09:00...2014-11-24T00:00:00.00+09:00 - 勤労感謝の日
|
204
|
+
# 2014-11-24T00:00:00.00+09:00...2014-11-25T00:00:00.00+09:00 - 勤労感謝の日 振替休日
|
205
|
+
# 2014-12-23T00:00:00.00+09:00...2014-12-24T00:00:00.00+09:00 - 天皇誕生日
|
206
|
+
# 2014-12-25T00:00:00.00+09:00...2014-12-26T00:00:00.00+09:00 - クリスマス
|
207
|
+
# 2014-12-31T00:00:00.00+09:00...2015-01-01T00:00:00.00+09:00 - 大晦日
|
208
|
+
end
|
209
|
+
|
210
|
+
For further detail, please refer to the [when_exe Wiki](http://www2u.biglobe.ne.jp/~suchowan/when_exe_wiki.html) pages.
|
data/lib/when_exe.rb
CHANGED
@@ -1,919 +1,923 @@
|
|
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
|
-
begin
|
9
|
-
require 'json'
|
10
|
-
rescue LoadError
|
11
|
-
end
|
12
|
-
begin
|
13
|
-
require 'rubygems'
|
14
|
-
rescue LoadError
|
15
|
-
end
|
16
|
-
begin
|
17
|
-
gem 'tzinfo'
|
18
|
-
autoload :TZInfo, 'tzinfo'
|
19
|
-
rescue LoadError, NoMethodError
|
20
|
-
end
|
21
|
-
begin
|
22
|
-
gem 'gcalapi'
|
23
|
-
autoload :GoogleCalendar, 'when_exe/googlecalendar'
|
24
|
-
rescue LoadError, NoMethodError
|
25
|
-
end
|
26
|
-
|
27
|
-
autoload :URI, 'uri'
|
28
|
-
autoload :OpenURI, 'open-uri'
|
29
|
-
autoload :OpenSSL, 'openssl'
|
30
|
-
autoload :FileUtils, 'fileutils'
|
31
|
-
autoload :REXML, 'rexml/document'
|
32
|
-
autoload :Mutex, 'thread' unless Object.const_defined?(:Mutex)
|
33
|
-
|
34
|
-
$:.unshift(File.dirname(__FILE__)) unless
|
35
|
-
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
36
|
-
|
37
|
-
#
|
38
|
-
# A multicultural and multilingualized calendar library based on ISO 8601, ISO 19108 and RFC 5545
|
39
|
-
#
|
40
|
-
module When
|
41
|
-
|
42
|
-
class << self
|
43
|
-
|
44
|
-
#
|
45
|
-
# マルチスレッド対応の場合 true
|
46
|
-
#
|
47
|
-
# @return [Boolean]
|
48
|
-
#
|
49
|
-
attr_reader :multi_thread
|
50
|
-
|
51
|
-
#
|
52
|
-
# Logger オブジェクト
|
53
|
-
#
|
54
|
-
# @return [Logger]
|
55
|
-
#
|
56
|
-
attr_accessor :logger
|
57
|
-
private :logger=
|
58
|
-
|
59
|
-
# Initializations
|
60
|
-
#
|
61
|
-
# @param [Hash] options 以下の通り
|
62
|
-
# @option options [When::Parts::Timezone::Base] :local デフォルトの地方時
|
63
|
-
# @option options [When::Coordinates::Spatial] :location デフォルトの空間位置
|
64
|
-
# @option options [When::TM::IntervalLength] :until V::Event::Enumerator の until
|
65
|
-
# @option options [Hash{String=>String}] :alias Locale の読替パターン ({ 読替前のlocale=>読替後のlocale })
|
66
|
-
# @option options [String] :namespace_format 名前空間定義の省略時に名前空間生成に用いる書式
|
67
|
-
# @option options [Hash{String=>String}] :unification 漢字の包摂パターン ({ 包摂前の文字列=>包摂後の文字列 })
|
68
|
-
# @option options [Array<String>] :order CalendarEra の検索順序 ([ IRI of When::TM::CalendarEra ])
|
69
|
-
# @option options [Hash{String=>Array, String}] :format strftime で用いる記号の定義 ({ 記号=>[ 書式,項目名 ] or 記号列 })
|
70
|
-
# @option options [Array<Array>] :leap_seconds 閏秒の挿入記録 ([ [JD, TAI-UTC, (MJD, OFFSET)] ])
|
71
|
-
# @option options [String] :base_uri Base URI for When_exe Resources (Default When::SourceURI)
|
72
|
-
# @option options [Hash<String=>String>] :additional_namespaces User defined namespaces (Default {})
|
73
|
-
# @option options [String] :root_dir Root Directory for When_exe Resources Cash data (Default When::RootDir)
|
74
|
-
# @option options [Boolean] :direct '_' で終わるメソッドをキャッシュせずに毎回計算するか否か
|
75
|
-
# @option options [Hash{Symbol=>boolean}] :escape 毎回 method_missing を発生させるメソッドを true にする
|
76
|
-
# @option options [false, nil] :escape to_str, to_ary, to_hash のみ毎回 method_missing を発生させる
|
77
|
-
# @option options [true] :escape すべて毎回 method_missing を発生させる
|
78
|
-
# @option options [Boolean] :multi_thread マルチスレッド対応 (true: 対応, false/nil: 非対応)
|
79
|
-
# @option options [Logger] :logger Logger オブジェクト
|
80
|
-
#
|
81
|
-
# @return [void]
|
82
|
-
#
|
83
|
-
# @note
|
84
|
-
# 本メソッドでマルチスレッド対応の管理変数の初期化を行っている。
|
85
|
-
# このため、本メソッド自体および本メソッドから呼んでいる各クラスの _setup_ メソッドはスレッドセーフでない。
|
86
|
-
#
|
87
|
-
def _setup_(options={})
|
88
|
-
@multi_thread = options[:multi_thread]
|
89
|
-
@logger = options[:logger]
|
90
|
-
Parts::MethodCash._setup_(options)
|
91
|
-
Parts::Resource._setup_(options)
|
92
|
-
Locale._setup_(options)
|
93
|
-
Coordinates::Spatial._setup_(options[:location])
|
94
|
-
TM::CalendarEra._setup_(options[:order])
|
95
|
-
TM::Calendar._setup_
|
96
|
-
TM::Clock._setup_(options[:local])
|
97
|
-
TM::TemporalPosition._setup_(options[:format])
|
98
|
-
V::Event._setup_(options[:until])
|
99
|
-
V::Timezone._setup_
|
100
|
-
Parts::Timezone._setup_
|
101
|
-
TimeStandard._setup_(options[:leap_seconds])
|
102
|
-
end
|
103
|
-
|
104
|
-
# 設定情報を取得する
|
105
|
-
#
|
106
|
-
# @return [Hash] 設定情報
|
107
|
-
#
|
108
|
-
def _setup_info
|
109
|
-
{:multi_thread => @multi_thread}.
|
110
|
-
update(Parts::MethodCash._setup_info).
|
111
|
-
update(Parts::Resource._setup_info).
|
112
|
-
update(Locale._setup_info).
|
113
|
-
update(Coordinates::Spatial._setup_info).
|
114
|
-
update(TM::CalendarEra._setup_info).
|
115
|
-
update(TM::Clock._setup_info).
|
116
|
-
update(TM::TemporalPosition._setup_info).
|
117
|
-
update(V::Event._setup_info).
|
118
|
-
update(TimeStandard._setup_info)
|
119
|
-
end
|
120
|
-
|
121
|
-
#
|
122
|
-
# When 直下に定数として定義する時法・暦法(明示的的追加)
|
123
|
-
#
|
124
|
-
# @private
|
125
|
-
def _define_common_calendar_types(list=%w(UTC Gregorian Julian Civil))
|
126
|
-
list.each do |calendar|
|
127
|
-
resource = Parts::Resource._instance(calendar, '_c:')
|
128
|
-
Parts::Resource.synchronize do
|
129
|
-
Parts::Resource::ConstList << calendar
|
130
|
-
const_set(calendar, resource)
|
131
|
-
end
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
alias :_const_missing :const_missing
|
136
|
-
|
137
|
-
#
|
138
|
-
# When 直下に定数として定義する時法・暦法など(暗黙的追加)
|
139
|
-
#
|
140
|
-
def const_missing(constant)
|
141
|
-
sgn, *args = TM::PeriodDuration._to_array(constant.to_s)
|
142
|
-
return const_set(constant, TM::PeriodDuration.new(*args)) if sgn
|
143
|
-
iri = Parts::Resource._abbreviation_to_iri(constant)
|
144
|
-
return _const_missing(constant) unless iri
|
145
|
-
resource = Parts::Resource._instance(iri)
|
146
|
-
return const_get(constant) if const_defined?(constant)
|
147
|
-
Parts::Resource.synchronize do
|
148
|
-
Parts::Resource::ConstList << constant
|
149
|
-
const_set(constant, resource)
|
150
|
-
end
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
#
|
155
|
-
# when_exe 用 International Resource Identifier
|
156
|
-
#
|
157
|
-
SourceURI = "http://hosi.org/When/"
|
158
|
-
|
159
|
-
#
|
160
|
-
# ライブラリのあるディレクトリ
|
161
|
-
#
|
162
|
-
RootDir = File.dirname(__FILE__).sub(/\/[^\/]*\z/,'')
|
163
|
-
|
164
|
-
require 'when_exe/version'
|
165
|
-
require 'when_exe/locales/locale'
|
166
|
-
require 'when_exe/locales/autoload'
|
167
|
-
require 'when_exe/parts/enumerator'
|
168
|
-
require 'when_exe/parts/resource'
|
169
|
-
require 'when_exe/parts/geometric_complex'
|
170
|
-
require 'when_exe/parts/timezone'
|
171
|
-
require 'when_exe/core/compatibility'
|
172
|
-
require 'when_exe/basictypes'
|
173
|
-
require 'when_exe/ephemeris'
|
174
|
-
require 'when_exe/coordinates'
|
175
|
-
require 'when_exe/icalendar'
|
176
|
-
require 'when_exe/tmobjects'
|
177
|
-
require 'when_exe/timestandard'
|
178
|
-
require 'when_exe/tmposition'
|
179
|
-
require 'when_exe/tmreference'
|
180
|
-
require 'when_exe/calendartypes'
|
181
|
-
require 'when_exe/calendarnote'
|
182
|
-
require 'when_exe/region/m17n'
|
183
|
-
require 'when_exe/region/residue'
|
184
|
-
require 'when_exe/inspect'
|
185
|
-
|
186
|
-
#
|
187
|
-
# Module Constants
|
188
|
-
#
|
189
|
-
|
190
|
-
# 1 second period duration
|
191
|
-
PT1S = TM::PeriodDuration.new(nil,[0,0,0,1])
|
192
|
-
|
193
|
-
# 1 minute period duration
|
194
|
-
PT1M = TM::PeriodDuration.new(nil,[0,0,1,0])
|
195
|
-
|
196
|
-
# 1 hour period duration
|
197
|
-
PT1H = TM::PeriodDuration.new(nil,[0,1,0,0])
|
198
|
-
|
199
|
-
# 1 day period duration
|
200
|
-
P1D = TM::PeriodDuration.new([0,0,1])
|
201
|
-
|
202
|
-
# 1 week period duration
|
203
|
-
P1W = TM::PeriodDuration.new([0,0,7])
|
204
|
-
|
205
|
-
# 1 month period duration
|
206
|
-
P1M = TM::PeriodDuration.new([0,1,0])
|
207
|
-
|
208
|
-
# 1 year period duration
|
209
|
-
P1Y = TM::PeriodDuration.new([1,0,0])
|
210
|
-
|
211
|
-
# kind of When::TM::Position or When::TM::TemporalPosition
|
212
|
-
TimeValue = TM::IndeterminateValue
|
213
|
-
|
214
|
-
# 7 days week residue
|
215
|
-
Week = When::Parts::Resource._instance('_co:Common::Week')
|
216
|
-
|
217
|
-
# Gregorian months
|
218
|
-
Month = When::Parts::Resource._instance('_m:Calendar::Month')
|
219
|
-
|
220
|
-
# + ∞
|
221
|
-
PlusInfinity = TM::TemporalPosition.new({:indeterminated_position=>TimeValue::Max})
|
222
|
-
|
223
|
-
# - ∞
|
224
|
-
MinusInfinity = TM::TemporalPosition.new({:indeterminated_position=>TimeValue::Min})
|
225
|
-
|
226
|
-
# UTF-8 encoding
|
227
|
-
UTF8 = '.UTF-8'
|
228
|
-
|
229
|
-
# Windows-31J encoding
|
230
|
-
W31J = '.Windows-31J'
|
231
|
-
|
232
|
-
# eucJP encoding
|
233
|
-
EUCJP = '.eucJP'
|
234
|
-
|
235
|
-
class BasicTypes::M17n
|
236
|
-
autoload :Japanese, 'when_exe/region/japanese'
|
237
|
-
autoload :Chinese, 'when_exe/region/chinese'
|
238
|
-
autoload :Yi, 'when_exe/region/chinese'
|
239
|
-
autoload :Tibetan, 'when_exe/region/tibetan'
|
240
|
-
autoload :Thai, 'when_exe/region/thai'
|
241
|
-
autoload :Balinese, 'when_exe/region/balinese'
|
242
|
-
autoload :Javanese, 'when_exe/region/javanese'
|
243
|
-
autoload :Indian, 'when_exe/region/indian'
|
244
|
-
autoload :Iranian, 'when_exe/region/iranian'
|
245
|
-
autoload :Islamic, 'when_exe/region/islamic'
|
246
|
-
autoload :Jewish, 'when_exe/region/jewish'
|
247
|
-
autoload :AncientOrient, 'when_exe/region/babylonian'
|
248
|
-
autoload :Armenian, 'when_exe/region/armenian'
|
249
|
-
autoload :Roman, 'when_exe/region/roman'
|
250
|
-
autoload :Coptic, 'when_exe/region/coptic'
|
251
|
-
autoload :French, 'when_exe/region/french'
|
252
|
-
autoload :World, 'when_exe/region/world'
|
253
|
-
autoload :Positivist, 'when_exe/region/positivist'
|
254
|
-
autoload :InternationalFixed, 'when_exe/region/international_fixed'
|
255
|
-
autoload :WorldSeason, 'when_exe/region/world_season'
|
256
|
-
autoload :Tranquility, 'when_exe/region/tranquility'
|
257
|
-
autoload :Pax, 'when_exe/region/pax'
|
258
|
-
autoload :HankeHenry, 'when_exe/region/hanke_henry'
|
259
|
-
autoload :Shire, 'when_exe/region/shire'
|
260
|
-
autoload :Dee, 'when_exe/region/dee'
|
261
|
-
autoload :VanishingLeprechaun, 'when_exe/region/vanishing_leprechaun'
|
262
|
-
autoload :Yerm, 'when_exe/region/yerm'
|
263
|
-
autoload :Goddess, 'when_exe/region/goddess'
|
264
|
-
autoload :Martian, 'when_exe/region/martian'
|
265
|
-
autoload :WeekDate, 'when_exe/region/weekdate'
|
266
|
-
end
|
267
|
-
|
268
|
-
module Locale
|
269
|
-
autoload :WikipediaLinks, 'when_exe/locales/links'
|
270
|
-
autoload :IAST, 'when_exe/locales/iast'
|
271
|
-
autoload :IASTR, 'when_exe/locales/iast'
|
272
|
-
autoload :AKT, 'when_exe/locales/akt'
|
273
|
-
end
|
274
|
-
|
275
|
-
module CalendarTypes
|
276
|
-
autoload :Japanese, 'when_exe/region/japanese/calendars'
|
277
|
-
autoload :JapaneseTwin, 'when_exe/region/japanese/twins'
|
278
|
-
autoload :ChineseTwin, 'when_exe/region/chinese/twins'
|
279
|
-
autoload :ChineseSolar, 'when_exe/region/chinese'
|
280
|
-
autoload :ChineseLuniSolar, 'when_exe/region/chinese'
|
281
|
-
autoload :Yi, 'when_exe/region/chinese'
|
282
|
-
autoload :Korean, 'when_exe/region/korean'
|
283
|
-
autoload :Tibetan, 'when_exe/region/tibetan'
|
284
|
-
autoload :Thai, 'when_exe/region/thai'
|
285
|
-
autoload :ThaiP, 'when_exe/region/thai'
|
286
|
-
autoload :ThaiC, 'when_exe/region/thai'
|
287
|
-
autoload :ThaiT, 'when_exe/region/thai'
|
288
|
-
autoload :Tenganan, 'when_exe/region/balinese'
|
289
|
-
autoload :Pranatamangsa, 'when_exe/region/javanese'
|
290
|
-
autoload :IndianNationalSolar, 'when_exe/region/indian'
|
291
|
-
autoload :Nanakshahi, 'when_exe/region/indian'
|
292
|
-
autoload :RevisedBengali, 'when_exe/region/indian'
|
293
|
-
autoload :HinduLuniSolar, 'when_exe/region/indian'
|
294
|
-
autoload :HinduSolar, 'when_exe/region/indian'
|
295
|
-
autoload :Jalali, 'when_exe/region/iranian'
|
296
|
-
autoload :TableBasedJalali, 'when_exe/region/iranian'
|
297
|
-
autoload :Borji, 'when_exe/region/iranian'
|
298
|
-
autoload :TableBasedBorji, 'when_exe/region/iranian'
|
299
|
-
autoload :SolarHijri, 'when_exe/region/iranian'
|
300
|
-
autoload :SolarHijriAlgorithmic, 'when_exe/region/iranian'
|
301
|
-
autoload :Zoroastrian, 'when_exe/region/zoroastrian'
|
302
|
-
autoload :Qadimi, 'when_exe/region/zoroastrian'
|
303
|
-
autoload :Shahanshahi, 'when_exe/region/zoroastrian'
|
304
|
-
autoload :Fasli, 'when_exe/region/zoroastrian'
|
305
|
-
autoload :Bahai, 'when_exe/region/bahai'
|
306
|
-
autoload :TabularIslamic, 'when_exe/region/islamic'
|
307
|
-
autoload :EphemerisBasedIslamic, 'when_exe/region/islamic'
|
308
|
-
autoload :Jewish, 'when_exe/region/jewish'
|
309
|
-
autoload :
|
310
|
-
autoload :
|
311
|
-
autoload :
|
312
|
-
autoload :
|
313
|
-
autoload :
|
314
|
-
autoload :
|
315
|
-
autoload :
|
316
|
-
autoload :
|
317
|
-
autoload :
|
318
|
-
autoload :
|
319
|
-
autoload :
|
320
|
-
autoload :
|
321
|
-
autoload :
|
322
|
-
autoload :
|
323
|
-
autoload :
|
324
|
-
autoload :
|
325
|
-
autoload :
|
326
|
-
autoload :
|
327
|
-
autoload :
|
328
|
-
autoload :
|
329
|
-
autoload :
|
330
|
-
autoload :
|
331
|
-
autoload :
|
332
|
-
autoload :
|
333
|
-
autoload :
|
334
|
-
autoload :
|
335
|
-
autoload :
|
336
|
-
autoload :
|
337
|
-
autoload :
|
338
|
-
autoload :
|
339
|
-
autoload :
|
340
|
-
autoload :
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
'
|
345
|
-
'
|
346
|
-
'
|
347
|
-
|
348
|
-
|
349
|
-
_time_systems.
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
autoload :
|
357
|
-
autoload :
|
358
|
-
autoload :
|
359
|
-
autoload :
|
360
|
-
autoload :
|
361
|
-
autoload :
|
362
|
-
autoload :
|
363
|
-
autoload :
|
364
|
-
autoload :
|
365
|
-
autoload :
|
366
|
-
autoload :
|
367
|
-
autoload :
|
368
|
-
autoload :
|
369
|
-
autoload :
|
370
|
-
autoload :
|
371
|
-
autoload :
|
372
|
-
autoload :
|
373
|
-
|
374
|
-
|
375
|
-
autoload :
|
376
|
-
autoload :
|
377
|
-
autoload :
|
378
|
-
autoload :
|
379
|
-
autoload :
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
autoload :
|
389
|
-
autoload :
|
390
|
-
autoload :
|
391
|
-
autoload :
|
392
|
-
autoload :
|
393
|
-
autoload :
|
394
|
-
autoload :
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
Index.new({:base=>0, :unit=>
|
409
|
-
Index.new({:base=>0, :unit=>60})
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
autoload :
|
421
|
-
autoload :
|
422
|
-
autoload :
|
423
|
-
autoload :
|
424
|
-
autoload :
|
425
|
-
autoload :
|
426
|
-
autoload :
|
427
|
-
autoload :
|
428
|
-
autoload :
|
429
|
-
autoload :
|
430
|
-
autoload :
|
431
|
-
autoload :
|
432
|
-
autoload :
|
433
|
-
autoload :
|
434
|
-
autoload :
|
435
|
-
|
436
|
-
autoload :
|
437
|
-
autoload :
|
438
|
-
|
439
|
-
autoload :
|
440
|
-
autoload :
|
441
|
-
autoload :
|
442
|
-
autoload :
|
443
|
-
autoload :
|
444
|
-
autoload :
|
445
|
-
autoload :
|
446
|
-
autoload :
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
'
|
454
|
-
'
|
455
|
-
'
|
456
|
-
'
|
457
|
-
'
|
458
|
-
'
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
['@
|
467
|
-
['@
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
#
|
496
|
-
#
|
497
|
-
|
498
|
-
|
499
|
-
#
|
500
|
-
#
|
501
|
-
# @param [
|
502
|
-
#
|
503
|
-
# @param [
|
504
|
-
#
|
505
|
-
# @
|
506
|
-
#
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
when
|
516
|
-
when
|
517
|
-
when
|
518
|
-
when
|
519
|
-
when
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
#
|
529
|
-
#
|
530
|
-
#
|
531
|
-
# @param [
|
532
|
-
#
|
533
|
-
# [
|
534
|
-
# [
|
535
|
-
#
|
536
|
-
# @
|
537
|
-
#
|
538
|
-
#
|
539
|
-
#
|
540
|
-
#
|
541
|
-
#
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
#
|
554
|
-
#
|
555
|
-
#
|
556
|
-
#
|
557
|
-
# @
|
558
|
-
#
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
options[:
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
#
|
577
|
-
#
|
578
|
-
#
|
579
|
-
#
|
580
|
-
#
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
#
|
590
|
-
#
|
591
|
-
# @
|
592
|
-
#
|
593
|
-
#
|
594
|
-
#
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
#
|
604
|
-
#
|
605
|
-
# @param [
|
606
|
-
#
|
607
|
-
# @
|
608
|
-
#
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
#
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
#
|
650
|
-
#
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
#
|
660
|
-
#
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
#
|
670
|
-
#
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
#
|
682
|
-
#
|
683
|
-
#
|
684
|
-
# @
|
685
|
-
# @
|
686
|
-
# @
|
687
|
-
# @
|
688
|
-
#
|
689
|
-
#
|
690
|
-
#
|
691
|
-
#
|
692
|
-
#
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
#
|
702
|
-
#
|
703
|
-
# @
|
704
|
-
#
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
when
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
#
|
729
|
-
#
|
730
|
-
#
|
731
|
-
#
|
732
|
-
# @param [
|
733
|
-
# @param [
|
734
|
-
#
|
735
|
-
#
|
736
|
-
# @param [
|
737
|
-
#
|
738
|
-
#
|
739
|
-
#
|
740
|
-
#
|
741
|
-
#
|
742
|
-
#
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
args.
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
#
|
775
|
-
#
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
end
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
#
|
793
|
-
#
|
794
|
-
#
|
795
|
-
# @
|
796
|
-
#
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
|
806
|
-
#
|
807
|
-
#
|
808
|
-
#
|
809
|
-
#
|
810
|
-
# @
|
811
|
-
#
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
#
|
821
|
-
#
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
#
|
831
|
-
#
|
832
|
-
# @param [
|
833
|
-
# @param [
|
834
|
-
#
|
835
|
-
# @
|
836
|
-
#
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
#
|
855
|
-
#
|
856
|
-
# @
|
857
|
-
#
|
858
|
-
# @
|
859
|
-
#
|
860
|
-
# @
|
861
|
-
#
|
862
|
-
#
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
#
|
879
|
-
#
|
880
|
-
#
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
#
|
891
|
-
#
|
892
|
-
#
|
893
|
-
# @
|
894
|
-
# @
|
895
|
-
# @
|
896
|
-
# @option options [
|
897
|
-
#
|
898
|
-
#
|
899
|
-
#
|
900
|
-
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
#
|
909
|
-
#
|
910
|
-
# @
|
911
|
-
#
|
912
|
-
|
913
|
-
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
|
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
|
+
begin
|
9
|
+
require 'json'
|
10
|
+
rescue LoadError
|
11
|
+
end
|
12
|
+
begin
|
13
|
+
require 'rubygems'
|
14
|
+
rescue LoadError
|
15
|
+
end
|
16
|
+
begin
|
17
|
+
gem 'tzinfo'
|
18
|
+
autoload :TZInfo, 'tzinfo'
|
19
|
+
rescue LoadError, NoMethodError
|
20
|
+
end
|
21
|
+
begin
|
22
|
+
gem 'gcalapi'
|
23
|
+
autoload :GoogleCalendar, 'when_exe/googlecalendar'
|
24
|
+
rescue LoadError, NoMethodError
|
25
|
+
end
|
26
|
+
|
27
|
+
autoload :URI, 'uri'
|
28
|
+
autoload :OpenURI, 'open-uri'
|
29
|
+
autoload :OpenSSL, 'openssl'
|
30
|
+
autoload :FileUtils, 'fileutils'
|
31
|
+
autoload :REXML, 'rexml/document'
|
32
|
+
autoload :Mutex, 'thread' unless Object.const_defined?(:Mutex)
|
33
|
+
|
34
|
+
$:.unshift(File.dirname(__FILE__)) unless
|
35
|
+
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
36
|
+
|
37
|
+
#
|
38
|
+
# A multicultural and multilingualized calendar library based on ISO 8601, ISO 19108 and RFC 5545
|
39
|
+
#
|
40
|
+
module When
|
41
|
+
|
42
|
+
class << self
|
43
|
+
|
44
|
+
#
|
45
|
+
# マルチスレッド対応の場合 true
|
46
|
+
#
|
47
|
+
# @return [Boolean]
|
48
|
+
#
|
49
|
+
attr_reader :multi_thread
|
50
|
+
|
51
|
+
#
|
52
|
+
# Logger オブジェクト
|
53
|
+
#
|
54
|
+
# @return [Logger]
|
55
|
+
#
|
56
|
+
attr_accessor :logger
|
57
|
+
private :logger=
|
58
|
+
|
59
|
+
# Initializations
|
60
|
+
#
|
61
|
+
# @param [Hash] options 以下の通り
|
62
|
+
# @option options [When::Parts::Timezone::Base] :local デフォルトの地方時
|
63
|
+
# @option options [When::Coordinates::Spatial] :location デフォルトの空間位置
|
64
|
+
# @option options [When::TM::IntervalLength] :until V::Event::Enumerator の until
|
65
|
+
# @option options [Hash{String=>String}] :alias Locale の読替パターン ({ 読替前のlocale=>読替後のlocale })
|
66
|
+
# @option options [String] :namespace_format 名前空間定義の省略時に名前空間生成に用いる書式
|
67
|
+
# @option options [Hash{String=>String}] :unification 漢字の包摂パターン ({ 包摂前の文字列=>包摂後の文字列 })
|
68
|
+
# @option options [Array<String>] :order CalendarEra の検索順序 ([ IRI of When::TM::CalendarEra ])
|
69
|
+
# @option options [Hash{String=>Array, String}] :format strftime で用いる記号の定義 ({ 記号=>[ 書式,項目名 ] or 記号列 })
|
70
|
+
# @option options [Array<Array>] :leap_seconds 閏秒の挿入記録 ([ [JD, TAI-UTC, (MJD, OFFSET)] ])
|
71
|
+
# @option options [String] :base_uri Base URI for When_exe Resources (Default When::SourceURI)
|
72
|
+
# @option options [Hash<String=>String>] :additional_namespaces User defined namespaces (Default {})
|
73
|
+
# @option options [String] :root_dir Root Directory for When_exe Resources Cash data (Default When::RootDir)
|
74
|
+
# @option options [Boolean] :direct '_' で終わるメソッドをキャッシュせずに毎回計算するか否か
|
75
|
+
# @option options [Hash{Symbol=>boolean}] :escape 毎回 method_missing を発生させるメソッドを true にする
|
76
|
+
# @option options [false, nil] :escape to_str, to_ary, to_hash のみ毎回 method_missing を発生させる
|
77
|
+
# @option options [true] :escape すべて毎回 method_missing を発生させる
|
78
|
+
# @option options [Boolean] :multi_thread マルチスレッド対応 (true: 対応, false/nil: 非対応)
|
79
|
+
# @option options [Logger] :logger Logger オブジェクト
|
80
|
+
#
|
81
|
+
# @return [void]
|
82
|
+
#
|
83
|
+
# @note
|
84
|
+
# 本メソッドでマルチスレッド対応の管理変数の初期化を行っている。
|
85
|
+
# このため、本メソッド自体および本メソッドから呼んでいる各クラスの _setup_ メソッドはスレッドセーフでない。
|
86
|
+
#
|
87
|
+
def _setup_(options={})
|
88
|
+
@multi_thread = options[:multi_thread]
|
89
|
+
@logger = options[:logger]
|
90
|
+
Parts::MethodCash._setup_(options)
|
91
|
+
Parts::Resource._setup_(options)
|
92
|
+
Locale._setup_(options)
|
93
|
+
Coordinates::Spatial._setup_(options[:location])
|
94
|
+
TM::CalendarEra._setup_(options[:order])
|
95
|
+
TM::Calendar._setup_
|
96
|
+
TM::Clock._setup_(options[:local])
|
97
|
+
TM::TemporalPosition._setup_(options[:format])
|
98
|
+
V::Event._setup_(options[:until])
|
99
|
+
V::Timezone._setup_
|
100
|
+
Parts::Timezone._setup_
|
101
|
+
TimeStandard._setup_(options[:leap_seconds])
|
102
|
+
end
|
103
|
+
|
104
|
+
# 設定情報を取得する
|
105
|
+
#
|
106
|
+
# @return [Hash] 設定情報
|
107
|
+
#
|
108
|
+
def _setup_info
|
109
|
+
{:multi_thread => @multi_thread}.
|
110
|
+
update(Parts::MethodCash._setup_info).
|
111
|
+
update(Parts::Resource._setup_info).
|
112
|
+
update(Locale._setup_info).
|
113
|
+
update(Coordinates::Spatial._setup_info).
|
114
|
+
update(TM::CalendarEra._setup_info).
|
115
|
+
update(TM::Clock._setup_info).
|
116
|
+
update(TM::TemporalPosition._setup_info).
|
117
|
+
update(V::Event._setup_info).
|
118
|
+
update(TimeStandard._setup_info)
|
119
|
+
end
|
120
|
+
|
121
|
+
#
|
122
|
+
# When 直下に定数として定義する時法・暦法(明示的的追加)
|
123
|
+
#
|
124
|
+
# @private
|
125
|
+
def _define_common_calendar_types(list=%w(UTC Gregorian Julian Civil))
|
126
|
+
list.each do |calendar|
|
127
|
+
resource = Parts::Resource._instance(calendar, '_c:')
|
128
|
+
Parts::Resource.synchronize do
|
129
|
+
Parts::Resource::ConstList << calendar
|
130
|
+
const_set(calendar, resource)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
alias :_const_missing :const_missing
|
136
|
+
|
137
|
+
#
|
138
|
+
# When 直下に定数として定義する時法・暦法など(暗黙的追加)
|
139
|
+
#
|
140
|
+
def const_missing(constant)
|
141
|
+
sgn, *args = TM::PeriodDuration._to_array(constant.to_s)
|
142
|
+
return const_set(constant, TM::PeriodDuration.new(*args)) if sgn
|
143
|
+
iri = Parts::Resource._abbreviation_to_iri(constant)
|
144
|
+
return _const_missing(constant) unless iri
|
145
|
+
resource = Parts::Resource._instance(iri)
|
146
|
+
return const_get(constant) if const_defined?(constant)
|
147
|
+
Parts::Resource.synchronize do
|
148
|
+
Parts::Resource::ConstList << constant
|
149
|
+
const_set(constant, resource)
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
#
|
155
|
+
# when_exe 用 International Resource Identifier
|
156
|
+
#
|
157
|
+
SourceURI = "http://hosi.org/When/"
|
158
|
+
|
159
|
+
#
|
160
|
+
# ライブラリのあるディレクトリ
|
161
|
+
#
|
162
|
+
RootDir = File.dirname(__FILE__).sub(/\/[^\/]*\z/,'')
|
163
|
+
|
164
|
+
require 'when_exe/version'
|
165
|
+
require 'when_exe/locales/locale'
|
166
|
+
require 'when_exe/locales/autoload'
|
167
|
+
require 'when_exe/parts/enumerator'
|
168
|
+
require 'when_exe/parts/resource'
|
169
|
+
require 'when_exe/parts/geometric_complex'
|
170
|
+
require 'when_exe/parts/timezone'
|
171
|
+
require 'when_exe/core/compatibility'
|
172
|
+
require 'when_exe/basictypes'
|
173
|
+
require 'when_exe/ephemeris'
|
174
|
+
require 'when_exe/coordinates'
|
175
|
+
require 'when_exe/icalendar'
|
176
|
+
require 'when_exe/tmobjects'
|
177
|
+
require 'when_exe/timestandard'
|
178
|
+
require 'when_exe/tmposition'
|
179
|
+
require 'when_exe/tmreference'
|
180
|
+
require 'when_exe/calendartypes'
|
181
|
+
require 'when_exe/calendarnote'
|
182
|
+
require 'when_exe/region/m17n'
|
183
|
+
require 'when_exe/region/residue'
|
184
|
+
require 'when_exe/inspect'
|
185
|
+
|
186
|
+
#
|
187
|
+
# Module Constants
|
188
|
+
#
|
189
|
+
|
190
|
+
# 1 second period duration
|
191
|
+
PT1S = TM::PeriodDuration.new(nil,[0,0,0,1])
|
192
|
+
|
193
|
+
# 1 minute period duration
|
194
|
+
PT1M = TM::PeriodDuration.new(nil,[0,0,1,0])
|
195
|
+
|
196
|
+
# 1 hour period duration
|
197
|
+
PT1H = TM::PeriodDuration.new(nil,[0,1,0,0])
|
198
|
+
|
199
|
+
# 1 day period duration
|
200
|
+
P1D = TM::PeriodDuration.new([0,0,1])
|
201
|
+
|
202
|
+
# 1 week period duration
|
203
|
+
P1W = TM::PeriodDuration.new([0,0,7])
|
204
|
+
|
205
|
+
# 1 month period duration
|
206
|
+
P1M = TM::PeriodDuration.new([0,1,0])
|
207
|
+
|
208
|
+
# 1 year period duration
|
209
|
+
P1Y = TM::PeriodDuration.new([1,0,0])
|
210
|
+
|
211
|
+
# kind of When::TM::Position or When::TM::TemporalPosition
|
212
|
+
TimeValue = TM::IndeterminateValue
|
213
|
+
|
214
|
+
# 7 days week residue
|
215
|
+
Week = When::Parts::Resource._instance('_co:Common::Week')
|
216
|
+
|
217
|
+
# Gregorian months
|
218
|
+
Month = When::Parts::Resource._instance('_m:Calendar::Month')
|
219
|
+
|
220
|
+
# + ∞
|
221
|
+
PlusInfinity = TM::TemporalPosition.new({:indeterminated_position=>TimeValue::Max})
|
222
|
+
|
223
|
+
# - ∞
|
224
|
+
MinusInfinity = TM::TemporalPosition.new({:indeterminated_position=>TimeValue::Min})
|
225
|
+
|
226
|
+
# UTF-8 encoding
|
227
|
+
UTF8 = '.UTF-8'
|
228
|
+
|
229
|
+
# Windows-31J encoding
|
230
|
+
W31J = '.Windows-31J'
|
231
|
+
|
232
|
+
# eucJP encoding
|
233
|
+
EUCJP = '.eucJP'
|
234
|
+
|
235
|
+
class BasicTypes::M17n
|
236
|
+
autoload :Japanese, 'when_exe/region/japanese'
|
237
|
+
autoload :Chinese, 'when_exe/region/chinese'
|
238
|
+
autoload :Yi, 'when_exe/region/chinese'
|
239
|
+
autoload :Tibetan, 'when_exe/region/tibetan'
|
240
|
+
autoload :Thai, 'when_exe/region/thai'
|
241
|
+
autoload :Balinese, 'when_exe/region/balinese'
|
242
|
+
autoload :Javanese, 'when_exe/region/javanese'
|
243
|
+
autoload :Indian, 'when_exe/region/indian'
|
244
|
+
autoload :Iranian, 'when_exe/region/iranian'
|
245
|
+
autoload :Islamic, 'when_exe/region/islamic'
|
246
|
+
autoload :Jewish, 'when_exe/region/jewish'
|
247
|
+
autoload :AncientOrient, 'when_exe/region/babylonian'
|
248
|
+
autoload :Armenian, 'when_exe/region/armenian'
|
249
|
+
autoload :Roman, 'when_exe/region/roman'
|
250
|
+
autoload :Coptic, 'when_exe/region/coptic'
|
251
|
+
autoload :French, 'when_exe/region/french'
|
252
|
+
autoload :World, 'when_exe/region/world'
|
253
|
+
autoload :Positivist, 'when_exe/region/positivist'
|
254
|
+
autoload :InternationalFixed, 'when_exe/region/international_fixed'
|
255
|
+
autoload :WorldSeason, 'when_exe/region/world_season'
|
256
|
+
autoload :Tranquility, 'when_exe/region/tranquility'
|
257
|
+
autoload :Pax, 'when_exe/region/pax'
|
258
|
+
autoload :HankeHenry, 'when_exe/region/hanke_henry'
|
259
|
+
autoload :Shire, 'when_exe/region/shire'
|
260
|
+
autoload :Dee, 'when_exe/region/dee'
|
261
|
+
autoload :VanishingLeprechaun, 'when_exe/region/vanishing_leprechaun'
|
262
|
+
autoload :Yerm, 'when_exe/region/yerm'
|
263
|
+
autoload :Goddess, 'when_exe/region/goddess'
|
264
|
+
autoload :Martian, 'when_exe/region/martian'
|
265
|
+
autoload :WeekDate, 'when_exe/region/weekdate'
|
266
|
+
end
|
267
|
+
|
268
|
+
module Locale
|
269
|
+
autoload :WikipediaLinks, 'when_exe/locales/links'
|
270
|
+
autoload :IAST, 'when_exe/locales/iast'
|
271
|
+
autoload :IASTR, 'when_exe/locales/iast'
|
272
|
+
autoload :AKT, 'when_exe/locales/akt'
|
273
|
+
end
|
274
|
+
|
275
|
+
module CalendarTypes
|
276
|
+
autoload :Japanese, 'when_exe/region/japanese/calendars'
|
277
|
+
autoload :JapaneseTwin, 'when_exe/region/japanese/twins'
|
278
|
+
autoload :ChineseTwin, 'when_exe/region/chinese/twins'
|
279
|
+
autoload :ChineseSolar, 'when_exe/region/chinese'
|
280
|
+
autoload :ChineseLuniSolar, 'when_exe/region/chinese'
|
281
|
+
autoload :Yi, 'when_exe/region/chinese'
|
282
|
+
autoload :Korean, 'when_exe/region/korean'
|
283
|
+
autoload :Tibetan, 'when_exe/region/tibetan'
|
284
|
+
autoload :Thai, 'when_exe/region/thai'
|
285
|
+
autoload :ThaiP, 'when_exe/region/thai'
|
286
|
+
autoload :ThaiC, 'when_exe/region/thai'
|
287
|
+
autoload :ThaiT, 'when_exe/region/thai'
|
288
|
+
autoload :Tenganan, 'when_exe/region/balinese'
|
289
|
+
autoload :Pranatamangsa, 'when_exe/region/javanese'
|
290
|
+
autoload :IndianNationalSolar, 'when_exe/region/indian'
|
291
|
+
autoload :Nanakshahi, 'when_exe/region/indian'
|
292
|
+
autoload :RevisedBengali, 'when_exe/region/indian'
|
293
|
+
autoload :HinduLuniSolar, 'when_exe/region/indian'
|
294
|
+
autoload :HinduSolar, 'when_exe/region/indian'
|
295
|
+
autoload :Jalali, 'when_exe/region/iranian'
|
296
|
+
autoload :TableBasedJalali, 'when_exe/region/iranian'
|
297
|
+
autoload :Borji, 'when_exe/region/iranian'
|
298
|
+
autoload :TableBasedBorji, 'when_exe/region/iranian'
|
299
|
+
autoload :SolarHijri, 'when_exe/region/iranian'
|
300
|
+
autoload :SolarHijriAlgorithmic, 'when_exe/region/iranian'
|
301
|
+
autoload :Zoroastrian, 'when_exe/region/zoroastrian'
|
302
|
+
autoload :Qadimi, 'when_exe/region/zoroastrian'
|
303
|
+
autoload :Shahanshahi, 'when_exe/region/zoroastrian'
|
304
|
+
autoload :Fasli, 'when_exe/region/zoroastrian'
|
305
|
+
autoload :Bahai, 'when_exe/region/bahai'
|
306
|
+
autoload :TabularIslamic, 'when_exe/region/islamic'
|
307
|
+
autoload :EphemerisBasedIslamic, 'when_exe/region/islamic'
|
308
|
+
autoload :Jewish, 'when_exe/region/jewish'
|
309
|
+
autoload :Hebrew, 'when_exe/region/jewish'
|
310
|
+
autoload :Armenian, 'when_exe/region/armenian'
|
311
|
+
autoload :Babylonian, 'when_exe/region/babylonian'
|
312
|
+
autoload :BabylonianPD, 'when_exe/region/babylonian'
|
313
|
+
autoload :Seleucid, 'when_exe/region/babylonian'
|
314
|
+
autoload :SeleucidPD, 'when_exe/region/babylonian'
|
315
|
+
autoload :Ptolemaic, 'when_exe/region/coptic'
|
316
|
+
autoload :Coptic, 'when_exe/region/coptic'
|
317
|
+
autoload :JulianA, 'when_exe/region/roman'
|
318
|
+
autoload :JulianB, 'when_exe/region/roman'
|
319
|
+
autoload :JulianC, 'when_exe/region/roman'
|
320
|
+
autoload :Roman, 'when_exe/region/roman'
|
321
|
+
autoload :Gregorian, 'when_exe/region/christian'
|
322
|
+
autoload :FrenchRepublican, 'when_exe/region/french'
|
323
|
+
autoload :World, 'when_exe/region/world'
|
324
|
+
autoload :LongCount, 'when_exe/region/mayan'
|
325
|
+
autoload :Positivist, 'when_exe/region/positivist'
|
326
|
+
autoload :InternationalFixed, 'when_exe/region/international_fixed'
|
327
|
+
autoload :WorldSeason, 'when_exe/region/world_season'
|
328
|
+
autoload :Pax, 'when_exe/region/pax'
|
329
|
+
autoload :Tranquility, 'when_exe/region/tranquility'
|
330
|
+
autoload :HankeHenry, 'when_exe/region/hanke_henry'
|
331
|
+
autoload :Discordian, 'when_exe/region/discordian'
|
332
|
+
autoload :Shire, 'when_exe/region/shire'
|
333
|
+
autoload :Sym454, 'when_exe/region/symmetry'
|
334
|
+
autoload :Sym010, 'when_exe/region/symmetry'
|
335
|
+
autoload :Dee, 'when_exe/region/dee'
|
336
|
+
autoload :DeeCecil, 'when_exe/region/dee'
|
337
|
+
autoload :VanishingLeprechaun, 'when_exe/region/vanishing_leprechaun'
|
338
|
+
autoload :Yerm, 'when_exe/region/yerm'
|
339
|
+
autoload :Goddess, 'when_exe/region/goddess'
|
340
|
+
autoload :Darian, 'when_exe/region/martian'
|
341
|
+
autoload :WeekDate, 'when_exe/region/weekdate'
|
342
|
+
|
343
|
+
_time_systems = {
|
344
|
+
'LMT' => nil, # Local Mean Time
|
345
|
+
'LAT' => nil, # Local Apparent Time
|
346
|
+
'THS' => nil, # Temporal Hour System
|
347
|
+
'MTC' => 'when_exe/region/martian', # Martian Time, Coordinated
|
348
|
+
}
|
349
|
+
TimeSystems = _time_systems.keys.join('|')
|
350
|
+
_time_systems.each_pair do |key, required|
|
351
|
+
autoload key.to_sym, required if required
|
352
|
+
end
|
353
|
+
end
|
354
|
+
|
355
|
+
class CalendarNote
|
356
|
+
autoload :SolarTerms, 'when_exe/ephemeris/notes'
|
357
|
+
autoload :LunarPhases, 'when_exe/ephemeris/notes'
|
358
|
+
autoload :Ephemeris, 'when_exe/ephemeris/notes'
|
359
|
+
autoload :Japanese, 'when_exe/region/japanese/notes'
|
360
|
+
autoload :CommonWithRokuyo, 'when_exe/region/japanese/weeks'
|
361
|
+
autoload :RokuyoWeek, 'when_exe/region/japanese/weeks'
|
362
|
+
autoload :Yis, 'when_exe/region/chinese'
|
363
|
+
autoload :Balinese, 'when_exe/region/balinese'
|
364
|
+
autoload :Javanese, 'when_exe/region/javanese'
|
365
|
+
autoload :Tibetan, 'when_exe/region/tibetan'
|
366
|
+
autoload :Bahai, 'when_exe/region/bahai'
|
367
|
+
autoload :Roman, 'when_exe/region/roman'
|
368
|
+
autoload :Mayan, 'when_exe/region/mayan'
|
369
|
+
autoload :Discordian, 'when_exe/region/discordian'
|
370
|
+
autoload :CommonWithSovietFiveDay, 'when_exe/region/soviet'
|
371
|
+
autoload :SovietFiveDayWeek, 'when_exe/region/soviet'
|
372
|
+
autoload :CommonWithSovietSixDay, 'when_exe/region/soviet'
|
373
|
+
autoload :SovietSixDayWeek, 'when_exe/region/soviet'
|
374
|
+
# autoload :Yerm, 'when_exe/region/yerm'
|
375
|
+
autoload :WorldWeek, 'when_exe/region/world'
|
376
|
+
autoload :PositivistWeek, 'when_exe/region/positivist'
|
377
|
+
autoload :InternationalFixedWeek, 'when_exe/region/international_fixed'
|
378
|
+
autoload :TranquilityWeek, 'when_exe/region/tranquility'
|
379
|
+
autoload :WorldSeasonWeek, 'when_exe/region/world_season'
|
380
|
+
autoload :ShireWeek, 'when_exe/region/shire'
|
381
|
+
|
382
|
+
Default = [['_m:Calendar::Month'], ['Common::Week']]
|
383
|
+
JulianDay = [['Common::Week', 'Common::干支']]
|
384
|
+
Chinese = [['Common::干支'], ['_m:Calendar::Month'], ['Common::Week', 'Common::干支']]
|
385
|
+
end
|
386
|
+
|
387
|
+
module Coordinates
|
388
|
+
autoload :Tibetan, 'when_exe/region/tibetan'
|
389
|
+
autoload :Yi, 'when_exe/region/chinese'
|
390
|
+
autoload :Javanese, 'when_exe/region/javanese'
|
391
|
+
autoload :Indian, 'when_exe/region/indian'
|
392
|
+
autoload :Iranian, 'when_exe/region/iranian'
|
393
|
+
autoload :Bahai, 'when_exe/region/bahai'
|
394
|
+
autoload :Roman, 'when_exe/region/roman'
|
395
|
+
autoload :Mayan, 'when_exe/region/mayan'
|
396
|
+
|
397
|
+
# default index for day coordinate
|
398
|
+
DefaultDayIndex = Index.new
|
399
|
+
|
400
|
+
# default indices for date coordinates
|
401
|
+
DefaultDateIndices = [
|
402
|
+
Index.new(When::Parts::Resource._instance('_m:Calendar::Month'), {:unit =>12}),
|
403
|
+
DefaultDayIndex
|
404
|
+
]
|
405
|
+
|
406
|
+
# default indices for time coordinates
|
407
|
+
DefaultTimeIndices = [
|
408
|
+
Index.new({:base=>0, :unit=>24}),
|
409
|
+
Index.new({:base=>0, :unit=>60}),
|
410
|
+
Index.new({:base=>0, :unit=>60})
|
411
|
+
]
|
412
|
+
end
|
413
|
+
|
414
|
+
module TM
|
415
|
+
class OrdinalReferenceSystem
|
416
|
+
autoload :GeologicalAge, 'when_exe/region/geologicalage'
|
417
|
+
end
|
418
|
+
|
419
|
+
class CalendarEra
|
420
|
+
autoload :Japanese, 'when_exe/region/japanese/epochs'
|
421
|
+
autoload :JapanesePrimeMinister, 'when_exe/region/japanese/epochs'
|
422
|
+
autoload :NihonKoki, 'when_exe/region/japanese/nihon_shoki'
|
423
|
+
autoload :NihonShoki, 'when_exe/region/japanese/nihon_shoki'
|
424
|
+
autoload :JapaneseSolar, 'when_exe/region/japanese/twins'
|
425
|
+
autoload :JapaneseLuniSolar, 'when_exe/region/japanese/twins'
|
426
|
+
autoload :Chinese, 'when_exe/region/chinese/epochs'
|
427
|
+
autoload :ChineseSolar, 'when_exe/region/chinese/twins'
|
428
|
+
autoload :ChineseLuniSolar, 'when_exe/region/chinese/twins'
|
429
|
+
autoload :Ryukyu, 'when_exe/region/ryukyu'
|
430
|
+
autoload :Korean, 'when_exe/region/korean'
|
431
|
+
autoload :Vietnamese, 'when_exe/region/vietnamese'
|
432
|
+
autoload :Manchurian, 'when_exe/region/east_asian'
|
433
|
+
autoload :Rouran, 'when_exe/region/east_asian'
|
434
|
+
autoload :Gaochang, 'when_exe/region/east_asian'
|
435
|
+
autoload :Yunnan, 'when_exe/region/east_asian'
|
436
|
+
autoload :WesternXia, 'when_exe/region/east_asian'
|
437
|
+
autoload :KaraKhitan, 'when_exe/region/east_asian'
|
438
|
+
# autoload :Tibetan, 'when_exe/region/tibetan'
|
439
|
+
autoload :BalineseLuniSolar, 'when_exe/region/balinese'
|
440
|
+
autoload :JavaneseLunar, 'when_exe/region/javanese'
|
441
|
+
autoload :Iranian, 'when_exe/region/iranian'
|
442
|
+
autoload :Hijra, 'when_exe/region/islamic'
|
443
|
+
autoload :Jewish, 'when_exe/region/jewish'
|
444
|
+
autoload :AncientOrient, 'when_exe/region/babylonian'
|
445
|
+
autoload :Roman, 'when_exe/region/roman'
|
446
|
+
autoload :Julian, 'when_exe/region/roman'
|
447
|
+
autoload :Pope, 'when_exe/region/pope'
|
448
|
+
autoload :Byzantine, 'when_exe/region/christian'
|
449
|
+
autoload :LongCount, 'when_exe/region/mayan'
|
450
|
+
|
451
|
+
# Defualt search path for Epochs and Eras
|
452
|
+
DefaultEpochs = ['Common', 'ModernJapanese',
|
453
|
+
'Hijra', 'Jewish', 'Iranian',
|
454
|
+
'Roman', 'Byzantine', 'AncientOrient', 'LongCount',
|
455
|
+
'BalineseLuniSolar', 'JavaneseLunar',
|
456
|
+
'Japanese', 'JapanesePrimeMinister', 'NihonKoki', 'NihonShoki',
|
457
|
+
'Chinese', 'Ryukyu', 'Vietnamese', 'Korean',
|
458
|
+
'JapaneseSolar', 'JapaneseLuniSolar',
|
459
|
+
'ChineseSolar', 'ChineseLuniSolar',
|
460
|
+
'Manchurian', 'Rouran', 'Gaochang',
|
461
|
+
'Yunnan', 'WesternXia', 'KaraKhitan', # 'Tibetan',
|
462
|
+
'Pope' ]
|
463
|
+
|
464
|
+
# Defualt events for Epochs and Eras
|
465
|
+
DefaultEvents = Hash[*([['@A', 'Accession' ],
|
466
|
+
['@FE', 'FelicitousEvent' ],
|
467
|
+
['@ND', 'NaturalDisaster' ],
|
468
|
+
['@IY', 'InauspiciousYear'],
|
469
|
+
['@F', 'Foundation' ],
|
470
|
+
['@CR', 'CalendarReform' ],
|
471
|
+
['@CE', 'CalendarEpoch' ]].map {|e|
|
472
|
+
[e[0], When::Parts::Resource._instance('EpochEvents::'+e[1], '_m:')]
|
473
|
+
}.flatten)]
|
474
|
+
|
475
|
+
# Common Era
|
476
|
+
Common = [{}, self, [
|
477
|
+
'area:Common#{?Reform=Reform}',
|
478
|
+
['[BeforeCommonEra=en:BCE_(disambiguation),*alias:BCE]0.1.1'],
|
479
|
+
['[CommonEra=en:Common_Era,*alias:CE]1.1.1', '@CE', '01-01-01^Julian'],
|
480
|
+
['[CommonEra=en:Common_Era,*alias:CE]#{Reform:1582.10.15}', '@CR', '#{Reform:1582.10.15}^Gregorian']
|
481
|
+
]]
|
482
|
+
|
483
|
+
# Modern Japanese Eras after the calendar reform to the Gregorian Calendar
|
484
|
+
ModernJapanese = [self, [
|
485
|
+
'area:[ModernJapanese]',
|
486
|
+
['[M=,alias:明=ja:%%<明治>]6.01.01', '@CR', '1873-01-01^Gregorian?note=Default'],
|
487
|
+
['[T=,alias:大=ja:%%<大正>]1.07.30', '@A', '1912-07-30'],
|
488
|
+
['[S=,alias:昭=ja:%%<昭和>]1.12.25', '@A', '1926-12-25'],
|
489
|
+
['[H=,alias:平=ja:%%<平成>]1.01.08', '@A', '1989-01-08']
|
490
|
+
]]
|
491
|
+
end
|
492
|
+
end
|
493
|
+
|
494
|
+
#
|
495
|
+
# Module Functions
|
496
|
+
#
|
497
|
+
module_function
|
498
|
+
|
499
|
+
# Generation of Temporal Objetct, duration or When::Parts::GeometricComplex
|
500
|
+
#
|
501
|
+
# @param [String] specification When.exe Standard Representation または ユリウス日JDN として解釈して生成する
|
502
|
+
# @param [Numeric] specification ユリウス日として解釈して生成する
|
503
|
+
# @param [Array] specification 要素を個別に解釈して生成したオブジェクトのArrayを返す
|
504
|
+
# @param [When::TM::TemporalPosition, When::Parts::GeometricComplex] specification specificationをそのまま返す
|
505
|
+
# @param [When::TM::TemporalPosition] specification specification.any_otherを返す
|
506
|
+
#
|
507
|
+
# @param [Hash] options 暦法や時法などの指定 (see {When::TM::TemporalPosition._instance})
|
508
|
+
#
|
509
|
+
# @return [When::TM::TemporalPosition, When::TM::Duration, When::Parts::GeometricComplex or Array<them>]
|
510
|
+
#
|
511
|
+
def when?(specification, options={})
|
512
|
+
|
513
|
+
# フォーマットごとの処理
|
514
|
+
case specification
|
515
|
+
when TM::TemporalPosition, Parts::GeometricComplex ; specification
|
516
|
+
when TM::Position ; specification.any_other
|
517
|
+
when Array ; begin options = TM::TemporalPosition._options(options) ; specification.map {|e| when?(e, options)} end
|
518
|
+
when /\Atoday\z/i ; today(options)
|
519
|
+
when /\Anow\z/i ; now(options)
|
520
|
+
when /(JDN|MJD|SDN|CEP)(\z|\^)/i; TM::JulianDate.parse(specification, options)
|
521
|
+
when /[\n\r]+/ ; when?(specification.split(/[\n\r]+/), options)
|
522
|
+
when String ; TM::TemporalPosition._instance(EncodingConversion.to_internal_encoding(specification), options)
|
523
|
+
when Numeric ; TM::JulianDate.new(+specification, TM::TemporalPosition._options(options))
|
524
|
+
else ; Calendar(options[:frame] || 'Gregorian').jul_trans(specification, options)
|
525
|
+
end
|
526
|
+
end
|
527
|
+
|
528
|
+
# When::TM::TemporalPosition の生成
|
529
|
+
#
|
530
|
+
# @overload TemporalPosition(*args, options={})
|
531
|
+
# @param [String or [String, Integer], Numeric, ...] args
|
532
|
+
# [String] 年号
|
533
|
+
# [Array<String, Integer>] 年号と 0 年の通年
|
534
|
+
# [Numeric] 年月日時分秒(途中で打ち切り可)
|
535
|
+
# @param [Hash] options 暦法や時法などの指定
|
536
|
+
# @option options [Symbol] :invalid
|
537
|
+
# [:raise 日時が存在しない場合例外発生 ]
|
538
|
+
# [:check 日時が存在しない場合 nil を返す ]
|
539
|
+
# [その他/nil 日時が存在することを確認しない(デフォルト)]
|
540
|
+
# @see When::TM::TemporalPosition._instance
|
541
|
+
#
|
542
|
+
# @return [When::TM::TemporalPosition]
|
543
|
+
# @raise [ArgumentError]
|
544
|
+
# options[ :invalid ] が :raise で、日時が存在しない場合
|
545
|
+
#
|
546
|
+
def TemporalPosition(*args)
|
547
|
+
TM::TemporalPosition._temporal_position(*args)
|
548
|
+
end
|
549
|
+
|
550
|
+
alias :tm_pos :TemporalPosition
|
551
|
+
module_function :tm_pos
|
552
|
+
|
553
|
+
# 指定日時に対応する When::TM::TemporalPosition の生成
|
554
|
+
# (When::TM::DateAndTime of specified Time)
|
555
|
+
#
|
556
|
+
# @param [::Time] time 変換元の日時のTimeオブジェクト
|
557
|
+
# @param [Float] time 1970-01-01T00:00:00Z からの経過秒数
|
558
|
+
# @param [Hash] options 暦法や時法などの指定
|
559
|
+
# @see When::TM::TemporalPosition._instance
|
560
|
+
#
|
561
|
+
# @return [When::TM::DateAndTime]
|
562
|
+
#
|
563
|
+
def at(time, options={})
|
564
|
+
options = options._attr if options.kind_of?(TM::TemporalPosition)
|
565
|
+
options[:frame] ||= 'Gregorian'
|
566
|
+
options[:frame] = Resource(options[:frame], '_c:') if options[:frame].kind_of?(String)
|
567
|
+
options[:clock] ||= Clock(time.utc_offset) if time.kind_of?(::Time)
|
568
|
+
jdt = TM::JulianDate.universal_time(time.to_f * TM::IntervalLength::SECOND, {:frame=>TM::Clock.get_clock(options)})
|
569
|
+
options[:clock] = jdt.frame
|
570
|
+
date = options[:frame].jul_trans(jdt, options)
|
571
|
+
date = TM::CalDate.new(date.cal_date, options) if options[:precision] &&
|
572
|
+
options[:precision] <= DAY
|
573
|
+
return date
|
574
|
+
end
|
575
|
+
|
576
|
+
# 現在日時に対応する When::TM::TemporalPosition の生成
|
577
|
+
# (When::TM::DateAndTime of now)
|
578
|
+
# @note メソッド実行時の「現在日時」である。@indeterminated_position は設定しないので自動的に日時が進むことはない
|
579
|
+
#
|
580
|
+
# @param [Hash] options 暦法や時法などの指定
|
581
|
+
# @see When::TM::TemporalPosition._instance
|
582
|
+
#
|
583
|
+
# @return [When::TM::DateAndTime]
|
584
|
+
#
|
585
|
+
def now(options={})
|
586
|
+
When.at(Time.now, options)
|
587
|
+
end
|
588
|
+
|
589
|
+
# 本日に対応する When::TM::CalDate の生成
|
590
|
+
# (When::TM::CalDate of today)
|
591
|
+
# @note メソッド実行時の「本日」である。@indeterminated_position は設定しないので自動的に日時が進むことはない
|
592
|
+
# @note options で時間帯を指定しても「本日」の決定に使用するのみで、戻り値には反映されない
|
593
|
+
#
|
594
|
+
# @param [Hash] options 暦法や時法などの指定
|
595
|
+
# @see When::TM::TemporalPosition._instance
|
596
|
+
#
|
597
|
+
# @return [When::TM::CalDate]
|
598
|
+
#
|
599
|
+
def today(options={})
|
600
|
+
now(options.merge({:precision=>DAY}))
|
601
|
+
end
|
602
|
+
|
603
|
+
# When::TM::Duration の生成
|
604
|
+
#
|
605
|
+
# @param [String] period When.exe Standard Representation として解釈して生成する
|
606
|
+
# @param [Numeric] period When::TM::IntervalLength::SYSTEM 単位の値として解釈して生成する
|
607
|
+
# @param [Array] period 要素を個別に解釈して生成したオブジェクトのArrayを返す
|
608
|
+
# @param [When::TM::Duration] period 処理を行わず、そのまま返す
|
609
|
+
# @param [Hash] options 現時点では未使用
|
610
|
+
#
|
611
|
+
# @return [When::TM::Duration or Array<them>]
|
612
|
+
#
|
613
|
+
def Duration(period, options={})
|
614
|
+
case period
|
615
|
+
when Array
|
616
|
+
period.map {|e| Duration(e, options)}
|
617
|
+
|
618
|
+
when TM::Duration
|
619
|
+
period
|
620
|
+
|
621
|
+
when 0
|
622
|
+
TM::IntervalLength.new(0, 'day')
|
623
|
+
|
624
|
+
when Numeric
|
625
|
+
[TM::Duration::YEAR, TM::Duration::MONTH, TM::Duration::WEEK, TM::Duration::DAY,
|
626
|
+
TM::Duration::HOUR, TM::Duration::MINUTE, TM::Duration::SECOND].each do |unit|
|
627
|
+
div, mod = period.divmod(unit)
|
628
|
+
return TM::IntervalLength.new(div, TM::Duration::Unit.invert[unit]) if mod == 0
|
629
|
+
end
|
630
|
+
TM::IntervalLength.new(period, 'system')
|
631
|
+
|
632
|
+
when String
|
633
|
+
# IntervalLength
|
634
|
+
args = TM::IntervalLength._to_array(period)
|
635
|
+
return TM::IntervalLength.new(*args) if args
|
636
|
+
|
637
|
+
# PeriodDuration
|
638
|
+
sign, *args = TM::PeriodDuration._to_array(period)
|
639
|
+
raise TypeError, "Argument 'period' is not a Duration" unless (sign)
|
640
|
+
args << options
|
641
|
+
duration = TM::PeriodDuration.new(*args)
|
642
|
+
return (sign >= 0) ? duration : -duration
|
643
|
+
|
644
|
+
else
|
645
|
+
nil
|
646
|
+
end
|
647
|
+
end
|
648
|
+
|
649
|
+
# When::TM::Calendar の生成/参照
|
650
|
+
#
|
651
|
+
# @param [String] calendar 暦法を表す文字列
|
652
|
+
#
|
653
|
+
# @return [When::TM::Calendar] calendar に対応する When::TM::Calendar オブジェクト
|
654
|
+
#
|
655
|
+
def Calendar(calendar)
|
656
|
+
Parts::Resource._instance(calendar, '_c:')
|
657
|
+
end
|
658
|
+
|
659
|
+
# When::CalendarNote の生成/参照
|
660
|
+
#
|
661
|
+
# @param [String] note 暦注リストを表す文字列
|
662
|
+
#
|
663
|
+
# @return [When::CalendarNote] note に対応する When::CalendarNote オブジェクト
|
664
|
+
#
|
665
|
+
def CalendarNote(note)
|
666
|
+
Parts::Resource._instance(note, '_n:')
|
667
|
+
end
|
668
|
+
|
669
|
+
# When::TM::CalendarEra の生成/参照
|
670
|
+
#
|
671
|
+
# @param [String] era 暦年代を表す文字列
|
672
|
+
#
|
673
|
+
# @return [When::TM::CalendarEra] era に対応する When::TM::CalendarEra オブジェクト
|
674
|
+
#
|
675
|
+
def CalendarEra(era)
|
676
|
+
Parts::Resource._instance(era, '_e:') do |iri|
|
677
|
+
TM::CalendarEra.send(:_behalf_of, iri)
|
678
|
+
end
|
679
|
+
end
|
680
|
+
|
681
|
+
# When::TM::CalendarEra の検索
|
682
|
+
#
|
683
|
+
# @overload era(key, epoch=nil, reverse=nil, options={})
|
684
|
+
# @param [String, Regexp] key 検索する暦年代または、暦年代にマッチする正規表現
|
685
|
+
# @param [Integer] epoch 年数を昇順にカウントする方式での暦元(0年)の通年(デフォルトは nil - 指定なし)
|
686
|
+
# @param [Integer] reverse 年数を降順にカウントする方式での暦元(0年)の通年(デフォルトは nil - 指定なし)
|
687
|
+
# @param [Hash] options 以下の通り
|
688
|
+
# @option options [String] :area 暦年代の使用地域の指定(デフォルトは nil - 指定なし)
|
689
|
+
# @option options [String] :period 暦年代の使用時代の指定(デフォルトは nil - 指定なし)
|
690
|
+
# @option options [Integer] :count 何件ヒットするまで検索するかを指定(デフォルトは 1件)
|
691
|
+
# @option options [String] the_others 例えば When::TM::CalendarEra オブジェクトの epoch_of_use に 'name' などの
|
692
|
+
# 指定がある場合、:name に指定しておけば、検索での絞り込みに使用できる。
|
693
|
+
#
|
694
|
+
# @return [Array<When::TM::CalendarEra>] 検索結果を When::TM::CalendarEra オブジェクトの Array で返す
|
695
|
+
# @note ヒット数が不足している場合は、_setup_ で指定した順序で When::TM::CalendarEra オブジェクトを生成しつつ読み込んで検索する。
|
696
|
+
#
|
697
|
+
def era(*args)
|
698
|
+
TM::CalendarEra._instance(*args)
|
699
|
+
end
|
700
|
+
|
701
|
+
# When::TM::Clock の生成/参照
|
702
|
+
#
|
703
|
+
# @param [When::Parts::Timezone::Base] clock なにもせず clock をそのまま返す
|
704
|
+
# @param [String] clock 時法を表す文字列
|
705
|
+
# @param [Numeric] clock 秒を単位として表した時差(東経側を + とする)
|
706
|
+
#
|
707
|
+
# @return [When::Parts::Timezone::Base] 生成/参照した When::Parts::Timezone::Base オブジェクト
|
708
|
+
#
|
709
|
+
def Clock(clock)
|
710
|
+
case clock
|
711
|
+
when Parts::Timezone::Base ; return clock
|
712
|
+
when 'Z', 0 ; return UTC
|
713
|
+
when Numeric ; return Parts::Resource._instance("_tm:Clock?label=" + TM::Clock.to_hms(clock))
|
714
|
+
when /\A#{CalendarTypes::TimeSystems}/ ; return Parts::Resource._instance('_c:' + clock)
|
715
|
+
when String ;
|
716
|
+
else ; raise TypeError, "Invalid Type: #{clock.class}"
|
717
|
+
end
|
718
|
+
c = TM::Clock[clock] || V::Timezone[clock]
|
719
|
+
return c if c
|
720
|
+
clock, options = clock.split('?')
|
721
|
+
hms = TM::Clock.to_hms(clock)
|
722
|
+
return Parts::Timezone[clock] unless hms
|
723
|
+
iri = "_tm:Clock?label=" + hms
|
724
|
+
iri += "&" + options if options
|
725
|
+
Parts::Resource._instance(iri)
|
726
|
+
end
|
727
|
+
|
728
|
+
# When::Coordinates::Spatial の生成/参照
|
729
|
+
#
|
730
|
+
# @overload Location(location)
|
731
|
+
# @param [When::Coordinates::Spatial] location なにもせず location をそのまま返す
|
732
|
+
# @param [String] location 空間位置の IRI (デフォルトプレフィクス _l:)
|
733
|
+
# @param [When::Parts::Timezone] 代表する都市の時間帯
|
734
|
+
#
|
735
|
+
# @overload Location(longitude, latitide, altitide=0, datum='Earth')
|
736
|
+
# @param [Numeric] longitude 経度 / 度 (東経を正とする)
|
737
|
+
# @param [Numeric] latitide 緯度 / 度 (北緯を正とする)
|
738
|
+
# @param [Numeric] altitide 高度 / m
|
739
|
+
# @param [When::Ephemeris::Datum] datum 座標系
|
740
|
+
# @param [String] datum 座標系の IRI (デフォルトプレフィクス _ep:)
|
741
|
+
#
|
742
|
+
# @note longitudeが経度を意味する文字列, latitude が緯度を意味する文字列の場合、
|
743
|
+
# 引数の順番によらず、それぞれ経度および緯度と解釈する
|
744
|
+
#
|
745
|
+
# @return [When::Coordinates::Spatial] 生成/参照した When::Coordinates::Spatial オブジェクト
|
746
|
+
#
|
747
|
+
def Location(*args)
|
748
|
+
case args[0]
|
749
|
+
when Coordinates::Spatial ; return args[0]
|
750
|
+
when Parts::Timezone ; return args[0].location
|
751
|
+
when String ; return Parts::Resource._instance(args[0], '_l:') if args.size == 1
|
752
|
+
when Numeric ;
|
753
|
+
else ; raise TypeError, "Invalid Type: #{args[0].class}"
|
754
|
+
end
|
755
|
+
rest = []
|
756
|
+
longitude = latitude = nil
|
757
|
+
args.each do |arg|
|
758
|
+
case arg
|
759
|
+
when /\A#{Coordinates::MATCH['EW']}\s*[.@\d]/, /[.@\d]\s*#{Coordinates::MATCH['EW']}\z/; longitude = arg
|
760
|
+
when /\A#{Coordinates::MATCH['NS']}\s*[.@\d]/, /[.@\d]\s*#{Coordinates::MATCH['NS']}\z/; latitude = arg
|
761
|
+
else ; rest << arg
|
762
|
+
end
|
763
|
+
end
|
764
|
+
longitude ||= rest.shift
|
765
|
+
latitude ||= rest.shift
|
766
|
+
raise ArgumentError, "too few arguments" unless longitude && latitude
|
767
|
+
altitude, datum = rest
|
768
|
+
iri = "_l:long=#{longitude}&lat=#{latitude}"
|
769
|
+
iri += "&alt=#{altitude}" if altitude
|
770
|
+
iri += "&datum=#{datum}" if datum
|
771
|
+
Parts::Resource._instance(iri)
|
772
|
+
end
|
773
|
+
|
774
|
+
# When::Coordinates::Border の生成/参照
|
775
|
+
#
|
776
|
+
# @param [String] border 年/日境界を表す文字列
|
777
|
+
#
|
778
|
+
# @return [When::Coordinates::Border] border に対応する When::Coordinates::Border オブジェクト
|
779
|
+
#
|
780
|
+
def Border(border)
|
781
|
+
case border
|
782
|
+
when Coordinates::Border ; return border
|
783
|
+
when /\([-\d]+?\)/ ; border = "_co:MultiBorder?borders=#{border}"
|
784
|
+
when /\A[^A-Z_]/i ; border = "_co:Border?border=#{border}"
|
785
|
+
end
|
786
|
+
|
787
|
+
Parts::Resource._instance(border, '_co:') do |iri|
|
788
|
+
Coordinates::CalendarBorder.send(:_behalf_of, iri)
|
789
|
+
end
|
790
|
+
end
|
791
|
+
|
792
|
+
#
|
793
|
+
# 曜日(剰余類)
|
794
|
+
#
|
795
|
+
# @param [Numeric] day 月曜を 0 とする七曜(剰余類)を返します
|
796
|
+
# @param [String] day 最初の3文字から決定した七曜(剰余類)を返します。
|
797
|
+
# 一致する七曜(剰余類)がない場合、名前の一致するその他の剰余類を探して返します。
|
798
|
+
#
|
799
|
+
# @return [When::Coordinates::Residue] 月曜を 0 とする七曜(剰余類) または 名前の一致するその他の剰余類
|
800
|
+
#
|
801
|
+
def Residue(day)
|
802
|
+
When::Coordinates::Residue.to_residue(day)
|
803
|
+
end
|
804
|
+
alias :day_of_week :Residue
|
805
|
+
|
806
|
+
#
|
807
|
+
# 月名
|
808
|
+
#
|
809
|
+
# @param [Numeric] name 指定の月番号の月名を返します
|
810
|
+
# @param [String] name 最初の3文字から決定した月名を返します。
|
811
|
+
# 一致する月名がない場合、名前の一致するその他のM17nを探して返します。
|
812
|
+
# (name が M17n なら name 自身をそのまま返します)
|
813
|
+
#
|
814
|
+
# @return [When::BasicTypes::M17n] 月名
|
815
|
+
#
|
816
|
+
def MonthName(name)
|
817
|
+
When::BasicTypes::M17n.month_name(name)
|
818
|
+
end
|
819
|
+
|
820
|
+
# When::BasicTypes::M17n の生成/参照
|
821
|
+
#
|
822
|
+
# @param [String] source 多言語対応文字列のIRI
|
823
|
+
#
|
824
|
+
# @return [When::BasicTypes::M17n] source に対応する When::BasicTypes::M17n オブジェクト
|
825
|
+
#
|
826
|
+
def M17n(source)
|
827
|
+
Parts::Resource._instance(source, '_m:')
|
828
|
+
end
|
829
|
+
|
830
|
+
# When::BasicTypes::M17n の生成/参照
|
831
|
+
#
|
832
|
+
# @param [When::BasicTypes::M17n] source 処理を行わず、そのままsourceを返す
|
833
|
+
# @param [String] source locale と 文字列の対応
|
834
|
+
# @param [Array] source 要素を個別に解釈して生成したオブジェクトのArrayを返す
|
835
|
+
# @param [Hash] namespace prefix の指定
|
836
|
+
# @param [Array] locale locale の定義順序の指定
|
837
|
+
# @param [Hash] options (see {When::BasicTypes::M17n.new}[link:When/BasicTypes/M17n.html#method-c-new])
|
838
|
+
#
|
839
|
+
# @return [When::BasicTypes::M17n or Array<them>]
|
840
|
+
#
|
841
|
+
def m17n(source, namespace=nil, locale=nil, options={})
|
842
|
+
case source
|
843
|
+
when Array ; BasicTypes::M17n.new(source, namespace, locale, options)
|
844
|
+
when BasicTypes::M17n ; source
|
845
|
+
when String
|
846
|
+
source = EncodingConversion.to_internal_encoding(source)
|
847
|
+
return self[$1] if source =~ /\A\s*\[((\.{1,2}|::)+[^\]]+)\]/ && self.kind_of?(When::Parts::Resource)
|
848
|
+
return Parts::Resource[$1] if source =~ /\A\s*\[::([^\]]+)\]/
|
849
|
+
BasicTypes::M17n.new(source, namespace, locale, options)
|
850
|
+
else ; raise TypeError, "Invalid Type: #{source.class}"
|
851
|
+
end
|
852
|
+
end
|
853
|
+
|
854
|
+
# Wikipedia を参照して When::BasicTypes::M17n を生成する
|
855
|
+
#
|
856
|
+
# @param [String] title Wikipedia の項目名
|
857
|
+
# @param [Hash] options 以下の通り
|
858
|
+
# @option options [String] :locale Wikipedia の言語(デフォルト 'en' - 英語)
|
859
|
+
# @option options [Numeric, nil] :interval Wikipedia サイトへのアクセス制御(デフォルト When::Locale.wikipedia_interval)
|
860
|
+
# @option options [Object] :その他 キャッシュファイルへの追加書き出し要素
|
861
|
+
#
|
862
|
+
# @return [When::BasicTypes::M17n] 項目に対応する多言語対応文字列
|
863
|
+
#
|
864
|
+
# @note 生成した多言語対応文字列の what が nil でない場合、
|
865
|
+
# その項目の位置情報を表わす When::Coordinates::Spatial を指す
|
866
|
+
#
|
867
|
+
def Wikipedia(title, options={})
|
868
|
+
locale = options.delete(:locale) || 'en'
|
869
|
+
title = EncodingConversion.to_internal_encoding(title)
|
870
|
+
entry, query = title.split('?', 2)
|
871
|
+
url = "http://#{locale}.wikipedia.org/wiki/#{URI.encode(entry).gsub(' ', '_')}"
|
872
|
+
Locale.send(:wikipedia_object, url, options) unless options.empty?
|
873
|
+
url += '?' + query if query
|
874
|
+
object = Parts::Resource._instance(url)
|
875
|
+
object.kind_of?(BasicTypes::M17n) ? object : object.label
|
876
|
+
end
|
877
|
+
|
878
|
+
# When::Parts::Resource の生成/参照
|
879
|
+
#
|
880
|
+
# @param [String] iri IRI を表す文字列
|
881
|
+
# @param [String] namespace デフォルトの namespace
|
882
|
+
#
|
883
|
+
# @return [When::Parts::Resourc] iri (または namespace:iri) に対応する When::Parts::Resource オブジェクト
|
884
|
+
#
|
885
|
+
def Resource(iri, namespace=nil)
|
886
|
+
Parts::Resource._instance(iri, namespace)
|
887
|
+
end
|
888
|
+
alias :IRI :Resource
|
889
|
+
|
890
|
+
# When::Coordinates::Index の生成
|
891
|
+
#
|
892
|
+
# @overload Index(terms=nil, name='Month', options)
|
893
|
+
# @param [String] terms trunk の用語空間名
|
894
|
+
# @param [String] name trunk の要素配列名
|
895
|
+
# @param [Hash] options
|
896
|
+
# @option options [Array] :trunk 幹の要素(省略時は使用しない)
|
897
|
+
# @option options [Hash] :branch 枝の要素(省略時は使用しない)
|
898
|
+
# @option options [Integer] :unit 要素の数(省略時は不定)
|
899
|
+
# @option options [Integer] :base 要素の最初の添え字(0 or 1(デフォルト))
|
900
|
+
# @option options [Integer] :shift 幹の要素のローテート数(省略時はローテートしない)
|
901
|
+
#
|
902
|
+
# @return [When::Coordinates::Index]
|
903
|
+
#
|
904
|
+
def Index(*args)
|
905
|
+
Coordinates::Index.new(*args)
|
906
|
+
end
|
907
|
+
|
908
|
+
# When::Coordinates::Pair の生成
|
909
|
+
#
|
910
|
+
# @param [Numeric, String] trunk 幹の要素
|
911
|
+
# @param [Numeric, String] branch 枝の要素
|
912
|
+
# @see When::Coordinates::Pair._force_pair
|
913
|
+
#
|
914
|
+
# @return [When::Coordinates::Pair]
|
915
|
+
#
|
916
|
+
def Pair(trunk, branch=nil)
|
917
|
+
Coordinates::Pair._force_pair(trunk, branch)
|
918
|
+
end
|
919
|
+
|
920
|
+
# When 直下に定数として時法・暦法を定義する
|
921
|
+
_define_common_calendar_types
|
922
|
+
|
923
|
+
end
|