when_exe 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +333 -212
- data/bin/make_ttl.rb +37 -0
- data/bin/make_ttl.rb.config +9 -0
- data/lib/when_exe.rb +923 -925
- data/lib/when_exe/calendarnote.rb +9 -5
- data/lib/when_exe/coordinates.rb +2437 -2446
- data/lib/when_exe/inspect.rb +1480 -1408
- data/lib/when_exe/linkeddata.rb +574 -0
- data/lib/when_exe/locales/akt.rb +177 -176
- data/lib/when_exe/locales/locale.rb +751 -751
- data/lib/when_exe/mini_application.rb +307 -307
- data/lib/when_exe/parts/resource.rb +1115 -1103
- data/lib/when_exe/region/chinese/epochs.rb +6 -5
- data/lib/when_exe/region/christian.rb +831 -829
- data/lib/when_exe/region/japanese.rb +93 -93
- data/lib/when_exe/region/japanese/notes.rb +1510 -1495
- data/lib/when_exe/region/japanese/residues.rb +13 -13
- data/lib/when_exe/tmposition.rb +2307 -2273
- data/lib/when_exe/tmreference.rb +1744 -1734
- data/lib/when_exe/version.rb +2 -2
- data/link_to_online_documents +1 -1
- data/test/scripts/3.ext.rb +6 -6
- data/test/scripts/3.rb +6 -6
- data/test/test.rb +76 -75
- data/test/test/icalendar.rb +883 -879
- data/test/test/linkeddata.rb +224 -0
- data/test/test/region/m17n.rb +193 -193
- data/when_exe.gemspec +3 -2
- metadata +13 -6
data/lib/when_exe/tmreference.rb
CHANGED
@@ -1,1734 +1,1744 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
=begin
|
3
|
-
Copyright (C) 2011-
|
4
|
-
|
5
|
-
You may use and/or modify this file according to the license described in the LICENSE.txt file included in this archive.
|
6
|
-
=end
|
7
|
-
|
8
|
-
#
|
9
|
-
# ISO 19108 Geographic information - Temporal schema
|
10
|
-
#
|
11
|
-
module When::TM
|
12
|
-
#
|
13
|
-
# (5.3) Temporal Reference System Package
|
14
|
-
#
|
15
|
-
|
16
|
-
# 時間参照系
|
17
|
-
#
|
18
|
-
# see {http://schemas.opengis.net/gml/3.1.1/base/temporalReferenceSystems.xsd#AbstractTimeReferenceSystemType gml schema}
|
19
|
-
#
|
20
|
-
class ReferenceSystem < When::TM::Object
|
21
|
-
|
22
|
-
# この時間参照系が使用する空間と時間の制限(実装は時間のみ)
|
23
|
-
#
|
24
|
-
# Limits of space and time within which the temporal reference system is use
|
25
|
-
#
|
26
|
-
# @return [When::EX::Extent]
|
27
|
-
#
|
28
|
-
# @note
|
29
|
-
# domain の最小・最大から範囲を決定して domain_of_validity としている
|
30
|
-
# domain_of_validity は ISO19108との互換性を確保するため提供しているが、
|
31
|
-
# 有効期間が複数に断片化していることがあるので、より正確な情報を含む
|
32
|
-
# domain の使用を推奨する
|
33
|
-
#
|
34
|
-
# マルチスレッド動作時 CalendarEra の生成で Calendar の本属性が更新される
|
35
|
-
# 参照・更新処理は synchronize { ... } の ... の部分に書く必要がある
|
36
|
-
#
|
37
|
-
attr_accessor :domain_of_validity
|
38
|
-
alias :domainOfValidity :domain_of_validity
|
39
|
-
|
40
|
-
# この時間参照系と関連付けられた時間位置 (relation - Reference)
|
41
|
-
#
|
42
|
-
# The temporal position associated with the time reference system being described
|
43
|
-
#
|
44
|
-
# @return [Array<When::TM::(Temporal)Position>]
|
45
|
-
#
|
46
|
-
attr_reader :position
|
47
|
-
|
48
|
-
# この時間参照系が使用する時間の範囲
|
49
|
-
#
|
50
|
-
# Range of time within which the temporal reference system is use
|
51
|
-
#
|
52
|
-
# @return [Hash<String=>When::Parts::GeomerticComplex>]
|
53
|
-
#
|
54
|
-
# @note
|
55
|
-
# マルチスレッド動作時 CalendarEra の生成で Calendar の本属性が更新される
|
56
|
-
# 参照・更新処理は synchronize { ... } の ... の部分に書く必要がある
|
57
|
-
#
|
58
|
-
def domain
|
59
|
-
@domain ||= Hash.new {|hash, key| hash[key] = When::Parts::GeometricComplex.new([])}
|
60
|
-
end
|
61
|
-
|
62
|
-
# 時間参照系を識別する名称
|
63
|
-
#
|
64
|
-
# Name by which the temporal reference system is known
|
65
|
-
#
|
66
|
-
# @return [When::RS::Identifier]
|
67
|
-
#
|
68
|
-
def name
|
69
|
-
@name ||= When::RS::Identifier.new(label, @version, @remarks)
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
# 順序時間参照系
|
74
|
-
#
|
75
|
-
# see {http://schemas.opengis.net/gml/3.1.1/base/temporalReferenceSystems.xsd#TimeOrdinalReferenceSystemType gml schema}
|
76
|
-
#
|
77
|
-
class OrdinalReferenceSystem < ReferenceSystem
|
78
|
-
|
79
|
-
# この順序時間参照系の最上位レベルを構成する順序年代 (relation - Structure)
|
80
|
-
#
|
81
|
-
# Ordinal eras that make up the highest level of this ordinal reference system
|
82
|
-
#
|
83
|
-
# @return [Array<When::TM::OrdinalEra>]
|
84
|
-
#
|
85
|
-
alias :component :child
|
86
|
-
|
87
|
-
private
|
88
|
-
|
89
|
-
# オブジェクトの正規化
|
90
|
-
def _normalize(args=[], options={})
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
# 暦
|
95
|
-
#
|
96
|
-
# see {http://schemas.opengis.net/gml/3.1.1/base/temporalReferenceSystems.xsd#TimeCalendarType gml schema}
|
97
|
-
#
|
98
|
-
class Calendar < ReferenceSystem
|
99
|
-
|
100
|
-
include When::Coordinates
|
101
|
-
include Spatial::Normalize
|
102
|
-
include Temporal
|
103
|
-
include When::TimeStandard::TimeBasis
|
104
|
-
|
105
|
-
# 初期化
|
106
|
-
#
|
107
|
-
# @return [void]
|
108
|
-
#
|
109
|
-
# @note
|
110
|
-
# 本メソッドでマルチスレッド対応の管理変数の初期化を行っている。
|
111
|
-
# このため、本メソッド自体はスレッドセーフでない。
|
112
|
-
#
|
113
|
-
def self._setup_
|
114
|
-
@_lock_ = Mutex.new if When.multi_thread
|
115
|
-
@_pool = {}
|
116
|
-
end
|
117
|
-
|
118
|
-
#
|
119
|
-
|
120
|
-
|
121
|
-
#
|
122
|
-
#
|
123
|
-
#
|
124
|
-
#
|
125
|
-
#
|
126
|
-
#
|
127
|
-
#
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
#
|
135
|
-
#
|
136
|
-
#
|
137
|
-
#
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
#
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
#
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
#
|
161
|
-
|
162
|
-
|
163
|
-
#
|
164
|
-
|
165
|
-
|
166
|
-
#
|
167
|
-
#
|
168
|
-
|
169
|
-
|
170
|
-
#
|
171
|
-
|
172
|
-
|
173
|
-
#
|
174
|
-
#
|
175
|
-
# @
|
176
|
-
#
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
#
|
189
|
-
#
|
190
|
-
# @
|
191
|
-
# @
|
192
|
-
#
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
cal_date
|
223
|
-
cal_date
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
#
|
234
|
-
#
|
235
|
-
#
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
#
|
244
|
-
#
|
245
|
-
#
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
#
|
256
|
-
#
|
257
|
-
#
|
258
|
-
# @
|
259
|
-
#
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
#
|
270
|
-
#
|
271
|
-
#
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
#
|
290
|
-
#
|
291
|
-
#
|
292
|
-
#
|
293
|
-
#
|
294
|
-
#
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
#
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
include
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
#
|
339
|
-
#
|
340
|
-
#
|
341
|
-
#
|
342
|
-
#
|
343
|
-
#
|
344
|
-
#
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
#
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
#
|
363
|
-
#
|
364
|
-
#
|
365
|
-
#
|
366
|
-
#
|
367
|
-
#
|
368
|
-
#
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
#
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
#
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
ss
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
mm
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
d1
|
445
|
-
d2
|
446
|
-
|
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
|
-
|
502
|
-
|
503
|
-
#
|
504
|
-
#
|
505
|
-
# @return [When::
|
506
|
-
#
|
507
|
-
|
508
|
-
|
509
|
-
#
|
510
|
-
#
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
#
|
515
|
-
#
|
516
|
-
#
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
#
|
521
|
-
#
|
522
|
-
# @return [
|
523
|
-
#
|
524
|
-
attr_reader :
|
525
|
-
|
526
|
-
|
527
|
-
#
|
528
|
-
#
|
529
|
-
#
|
530
|
-
|
531
|
-
|
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
|
-
|
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
|
-
|
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
|
-
name
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
#
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
end
|
715
|
-
|
716
|
-
#
|
717
|
-
# @return [When::TM::Clock]
|
718
|
-
def
|
719
|
-
_tz_prop ? _tz_prop.
|
720
|
-
end
|
721
|
-
|
722
|
-
#
|
723
|
-
# @return [When::TM
|
724
|
-
def
|
725
|
-
_tz_prop ? _tz_prop.
|
726
|
-
end
|
727
|
-
|
728
|
-
#
|
729
|
-
# @
|
730
|
-
def
|
731
|
-
_tz_prop ? _tz_prop.
|
732
|
-
end
|
733
|
-
|
734
|
-
#
|
735
|
-
# @private
|
736
|
-
def
|
737
|
-
_tz_prop ? _tz_prop.
|
738
|
-
end
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
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
|
-
|
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
|
-
|
833
|
-
|
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
|
-
# @return [
|
863
|
-
#
|
864
|
-
alias :
|
865
|
-
|
866
|
-
#
|
867
|
-
#
|
868
|
-
# Ordinal
|
869
|
-
#
|
870
|
-
# @return [When::TM::
|
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
|
-
# Date at which the ordinal era
|
897
|
-
#
|
898
|
-
# @return [When::BasicTypes::DateTime]
|
899
|
-
#
|
900
|
-
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
#
|
905
|
-
#
|
906
|
-
# @
|
907
|
-
#
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
|
912
|
-
|
913
|
-
|
914
|
-
|
915
|
-
|
916
|
-
#
|
917
|
-
#
|
918
|
-
|
919
|
-
|
920
|
-
|
921
|
-
|
922
|
-
|
923
|
-
|
924
|
-
#
|
925
|
-
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
933
|
-
|
934
|
-
|
935
|
-
@
|
936
|
-
@
|
937
|
-
|
938
|
-
|
939
|
-
|
940
|
-
|
941
|
-
@
|
942
|
-
|
943
|
-
|
944
|
-
@
|
945
|
-
|
946
|
-
|
947
|
-
|
948
|
-
|
949
|
-
|
950
|
-
|
951
|
-
|
952
|
-
|
953
|
-
|
954
|
-
|
955
|
-
|
956
|
-
|
957
|
-
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
|
962
|
-
|
963
|
-
|
964
|
-
|
965
|
-
|
966
|
-
|
967
|
-
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
|
977
|
-
|
978
|
-
|
979
|
-
|
980
|
-
|
981
|
-
|
982
|
-
|
983
|
-
#
|
984
|
-
#
|
985
|
-
|
986
|
-
|
987
|
-
|
988
|
-
|
989
|
-
|
990
|
-
|
991
|
-
#
|
992
|
-
#
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
end
|
998
|
-
|
999
|
-
#
|
1000
|
-
#
|
1001
|
-
# @
|
1002
|
-
#
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1007
|
-
#
|
1008
|
-
#
|
1009
|
-
#
|
1010
|
-
#
|
1011
|
-
#
|
1012
|
-
#
|
1013
|
-
#
|
1014
|
-
#
|
1015
|
-
|
1016
|
-
|
1017
|
-
|
1018
|
-
|
1019
|
-
|
1020
|
-
|
1021
|
-
|
1022
|
-
|
1023
|
-
|
1024
|
-
|
1025
|
-
|
1026
|
-
|
1027
|
-
|
1028
|
-
|
1029
|
-
|
1030
|
-
|
1031
|
-
|
1032
|
-
|
1033
|
-
|
1034
|
-
|
1035
|
-
|
1036
|
-
|
1037
|
-
|
1038
|
-
|
1039
|
-
|
1040
|
-
|
1041
|
-
|
1042
|
-
|
1043
|
-
|
1044
|
-
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
1052
|
-
|
1053
|
-
|
1054
|
-
|
1055
|
-
|
1056
|
-
|
1057
|
-
|
1058
|
-
|
1059
|
-
|
1060
|
-
|
1061
|
-
|
1062
|
-
|
1063
|
-
|
1064
|
-
|
1065
|
-
|
1066
|
-
|
1067
|
-
|
1068
|
-
|
1069
|
-
|
1070
|
-
|
1071
|
-
|
1072
|
-
|
1073
|
-
|
1074
|
-
|
1075
|
-
|
1076
|
-
|
1077
|
-
|
1078
|
-
|
1079
|
-
|
1080
|
-
|
1081
|
-
|
1082
|
-
|
1083
|
-
|
1084
|
-
|
1085
|
-
|
1086
|
-
|
1087
|
-
|
1088
|
-
|
1089
|
-
|
1090
|
-
|
1091
|
-
|
1092
|
-
|
1093
|
-
|
1094
|
-
|
1095
|
-
|
1096
|
-
|
1097
|
-
|
1098
|
-
|
1099
|
-
|
1100
|
-
|
1101
|
-
|
1102
|
-
|
1103
|
-
|
1104
|
-
|
1105
|
-
|
1106
|
-
|
1107
|
-
|
1108
|
-
|
1109
|
-
era
|
1110
|
-
|
1111
|
-
|
1112
|
-
|
1113
|
-
|
1114
|
-
|
1115
|
-
|
1116
|
-
|
1117
|
-
|
1118
|
-
|
1119
|
-
|
1120
|
-
|
1121
|
-
|
1122
|
-
# @
|
1123
|
-
|
1124
|
-
|
1125
|
-
|
1126
|
-
|
1127
|
-
#
|
1128
|
-
#
|
1129
|
-
#
|
1130
|
-
#
|
1131
|
-
# @return [String]
|
1132
|
-
# 通常 String のサブクラスである When::BasicTypes::M17n を使用する。
|
1133
|
-
#
|
1134
|
-
|
1135
|
-
|
1136
|
-
#
|
1137
|
-
#
|
1138
|
-
#
|
1139
|
-
#
|
1140
|
-
#
|
1141
|
-
#
|
1142
|
-
#
|
1143
|
-
#
|
1144
|
-
#
|
1145
|
-
|
1146
|
-
|
1147
|
-
|
1148
|
-
#
|
1149
|
-
#
|
1150
|
-
#
|
1151
|
-
#
|
1152
|
-
#
|
1153
|
-
#
|
1154
|
-
|
1155
|
-
|
1156
|
-
|
1157
|
-
#
|
1158
|
-
#
|
1159
|
-
#
|
1160
|
-
#
|
1161
|
-
|
1162
|
-
|
1163
|
-
|
1164
|
-
#
|
1165
|
-
#
|
1166
|
-
#
|
1167
|
-
#
|
1168
|
-
#
|
1169
|
-
#
|
1170
|
-
attr_reader :
|
1171
|
-
alias :
|
1172
|
-
|
1173
|
-
#
|
1174
|
-
#
|
1175
|
-
#
|
1176
|
-
#
|
1177
|
-
# @return [
|
1178
|
-
#
|
1179
|
-
|
1180
|
-
|
1181
|
-
|
1182
|
-
#
|
1183
|
-
#
|
1184
|
-
|
1185
|
-
|
1186
|
-
#
|
1187
|
-
#
|
1188
|
-
#
|
1189
|
-
#
|
1190
|
-
#
|
1191
|
-
#
|
1192
|
-
|
1193
|
-
|
1194
|
-
|
1195
|
-
#
|
1196
|
-
#
|
1197
|
-
# The
|
1198
|
-
#
|
1199
|
-
# @return [
|
1200
|
-
#
|
1201
|
-
attr_reader :
|
1202
|
-
alias :
|
1203
|
-
|
1204
|
-
#
|
1205
|
-
#
|
1206
|
-
#
|
1207
|
-
#
|
1208
|
-
#
|
1209
|
-
#
|
1210
|
-
|
1211
|
-
|
1212
|
-
|
1213
|
-
#
|
1214
|
-
#
|
1215
|
-
#
|
1216
|
-
#
|
1217
|
-
#
|
1218
|
-
#
|
1219
|
-
#
|
1220
|
-
|
1221
|
-
|
1222
|
-
#
|
1223
|
-
|
1224
|
-
|
1225
|
-
|
1226
|
-
|
1227
|
-
|
1228
|
-
|
1229
|
-
|
1230
|
-
|
1231
|
-
|
1232
|
-
|
1233
|
-
|
1234
|
-
|
1235
|
-
|
1236
|
-
|
1237
|
-
|
1238
|
-
|
1239
|
-
|
1240
|
-
|
1241
|
-
|
1242
|
-
|
1243
|
-
|
1244
|
-
|
1245
|
-
|
1246
|
-
|
1247
|
-
#
|
1248
|
-
#
|
1249
|
-
#
|
1250
|
-
# [
|
1251
|
-
#
|
1252
|
-
|
1253
|
-
|
1254
|
-
|
1255
|
-
|
1256
|
-
|
1257
|
-
#
|
1258
|
-
#
|
1259
|
-
#
|
1260
|
-
#
|
1261
|
-
|
1262
|
-
|
1263
|
-
|
1264
|
-
|
1265
|
-
|
1266
|
-
#
|
1267
|
-
#
|
1268
|
-
# @
|
1269
|
-
#
|
1270
|
-
|
1271
|
-
|
1272
|
-
|
1273
|
-
|
1274
|
-
#
|
1275
|
-
#
|
1276
|
-
# @
|
1277
|
-
#
|
1278
|
-
#
|
1279
|
-
# [
|
1280
|
-
#
|
1281
|
-
|
1282
|
-
|
1283
|
-
|
1284
|
-
|
1285
|
-
|
1286
|
-
|
1287
|
-
|
1288
|
-
|
1289
|
-
|
1290
|
-
|
1291
|
-
|
1292
|
-
|
1293
|
-
|
1294
|
-
|
1295
|
-
|
1296
|
-
|
1297
|
-
|
1298
|
-
|
1299
|
-
|
1300
|
-
|
1301
|
-
|
1302
|
-
|
1303
|
-
|
1304
|
-
|
1305
|
-
return cal_date
|
1306
|
-
|
1307
|
-
|
1308
|
-
|
1309
|
-
|
1310
|
-
|
1311
|
-
|
1312
|
-
cal_date
|
1313
|
-
|
1314
|
-
return cal_date
|
1315
|
-
end
|
1316
|
-
|
1317
|
-
#
|
1318
|
-
#
|
1319
|
-
|
1320
|
-
|
1321
|
-
|
1322
|
-
|
1323
|
-
|
1324
|
-
|
1325
|
-
|
1326
|
-
|
1327
|
-
#
|
1328
|
-
# @
|
1329
|
-
|
1330
|
-
|
1331
|
-
|
1332
|
-
|
1333
|
-
|
1334
|
-
|
1335
|
-
|
1336
|
-
|
1337
|
-
|
1338
|
-
|
1339
|
-
|
1340
|
-
|
1341
|
-
|
1342
|
-
|
1343
|
-
|
1344
|
-
|
1345
|
-
|
1346
|
-
|
1347
|
-
|
1348
|
-
|
1349
|
-
|
1350
|
-
|
1351
|
-
|
1352
|
-
|
1353
|
-
|
1354
|
-
|
1355
|
-
|
1356
|
-
|
1357
|
-
|
1358
|
-
|
1359
|
-
|
1360
|
-
|
1361
|
-
|
1362
|
-
|
1363
|
-
|
1364
|
-
|
1365
|
-
|
1366
|
-
|
1367
|
-
|
1368
|
-
|
1369
|
-
|
1370
|
-
|
1371
|
-
#
|
1372
|
-
|
1373
|
-
|
1374
|
-
|
1375
|
-
|
1376
|
-
|
1377
|
-
|
1378
|
-
|
1379
|
-
|
1380
|
-
|
1381
|
-
|
1382
|
-
|
1383
|
-
|
1384
|
-
|
1385
|
-
|
1386
|
-
|
1387
|
-
|
1388
|
-
|
1389
|
-
|
1390
|
-
|
1391
|
-
|
1392
|
-
|
1393
|
-
|
1394
|
-
@
|
1395
|
-
|
1396
|
-
|
1397
|
-
|
1398
|
-
|
1399
|
-
|
1400
|
-
|
1401
|
-
|
1402
|
-
@
|
1403
|
-
@child.
|
1404
|
-
|
1405
|
-
|
1406
|
-
|
1407
|
-
|
1408
|
-
|
1409
|
-
|
1410
|
-
|
1411
|
-
|
1412
|
-
|
1413
|
-
|
1414
|
-
|
1415
|
-
|
1416
|
-
|
1417
|
-
|
1418
|
-
|
1419
|
-
|
1420
|
-
|
1421
|
-
|
1422
|
-
|
1423
|
-
|
1424
|
-
|
1425
|
-
|
1426
|
-
|
1427
|
-
|
1428
|
-
@_pool[
|
1429
|
-
|
1430
|
-
|
1431
|
-
|
1432
|
-
@
|
1433
|
-
@
|
1434
|
-
@
|
1435
|
-
|
1436
|
-
|
1437
|
-
@
|
1438
|
-
|
1439
|
-
|
1440
|
-
term_options[:options][:
|
1441
|
-
|
1442
|
-
@
|
1443
|
-
|
1444
|
-
|
1445
|
-
|
1446
|
-
|
1447
|
-
|
1448
|
-
|
1449
|
-
|
1450
|
-
|
1451
|
-
|
1452
|
-
|
1453
|
-
|
1454
|
-
|
1455
|
-
|
1456
|
-
|
1457
|
-
|
1458
|
-
|
1459
|
-
|
1460
|
-
|
1461
|
-
|
1462
|
-
|
1463
|
-
end
|
1464
|
-
|
1465
|
-
|
1466
|
-
|
1467
|
-
|
1468
|
-
|
1469
|
-
|
1470
|
-
|
1471
|
-
|
1472
|
-
|
1473
|
-
|
1474
|
-
|
1475
|
-
|
1476
|
-
|
1477
|
-
|
1478
|
-
|
1479
|
-
|
1480
|
-
|
1481
|
-
|
1482
|
-
|
1483
|
-
|
1484
|
-
|
1485
|
-
|
1486
|
-
|
1487
|
-
|
1488
|
-
|
1489
|
-
|
1490
|
-
|
1491
|
-
|
1492
|
-
|
1493
|
-
|
1494
|
-
|
1495
|
-
|
1496
|
-
|
1497
|
-
|
1498
|
-
|
1499
|
-
|
1500
|
-
|
1501
|
-
|
1502
|
-
|
1503
|
-
|
1504
|
-
|
1505
|
-
|
1506
|
-
|
1507
|
-
|
1508
|
-
|
1509
|
-
|
1510
|
-
|
1511
|
-
|
1512
|
-
|
1513
|
-
|
1514
|
-
|
1515
|
-
|
1516
|
-
|
1517
|
-
|
1518
|
-
|
1519
|
-
|
1520
|
-
|
1521
|
-
|
1522
|
-
|
1523
|
-
|
1524
|
-
|
1525
|
-
@
|
1526
|
-
|
1527
|
-
|
1528
|
-
|
1529
|
-
|
1530
|
-
|
1531
|
-
|
1532
|
-
|
1533
|
-
|
1534
|
-
|
1535
|
-
|
1536
|
-
|
1537
|
-
|
1538
|
-
|
1539
|
-
|
1540
|
-
|
1541
|
-
|
1542
|
-
|
1543
|
-
|
1544
|
-
|
1545
|
-
|
1546
|
-
|
1547
|
-
|
1548
|
-
|
1549
|
-
|
1550
|
-
|
1551
|
-
|
1552
|
-
|
1553
|
-
|
1554
|
-
|
1555
|
-
|
1556
|
-
|
1557
|
-
|
1558
|
-
|
1559
|
-
|
1560
|
-
|
1561
|
-
|
1562
|
-
|
1563
|
-
|
1564
|
-
|
1565
|
-
|
1566
|
-
|
1567
|
-
|
1568
|
-
|
1569
|
-
|
1570
|
-
|
1571
|
-
|
1572
|
-
|
1573
|
-
|
1574
|
-
|
1575
|
-
|
1576
|
-
|
1577
|
-
|
1578
|
-
|
1579
|
-
|
1580
|
-
|
1581
|
-
|
1582
|
-
|
1583
|
-
|
1584
|
-
|
1585
|
-
|
1586
|
-
|
1587
|
-
|
1588
|
-
|
1589
|
-
|
1590
|
-
|
1591
|
-
|
1592
|
-
|
1593
|
-
|
1594
|
-
|
1595
|
-
|
1596
|
-
|
1597
|
-
|
1598
|
-
|
1599
|
-
|
1600
|
-
|
1601
|
-
|
1602
|
-
|
1603
|
-
|
1604
|
-
|
1605
|
-
|
1606
|
-
|
1607
|
-
|
1608
|
-
|
1609
|
-
|
1610
|
-
|
1611
|
-
|
1612
|
-
|
1613
|
-
|
1614
|
-
|
1615
|
-
|
1616
|
-
|
1617
|
-
|
1618
|
-
|
1619
|
-
|
1620
|
-
|
1621
|
-
|
1622
|
-
|
1623
|
-
|
1624
|
-
|
1625
|
-
|
1626
|
-
|
1627
|
-
|
1628
|
-
|
1629
|
-
|
1630
|
-
|
1631
|
-
|
1632
|
-
|
1633
|
-
|
1634
|
-
|
1635
|
-
|
1636
|
-
|
1637
|
-
|
1638
|
-
|
1639
|
-
|
1640
|
-
|
1641
|
-
|
1642
|
-
|
1643
|
-
|
1644
|
-
|
1645
|
-
|
1646
|
-
|
1647
|
-
|
1648
|
-
|
1649
|
-
|
1650
|
-
|
1651
|
-
|
1652
|
-
|
1653
|
-
|
1654
|
-
|
1655
|
-
|
1656
|
-
@child
|
1657
|
-
|
1658
|
-
|
1659
|
-
|
1660
|
-
|
1661
|
-
|
1662
|
-
|
1663
|
-
|
1664
|
-
end
|
1665
|
-
|
1666
|
-
|
1667
|
-
|
1668
|
-
|
1669
|
-
|
1670
|
-
|
1671
|
-
|
1672
|
-
|
1673
|
-
|
1674
|
-
|
1675
|
-
|
1676
|
-
|
1677
|
-
|
1678
|
-
|
1679
|
-
|
1680
|
-
|
1681
|
-
|
1682
|
-
|
1683
|
-
|
1684
|
-
|
1685
|
-
|
1686
|
-
|
1687
|
-
|
1688
|
-
|
1689
|
-
|
1690
|
-
|
1691
|
-
|
1692
|
-
|
1693
|
-
|
1694
|
-
|
1695
|
-
|
1696
|
-
|
1697
|
-
|
1698
|
-
|
1699
|
-
|
1700
|
-
|
1701
|
-
|
1702
|
-
|
1703
|
-
|
1704
|
-
|
1705
|
-
return
|
1706
|
-
|
1707
|
-
|
1708
|
-
|
1709
|
-
|
1710
|
-
|
1711
|
-
|
1712
|
-
|
1713
|
-
|
1714
|
-
|
1715
|
-
|
1716
|
-
|
1717
|
-
|
1718
|
-
|
1719
|
-
|
1720
|
-
|
1721
|
-
#
|
1722
|
-
#
|
1723
|
-
#
|
1724
|
-
#
|
1725
|
-
def
|
1726
|
-
|
1727
|
-
|
1728
|
-
|
1729
|
-
|
1730
|
-
|
1731
|
-
|
1732
|
-
|
1733
|
-
|
1734
|
-
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
=begin
|
3
|
+
Copyright (C) 2011-2015 Takashi SUGA
|
4
|
+
|
5
|
+
You may use and/or modify this file according to the license described in the LICENSE.txt file included in this archive.
|
6
|
+
=end
|
7
|
+
|
8
|
+
#
|
9
|
+
# ISO 19108 Geographic information - Temporal schema
|
10
|
+
#
|
11
|
+
module When::TM
|
12
|
+
#
|
13
|
+
# (5.3) Temporal Reference System Package
|
14
|
+
#
|
15
|
+
|
16
|
+
# 時間参照系
|
17
|
+
#
|
18
|
+
# see {http://schemas.opengis.net/gml/3.1.1/base/temporalReferenceSystems.xsd#AbstractTimeReferenceSystemType gml schema}
|
19
|
+
#
|
20
|
+
class ReferenceSystem < When::TM::Object
|
21
|
+
|
22
|
+
# この時間参照系が使用する空間と時間の制限(実装は時間のみ)
|
23
|
+
#
|
24
|
+
# Limits of space and time within which the temporal reference system is use
|
25
|
+
#
|
26
|
+
# @return [When::EX::Extent]
|
27
|
+
#
|
28
|
+
# @note
|
29
|
+
# domain の最小・最大から範囲を決定して domain_of_validity としている
|
30
|
+
# domain_of_validity は ISO19108との互換性を確保するため提供しているが、
|
31
|
+
# 有効期間が複数に断片化していることがあるので、より正確な情報を含む
|
32
|
+
# domain の使用を推奨する
|
33
|
+
#
|
34
|
+
# マルチスレッド動作時 CalendarEra の生成で Calendar の本属性が更新される
|
35
|
+
# 参照・更新処理は synchronize { ... } の ... の部分に書く必要がある
|
36
|
+
#
|
37
|
+
attr_accessor :domain_of_validity
|
38
|
+
alias :domainOfValidity :domain_of_validity
|
39
|
+
|
40
|
+
# この時間参照系と関連付けられた時間位置 (relation - Reference)
|
41
|
+
#
|
42
|
+
# The temporal position associated with the time reference system being described
|
43
|
+
#
|
44
|
+
# @return [Array<When::TM::(Temporal)Position>]
|
45
|
+
#
|
46
|
+
attr_reader :position
|
47
|
+
|
48
|
+
# この時間参照系が使用する時間の範囲
|
49
|
+
#
|
50
|
+
# Range of time within which the temporal reference system is use
|
51
|
+
#
|
52
|
+
# @return [Hash<String=>When::Parts::GeomerticComplex>]
|
53
|
+
#
|
54
|
+
# @note
|
55
|
+
# マルチスレッド動作時 CalendarEra の生成で Calendar の本属性が更新される
|
56
|
+
# 参照・更新処理は synchronize { ... } の ... の部分に書く必要がある
|
57
|
+
#
|
58
|
+
def domain
|
59
|
+
@domain ||= Hash.new {|hash, key| hash[key] = When::Parts::GeometricComplex.new([])}
|
60
|
+
end
|
61
|
+
|
62
|
+
# 時間参照系を識別する名称
|
63
|
+
#
|
64
|
+
# Name by which the temporal reference system is known
|
65
|
+
#
|
66
|
+
# @return [When::RS::Identifier]
|
67
|
+
#
|
68
|
+
def name
|
69
|
+
@name ||= When::RS::Identifier.new(label, @version, @remarks)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
# 順序時間参照系
|
74
|
+
#
|
75
|
+
# see {http://schemas.opengis.net/gml/3.1.1/base/temporalReferenceSystems.xsd#TimeOrdinalReferenceSystemType gml schema}
|
76
|
+
#
|
77
|
+
class OrdinalReferenceSystem < ReferenceSystem
|
78
|
+
|
79
|
+
# この順序時間参照系の最上位レベルを構成する順序年代 (relation - Structure)
|
80
|
+
#
|
81
|
+
# Ordinal eras that make up the highest level of this ordinal reference system
|
82
|
+
#
|
83
|
+
# @return [Array<When::TM::OrdinalEra>]
|
84
|
+
#
|
85
|
+
alias :component :child
|
86
|
+
|
87
|
+
private
|
88
|
+
|
89
|
+
# オブジェクトの正規化
|
90
|
+
def _normalize(args=[], options={})
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
# 暦
|
95
|
+
#
|
96
|
+
# see {http://schemas.opengis.net/gml/3.1.1/base/temporalReferenceSystems.xsd#TimeCalendarType gml schema}
|
97
|
+
#
|
98
|
+
class Calendar < ReferenceSystem
|
99
|
+
|
100
|
+
include When::Coordinates
|
101
|
+
include Spatial::Normalize
|
102
|
+
include Temporal
|
103
|
+
include When::TimeStandard::TimeBasis
|
104
|
+
|
105
|
+
# 初期化
|
106
|
+
#
|
107
|
+
# @return [void]
|
108
|
+
#
|
109
|
+
# @note
|
110
|
+
# 本メソッドでマルチスレッド対応の管理変数の初期化を行っている。
|
111
|
+
# このため、本メソッド自体はスレッドセーフでない。
|
112
|
+
#
|
113
|
+
def self._setup_
|
114
|
+
@_lock_ = Mutex.new if When.multi_thread
|
115
|
+
@_pool = {}
|
116
|
+
end
|
117
|
+
|
118
|
+
# @private
|
119
|
+
HashProperty = [:label, :referenceFrame, :timeBasis]
|
120
|
+
|
121
|
+
# この暦と関連付けられた暦年代 (relation - Basis)
|
122
|
+
#
|
123
|
+
# The calendar eras associated with the calendar being described
|
124
|
+
#
|
125
|
+
# @return [Array<When::TM::CalendarEra>]
|
126
|
+
#
|
127
|
+
# @note
|
128
|
+
# マルチスレッド動作時 CalendarEra の生成で 本属性が更新される
|
129
|
+
# 参照・更新処理は synchronize { ... } の ... の部分に書く必要がある
|
130
|
+
#
|
131
|
+
attr_reader :reference_frame
|
132
|
+
alias :referenceFrame :reference_frame
|
133
|
+
|
134
|
+
# 一暦日の中の時間位置を定めるために、この暦とともに使用する時計 (relation - Resolution)
|
135
|
+
#
|
136
|
+
# The clock that is used with this calendar to define
|
137
|
+
# temporal position within a calendar day
|
138
|
+
#
|
139
|
+
# @return [Array<When::TM::Clock>]
|
140
|
+
#
|
141
|
+
attr_reader :time_basis
|
142
|
+
alias :timeBasis :time_basis
|
143
|
+
|
144
|
+
# 時刻制 - additional attribute
|
145
|
+
#
|
146
|
+
# @return [When::TimeStandard, nil]
|
147
|
+
#
|
148
|
+
def time_standard
|
149
|
+
@time_basis ? @time_basis.time_standard : nil
|
150
|
+
end
|
151
|
+
|
152
|
+
# 時間の歩度
|
153
|
+
#
|
154
|
+
# @return [Numeric]
|
155
|
+
#
|
156
|
+
def rate_of_clock
|
157
|
+
@time_basis ? @time_basis.time_standard.rate_of_clock : 1.0
|
158
|
+
end
|
159
|
+
|
160
|
+
# 西暦との年次の相違(外部表現の0年に対応する西暦年) - additional attribute
|
161
|
+
#
|
162
|
+
# @return [Numeric]
|
163
|
+
#
|
164
|
+
attr_reader :epoch_in_CE
|
165
|
+
|
166
|
+
# 西暦との年次の相違(内部表現の0年に対応する西暦年) - additional attribute
|
167
|
+
#
|
168
|
+
# @return [Numeric]
|
169
|
+
#
|
170
|
+
# @private
|
171
|
+
attr_reader :diff_to_CE
|
172
|
+
|
173
|
+
# 日付と時刻をユリウス日(When::TM::JulianDate)に変換する
|
174
|
+
#
|
175
|
+
# @param [When::TM::CalDate] cal_date
|
176
|
+
# @param [When::TM::ClockTime] time
|
177
|
+
#
|
178
|
+
# @return [When::TM::JulianDate]
|
179
|
+
#
|
180
|
+
def date_trans(cal_date, time=nil, options={})
|
181
|
+
time = cal_date.clk_time if ((time == nil) && cal_date.kind_of?(DateAndTime))
|
182
|
+
frac = (time) ? time.universal_time : 0.0
|
183
|
+
jdn = to_julian_date(cal_date.cal_date)
|
184
|
+
return JulianDate.universal_time((jdn - JulianDate::JD19700101) * Duration::DAY + frac, options)
|
185
|
+
end
|
186
|
+
alias :dateTrans :date_trans
|
187
|
+
|
188
|
+
# ユリウス日(When::TM::JulianDate)を日付に変換する
|
189
|
+
#
|
190
|
+
# @param [When::TM::JulianDate] jdt
|
191
|
+
# @param [Hash] options see {When::TM::TemporalPosition._instance}
|
192
|
+
#
|
193
|
+
# @return [When::TM::CalDate] if (options[:clock or :tz] == nil)
|
194
|
+
# @return [When::TM::CalDateAndTime] if (options[:clock or :tz] != nil)
|
195
|
+
#
|
196
|
+
def jul_trans(jdt, options={})
|
197
|
+
options = TemporalPosition._options(options)
|
198
|
+
unless jdt.kind_of?(When::TimeValue)
|
199
|
+
options[:clock] ||= @time_basis unless rate_of_clock == 1.0
|
200
|
+
jdt = JulianDate.new(jdt, options)
|
201
|
+
end
|
202
|
+
cal_options = jdt._attr
|
203
|
+
cal_options.delete(:era_name)
|
204
|
+
cal_options.delete(:era)
|
205
|
+
unless rate_of_clock == jdt.time_standard.rate_of_clock
|
206
|
+
cal_options.delete(:time_standard)
|
207
|
+
cal_options[:clock] = @time_basis || When::UTC
|
208
|
+
jdt = JulianDate.dynamical_time(jdt.dynamical_time, {:time_standard=>time_standard})
|
209
|
+
end
|
210
|
+
|
211
|
+
cal_options.update(options)
|
212
|
+
cal_options[:frame] = self
|
213
|
+
clock = Clock.get_clock_option(cal_options) || jdt.clock
|
214
|
+
|
215
|
+
if clock
|
216
|
+
clock = When.Clock(clock) if clock.kind_of?(String)
|
217
|
+
clock = clock._daylight(jdt.universal_time) if clock._need_validate
|
218
|
+
frac = clock.universal_time(jdt.to_i)
|
219
|
+
sdn, time = (jdt.universal_time - frac).divmod(Duration::DAY)
|
220
|
+
cal_options[:clock] = clock
|
221
|
+
cal_date = to_cal_date(sdn.to_i + JulianDate::JD19700101)
|
222
|
+
cal_date[0] -= cal_options[:era_name][1] if cal_options[:era_name]
|
223
|
+
DateAndTime.new(cal_date, time+frac, cal_options)
|
224
|
+
else
|
225
|
+
cal_date = to_cal_date(jdt.to_i)
|
226
|
+
cal_date[0] -= cal_options[:era_name][1] if cal_options[:era_name]
|
227
|
+
CalDate.new(cal_date, cal_options)
|
228
|
+
end
|
229
|
+
end
|
230
|
+
alias :julTrans :jul_trans
|
231
|
+
alias :^ :jul_trans
|
232
|
+
|
233
|
+
# ユリウス日(Numeric)を日付に変換する
|
234
|
+
#
|
235
|
+
# @param [Integer] jdn
|
236
|
+
#
|
237
|
+
# @return [Array<Numeric>]
|
238
|
+
#
|
239
|
+
def to_cal_date(jdn)
|
240
|
+
_encode(_number_to_coordinates(jdn))
|
241
|
+
end
|
242
|
+
|
243
|
+
# 日付をユリウス日(Numeric)に変換する
|
244
|
+
#
|
245
|
+
# @param [Array<Numeric>] cal_date
|
246
|
+
#
|
247
|
+
# @return [Integer] JulianDate
|
248
|
+
#
|
249
|
+
def to_julian_date(cal_date)
|
250
|
+
date = _decode(cal_date)
|
251
|
+
date[0] = +date[0]
|
252
|
+
_coordinates_to_number(*date)
|
253
|
+
end
|
254
|
+
|
255
|
+
# 日付・時刻をUniversal Time(Numeric)に変換する
|
256
|
+
#
|
257
|
+
# @param [Array<Numeric>] cal_date 日付
|
258
|
+
# @param [Array<Numeric>] clk_time 時刻
|
259
|
+
# @param [When::TM::Clock] clock 時法
|
260
|
+
#
|
261
|
+
# @return [Numeric] Universal Time
|
262
|
+
#
|
263
|
+
def to_universal_time(cal_date, clk_time, clock=When::UTC)
|
264
|
+
time = clk_time.dup
|
265
|
+
time[0] += _coordinates_to_number(*_decode(cal_date))
|
266
|
+
clock.to_universal_time(time) - When::TM::JulianDate::JD19700101 * When::TM::Duration::DAY
|
267
|
+
end
|
268
|
+
|
269
|
+
# 月初の通日
|
270
|
+
#
|
271
|
+
# @param [Integer] m 通月
|
272
|
+
#
|
273
|
+
# @return [Numeric] 月初の通日
|
274
|
+
#
|
275
|
+
def _new_month_(m)
|
276
|
+
date = @base.map {|d| d||0}
|
277
|
+
if @indices[-2].unit
|
278
|
+
date[-2] += m
|
279
|
+
_coordinates_to_number(*_decode(date))
|
280
|
+
else
|
281
|
+
d0 = _coordinates_to_number(*_decode(date))
|
282
|
+
date[-3] += (m * @mean_month / @mean_year).floor - 1
|
283
|
+
d1 = _coordinates_to_number(*_decode(date))
|
284
|
+
date[-2] += m - ((d1 - d0) / @mean_month + 0.5).floor
|
285
|
+
_coordinates_to_number(*_decode(date))
|
286
|
+
end
|
287
|
+
end
|
288
|
+
|
289
|
+
# 通日 - > [通月,月内日数,月の日数]
|
290
|
+
#
|
291
|
+
# @param [Integer] sdn 通日
|
292
|
+
#
|
293
|
+
# @return [Array<Numeric>] ( m, d, n )
|
294
|
+
# [ m - 通月]
|
295
|
+
# [ d - 月内の日数 (0 始まり)]
|
296
|
+
# [ n - 月の日数]
|
297
|
+
#
|
298
|
+
def _to_month_number_(sdn)
|
299
|
+
Residue.mod(sdn) {|m| _new_month(m)}
|
300
|
+
end
|
301
|
+
|
302
|
+
private
|
303
|
+
|
304
|
+
# オブジェクトの正規化
|
305
|
+
def _normalize(args=[], options={})
|
306
|
+
@indices ||= DefaultDateIndices
|
307
|
+
_normalize_spatial
|
308
|
+
_normalize_time_basis
|
309
|
+
_default_index_of_MSC
|
310
|
+
_normalize_temporal
|
311
|
+
@reference_frame ||= []
|
312
|
+
@epoch_in_CE ||=
|
313
|
+
if @diff_to_CE
|
314
|
+
@diff_to_CE = @diff_to_CE.to_i
|
315
|
+
@diff_to_CE - @origin_of_MSC
|
316
|
+
else
|
317
|
+
0
|
318
|
+
end
|
319
|
+
@epoch_in_CE = @epoch_in_CE.to_i
|
320
|
+
@diff_to_CE = @epoch_in_CE + @origin_of_MSC
|
321
|
+
end
|
322
|
+
end
|
323
|
+
|
324
|
+
# 時計
|
325
|
+
#
|
326
|
+
# see {http://schemas.opengis.net/gml/3.1.1/base/temporalReferenceSystems.xsd#TimeClockType gml schema}
|
327
|
+
#
|
328
|
+
class Clock < ReferenceSystem
|
329
|
+
|
330
|
+
include When::Coordinates
|
331
|
+
include When::Parts::Timezone::Base
|
332
|
+
include Spatial::Normalize
|
333
|
+
include Temporal
|
334
|
+
|
335
|
+
class << self
|
336
|
+
include When::Parts::Resource::Pool
|
337
|
+
|
338
|
+
# When::TM::Clock Class のグローバルな設定を行う
|
339
|
+
#
|
340
|
+
# @param [When::Parts::Timezone::Base, String] local 地方時を使用する場合、指定する
|
341
|
+
#
|
342
|
+
# @return [void]
|
343
|
+
#
|
344
|
+
# @note
|
345
|
+
# 本メソッドでマルチスレッド対応の管理変数の初期化を行っている。
|
346
|
+
# このため、本メソッド自体はスレッドセーフでない。
|
347
|
+
#
|
348
|
+
def _setup_(local=nil)
|
349
|
+
@_lock_ = Mutex.new if When.multi_thread
|
350
|
+
@_pool = {}
|
351
|
+
@local_time = local
|
352
|
+
end
|
353
|
+
|
354
|
+
# 設定情報を取得する
|
355
|
+
#
|
356
|
+
# @return [Hash] 設定情報
|
357
|
+
#
|
358
|
+
def _setup_info
|
359
|
+
{:local => _local_time}
|
360
|
+
end
|
361
|
+
|
362
|
+
# 地方時
|
363
|
+
#
|
364
|
+
# @param [When::Parts::Timezone::Base, String] local 地方時
|
365
|
+
#
|
366
|
+
# @return [When::Parts::Timezone::Base, String]
|
367
|
+
#
|
368
|
+
# @note
|
369
|
+
# @local_timeは、原則、ライブラリ立ち上げ時に _setup_ で初期化する。
|
370
|
+
# 以降、@local_timeに代入を行っても、すでに生成した When::TM::TemporalPosition 等には反映されない。
|
371
|
+
#
|
372
|
+
def local_time=(local)
|
373
|
+
if @_pool
|
374
|
+
@local_time = local
|
375
|
+
else
|
376
|
+
_setup_(local)
|
377
|
+
end
|
378
|
+
end
|
379
|
+
|
380
|
+
# When::TM::Clock のローカルタイムを読みだす
|
381
|
+
#
|
382
|
+
# @return [When::Parts::Timezone::Base]
|
383
|
+
#
|
384
|
+
def local_time
|
385
|
+
_local_time[1]
|
386
|
+
end
|
387
|
+
|
388
|
+
# When::TM::Clock のローカルタイムが設定されているか?
|
389
|
+
#
|
390
|
+
# @return [true, false]
|
391
|
+
#
|
392
|
+
def is_local_time_set?
|
393
|
+
_local_time[0]
|
394
|
+
end
|
395
|
+
|
396
|
+
# 共通処理
|
397
|
+
def _local_time
|
398
|
+
case @local_time
|
399
|
+
when Array ; @local_time
|
400
|
+
when nil ; @local_time = [false, When::UTC]
|
401
|
+
when String ; @local_time = [true, When::Parts::Timezone[@local_time] ||
|
402
|
+
When::V::Timezone[@local_time] ||
|
403
|
+
When.Clock(@local_time)]
|
404
|
+
else ; @local_time = [true, @local_time]
|
405
|
+
end
|
406
|
+
end
|
407
|
+
private :_local_time
|
408
|
+
|
409
|
+
# @private
|
410
|
+
def get_clock(options)
|
411
|
+
get_clock_option(options) || local_time
|
412
|
+
end
|
413
|
+
|
414
|
+
# @private
|
415
|
+
def get_clock_option(options)
|
416
|
+
clock = options.delete(:clock)
|
417
|
+
tz = options.delete(:tz)
|
418
|
+
tz ? (When::V::Timezone[tz] || When::Parts::Timezone[tz]) : clock
|
419
|
+
end
|
420
|
+
|
421
|
+
# @private
|
422
|
+
def to_hms(hms, extended=true)
|
423
|
+
case hms
|
424
|
+
when Numeric
|
425
|
+
sgn = (hms >= 0) ? '+' : '-'
|
426
|
+
hh, mm = hms.abs.divmod(3600)
|
427
|
+
mm, ss = mm.divmod(60)
|
428
|
+
ss, ff = ss.divmod(1)
|
429
|
+
ff = (ff == 0 || When::STRING <= When::SECOND) ? '' :
|
430
|
+
("%.#{When::STRING - When::SECOND}f" % ff)[1..-1]
|
431
|
+
ss = (ss == 0 && ff == '') ? '' : ("%02d" % ss)
|
432
|
+
mm = "%02d" % mm
|
433
|
+
hh = "%02d" % hh
|
434
|
+
when /\A([-+])(\d{2})([:=*])?(\d{2})?([:=*])?(\d{2})?(\.\d+)?\z/
|
435
|
+
sgn, hh, d1, mm, d2, ss, ff = $~[1..7]
|
436
|
+
ff ||= ''
|
437
|
+
ss ||= ''
|
438
|
+
mm ||= ''
|
439
|
+
else
|
440
|
+
return nil
|
441
|
+
end
|
442
|
+
|
443
|
+
if (extended)
|
444
|
+
d1 ||= (mm=='') ? '' : ':'
|
445
|
+
d2 ||= (ss=='') ? '' : ':'
|
446
|
+
else
|
447
|
+
d1 = ''
|
448
|
+
d2 = ''
|
449
|
+
end
|
450
|
+
sgn + hh + d1 + mm + d2 + ss + ff
|
451
|
+
end
|
452
|
+
end
|
453
|
+
|
454
|
+
# @private
|
455
|
+
HashProperty = [:label, :referenceEvent, :referenceTime, :utcReference, :dateBasis]
|
456
|
+
|
457
|
+
# この時法の基点となる事象
|
458
|
+
#
|
459
|
+
# Event used as the datum for this clock
|
460
|
+
#
|
461
|
+
# @return [String]
|
462
|
+
#
|
463
|
+
# @note
|
464
|
+
# new の options 引数に :reference_event があれば設定される。
|
465
|
+
# ライブラリとしては本変数を参照していない。下記の振る舞いを String で説明するため用いてもよい。
|
466
|
+
#
|
467
|
+
# @note
|
468
|
+
# 日付の境界が午前0時でない場合、When::Coordinates::Temporal.border により、境界が指定される。
|
469
|
+
# border, behavior メソッドをオーバーライドすることで、日の出、日の入りなど event 時刻が一定
|
470
|
+
# しない場合にも対応する。
|
471
|
+
#
|
472
|
+
attr_reader :reference_event
|
473
|
+
alias :referenceEvent :reference_event
|
474
|
+
|
475
|
+
# この時法による参照事象の時刻
|
476
|
+
#
|
477
|
+
# Time of the reference event for this clock
|
478
|
+
#
|
479
|
+
# @return [When::TM::ClockTime]
|
480
|
+
#
|
481
|
+
attr_reader :reference_time
|
482
|
+
alias :referenceTime :reference_time
|
483
|
+
|
484
|
+
# UTCによる参照事象の時刻
|
485
|
+
#
|
486
|
+
# UTC time of the reference event
|
487
|
+
#
|
488
|
+
# @return [When::TM::ClockTime]
|
489
|
+
#
|
490
|
+
attr_reader :utc_reference
|
491
|
+
alias :utcReference :utc_reference
|
492
|
+
|
493
|
+
# 一暦日の中の時間位置を定めるために、この時計とともに使用する暦 (relation - Resolution)
|
494
|
+
#
|
495
|
+
# The calendar that is used with this clock to define
|
496
|
+
# temporal position within a calendar day
|
497
|
+
#
|
498
|
+
# @return [Array<When::TM::Calendar>]
|
499
|
+
#
|
500
|
+
attr_reader :date_basis
|
501
|
+
alias :dateBasis :date_basis
|
502
|
+
|
503
|
+
# 時刻制 - additional attribute
|
504
|
+
#
|
505
|
+
# @return [When::TimeStandard]
|
506
|
+
#
|
507
|
+
attr_reader :time_standard
|
508
|
+
|
509
|
+
# この時法を生成した時間帯プロパティ - additional attribute
|
510
|
+
#
|
511
|
+
# @return [When::V::TimezoneProperty]
|
512
|
+
#
|
513
|
+
# @note
|
514
|
+
# When::TM::TemporalPosition に対して加減算を行うと、時間帯が変わる可能性がある。
|
515
|
+
# 本変数により、時間帯決定ルール(When::V::TimezoneProperty#rrule)を参照する。
|
516
|
+
#
|
517
|
+
attr_accessor :tz_prop
|
518
|
+
alias :tzProp :tz_prop
|
519
|
+
|
520
|
+
# universal_timeとこの時法の最小単位との比 - additional attribute
|
521
|
+
#
|
522
|
+
# @return [Numeric]
|
523
|
+
#
|
524
|
+
attr_reader :second
|
525
|
+
|
526
|
+
# この時法のUTCとの差(ISO 8601 extended format) - additional attribute
|
527
|
+
#
|
528
|
+
# @return [String] (±hh:mm)
|
529
|
+
#
|
530
|
+
attr_reader :zone
|
531
|
+
alias :to_extended :zone
|
532
|
+
|
533
|
+
# 時間の歩度
|
534
|
+
#
|
535
|
+
# @return [Numeric]
|
536
|
+
#
|
537
|
+
def rate_of_clock
|
538
|
+
@time_standard.rate_of_clock
|
539
|
+
end
|
540
|
+
|
541
|
+
# 128秒単位の実数による参照事象の時刻
|
542
|
+
#
|
543
|
+
# Fraction time of the reference event
|
544
|
+
#
|
545
|
+
# @param [Integer] sdn 参照事象の通し番号(ダミー)
|
546
|
+
#
|
547
|
+
# @return [Numeric]
|
548
|
+
#
|
549
|
+
# T00:00:00Z からの参照事象の経過時間 / 128秒
|
550
|
+
#
|
551
|
+
def universal_time(sdn=nil)
|
552
|
+
return @utc_reference.universal_time
|
553
|
+
end
|
554
|
+
|
555
|
+
# この時法の時刻をUTC時刻に変換する
|
556
|
+
#
|
557
|
+
# @param [When::TM::ClockTime] u_time
|
558
|
+
#
|
559
|
+
# @return [When::TM::ClockTime]
|
560
|
+
#
|
561
|
+
def utc_trans(u_time)
|
562
|
+
return When::UTC.to_clk_time(self.to_universal_time(u_time.clk_time))
|
563
|
+
end
|
564
|
+
alias :utcTrans :utc_trans
|
565
|
+
|
566
|
+
# UTC時刻をこの時法の時刻に変換する
|
567
|
+
#
|
568
|
+
# @param [When::TM::ClockTime] clk_time
|
569
|
+
#
|
570
|
+
# @return [When::TM::ClockTime]
|
571
|
+
#
|
572
|
+
def clk_trans(clk_time)
|
573
|
+
return self.to_clk_time(When::UTC.to_universal_time(u_time.clk_time))
|
574
|
+
end
|
575
|
+
alias :clkTrans :clk_trans
|
576
|
+
|
577
|
+
# この時法の時刻を128秒単位の実数に変換する
|
578
|
+
#
|
579
|
+
# @param [Array<Numeric>] clk_time
|
580
|
+
# @param [Integer] sdn 参照事象の通し番号(ダミー)
|
581
|
+
#
|
582
|
+
# @return [Numeric]
|
583
|
+
#
|
584
|
+
def to_universal_time(clk_time, sdn=nil)
|
585
|
+
return _coordinates_to_number(_decode(clk_time)) / @second
|
586
|
+
end
|
587
|
+
alias :to_local_time :to_universal_time
|
588
|
+
|
589
|
+
# 128秒単位の実数をこの時法の時刻に変換する
|
590
|
+
#
|
591
|
+
# @param [Numeric] fod
|
592
|
+
#
|
593
|
+
# @return [When::TM::ClockTime]
|
594
|
+
#
|
595
|
+
def to_clk_time(fod, options={})
|
596
|
+
options[:frame] = self
|
597
|
+
fod, second = fod.trunk, fod.branch / fod.second if fod.kind_of?(When::Coordinates::LeapSeconds)
|
598
|
+
clk_time = ClockTime.new(_encode(_number_to_coordinates(fod * @second)), options)
|
599
|
+
return clk_time if (second||0) == 0
|
600
|
+
clk_time.clk_time[-1] += second
|
601
|
+
return clk_time
|
602
|
+
end
|
603
|
+
|
604
|
+
# 時刻をNumeric(serial time)に変換する
|
605
|
+
#
|
606
|
+
# @param [Numeric] clk_time
|
607
|
+
#
|
608
|
+
# @return [Numeric] serial time
|
609
|
+
#
|
610
|
+
def _coordinates_to_number(clk_time)
|
611
|
+
u = 1
|
612
|
+
s = 0
|
613
|
+
(@base.length-1).downto(1) do |i|
|
614
|
+
s += u * (+clk_time[i] - @base[i]) if (clk_time[i])
|
615
|
+
u *= @unit[i]
|
616
|
+
end
|
617
|
+
return s + u * (+clk_time[0]) + @origin_of_LSC
|
618
|
+
end
|
619
|
+
|
620
|
+
# Numeric(serial time)を時刻に変換する
|
621
|
+
#
|
622
|
+
# @param [Numeric] serial_time
|
623
|
+
#
|
624
|
+
# @return [Numeric]
|
625
|
+
#
|
626
|
+
def _number_to_coordinates(serial_time)
|
627
|
+
time = [serial_time-@origin_of_LSC]
|
628
|
+
(@base.length-1).downto(1) do |i|
|
629
|
+
carry, time[0] = (+time[0]).divmod(@unit[i])
|
630
|
+
time[0] += @base[i]
|
631
|
+
time.unshift(carry)
|
632
|
+
end
|
633
|
+
return time
|
634
|
+
end
|
635
|
+
|
636
|
+
#
|
637
|
+
# _m17n_form のための要素生成
|
638
|
+
#
|
639
|
+
# @param [Hash] options 下記のとおり
|
640
|
+
# @option options [Symbol] :method :to_m17n なら時間帯名を返す、その他は When::Parts::Resource#to_h 参照
|
641
|
+
#
|
642
|
+
# @private
|
643
|
+
def _to_hash_value(options={})
|
644
|
+
options[:method] == :to_m17n ? tzname(:hash)[0] : super
|
645
|
+
end
|
646
|
+
|
647
|
+
# この時法のUTCとの差(ISO 8601 basic format)
|
648
|
+
#
|
649
|
+
# @return [String] (±hhmm)
|
650
|
+
#
|
651
|
+
def to_basic
|
652
|
+
return '' unless @zone
|
653
|
+
@zone.gsub(/:/, '')
|
654
|
+
end
|
655
|
+
|
656
|
+
# 期間オブジェクトの桁数合わせ
|
657
|
+
# @private
|
658
|
+
def _arrange_length(period)
|
659
|
+
return period unless period.kind_of?(Array)
|
660
|
+
diff = @indices.length - period.length + 1
|
661
|
+
return period if (diff == 0)
|
662
|
+
return (diff > 0) ? period + Array.new(diff, 0) : period[0...diff]
|
663
|
+
end
|
664
|
+
|
665
|
+
# 時刻配列の分解能
|
666
|
+
# @private
|
667
|
+
def _precision(time, default=nil)
|
668
|
+
nil_index = time.index(nil) || time.length
|
669
|
+
precision = nil_index - 1 if (nil_index < @base.length || time[-1].kind_of?(Integer))
|
670
|
+
When::Coordinates::Index.precision(default || precision)
|
671
|
+
end
|
672
|
+
|
673
|
+
# 丸め量 / When::TM::Duration::SYSTEM
|
674
|
+
# @private
|
675
|
+
def _round_value(precision)
|
676
|
+
offset = When::TM::Duration::DAY / 2
|
677
|
+
precision.times do |i|
|
678
|
+
offset /= @unit[i+1] ? @unit[i+1] : 10
|
679
|
+
end
|
680
|
+
offset
|
681
|
+
end
|
682
|
+
|
683
|
+
# この時法の時間帯名
|
684
|
+
#
|
685
|
+
# @param [Symbol] format
|
686
|
+
# - :extended ISO 8601 extended format (default)
|
687
|
+
# - :basic ISO 8601 basic format
|
688
|
+
# - :hash 時間帯名の後ろにISO 8601 extended format を付加する
|
689
|
+
#
|
690
|
+
# @return [Array<String>]
|
691
|
+
#
|
692
|
+
# @note
|
693
|
+
# :extended または :basicが指定され、上記は時間帯名が定義されていない場合は、ISO 8601形式で返す
|
694
|
+
#
|
695
|
+
def tzname(format=:extended)
|
696
|
+
name = @tz_prop.tzname if @tz_prop.kind_of?(When::V::TimezoneProperty) && format != :hash
|
697
|
+
name ||= format == :basic ? to_basic : @zone
|
698
|
+
name = Array(name)
|
699
|
+
return name unless format == :hash
|
700
|
+
tzid = case @tz_prop
|
701
|
+
when When::V::TimezoneProperty ; @tz_prop['..'].property['tzid'].object
|
702
|
+
when When::Parts::Timezone ; @tz_prop.timezone.name
|
703
|
+
else ; ''
|
704
|
+
end
|
705
|
+
name[0] = tzid + name[0]
|
706
|
+
name
|
707
|
+
end
|
708
|
+
|
709
|
+
# 時間帯を代表する空間位置
|
710
|
+
# @return [When::Coordinates::Spatial]
|
711
|
+
def location
|
712
|
+
@location ||= @tz_prop.kind_of?(When::Parts::Timezone) ? @tz_prop.location :
|
713
|
+
When::Coordinates::Spatial.default_location
|
714
|
+
end
|
715
|
+
|
716
|
+
# 標準時間帯の時計
|
717
|
+
# @return [When::TM::Clock]
|
718
|
+
def standard
|
719
|
+
_tz_prop ? _tz_prop.standard : self
|
720
|
+
end
|
721
|
+
|
722
|
+
# 夏時間帯の時計
|
723
|
+
# @return [When::TM::Clock]
|
724
|
+
def daylight
|
725
|
+
_tz_prop ? _tz_prop.daylight : self
|
726
|
+
end
|
727
|
+
|
728
|
+
# 夏時間帯と標準時間帯の時間差
|
729
|
+
# @return [When::TM:IntervalLength]
|
730
|
+
def tz_difference
|
731
|
+
_tz_prop ? _tz_prop.tz_difference : 0
|
732
|
+
end
|
733
|
+
|
734
|
+
# 夏時間の有無
|
735
|
+
# @private
|
736
|
+
def _need_validate
|
737
|
+
_tz_prop ? _tz_prop._need_validate : false
|
738
|
+
end
|
739
|
+
|
740
|
+
# 夏時間
|
741
|
+
# @private
|
742
|
+
def _daylight(time)
|
743
|
+
_tz_prop ? _tz_prop._daylight(time) : self
|
744
|
+
end
|
745
|
+
|
746
|
+
private
|
747
|
+
|
748
|
+
# Timezone オブジェクト
|
749
|
+
def _tz_prop
|
750
|
+
@tz_prop.kind_of?(When::V::TimezoneProperty) ? @tz_prop._pool['..'] : @tz_prop
|
751
|
+
end
|
752
|
+
|
753
|
+
# オブジェクトの正規化
|
754
|
+
def _normalize(args=[], options={})
|
755
|
+
@indices ||= DefaultTimeIndices
|
756
|
+
|
757
|
+
# note
|
758
|
+
@note ||= 'JulianDay'
|
759
|
+
|
760
|
+
# normalize spatial module
|
761
|
+
_normalize_spatial
|
762
|
+
|
763
|
+
# normalize temporal module
|
764
|
+
_normalize_temporal
|
765
|
+
|
766
|
+
# second
|
767
|
+
@second = (@second||1/When::TM::Duration::SECOND).to_f
|
768
|
+
|
769
|
+
# zone
|
770
|
+
@zone = Clock.to_hms(@zone || @label || @reference_event)
|
771
|
+
|
772
|
+
# time_standard
|
773
|
+
@time_standard = When.Resource(@time_standard||'UniversalTime', '_t:') unless @time_standard.kind_of?(When::TimeStandard)
|
774
|
+
|
775
|
+
# utc_reference
|
776
|
+
@utc_reference ||= @zone ? ClockTime.new(@zone.to_s, {:frame=>When::UTC}) : Clock.local_time
|
777
|
+
|
778
|
+
# reference_time & origin_of_LSC
|
779
|
+
case @reference_time
|
780
|
+
when Array ; clk_time = @reference_time
|
781
|
+
when String ; clk_time = Pair._en_pair_date_time(@reference_time)
|
782
|
+
when ClockTime ; clk_time = @reference_time.clk_time
|
783
|
+
when nil ; clk_time = [0, 0]
|
784
|
+
else ; raise TypeError, "reference_time type mismatch"
|
785
|
+
end
|
786
|
+
@origin_of_LSC -= (to_universal_time(clk_time) - @utc_reference.universal_time) * @second
|
787
|
+
@reference_time = ClockTime.new(clk_time, {:frame=>self})
|
788
|
+
end
|
789
|
+
end
|
790
|
+
|
791
|
+
# 時間座標系
|
792
|
+
#
|
793
|
+
# see {http://schemas.opengis.net/gml/3.1.1/base/temporalReferenceSystems.xsd#TimeCoordinateSystemType gml schema}
|
794
|
+
#
|
795
|
+
class CoordinateSystem < ReferenceSystem
|
796
|
+
|
797
|
+
# グレゴリオ暦の日付及びその日のUTCの時刻で表現する、座標参照系の尺度の原点位置
|
798
|
+
#
|
799
|
+
# Position of the origin of the scale on which the temporal coordinate
|
800
|
+
# system is based expressed as a date in the Gregorian calendar and
|
801
|
+
# time of day in UTC
|
802
|
+
#
|
803
|
+
# @return [When::BasicTypes::DateTime]
|
804
|
+
#
|
805
|
+
attr_reader :origin
|
806
|
+
|
807
|
+
# この参照系の軸で時間の参照単位とする間隔
|
808
|
+
#
|
809
|
+
# Standard unit of time used to measure duration
|
810
|
+
# on the axis of the coordinate system
|
811
|
+
#
|
812
|
+
# @return [When::TM::Duration] (changed from String)
|
813
|
+
#
|
814
|
+
attr_reader :interval
|
815
|
+
|
816
|
+
# この時間参照系の座標値をグレゴリオ暦及びUTC時刻に変換する
|
817
|
+
#
|
818
|
+
# @param [When::TM::Coordinate] c_value
|
819
|
+
#
|
820
|
+
# @return [When::TM::DateAndTime] (When::TM::BasicTypes::DateTimeはまちがい)
|
821
|
+
#
|
822
|
+
def transform_coord(c_value)
|
823
|
+
When::Gregorian.jul_trans(JulianDate.universal_time(c_value.universal_time, {:frame=>When::UTC}))
|
824
|
+
end
|
825
|
+
alias :transformCoord :transform_coord
|
826
|
+
|
827
|
+
# グレゴリオ暦及びUTC時刻をこの時間参照系の座標値に変換する
|
828
|
+
#
|
829
|
+
# @param [When::TM::DateAndTime (BasicTypes::DateTimeはまちがい)] date_time
|
830
|
+
#
|
831
|
+
# @return [When::TM::Coordinate]
|
832
|
+
#
|
833
|
+
def transform_date_time(date_time)
|
834
|
+
Coordinate.universal_time(date_time.universal_time, {:frame=>self})
|
835
|
+
end
|
836
|
+
alias :transformDateTime :transform_date_time
|
837
|
+
|
838
|
+
private
|
839
|
+
|
840
|
+
# オブジェクトの正規化
|
841
|
+
def _normalize(args=[], options={})
|
842
|
+
@origin = When.when?(@origin, options)
|
843
|
+
@interval = When.Duration(@interval)
|
844
|
+
raise TypeError, "Interval should be IntervalLength" unless @interval.kind_of?(IntervalLength)
|
845
|
+
end
|
846
|
+
end
|
847
|
+
|
848
|
+
# 順序時間参照系
|
849
|
+
#
|
850
|
+
# see {http://schemas.opengis.net/gml/3.1.1/base/temporalReferenceSystems.xsd#TimeOrdinalEraType gml schema}
|
851
|
+
#
|
852
|
+
class OrdinalEra < When::TM::Object
|
853
|
+
|
854
|
+
include Separation
|
855
|
+
|
856
|
+
HashProperty = [:label, :begin, :end]
|
857
|
+
|
858
|
+
# この順序年代を識別する名称
|
859
|
+
#
|
860
|
+
# Name that identifies a specific ordinal era
|
861
|
+
#
|
862
|
+
# @return [String]
|
863
|
+
#
|
864
|
+
alias :name :label
|
865
|
+
|
866
|
+
# この順序年代をさらに分割する順序年代
|
867
|
+
#
|
868
|
+
# Ordinal eras that subdivide this ordinal era
|
869
|
+
#
|
870
|
+
# @return [Array<When::TM::OrdinalEra>]
|
871
|
+
#
|
872
|
+
alias :member :child
|
873
|
+
|
874
|
+
# この順序年代が属する順序時間参照系 (relation - Structure)
|
875
|
+
#
|
876
|
+
# Ordinal reference system that contains this ordinal era
|
877
|
+
#
|
878
|
+
# @return [When::TM::OrdinalReferenceSystem, nil]
|
879
|
+
#
|
880
|
+
def system
|
881
|
+
_pool['..'].kind_of?(String) ? _pool['..'] : nil
|
882
|
+
end
|
883
|
+
|
884
|
+
# この順序年代が属する上位順序年代 (relation - Composition)
|
885
|
+
#
|
886
|
+
# Ordinal era that contains this ordinal era
|
887
|
+
#
|
888
|
+
# @return [When::TM::OrdinalEra, nil]
|
889
|
+
#
|
890
|
+
def group
|
891
|
+
_pool['..'].kind_of?(String)? nil : _pool['..']
|
892
|
+
end
|
893
|
+
|
894
|
+
# この順序年代が始まる時点
|
895
|
+
#
|
896
|
+
# Date at which the ordinal era began
|
897
|
+
#
|
898
|
+
# @return [When::BasicTypes::DateTime]
|
899
|
+
#
|
900
|
+
attr_reader :begin
|
901
|
+
|
902
|
+
# この順序年代が終わる時点
|
903
|
+
#
|
904
|
+
# Date at which the ordinal era ended
|
905
|
+
#
|
906
|
+
# @return [When::BasicTypes::DateTime]
|
907
|
+
#
|
908
|
+
def end
|
909
|
+
@end || (@_pool['.->'] ? @_pool['.->'].begin : nil)
|
910
|
+
end
|
911
|
+
|
912
|
+
# 日時が属するか?
|
913
|
+
#
|
914
|
+
# @param [When::TM::TemporalPosition] other
|
915
|
+
#
|
916
|
+
# @return [Boolean]
|
917
|
+
# [ true - 属する ]
|
918
|
+
# [ false - 属さない ]
|
919
|
+
#
|
920
|
+
def include?(other)
|
921
|
+
self.begin <= other && other < self.end
|
922
|
+
end
|
923
|
+
|
924
|
+
# When::TM::TemporalPosition ^ When::TM::OrdinalEra で呼ばれる
|
925
|
+
# @private
|
926
|
+
def ^(other)
|
927
|
+
include?(other) ? self : nil
|
928
|
+
end
|
929
|
+
|
930
|
+
private
|
931
|
+
|
932
|
+
# オブジェクトの正規化
|
933
|
+
def _normalize(args=[], options={})
|
934
|
+
# options
|
935
|
+
@options ||= {}
|
936
|
+
term_options = @options.merge({'namespace'=>@namespace, 'locale'=>@locale})
|
937
|
+
|
938
|
+
label, begun, ended = args
|
939
|
+
|
940
|
+
# label
|
941
|
+
@label = label if label
|
942
|
+
@label = m17n(@label, nil, nil, term_options) if (@label.instance_of?(String))
|
943
|
+
@label._pool['..'] ||= self
|
944
|
+
@_pool[@label.to_s] = @label
|
945
|
+
|
946
|
+
# begin
|
947
|
+
@begin = begun if begun
|
948
|
+
@begin = When.when?(@begin, @options) if @begin
|
949
|
+
@begin = @child[0].begin if !@begin && @child[0]
|
950
|
+
|
951
|
+
# end
|
952
|
+
@end = ended if ended
|
953
|
+
@end = When.when?(@end, @options) if @end
|
954
|
+
@end = @child[-1].end if !@end && @child[-1]
|
955
|
+
end
|
956
|
+
|
957
|
+
# その他のメソッド
|
958
|
+
#
|
959
|
+
# @note
|
960
|
+
# When::TM::OrdinalEra で定義されていないメソッドは
|
961
|
+
# 処理を @begin (type: When::TM::TemporalPosition) に委譲する
|
962
|
+
#
|
963
|
+
def method_missing(name, *args, &block)
|
964
|
+
self.class.module_eval %Q{
|
965
|
+
def #{name}(*args, &block)
|
966
|
+
@begin.send("#{name}", *args, &block)
|
967
|
+
end
|
968
|
+
} unless When::Parts::MethodCash.escape(name)
|
969
|
+
@begin.send(name, *args, &block)
|
970
|
+
end
|
971
|
+
end
|
972
|
+
|
973
|
+
# 暦年代
|
974
|
+
#
|
975
|
+
# see {http://schemas.opengis.net/gml/3.1.1/base/temporalReferenceSystems.xsd#TimeCalendarEraType gml schema}
|
976
|
+
#
|
977
|
+
class CalendarEra < When::TM::Object
|
978
|
+
|
979
|
+
class << self
|
980
|
+
|
981
|
+
include When::Parts::Resource::Pool
|
982
|
+
|
983
|
+
# When::TM::CalendarEra Class のグローバルな設定を行う
|
984
|
+
#
|
985
|
+
# @param [Array<String>] order When::TM::CalendarEra の検索順序を指定するIRI文字列のArray
|
986
|
+
#
|
987
|
+
# @return [void]
|
988
|
+
#
|
989
|
+
# @note
|
990
|
+
# 本メソッドでマルチスレッド対応の管理変数の初期化を行っている。
|
991
|
+
# このため、本メソッド自体はスレッドセーフでない。
|
992
|
+
#
|
993
|
+
def _setup_(order=nil)
|
994
|
+
@_lock_ = Mutex.new if When.multi_thread
|
995
|
+
@_pool = {}
|
996
|
+
@order = order || DefaultEpochs
|
997
|
+
end
|
998
|
+
|
999
|
+
# 設定情報を取得する
|
1000
|
+
#
|
1001
|
+
# @return [Hash] 設定情報
|
1002
|
+
#
|
1003
|
+
def _setup_info
|
1004
|
+
{:order => @order || _setup_}
|
1005
|
+
end
|
1006
|
+
|
1007
|
+
# When::TM::CalendarEra オブジェクトを検索し取得する
|
1008
|
+
#
|
1009
|
+
# @overload _instance(key, epoch=nil, reverse=nil, options={})
|
1010
|
+
# @param [String, Regexp] key 検索する暦年代または、暦年代にマッチする正規表現
|
1011
|
+
# @param [Integer] epoch 年数を昇順にカウントする方式での暦元(0年)の通年(デフォルトは nil - 指定なし)
|
1012
|
+
# @param [Integer] reverse 年数を降順にカウントする方式での暦元(0年)の通年(デフォルトは nil - 指定なし)
|
1013
|
+
# @param [Hash] options 以下の通り
|
1014
|
+
# @option options [String] :area 暦年代の使用地域の指定(デフォルトは nil - 指定なし)
|
1015
|
+
# @option options [String] :period 暦年代の使用時代の指定(デフォルトは nil - 指定なし)
|
1016
|
+
# @option options [Integer] :count 何件ヒットするまで検索するかを指定(デフォルトは 1件)
|
1017
|
+
# @option options [String] the_others 例えば When::TM::CalendarEra オブジェクトの epoch_of_use に 'name' などの
|
1018
|
+
# 指定がある場合、:name に指定しておけば、検索での絞り込みに使用できる。
|
1019
|
+
#
|
1020
|
+
# @note 検索用のインデクスはインスタンスの生成時に作成する。
|
1021
|
+
# 作成後にキーワードとなる年号(M17nクラス)にローケールが追加されても反映されない。
|
1022
|
+
#
|
1023
|
+
def _instance(*args)
|
1024
|
+
# パラメータ
|
1025
|
+
args = args.dup
|
1026
|
+
options = (args[-1].kind_of?(Hash)) ? args.pop.dup : {}
|
1027
|
+
key, epoch, reverse = options.delete(:label) || args
|
1028
|
+
key = When::Locale.ideographic_unification(key)
|
1029
|
+
if key.kind_of?(String)
|
1030
|
+
key.gsub!(When::Parts::Resource::IRIDecode) {|c| When::Parts::Resource::IRIDecodeTable[c]}
|
1031
|
+
key, *parents = key.split(/::/).reverse
|
1032
|
+
else
|
1033
|
+
parents = []
|
1034
|
+
end
|
1035
|
+
area = options.delete(:area)
|
1036
|
+
period = options.delete(:period)
|
1037
|
+
count = options.delete(:count) || 1
|
1038
|
+
|
1039
|
+
# 候補
|
1040
|
+
_setup_ unless @_pool
|
1041
|
+
pool = _candidates(options, area, period, key, epoch, false) +
|
1042
|
+
_candidates(options, area, period, key, reverse, true)
|
1043
|
+
_compact(pool, parents)
|
1044
|
+
return pool unless pool.size < count
|
1045
|
+
|
1046
|
+
order = @order
|
1047
|
+
if /\?.+?=/ =~ parents[-1]
|
1048
|
+
begin
|
1049
|
+
head = When.CalendarEra(parents[-1])
|
1050
|
+
order = order.dup.unshift(head)
|
1051
|
+
rescue
|
1052
|
+
end
|
1053
|
+
end
|
1054
|
+
order.each do |iri|
|
1055
|
+
When.CalendarEra(iri)
|
1056
|
+
pool = _candidates(options, area, period, key, epoch, false) +
|
1057
|
+
_candidates(options, area, period, key, reverse, true)
|
1058
|
+
_compact(pool, parents)
|
1059
|
+
return pool unless pool.size < count
|
1060
|
+
end
|
1061
|
+
|
1062
|
+
return []
|
1063
|
+
end
|
1064
|
+
|
1065
|
+
private
|
1066
|
+
|
1067
|
+
# 候補の抽出
|
1068
|
+
def _candidates(options, area, period, key, epoch, reverse)
|
1069
|
+
regexp, key = key if key.kind_of?(Regexp)
|
1070
|
+
return [] unless @_pool[area] &&
|
1071
|
+
@_pool[area][period] &&
|
1072
|
+
@_pool[area][period][key] &&
|
1073
|
+
@_pool[area][period][key][epoch]
|
1074
|
+
pool = @_pool[area][period][key][epoch].dup
|
1075
|
+
pool.delete_if {|e| regexp !~ e.name} if regexp
|
1076
|
+
return pool if options.empty?
|
1077
|
+
pool.delete_if {|e| !_match(e, reverse, options) }
|
1078
|
+
end
|
1079
|
+
|
1080
|
+
def _match(epoch, reverse, options)
|
1081
|
+
return false unless epoch.reverse? == reverse
|
1082
|
+
target = {:reference_event => epoch.reference_event,
|
1083
|
+
:reference_date => epoch.reference_date,
|
1084
|
+
:julian_reference => epoch.julian_reference
|
1085
|
+
}
|
1086
|
+
options.each_pair do |k,v|
|
1087
|
+
return false unless (v === (target.key?(k) ? target[k] : epoch.options[k]))
|
1088
|
+
end
|
1089
|
+
return true
|
1090
|
+
end
|
1091
|
+
|
1092
|
+
def _compact(pool, parents)
|
1093
|
+
pool.uniq!
|
1094
|
+
return if parents.empty?
|
1095
|
+
pool.delete_if {|e|
|
1096
|
+
!parents.each do |parent|
|
1097
|
+
e = e.parent
|
1098
|
+
break false unless parent == e.name
|
1099
|
+
end
|
1100
|
+
}
|
1101
|
+
end
|
1102
|
+
|
1103
|
+
def _behalf_of(iri)
|
1104
|
+
base = iri.dup.sub!('/TM/CalendarEra/','/CalendarTypes/')
|
1105
|
+
return nil unless base
|
1106
|
+
calendar = When::Parts::Resource._instance(base)
|
1107
|
+
date = When.tm_pos(1, {:frame=>calendar}).floor
|
1108
|
+
label = calendar.label
|
1109
|
+
era = label.names['era']
|
1110
|
+
label = label.dup.send(:_copy, {:label=>era}) if era
|
1111
|
+
options = {:label=>label, '..'=>iri}
|
1112
|
+
%w(period area).each do |name|
|
1113
|
+
value = calendar.instance_variable_get('@' + name)
|
1114
|
+
options[name.to_sym] = value if value
|
1115
|
+
end
|
1116
|
+
era = self.new(date, '@CE', date, options)
|
1117
|
+
era.send(:_register_calendar_era)
|
1118
|
+
era
|
1119
|
+
end
|
1120
|
+
end
|
1121
|
+
|
1122
|
+
# @private
|
1123
|
+
HashProperty =
|
1124
|
+
[:label, :referenceEvent, :referenceDate, :julianReference, :datingSystem, # :epoch_of_use
|
1125
|
+
:epoch, :options]
|
1126
|
+
|
1127
|
+
# この暦年代を識別する名称
|
1128
|
+
#
|
1129
|
+
# Name by which this calendar era is known
|
1130
|
+
#
|
1131
|
+
# @return [String]
|
1132
|
+
# 通常 String のサブクラスである When::BasicTypes::M17n を使用する。
|
1133
|
+
#
|
1134
|
+
alias :name :label
|
1135
|
+
|
1136
|
+
# この暦年代の基点となる事象
|
1137
|
+
#
|
1138
|
+
# Event used as the datum for this calendar era
|
1139
|
+
#
|
1140
|
+
# @return [String]
|
1141
|
+
# 通常 String のサブクラスである When::BasicTypes::M17n を使用する。
|
1142
|
+
#
|
1143
|
+
# @note
|
1144
|
+
# [Accession,代始]:: 天皇・皇帝などの代始めの改元,必ずしも践祚と連動しない。
|
1145
|
+
# :: JIS X7108 附属書D表3に参照事象の例として「新しい天皇の即位」とある。
|
1146
|
+
# :: これは践祚を意味するので、岡田芳朗氏によれば適切ではないとのこと。
|
1147
|
+
# :: 英語には適切な訳語がないと思われる。
|
1148
|
+
# [FelicitousEvent,祥瑞]:: 祥瑞の発生に伴う改元
|
1149
|
+
# [NaturalDisaster,災異]:: 災異の発生に伴う改元
|
1150
|
+
# [InauspiciousYear,革年]:: 甲子革令・辛酉革命説による改元
|
1151
|
+
# [Foundation,創業]:: 建国による元号の制定
|
1152
|
+
# [CalendarReform,改暦]:: 改暦に伴う epoch_of_use の境界
|
1153
|
+
#
|
1154
|
+
attr_reader :reference_event
|
1155
|
+
alias :referenceEvent :reference_event
|
1156
|
+
|
1157
|
+
# この暦による参照事象の日付
|
1158
|
+
#
|
1159
|
+
# Date of the reference event in the calendar being described
|
1160
|
+
#
|
1161
|
+
# @return [When::TM::CalDate]
|
1162
|
+
#
|
1163
|
+
# @note
|
1164
|
+
# 明治以前の改元は当該年の初めにに遡って適用された。しかし、日記などの資料は当然旧年号で
|
1165
|
+
# 記載されている。このような場合、reference_date の分解能を「年」とする。
|
1166
|
+
# 本ライブラリでは、reference_date の分解能が「年」の場合、When::TM::TemporalPosition._instance
|
1167
|
+
# の options[:lower] で年号使用の下限を年初とするか、epoch_of_use の下限とするかを
|
1168
|
+
# 指定することができる。
|
1169
|
+
#
|
1170
|
+
attr_reader :reference_date
|
1171
|
+
alias :referenceDate :reference_date
|
1172
|
+
|
1173
|
+
# 参照事象のユリウス日
|
1174
|
+
#
|
1175
|
+
# Julian date of the reference event
|
1176
|
+
#
|
1177
|
+
# @return [When::TM::JulianDate]
|
1178
|
+
#
|
1179
|
+
attr_reader :julian_reference
|
1180
|
+
alias :julianReference :julian_reference
|
1181
|
+
|
1182
|
+
# この暦年代が日付の基礎として使用する期間
|
1183
|
+
#
|
1184
|
+
# Period for which the era was used as a basis for dating
|
1185
|
+
#
|
1186
|
+
# @return [Array<When::TM::TemporalPosition>]
|
1187
|
+
#
|
1188
|
+
# @note
|
1189
|
+
# 途中の改暦を指定するために要素が必要になることがあり、要素数が2を超えることがある。
|
1190
|
+
# 最初の要素が When::TimeValue::MIN(-Infinity)の場合、年数を降順にカウントする。
|
1191
|
+
# 暦年代の分解能を“日”より細かくすることはできない。
|
1192
|
+
#
|
1193
|
+
attr_reader :epoch
|
1194
|
+
|
1195
|
+
# この暦年代と関連付けられた暦 (relation - Basis)
|
1196
|
+
#
|
1197
|
+
# The calendar associated with the calendar eras being described
|
1198
|
+
#
|
1199
|
+
# @return [Array<When::TM::Calendar>]
|
1200
|
+
#
|
1201
|
+
attr_reader :dating_system
|
1202
|
+
alias :datingSystem :dating_system
|
1203
|
+
|
1204
|
+
# この暦年代の元年の年番号(additional attribute)
|
1205
|
+
#
|
1206
|
+
# The year number of the calendar associated with the first year of this calendar era
|
1207
|
+
#
|
1208
|
+
# @return [Integer]
|
1209
|
+
#
|
1210
|
+
attr_reader :epoch_year
|
1211
|
+
alias :epochYear :epoch_year
|
1212
|
+
|
1213
|
+
# その他の属性 - additional attribute
|
1214
|
+
#
|
1215
|
+
# @return [Hash]
|
1216
|
+
# [ 'area' => 暦年代の使用地域 [When::BasicTypes::M17n] ]
|
1217
|
+
# [ 'period' => 暦年代の使用時代 [When::BasicTypes::M17n] ]
|
1218
|
+
# [ the others => epoch_of_use の 'name' などの指定を反映 [String] ]
|
1219
|
+
#
|
1220
|
+
attr_reader :options
|
1221
|
+
|
1222
|
+
# この暦年代が日付の基礎として使用する期間
|
1223
|
+
#
|
1224
|
+
# Period for which the era was used as a basis for dating
|
1225
|
+
#
|
1226
|
+
# @return [When::TM::Period]
|
1227
|
+
#
|
1228
|
+
# @note
|
1229
|
+
# epoch_of_use メソッドの戻り値は ISO19108 で When::TM::Period と規定されている。
|
1230
|
+
# このため変数 @epoch とは別に、本メソッドを提供する。
|
1231
|
+
#
|
1232
|
+
def epoch_of_use
|
1233
|
+
@epoch_of_use ||=
|
1234
|
+
Period.new(*([0, -1].map {|i|
|
1235
|
+
date = @epoch[i]
|
1236
|
+
if date.kind_of?(CalDate)
|
1237
|
+
options = date._attr
|
1238
|
+
options[:frame] = options.delete(:clock)
|
1239
|
+
date = JulianDate.universal_time(date.universal_time, options)
|
1240
|
+
end
|
1241
|
+
Instant.new(date) # See JIS X7108 5.3.2.2 e) When::TM::Period は直接 JulianDate を保持できない
|
1242
|
+
}))
|
1243
|
+
end
|
1244
|
+
alias :epochOfUse :epoch_of_use
|
1245
|
+
|
1246
|
+
# 年数の数え方
|
1247
|
+
#
|
1248
|
+
# @return [Boolean]
|
1249
|
+
# [ true - 降順 (Before Common Era 方式)]
|
1250
|
+
# [ false - 昇順 (Common Era 方式) ]
|
1251
|
+
#
|
1252
|
+
def reverse?
|
1253
|
+
@epoch[0].indeterminated_position == When::TimeValue::Min
|
1254
|
+
end
|
1255
|
+
|
1256
|
+
# 未来永劫使用するか?
|
1257
|
+
#
|
1258
|
+
# @return [Boolean]
|
1259
|
+
# [ true - する ]
|
1260
|
+
# [ false - しない ]
|
1261
|
+
#
|
1262
|
+
def unlimited?
|
1263
|
+
@epoch[-1].indeterminated_position == When::TimeValue::Max
|
1264
|
+
end
|
1265
|
+
|
1266
|
+
# 時間の歩度
|
1267
|
+
#
|
1268
|
+
# @return [Numeric]
|
1269
|
+
#
|
1270
|
+
def rate_of_clock
|
1271
|
+
_typical_epoch.time_standard.rate_of_clock
|
1272
|
+
end
|
1273
|
+
|
1274
|
+
# 当該の暦年代の日付に変換する
|
1275
|
+
#
|
1276
|
+
# @param [When::TM::TemporalPosition] date
|
1277
|
+
# @param [Hash] trans_options 以下の通り
|
1278
|
+
# @option trans_options [Hash] :lower 暦年代適用の下限
|
1279
|
+
# [ true - epoch_of_use の始め(省略時) ]
|
1280
|
+
# [ :reference_date - 参照事象の日付 ]
|
1281
|
+
# @option trans_options [Hash] :upper 暦年代適用の上限
|
1282
|
+
# [ true - epoch_of_use の終わり(省略時) ]
|
1283
|
+
# [ :reference_date - 参照事象の日付 ]
|
1284
|
+
#
|
1285
|
+
# @return [When::TM::TemporalPosition]
|
1286
|
+
# [ When::TimeValue::Before - 当該の暦年代より前の日付である ]
|
1287
|
+
# [ When::TimeValue::After - 当該の暦年代より後の日付である ]
|
1288
|
+
# [ その他 - 当該の暦年代の日付に変換された When::TM::TemporalPosition ]
|
1289
|
+
#
|
1290
|
+
def trans(date, trans_options={})
|
1291
|
+
# 当該日付の決定
|
1292
|
+
date = Position.any_other(date, trans_options) unless date.kind_of?(Array)
|
1293
|
+
epoch, cal_date =
|
1294
|
+
case date
|
1295
|
+
when Array ; _trans_array(date)
|
1296
|
+
when JulianDate, DateAndTime ; _trans_date(date, date.clock)
|
1297
|
+
when When::TimeValue ; _trans_date(date)
|
1298
|
+
when Numeric ; _trans_date(JulianDate.universal_time((date-JulianDate::JD19700101)*Duration::DAY))
|
1299
|
+
else ; raise TypeError, "Irregal Seed Date Type"
|
1300
|
+
end
|
1301
|
+
return epoch unless cal_date
|
1302
|
+
|
1303
|
+
# 上下限の確認
|
1304
|
+
trans_options ||= {}
|
1305
|
+
return When::TimeValue::Before if cal_date.to_i < lower_bound(trans_options[:lower] || :reference_date)
|
1306
|
+
return When::TimeValue::After if cal_date.to_i > upper_bound(trans_options[:upper] || true)
|
1307
|
+
|
1308
|
+
# 発見した日時の属性設定
|
1309
|
+
cal_date.send(:calendar_era=, self)
|
1310
|
+
cal_date.send(:calendar_era_props=, [@label, @epoch_year, reverse?, cal_date.to_i < @epoch[0].to_i])
|
1311
|
+
cal_date.cal_date[0] -= @epoch_year
|
1312
|
+
cal_date.trans = trans_options.dup
|
1313
|
+
cal_date.query = (epoch.query || {}).dup
|
1314
|
+
return cal_date
|
1315
|
+
end
|
1316
|
+
|
1317
|
+
# When::TM::TemporalPosition ^ When::TM::CalendarEra で呼ばれる
|
1318
|
+
# @private
|
1319
|
+
def ^(date, options={})
|
1320
|
+
date = Position.any_other(date, options)
|
1321
|
+
cal_date = trans(date, (date.trans||{}).merge(options))
|
1322
|
+
return nil unless cal_date.kind_of?(CalDate)
|
1323
|
+
return cal_date
|
1324
|
+
end
|
1325
|
+
|
1326
|
+
# other と @julian_reference とを比較する
|
1327
|
+
#
|
1328
|
+
# @param [Comparable] other 比較対象
|
1329
|
+
#
|
1330
|
+
# @return [Integer] 比較結果を 負, 0, 正の値で返す
|
1331
|
+
#
|
1332
|
+
def <=>(other) #TODO @precision は?
|
1333
|
+
@julian_reference.universal_time <=> other.julian_reference.universal_time
|
1334
|
+
end
|
1335
|
+
|
1336
|
+
# 暦年代の下限
|
1337
|
+
# @private
|
1338
|
+
def lower_bound(type=nil)
|
1339
|
+
@lower_bound[type] ||= @epoch[0].indeterminated_position == When::TimeValue::Min ? -Float::MAX :
|
1340
|
+
@reference_date.precision == When::YEAR &&
|
1341
|
+
@reference_date.cal_date[When::YEAR-1] == 0 ? @epoch[0].ceil(When::YEAR).to_i :
|
1342
|
+
case type
|
1343
|
+
when true ; @epoch[0].to_i
|
1344
|
+
when :reference_date ; @reference_date.to_i
|
1345
|
+
else ; [@reference_date.to_i, @epoch[0].to_i].min
|
1346
|
+
end
|
1347
|
+
end
|
1348
|
+
|
1349
|
+
# 暦年代の上限
|
1350
|
+
# @private
|
1351
|
+
def upper_bound(type=nil)
|
1352
|
+
@upper_bound[type] ||= @epoch[-1].indeterminated_position == When::TimeValue::Max ? +Float::MAX :
|
1353
|
+
begin
|
1354
|
+
next_era = succ
|
1355
|
+
next_ref = next_era.reference_date if next_era.respond_to?(:reference_date)
|
1356
|
+
next_ref &&
|
1357
|
+
next_ref.precision == When::YEAR &&
|
1358
|
+
next_ref.cal_date[When::YEAR-1] == 0 ? @epoch[-1].ceil(When::YEAR).to_i - 1 :
|
1359
|
+
case type
|
1360
|
+
when true ; @epoch[-1].to_i - 1
|
1361
|
+
when :reference_date ; @reference_date.to_i
|
1362
|
+
else ; [@reference_date.to_i, @epoch[-1].to_i - 1].max
|
1363
|
+
end
|
1364
|
+
end
|
1365
|
+
end
|
1366
|
+
|
1367
|
+
private
|
1368
|
+
|
1369
|
+
# オブジェクトの正規化
|
1370
|
+
def _normalize(args=[], options={})
|
1371
|
+
# area, period
|
1372
|
+
term_options = {:namespace=>@namespace, :locale=>@locale, :options=>options}
|
1373
|
+
@area = m17n(@area, nil, nil, term_options) if @area.instance_of?(String)
|
1374
|
+
@period = m17n(@period, nil, nil, term_options) if @period.instance_of?(String)
|
1375
|
+
|
1376
|
+
# 暦年代の上下限
|
1377
|
+
@lower_bound = {}
|
1378
|
+
@upper_bound = {}
|
1379
|
+
|
1380
|
+
# other attributes
|
1381
|
+
if @child && @child.length>0
|
1382
|
+
_non_leaf_era(args, term_options)
|
1383
|
+
_register_calendar_era unless _pool['..'].kind_of?(CalendarEra)
|
1384
|
+
@child.each do |era|
|
1385
|
+
era.send(:_register_calendar_era)
|
1386
|
+
end
|
1387
|
+
else
|
1388
|
+
_set_leaf_era(args, term_options)
|
1389
|
+
_normalize_leaf_era unless @epoch[0].indeterminated_position == When::TimeValue::Min
|
1390
|
+
end
|
1391
|
+
end
|
1392
|
+
|
1393
|
+
def _non_leaf_era(args, term_options)
|
1394
|
+
@label = m17n(@label, nil, nil, term_options) if @label.instance_of?(String)
|
1395
|
+
if @label
|
1396
|
+
@label._pool['..'] = self # TODO ここを ||= にすると leaf? の判定がおかしくなる
|
1397
|
+
@_pool[@label.to_s] = @label
|
1398
|
+
end
|
1399
|
+
|
1400
|
+
# reference_date, reference_event & label
|
1401
|
+
@reference_date = @child[0].reference_date
|
1402
|
+
@reference_event = @child[0].reference_event
|
1403
|
+
@epoch_year = 0 # @child[0].epoch_year
|
1404
|
+
@julian_reference = @child[0].julian_reference
|
1405
|
+
|
1406
|
+
# options
|
1407
|
+
@options ||= {}
|
1408
|
+
@options.update({'area'=>@area, 'period'=>@period})
|
1409
|
+
|
1410
|
+
# epoch
|
1411
|
+
@epoch = []
|
1412
|
+
@child.each do |c|
|
1413
|
+
c.epoch.each do |e|
|
1414
|
+
@epoch << e unless e == @epoch[-1]
|
1415
|
+
end
|
1416
|
+
end
|
1417
|
+
end
|
1418
|
+
|
1419
|
+
def _set_leaf_era(args, term_options)
|
1420
|
+
# 変数の読み込み
|
1421
|
+
reference_date, reference_event, *epochs = args
|
1422
|
+
|
1423
|
+
# reference_date & label
|
1424
|
+
if reference_date
|
1425
|
+
@reference_date = reference_date
|
1426
|
+
@label ||= m17n(@reference_date[/\A\[[^\]]+\]|^[^-+0-9]+/], nil, nil, term_options)
|
1427
|
+
end
|
1428
|
+
@label._pool['..'] ||= self
|
1429
|
+
@_pool[@label.to_s] = @label
|
1430
|
+
|
1431
|
+
# reference_event
|
1432
|
+
@reference_event = reference_event if reference_event
|
1433
|
+
@reference_event ||= ""
|
1434
|
+
@reference_event = DefaultEvents[@reference_event] if DefaultEvents[@reference_event]
|
1435
|
+
@reference_event = m17n(@reference_event, nil, nil, term_options) if @reference_event.instance_of?(String)
|
1436
|
+
@reference_event._pool['..'] ||= self
|
1437
|
+
@_pool[@reference_event.to_s] = @reference_event
|
1438
|
+
|
1439
|
+
# options
|
1440
|
+
term_options[:options][:query] ||= {}
|
1441
|
+
@options ||= {}
|
1442
|
+
@options.update(term_options[:options][:query])
|
1443
|
+
@options.update({'area'=>@area, 'period'=>@period})
|
1444
|
+
|
1445
|
+
# epoch
|
1446
|
+
@epoch ||= epochs
|
1447
|
+
@epoch[0] ||= '-Infinity'
|
1448
|
+
@epoch[1] ||= '+Infinity'
|
1449
|
+
term_options[:options][:frame] ||= When::Gregorian
|
1450
|
+
epoch = ''
|
1451
|
+
@epoch = @epoch.map {|e|
|
1452
|
+
case e
|
1453
|
+
when ''
|
1454
|
+
When.when?('+Infinity')
|
1455
|
+
when String
|
1456
|
+
d, f = e.split(/\^{1,2}/)
|
1457
|
+
term_options[:options][:frame] = When.Resource(f, '_c:') if (f)
|
1458
|
+
d.split(/;/).each do |v|
|
1459
|
+
v.strip!
|
1460
|
+
if (v =~ /\A[-+\d]|^Now$|^Unknown$|^[-+]Infinity\z/i)
|
1461
|
+
epoch = v
|
1462
|
+
break
|
1463
|
+
end
|
1464
|
+
k, c = v.split(/\s*[:=]\s*/, 2)
|
1465
|
+
if (c.kind_of?(String))
|
1466
|
+
code = m17n(c.gsub(/%2C/,','), nil, nil, term_options)
|
1467
|
+
@_pool[code.to_s] ||= code
|
1468
|
+
code._pool['..'] = self
|
1469
|
+
@options[k] = term_options[:options][:query][k] = @_pool[code.to_s]
|
1470
|
+
else
|
1471
|
+
@options.delete(k)
|
1472
|
+
term_options[:options][:query].delete(k)
|
1473
|
+
end
|
1474
|
+
end
|
1475
|
+
When.when?(epoch, @options.merge({:frame=>term_options[:options][:frame], :validate=>:epoch}))
|
1476
|
+
else
|
1477
|
+
e
|
1478
|
+
end
|
1479
|
+
}
|
1480
|
+
|
1481
|
+
# normalize for last era
|
1482
|
+
last_era = _pool['..'].child[-1] if _pool['..'].kind_of?(CalendarEra)
|
1483
|
+
if last_era
|
1484
|
+
if last_era.epoch[0].indeterminated_position == When::TimeValue::Min
|
1485
|
+
last_era.epoch[0].frame = @epoch[0].frame
|
1486
|
+
last_era.epoch[1] = @epoch[0]
|
1487
|
+
last_era.send(:_normalize_leaf_era)
|
1488
|
+
elsif last_era.epoch[-1].indeterminated_position == When::TimeValue::Max
|
1489
|
+
last_era.epoch[-1] = @epoch[0]
|
1490
|
+
end
|
1491
|
+
end
|
1492
|
+
end
|
1493
|
+
|
1494
|
+
# 先端の暦年代の正規化
|
1495
|
+
def _normalize_leaf_era
|
1496
|
+
# r_date and others
|
1497
|
+
case @reference_date
|
1498
|
+
when String ; format, r_date, r_era = When::BasicTypes::DateTime._to_array(@reference_date)
|
1499
|
+
when Array ; r_era, *r_date = @reference_date
|
1500
|
+
when CalDate ; r_era, r_date = @reference_date.calendar_era_props, @reference_date.cal_date
|
1501
|
+
when nil ;
|
1502
|
+
else ; raise TypeError, "ReferenceDate is invalid type"
|
1503
|
+
end
|
1504
|
+
r_era, r_year = r_era
|
1505
|
+
|
1506
|
+
epochs = @epoch.dup
|
1507
|
+
epochs.shift if (epochs[0].indeterminated_position == When::TimeValue::Min)
|
1508
|
+
# j_date and calculated reference_date !((julian_reference == nil) && (reference_date != nil))
|
1509
|
+
if @julian_reference
|
1510
|
+
jdn = @julian_reference.to_i
|
1511
|
+
epoch = epochs[0]
|
1512
|
+
epochs.each do |e|
|
1513
|
+
if (e.indeterminated_position == When::TimeValue::Max)
|
1514
|
+
epoch = e
|
1515
|
+
break
|
1516
|
+
elsif (jdn < e.to_i)
|
1517
|
+
break
|
1518
|
+
else
|
1519
|
+
epoch = e
|
1520
|
+
end
|
1521
|
+
end
|
1522
|
+
@reference_date = epoch.frame.jul_trans(When.when?(jdn), {:frame=>epoch.frame})
|
1523
|
+
j_date = @reference_date.cal_date
|
1524
|
+
elsif (@reference_date == nil)
|
1525
|
+
@reference_date = epochs[0].dup
|
1526
|
+
j_date = @reference_date.cal_date
|
1527
|
+
end
|
1528
|
+
|
1529
|
+
# epoch_year
|
1530
|
+
@epoch_year ||= r_year
|
1531
|
+
@epoch_year = @epoch_year.to_i if (@epoch_year)
|
1532
|
+
raise ArgumentError, "EpochYear mismatch" unless (@epoch_year == r_year)
|
1533
|
+
unless @epoch_year
|
1534
|
+
raise ArgumentError, "ReferenceDate is absent" unless r_date
|
1535
|
+
@epoch_year = epochs[0].cal_date[0] * 1 - r_date[0] * 1
|
1536
|
+
end
|
1537
|
+
|
1538
|
+
# j_date and calculated reference_date ((julian_reference == nil) && (reference_date != nil))
|
1539
|
+
unless j_date
|
1540
|
+
j_date = [+r_date[0]+@epoch_year, *r_date[1..-1]]
|
1541
|
+
epochs.each_index do |i|
|
1542
|
+
e = epochs[i]
|
1543
|
+
d = CalDate.new(j_date,{:frame=>e.frame})
|
1544
|
+
if (e.indeterminated_position == When::TimeValue::Max)
|
1545
|
+
@reference_date = d
|
1546
|
+
break
|
1547
|
+
elsif (d.to_i < e.to_i)
|
1548
|
+
@reference_date = d if (i==0)
|
1549
|
+
break
|
1550
|
+
else
|
1551
|
+
@reference_date = d
|
1552
|
+
end
|
1553
|
+
end
|
1554
|
+
end
|
1555
|
+
|
1556
|
+
# julian_reference and reference_date
|
1557
|
+
@julian_reference = JulianDate.universal_time(@reference_date.universal_time)
|
1558
|
+
@reference_date.cal_date[0] -= @epoch_year
|
1559
|
+
@reference_date.send(:calendar_era_props=, [(r_era ? r_era : @label), @epoch_year])
|
1560
|
+
if (r_date)
|
1561
|
+
raise ArgumentError, "JulianReference and ReferenceDate are mismatch" unless (@epoch_year == +j_date[0]-(+r_date[0]))
|
1562
|
+
raise ArgumentError, "JulianReference and ReferenceDate are mismatch" unless (j_date[1..-1] == r_date[1..-1])
|
1563
|
+
#raise ArgumentError, "JulianReference and ReferenceDate are mismatch" unless (j_date == r_date)
|
1564
|
+
if (r_date[1] == nil)
|
1565
|
+
@reference_date.precision = When::YEAR
|
1566
|
+
elsif (r_date[2] == nil)
|
1567
|
+
@reference_date.precision = When::MONTH
|
1568
|
+
end
|
1569
|
+
end
|
1570
|
+
end
|
1571
|
+
|
1572
|
+
# 暦年代の検索表への登録
|
1573
|
+
def _register_calendar_era
|
1574
|
+
return unless @label.kind_of?(When::BasicTypes::M17n)
|
1575
|
+
|
1576
|
+
# dating_system
|
1577
|
+
@dating_system = (@epoch.map {|e| e.frame}).compact.uniq
|
1578
|
+
|
1579
|
+
unless @child && @child.length>0
|
1580
|
+
ancestors = hierarchy.inject(['']) {|list,era|
|
1581
|
+
list << list[-1] + '::' + era.label.to_s
|
1582
|
+
list
|
1583
|
+
}
|
1584
|
+
if @epoch.length == 1
|
1585
|
+
epoch[0].frame.synchronize {
|
1586
|
+
range = When::Parts::GeometricComplex.new([[epoch[0],true]])
|
1587
|
+
ancestors.each do |ancestor|
|
1588
|
+
epoch[0].frame.domain[ancestor] |= range
|
1589
|
+
end
|
1590
|
+
} if epoch[0].frame
|
1591
|
+
elsif reverse?
|
1592
|
+
epoch[1].frame.synchronize {
|
1593
|
+
range = When::Parts::GeometricComplex.new([[epoch[1],true]], true)
|
1594
|
+
ancestors.each do |ancestor|
|
1595
|
+
epoch[1].frame.domain[ancestor] |= range
|
1596
|
+
end
|
1597
|
+
} if epoch[1].frame
|
1598
|
+
else
|
1599
|
+
(epoch.length-1).times do |i|
|
1600
|
+
epoch[i].frame.synchronize {
|
1601
|
+
range = When::Parts::GeometricComplex.new([[epoch[i],true], [epoch[i+1],false]])
|
1602
|
+
ancestors.each do |ancestor|
|
1603
|
+
epoch[i].frame.domain[ancestor] |= range
|
1604
|
+
end
|
1605
|
+
} if epoch[i].frame
|
1606
|
+
end
|
1607
|
+
end
|
1608
|
+
end
|
1609
|
+
|
1610
|
+
@dating_system.each do |f|
|
1611
|
+
f.synchronize do
|
1612
|
+
f.reference_frame << self
|
1613
|
+
f.reference_frame.uniq!
|
1614
|
+
f.reference_frame.sort!
|
1615
|
+
first = f.domain[''].first(When::MinusInfinity)
|
1616
|
+
last = f.domain[''].last(When::PlusInfinity)
|
1617
|
+
f.domain_of_validity = When::EX::Extent.new(
|
1618
|
+
When::TM::Period.new(
|
1619
|
+
When::TM::Instant.new(first),
|
1620
|
+
When::TM::Instant.new(last))) if first && first <= last
|
1621
|
+
end
|
1622
|
+
end
|
1623
|
+
|
1624
|
+
# インデクス登録
|
1625
|
+
(_expand_sharp((@area||{}).values) + [nil]).each do |a|
|
1626
|
+
self.class[a] ||= {}
|
1627
|
+
(_expand_sharp((@period||{}).values) + [nil]).each do |p|
|
1628
|
+
self.class[a][p] ||= {}
|
1629
|
+
(_expand_sharp(@label.values) + [nil]).each do |k|
|
1630
|
+
self.class[a][p][k] ||= {}
|
1631
|
+
[@epoch_year, nil].each do |e|
|
1632
|
+
self.class[a][p][k][e] ||= []
|
1633
|
+
self.class[a][p][k][e] << self
|
1634
|
+
end
|
1635
|
+
end
|
1636
|
+
end
|
1637
|
+
end
|
1638
|
+
end
|
1639
|
+
|
1640
|
+
# '#' つきの年号を '#'つきと'#'なしに展開する
|
1641
|
+
# また <...> や (..) の '<','(' と '>',')' を取り去ったものも登録する
|
1642
|
+
def _expand_sharp(list)
|
1643
|
+
list.map {|name|
|
1644
|
+
case name
|
1645
|
+
when /\A[\(<](.+)[\)>]\z/, /\A(.+)\?\z/
|
1646
|
+
[name, $1]
|
1647
|
+
else
|
1648
|
+
parts = name.split('#', 2)
|
1649
|
+
parts.size < 2 ? name : [name, parts.last]
|
1650
|
+
end
|
1651
|
+
}.flatten
|
1652
|
+
end
|
1653
|
+
|
1654
|
+
# 配下のオブジェクトの前後関係の設定
|
1655
|
+
def _sequence
|
1656
|
+
return unless @child
|
1657
|
+
prev = nil
|
1658
|
+
if @_pool['..'].respond_to?(:child) && @_pool['..'].child
|
1659
|
+
(@_pool['..'].child.length-1).downto(0) do |i|
|
1660
|
+
v = @_pool['..'].child[i]
|
1661
|
+
next if (v.epoch[0]>=self.epoch[0])
|
1662
|
+
prev = v
|
1663
|
+
break
|
1664
|
+
end
|
1665
|
+
end
|
1666
|
+
@child.each do |v|
|
1667
|
+
if prev
|
1668
|
+
v._pool['.<-'] = prev
|
1669
|
+
prev._pool['.->'] ||= v
|
1670
|
+
while (prev.child && prev.child[-1]) do
|
1671
|
+
prev = prev.child[-1]
|
1672
|
+
prev._pool['.->'] ||= v
|
1673
|
+
end
|
1674
|
+
end
|
1675
|
+
@_pool[v.label.to_s] = v
|
1676
|
+
prev = v
|
1677
|
+
end
|
1678
|
+
end
|
1679
|
+
|
1680
|
+
def _trans_array(date)
|
1681
|
+
date = date.dup
|
1682
|
+
epoch0 = @epoch.first
|
1683
|
+
date0 = date1 = CalDate.new(date, {:frame=>epoch0.frame}) if epoch0.frame
|
1684
|
+
@epoch.each do |epoch1|
|
1685
|
+
date1 = CalDate.new(date, {:frame=>epoch1.frame}) unless epoch0.frame.equal?(epoch1.frame)
|
1686
|
+
return [epoch0, date0] if epoch1.indeterminated_position == When::TimeValue::Max
|
1687
|
+
if date1.to_i < epoch1.to_i
|
1688
|
+
return [epoch0, date0] if date0.to_i < epoch1.to_i
|
1689
|
+
return [epoch1, epoch1.frame ^ date0.to_i]
|
1690
|
+
end
|
1691
|
+
date0, epoch0 = date1, epoch1
|
1692
|
+
end
|
1693
|
+
return [@epoch.last, date1]
|
1694
|
+
end
|
1695
|
+
|
1696
|
+
def _trans_date(date, clock=nil)
|
1697
|
+
unless rate_of_clock == date.time_standard.rate_of_clock
|
1698
|
+
date = JulianDate.dynamical_time(date.dynamical_time, {:time_standard=>_typical_epoch.time_standard})
|
1699
|
+
clock = _typical_epoch.clock
|
1700
|
+
end
|
1701
|
+
frac = clock ? clock.universal_time : 0
|
1702
|
+
sdn, time = (date.universal_time - frac).divmod(Duration::DAY)
|
1703
|
+
sdn += JulianDate::JD19700101
|
1704
|
+
epoch = @epoch[0]
|
1705
|
+
return When::TimeValue::Before if sdn < lower_bound
|
1706
|
+
return When::TimeValue::After if sdn > upper_bound
|
1707
|
+
@epoch.each do |e|
|
1708
|
+
break if e.indeterminated_position == When::TimeValue::Max
|
1709
|
+
break if sdn < e.to_i
|
1710
|
+
epoch = e
|
1711
|
+
end
|
1712
|
+
frame = epoch.frame
|
1713
|
+
cal_date = frame.to_cal_date(sdn)
|
1714
|
+
options = {:frame=>frame}
|
1715
|
+
return epoch, CalDate.new(cal_date, options) unless clock
|
1716
|
+
options[:clock] = clock
|
1717
|
+
options[:location] = date.location if date.location
|
1718
|
+
return epoch, DateAndTime.new(cal_date, time+frac, options)
|
1719
|
+
end
|
1720
|
+
|
1721
|
+
# 代表的な元期
|
1722
|
+
#
|
1723
|
+
# @return [When::TM::TemporalPosition]
|
1724
|
+
#
|
1725
|
+
def _typical_epoch
|
1726
|
+
@_typical_epoch ||= reverse? ? @epoch[-1] : @epoch[0]
|
1727
|
+
end
|
1728
|
+
|
1729
|
+
# その他のメソッド
|
1730
|
+
#
|
1731
|
+
# @note
|
1732
|
+
# When::TM::CalendarEra で定義されていないメソッドは
|
1733
|
+
# 処理を @reference_date (type: When::TM::TemporalPosition) に委譲する
|
1734
|
+
#
|
1735
|
+
def method_missing(name, *args, &block)
|
1736
|
+
self.class.module_eval %Q{
|
1737
|
+
def #{name}(*args, &block)
|
1738
|
+
@reference_date.send("#{name}", *args, &block)
|
1739
|
+
end
|
1740
|
+
} unless When::Parts::MethodCash.escape(name)
|
1741
|
+
@reference_date.send(name, *args, &block)
|
1742
|
+
end
|
1743
|
+
end
|
1744
|
+
end
|