when_exe 0.3.9 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4aa361eea778047e510eff92c02580c2c0a9032c
4
- data.tar.gz: 6828e97bdca91d3533a2a8a9832259a2f22c2a38
3
+ metadata.gz: 61a3f8c00d80359403cc75825c11f1945bce2c28
4
+ data.tar.gz: ebe31639b5e037a4ffba17a75005e7136b0827b5
5
5
  SHA512:
6
- metadata.gz: 76e950b423e1219e64a648826c6cf0de99ff6a738382b227f0f6d93ac9bcdf5b46459a2876d73a515c46a18ba761232ed0510eea2eb4d7063fe2377481fabaae
7
- data.tar.gz: 12cd771a12962d12b8972bfa21524d43d537104847c6d5f803133bf795beaa879c7e6a5ee3a229bee09c4662a4de1cef7a4733ca5f60f8ef8a0de55500da8699
6
+ metadata.gz: fe803b369afa1fd2ab944705c2ad4a766b687491759dd18474cfd0239f344a8d30bb8fdff2207881d5f04762d2c02d73d0615fbdc8eb549cd27c0bb200ef1929
7
+ data.tar.gz: 67420672b88943d9247dba224d996eca6474220bf6f508b60ed9449f9164407a09e37f97596ac305873085e5c4a13a0d261acb8e4a2740bd706c00450f128154
data/README.md CHANGED
@@ -1,210 +1,212 @@
1
- when_exe - A multicultural and multilingualized calendar library
2
- ================================================================
3
-
4
- [![Gem Version](https://badge.fury.io/rb/when_exe.svg)](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.
1
+ when_exe - A multicultural and multilingualized calendar library
2
+ ================================================================
3
+
4
+ [![Gem Version](https://badge.fury.io/rb/when_exe.svg)](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
+ Whole TemporalReferenceSystem resources are listed in the [Resource Dictionary](http://www2u.biglobe.ne.jp/~suchowan/ResourceDictionary.html).
38
+
39
+ License
40
+ -------
41
+
42
+ This beta version's license is limited. Please see [LICENSE.txt](https://github.com/suchowan/when_exe/blob/master/LICENSE.txt) for details.
43
+
44
+
45
+ Source Code
46
+ -----------
47
+
48
+ Source code for when_exe is available on [GitHub](https://github.com/suchowan/when_exe).
49
+
50
+
51
+ Example Usage
52
+ -------------
53
+
54
+ require 'when_exe'
55
+
56
+ # When::TM::CalDate ---------------------------
57
+
58
+ gregorian_date = When.tm_pos(2014, 8, 1)
59
+ p gregorian_date #=> 2014-08-01
60
+ p When.when?('2014-08-01') #=> 2014-08-01, the same date
61
+ p gregorian_date.to_i #=> 2456871, Julian Day Number(Integer)
62
+ p gregorian_date.to_f #=> 2456871.0, at noon for UTC
63
+ p gregorian_date.class #=> When::TM::CalDate
64
+ p gregorian_date.frame.iri #=> "http://hosi.org/When/CalendarTypes/Gregorian"
65
+ puts gregorian_date.name(When::MONTH).class #=> When::BasicTypes::M17n
66
+ puts gregorian_date.name(When::MONTH).iri #=> http://hosi.org/When/BasicTypes/M17n/Calendar::Month::August
67
+ puts gregorian_date.name(When::MONTH) / 'en' #=> August
68
+ puts gregorian_date.name(When::MONTH) / 'fr' #=> août
69
+ puts gregorian_date.name(When::MONTH) / 'ar' #=> اغسطس
70
+ p gregorian_date.easter #=> 2014-04-20
71
+ p gregorian_date.is?('Easter') #=> false
72
+ p When.tm_pos(2014, 4, 20).is?('Easter') #=> true
73
+
74
+ islamic_date = When::TabularIslamic ^ gregorian_date
75
+ p islamic_date #=> 1435-10-04
76
+ p When.tm_pos(1435, 10, 4, :frame=>'TabularIslamic')
77
+ #=> 1435-10-04, the same date
78
+ p When.when?('1435-10-4^TabularIslamic') #=> 1435-10-04, the same date
79
+ p islamic_date.frame.iri #=> "http://hosi.org/When/CalendarTypes/TabularIslamic"
80
+ puts islamic_date.name(When::MONTH) / 'en' #=> Shawwal
81
+ puts islamic_date.name(When::MONTH) / 'ar' #=> شوال
82
+
83
+ # When::TM::DateAndTime ------------------------
84
+
85
+ gregorian_date = When.tm_pos(2014, 8, 1, 9, 0, 0, :clock=>'+09:00')
86
+ p gregorian_date #=> 2014-08-01T09:00:00+09:00
87
+ p When.when?('2014-08-01T09:00:00+09:00') #=> 2014-08-01T09:00:00+09:00, the same date
88
+ p gregorian_date.to_i #=> 2456871, Julian Day Number(Integer)
89
+ p gregorian_date.to_f #=> 2456870.5 at 09:00:00 of Timezone +09:00
90
+ p gregorian_date.class #=> When::TM::DateAndTime
91
+ p gregorian_date.frame.iri #=> "http://hosi.org/When/CalendarTypes/Gregorian"
92
+ p gregorian_date.clk_time.class #=> When::TM::ClockTime
93
+ p gregorian_date.clk_time.frame.iri #=> "http://hosi.org/When/TM/Clock?label=+09:00"
94
+
95
+ gregorian_date = When.tm_pos(2014, 8, 1, 9, 0, 0, :clock=>'+09:00',
96
+ :long=>'139.413012E', :lat=>'35.412222N')
97
+ p gregorian_date #=> 2014-08-01T09:00:00+09:00
98
+ p gregorian_date.location.iri #=> "http://hosi.org/When/Coordinates/Spatial?long=139.413012E&lat=35.412222N&alt=0"
99
+ p gregorian_date.sunrise.floor(When::MINUTE) #=> 2014-08-01T04:48+09:00
100
+ p gregorian_date.sunset.floor(When::MINUTE) #=> 2014-08-01T18:46+09:00
101
+
102
+ darian_date = When::Darian ^ gregorian_date
103
+ p darian_date #=> 0216-13-23T15:12:11MTC
104
+ p darian_date.to_i #=> 49974, Serial Day Number(Integer)
105
+ p darian_date.to_f #=> 49974.13346485421
106
+ p darian_date.frame.iri #=> "http://hosi.org/When/CalendarTypes/Darian"
107
+ p darian_date.clk_time.frame.iri #=> "http://hosi.org/When/CalendarTypes/MTC"
108
+ p darian_date.time_standard.iri #=> "http://hosi.org/When/TimeStandard/MartianTimeCoordinated?location=(_l:long=0&datum=Mars)"
109
+
110
+ # When::TM::CalendarEra ------------------------
111
+
112
+ babylonian_date = When.tm_pos('NebuchadnezzarII', 1, 1, 1)
113
+ p babylonian_date #=> NebuchadnezzarII01(-603).01.01
114
+ p When.when?('NebuchadnezzarII1.1.1') #=> NebuchadnezzarII01(-603).01.01, the same date
115
+ p babylonian_date.to_i #=> 1500904, Julian Day Number(Integer)
116
+ p When.era('NebuchadnezzarII') #=> [_e:AncientOrient::Neo-Babylonian::NebuchadnezzarII]
117
+ p When.era('NebuchadnezzarII')[0] ^ 1500904 #=> NebuchadnezzarII01(-603).01.01, the same date
118
+ p babylonian_date.to_f #=> 1500904.0, at noon for UTC
119
+ p babylonian_date.frame.iri #=> "http://hosi.org/When/CalendarTypes/BabylonianPD"
120
+ p babylonian_date.calendar_era.iri #=> "http://hosi.org/When/TM/CalendarEra/AncientOrient::Neo-Babylonian::NebuchadnezzarII"
121
+
122
+ babylonian_date = When.when?('NebuchadnezzarII1.1.1T18:13:00',
123
+ :clock=>'+03:00?long=45&lat=32&border=Sunset')
124
+ 4.times do
125
+ p [babylonian_date, babylonian_date.to_i] #=>
126
+ # [NebuchadnezzarII01(-603).01.01T:18:13:00+03:00, 1500904]
127
+ # [NebuchadnezzarII01(-603).01.01T:18:14:00+03:00, 1500904]
128
+ # [NebuchadnezzarII01(-603).01.02T*18:15:00+03:00, 1500905]
129
+ # [NebuchadnezzarII01(-603).01.02T*18:16:00+03:00, 1500905]
130
+ babylonian_date += When::PT1M
131
+ end
132
+
133
+ # Web service ----------------------------------
134
+ # retrieve JSON response from http://hosi.org:3000 (when_exe demonstration web server)
135
+ require 'open-uri'
136
+ open('http://hosi.org:3000/Date/2014-04-20.json') do |json|
137
+ puts json.read #=> newlines and blanks are inserted for readability.
138
+ # {"frame" : "http://hosi.org/When/CalendarTypes/Gregorian",
139
+ # "precision": 0,
140
+ # "location" : "http://hosi.org/When/Coordinates/Spatial?long=139.4441E&lat=35.3916N&alt=0.0",
141
+ # "sdn" : 2456768,
142
+ # "calendar" : ["http://hosi.org/When/CalendarTypes/Gregorian"],
143
+ # "notes" : [[{"note":"Month","value":"April"}],
144
+ # [{"note":"Week","value":"Sunday(6)"}]],
145
+ # "clock" : "Asia/Tokyo+09:00",
146
+ # "clk_time" : [2456768,0,0,0],
147
+ # "dynamical": 1397919667.184082,
148
+ # "universal": 1397919600.0,
149
+ # "cal_date" : [2014,4,20]}
150
+ end
151
+
152
+ # TZInfo --------------------------------------
153
+ # https://rubygems.org/gems/tzinfo is required for this section's operations.
154
+ # Please install tzinfo before operation.
155
+
156
+ gregorian_date = When.tm_pos(2014, 8, 1, 9, 0, 0, :tz=>'Asia/Tokyo')
157
+ p gregorian_date #=> 2014-08-01T09:00:00+09:00
158
+ p gregorian_date.location.iri #=> "http://hosi.org/When/Coordinates/Spatial?long=139.4441E&lat=35.3916N&label=Asia/Tokyo"
159
+ p gregorian_date.sunrise.floor(When::MINUTE) #=> 2014-08-01T04:48+09:00
160
+ p gregorian_date.sunset.floor(When::MINUTE) #=> 2014-08-01T18:45+09:00
161
+
162
+ jst = When.tm_pos(1997, 4, 6, 15, 30, 00, :tz=>'Asia/Tokyo')
163
+ p jst #=> 1997-04-06T15:30:00+09:00
164
+ est = When.Clock('America/New_York') ^ jst
165
+ p est #=> 1997-04-06T01:30:00-05:00
166
+ jst = When.tm_pos(1997, 4, 6, 16, 30, 00, :tz=>'Asia/Tokyo')
167
+ p jst #=> 1997-04-06T16:30:00+09:00
168
+ edt = When.Clock('America/New_York') ^ jst
169
+ p edt #=> 1997-04-06T03:30:00-04:00
170
+
171
+ p When.when?('TZID=America/New_York:1997-10-26T01:30') #=> 1997-10-26T01:30-04:00
172
+ p When.when?('TZID=America/New_York:1997-10-26T01=30') #=> 1997-10-26T01:30-05:00, '=' indicates "leap hour"
173
+ p When.when?('TZID=America/New_York:1997-10-26T02:30') #=> 1997-10-26T02:30-05:00
174
+ p When.when?('TZID=America/New_York:1997-10-26T03:30') #=> 1997-10-26T03:30-05:00
175
+
176
+ # Google Calendar ------------------------------
177
+ # https://github.com/suchowan/gcalapi is required for this section's operations.
178
+ # Please install gcalapi before operation.
179
+ # Please replace xxxxxxxx and ******** to valid id/password pair and access Google Calendar.
180
+
181
+ service = GoogleCalendar::Service.new('xxxxxxxx@gmail.com', '********')
182
+ feed = "http://www.google.com/calendar/feeds/%s__%s%%40holiday.calendar.google.com/public/full" %
183
+ ['japanese', 'ja']
184
+ gcal = GoogleCalendar::Calendar::new(service, feed)
185
+ gcal.enum_for({'start-min'=>'2014-01-01', 'start-max'=>'2015-01-01',
186
+ 'orderby'=>'starttime', 'sortorder'=>'a'
187
+ }).each do |range|
188
+ puts '%s - %s' % [range, range.events[0].summary] #=>
189
+ # 2014-01-01T00:00:00.00+09:00...2014-01-02T00:00:00.00+09:00 - 元日
190
+ # 2014-01-02T00:00:00.00+09:00...2014-01-03T00:00:00.00+09:00 - 銀行休業日
191
+ # 2014-01-03T00:00:00.00+09:00...2014-01-04T00:00:00.00+09:00 - 銀行休業日
192
+ # 2014-01-13T00:00:00.00+09:00...2014-01-14T00:00:00.00+09:00 - 成人の日
193
+ # 2014-02-11T00:00:00.00+09:00...2014-02-12T00:00:00.00+09:00 - 建国記念の日
194
+ # 2014-03-21T00:00:00.00+09:00...2014-03-22T00:00:00.00+09:00 - 春分の日
195
+ # 2014-04-29T00:00:00.00+09:00...2014-04-30T00:00:00.00+09:00 - 昭和の日
196
+ # 2014-05-03T00:00:00.00+09:00...2014-05-04T00:00:00.00+09:00 - 憲法記念日
197
+ # 2014-05-04T00:00:00.00+09:00...2014-05-05T00:00:00.00+09:00 - みどりの日
198
+ # 2014-05-05T00:00:00.00+09:00...2014-05-06T00:00:00.00+09:00 - こどもの日
199
+ # 2014-05-06T00:00:00.00+09:00...2014-05-07T00:00:00.00+09:00 - みどりの日 振替休日
200
+ # 2014-07-21T00:00:00.00+09:00...2014-07-22T00:00:00.00+09:00 - 海の日
201
+ # 2014-09-15T00:00:00.00+09:00...2014-09-16T00:00:00.00+09:00 - 敬老の日
202
+ # 2014-09-23T00:00:00.00+09:00...2014-09-24T00:00:00.00+09:00 - 秋分の日
203
+ # 2014-10-13T00:00:00.00+09:00...2014-10-14T00:00:00.00+09:00 - 体育の日
204
+ # 2014-11-03T00:00:00.00+09:00...2014-11-04T00:00:00.00+09:00 - 文化の日
205
+ # 2014-11-23T00:00:00.00+09:00...2014-11-24T00:00:00.00+09:00 - 勤労感謝の日
206
+ # 2014-11-24T00:00:00.00+09:00...2014-11-25T00:00:00.00+09:00 - 勤労感謝の日 振替休日
207
+ # 2014-12-23T00:00:00.00+09:00...2014-12-24T00:00:00.00+09:00 - 天皇誕生日
208
+ # 2014-12-25T00:00:00.00+09:00...2014-12-26T00:00:00.00+09:00 - クリスマス
209
+ # 2014-12-31T00:00:00.00+09:00...2015-01-01T00:00:00.00+09:00 - 大晦日
210
+ end
211
+
212
+ For further detail, please refer to the [when_exe Wiki](http://www2u.biglobe.ne.jp/~suchowan/when_exe_wiki.html) pages.
@@ -279,6 +279,8 @@ module When
279
279
  autoload :ChineseSolar, 'when_exe/region/chinese'
280
280
  autoload :ChineseLuniSolar, 'when_exe/region/chinese'
281
281
  autoload :Yi, 'when_exe/region/chinese'
282
+ autoload :TenrekiA, 'when_exe/region/chinese'
283
+ autoload :TenrekiB, 'when_exe/region/chinese'
282
284
  autoload :Korean, 'when_exe/region/korean'
283
285
  autoload :Tibetan, 'when_exe/region/tibetan'
284
286
  autoload :Thai, 'when_exe/region/thai'
@@ -366,9 +368,9 @@ module When
366
368
  autoload :Bahai, 'when_exe/region/bahai'
367
369
  autoload :Roman, 'when_exe/region/roman'
368
370
  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'
371
+ autoload :DiscordianWeek, 'when_exe/region/discordian'
372
+ autoload :CommonWithSovietFiveDay, 'when_exe/region/soviet'
373
+ autoload :SovietFiveDayWeek, 'when_exe/region/soviet'
372
374
  autoload :CommonWithSovietSixDay, 'when_exe/region/soviet'
373
375
  autoload :SovietSixDayWeek, 'when_exe/region/soviet'
374
376
  # autoload :Yerm, 'when_exe/region/yerm'
@@ -449,17 +451,17 @@ module When
449
451
  autoload :LongCount, 'when_exe/region/mayan'
450
452
 
451
453
  # Defualt search path for Epochs and Eras
452
- DefaultEpochs = ['Common', 'ModernJapanese',
453
- 'Hijra', 'Jewish', 'Iranian',
454
- 'Roman', 'Byzantine', 'AncientOrient', 'LongCount',
454
+ DefaultEpochs = ['Common', 'ModernJapanese',
455
+ 'Hijra', 'Jewish', 'Iranian',
456
+ 'Roman', 'Byzantine', 'AncientOrient', 'LongCount',
455
457
  'BalineseLuniSolar', 'JavaneseLunar',
456
- 'Japanese', 'JapanesePrimeMinister', 'NihonKoki', 'NihonShoki',
457
- 'Chinese', 'Ryukyu', 'Vietnamese', 'Korean',
458
- 'JapaneseSolar', 'JapaneseLuniSolar',
459
- 'ChineseSolar', 'ChineseLuniSolar',
458
+ 'Japanese', 'NihonKoki', 'NihonShoki',
459
+ 'Chinese', 'Ryukyu', 'Vietnamese', 'Korean',
460
+ 'JapaneseLuniSolar', 'JapaneseSolar',
461
+ 'ChineseLuniSolar', 'ChineseSolar',
460
462
  'Manchurian', 'Rouran', 'Gaochang',
461
- 'Yunnan', 'WesternXia', 'KaraKhitan', # 'Tibetan',
462
- 'Pope' ]
463
+ 'Yunnan', 'WesternXia', 'KaraKhitan', # 'Tibetan',
464
+ 'Pope', 'JapanesePrimeMinister']
463
465
 
464
466
  # Defualt events for Epochs and Eras
465
467
  DefaultEvents = Hash[*([['@A', 'Accession' ],