qreki 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile +2 -0
- data/README.md +18 -0
- data/lib/qreki.rb +34 -10
- data/lib/qreki/version.rb +1 -1
- data/spec/qreki_spec.rb +56 -26
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9bfe2c912114cb5bd3ce3b87093b63be6b126189
|
4
|
+
data.tar.gz: ef14bbf85a0a8fd94626900f87169ba83fe5ef4e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3bf1e9f58fe719034b981084bef470298a8dacbfe1c186aa36d1d9138bc351413d724a108789d8bf7eab8df9c354a1b0ab2658e15a06c42f7ccb99426c981fc5
|
7
|
+
data.tar.gz: 579e1064028e24c0f0d980dbc811a8dbde3986b32b5b8091fb8bd611f896d1116827a82b6f84b625f57b5e2b7fbe73abd56a276870e44c00c6a917faacc194e8
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -18,6 +18,10 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
|
+
>> require 'qreki'
|
22
|
+
|
23
|
+
Calc qreki "旧暦" as:
|
24
|
+
|
21
25
|
>> qreki = Qreki.calc(2013,11,7)
|
22
26
|
>> qreki.year # 2013
|
23
27
|
>> qreki.uruu # false
|
@@ -26,6 +30,20 @@ Or install it yourself as:
|
|
26
30
|
>> qreki.rokuyou # "友引"
|
27
31
|
>> qreki.sekki # "立冬"
|
28
32
|
|
33
|
+
Calc shunbun "春分の日" as:
|
34
|
+
|
35
|
+
>> sreki = Qreki.shunbun(2014)
|
36
|
+
>> sreki.year # 2014
|
37
|
+
>> sreki.month # 3
|
38
|
+
>> sreki.day # 21
|
39
|
+
|
40
|
+
Calc shuubun "秋分の日" as:
|
41
|
+
|
42
|
+
>> sreki = Qreki.shuubun(2014)
|
43
|
+
>> sreki.year # 2014
|
44
|
+
>> sreki.month # 9
|
45
|
+
>> sreki.day # 23
|
46
|
+
|
29
47
|
## Contributing
|
30
48
|
|
31
49
|
1. Fork it
|
data/lib/qreki.rb
CHANGED
@@ -9,6 +9,10 @@ require "date"
|
|
9
9
|
|
10
10
|
module Qreki
|
11
11
|
|
12
|
+
class Srk
|
13
|
+
attr_accessor :year, :month, :day
|
14
|
+
end
|
15
|
+
|
12
16
|
class Qrk
|
13
17
|
attr_accessor :year, :uruu, :month, :day, :rokuyou, :sekki
|
14
18
|
end
|
@@ -30,7 +34,7 @@ module Qreki
|
|
30
34
|
# q.sekki : 二十四節気
|
31
35
|
#=========================================================================
|
32
36
|
def self.calc(year, month, day)
|
33
|
-
|
37
|
+
calc_from_date(Date.new(year, month, day))
|
34
38
|
end
|
35
39
|
|
36
40
|
def self.calc_from_date(tm)
|
@@ -42,7 +46,7 @@ module Qreki
|
|
42
46
|
qreki.day = array[3]
|
43
47
|
qreki.rokuyou = rokuyou(tm.year, tm.month, tm.day)
|
44
48
|
qreki.sekki = sekki(tm.year, tm.month, tm.day)
|
45
|
-
|
49
|
+
qreki
|
46
50
|
end
|
47
51
|
|
48
52
|
# =========================================================================
|
@@ -189,7 +193,7 @@ module Qreki
|
|
189
193
|
kyureki[0] -= 1
|
190
194
|
end
|
191
195
|
|
192
|
-
|
196
|
+
[kyureki[0], kyureki[1], kyureki[2], kyureki[3]]
|
193
197
|
end
|
194
198
|
|
195
199
|
# =========================================================================
|
@@ -271,7 +275,7 @@ module Qreki
|
|
271
275
|
# 戻り値の作成
|
272
276
|
# 時刻引数を合成し、戻り値(JSTユリウス日)とする
|
273
277
|
# -----------------------------------------------------------------------
|
274
|
-
|
278
|
+
tm2 + tm1 - $tz
|
275
279
|
end
|
276
280
|
|
277
281
|
# =========================================================================
|
@@ -381,7 +385,7 @@ module Qreki
|
|
381
385
|
# 戻り値の作成
|
382
386
|
# 時刻引数を合成し、戻り値(ユリウス日)とする
|
383
387
|
# -----------------------------------------------------------------------
|
384
|
-
|
388
|
+
tm2 + tm1 - $tz
|
385
389
|
end
|
386
390
|
|
387
391
|
# =========================================================================
|
@@ -426,7 +430,7 @@ module Qreki
|
|
426
430
|
ang = normalization_angle( ang + 280.4659 )
|
427
431
|
th = normalization_angle( th + ang )
|
428
432
|
|
429
|
-
|
433
|
+
th
|
430
434
|
end
|
431
435
|
|
432
436
|
# =========================================================================
|
@@ -505,7 +509,7 @@ module Qreki
|
|
505
509
|
ang = normalization_angle( ang + 218.3162 )
|
506
510
|
th = normalization_angle( th + ang )
|
507
511
|
|
508
|
-
|
512
|
+
th
|
509
513
|
end
|
510
514
|
|
511
515
|
#=========================================================================
|
@@ -534,7 +538,7 @@ module Qreki
|
|
534
538
|
|
535
539
|
jd += t
|
536
540
|
|
537
|
-
|
541
|
+
jd
|
538
542
|
end
|
539
543
|
|
540
544
|
#=========================================================================
|
@@ -577,7 +581,7 @@ module Qreki
|
|
577
581
|
time[4] = ( (tm - 3600.0 * time[3] ) / 60.0 ).to_i
|
578
582
|
time[5] = ( tm - 3600.0 * time[3] - 60 * time[4] ).to_i
|
579
583
|
|
580
|
-
|
584
|
+
time
|
581
585
|
end
|
582
586
|
|
583
587
|
#=========================================================================
|
@@ -591,7 +595,7 @@ module Qreki
|
|
591
595
|
|
592
596
|
q_yaer, uruu, q_mon, q_day = calc_kyureki(year, mon, day)
|
593
597
|
|
594
|
-
|
598
|
+
rokuyou[ (q_mon + q_day) % 6 ]
|
595
599
|
end
|
596
600
|
|
597
601
|
#=========================================================================
|
@@ -639,4 +643,24 @@ module Qreki
|
|
639
643
|
return ''
|
640
644
|
end
|
641
645
|
end
|
646
|
+
|
647
|
+
def self.shunbun(year)
|
648
|
+
day = (20.8431 + 0.242194 * ( year - 1980 ) - ( year - 1980 ) / 4).to_i
|
649
|
+
|
650
|
+
sreki = Srk.new
|
651
|
+
sreki.year = year
|
652
|
+
sreki.month = 3
|
653
|
+
sreki.day = day
|
654
|
+
sreki
|
655
|
+
end
|
656
|
+
|
657
|
+
def self.shuubun(year)
|
658
|
+
day = (23.2488 + 0.242194 * ( year - 1980 ) - ( year - 1980 ) / 4).to_i
|
659
|
+
|
660
|
+
sreki = Srk.new
|
661
|
+
sreki.year = year
|
662
|
+
sreki.month = 9
|
663
|
+
sreki.day = day
|
664
|
+
sreki
|
665
|
+
end
|
642
666
|
end
|
data/lib/qreki/version.rb
CHANGED
data/spec/qreki_spec.rb
CHANGED
@@ -11,41 +11,71 @@ describe Qreki do
|
|
11
11
|
|
12
12
|
it "should calc eql 2013,11,1 => 2013,false,9,28 赤口" do
|
13
13
|
@q = Qreki.calc(2013,11,1)
|
14
|
-
@q.year.
|
15
|
-
@q.uruu.
|
16
|
-
@q.month.
|
17
|
-
@q.day.
|
18
|
-
@q.rokuyou.
|
19
|
-
@q.sekki.
|
14
|
+
expect(@q.year).to eql 2013
|
15
|
+
expect(@q.uruu).to eql false
|
16
|
+
expect(@q.month).to eql 9
|
17
|
+
expect(@q.day).to eql 28
|
18
|
+
expect(@q.rokuyou).to eql "赤口"
|
19
|
+
expect(@q.sekki).to eql ""
|
20
20
|
end
|
21
21
|
|
22
22
|
it "should calc eql 2014,11,1 => 2014,true, 9,9 大安" do
|
23
23
|
@q = Qreki.calc(2014,11,1)
|
24
|
-
@q.year.
|
25
|
-
@q.uruu.
|
26
|
-
@q.month.
|
27
|
-
@q.day.
|
28
|
-
@q.rokuyou.
|
29
|
-
@q.sekki.
|
24
|
+
expect(@q.year).to eql 2014
|
25
|
+
expect(@q.uruu).to eql true
|
26
|
+
expect(@q.month).to eql 9
|
27
|
+
expect(@q.day).to eql 9
|
28
|
+
expect(@q.rokuyou).to eql "大安"
|
29
|
+
expect(@q.sekki).to eql ""
|
30
30
|
end
|
31
31
|
|
32
32
|
it "should calc eql 2014,3,30 => 2014,false,2,30" do
|
33
33
|
@q = Qreki.calc(2014,3,30) # => 2014,false,2,30
|
34
|
-
@q.year.
|
35
|
-
@q.uruu.
|
36
|
-
@q.month.
|
37
|
-
@q.day.
|
38
|
-
@q.rokuyou.
|
39
|
-
@q.sekki.
|
34
|
+
expect(@q.year).to eql 2014
|
35
|
+
expect(@q.uruu).to eql false
|
36
|
+
expect(@q.month).to eql 2
|
37
|
+
expect(@q.day).to eql 30
|
38
|
+
expect(@q.rokuyou).to eql "先勝"
|
39
|
+
expect(@q.sekki).to eql ""
|
40
40
|
end
|
41
41
|
|
42
42
|
it "should calc_from_date eql 2013,11,7 => 2013,false,10,5" do
|
43
43
|
@q = Qreki.calc_from_date(Date.new(2013,11,7))
|
44
|
-
@q.year.
|
45
|
-
@q.uruu.
|
46
|
-
@q.month.
|
47
|
-
@q.day.
|
48
|
-
@q.rokuyou.
|
49
|
-
@q.sekki.
|
50
|
-
end
|
51
|
-
|
44
|
+
expect(@q.year).to eql 2013
|
45
|
+
expect(@q.uruu).to eql false
|
46
|
+
expect(@q.month).to eql 10
|
47
|
+
expect(@q.day).to eql 5
|
48
|
+
expect(@q.rokuyou).to eql "友引"
|
49
|
+
expect(@q.sekki).to eql "立冬"
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
it "should shunbun eql 2014 => 2014,3,21" do
|
54
|
+
@q = Qreki.shunbun(2014) # => 2014,3,21
|
55
|
+
expect(@q.year).to eql 2014
|
56
|
+
expect(@q.month).to eql 3
|
57
|
+
expect(@q.day).to eql 21
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should shunbun eql 2030 => 2030,3,20" do
|
61
|
+
@q = Qreki.shunbun(2030) # => 2030,3,20
|
62
|
+
expect(@q.year).to eql 2030
|
63
|
+
expect(@q.month).to eql 3
|
64
|
+
expect(@q.day).to eql 20
|
65
|
+
end
|
66
|
+
|
67
|
+
|
68
|
+
it "should shuubun eql 2014 => 2014,9,23" do
|
69
|
+
@q = Qreki.shuubun(2014) # => 2014,9,23
|
70
|
+
expect(@q.year).to eql 2014
|
71
|
+
expect(@q.month).to eql 9
|
72
|
+
expect(@q.day).to eql 23
|
73
|
+
end
|
74
|
+
|
75
|
+
it "should shuubun eql 2030 => 2030,9,23" do
|
76
|
+
@q = Qreki.shuubun(2030) # => 2030,9,23
|
77
|
+
expect(@q.year).to eql 2030
|
78
|
+
expect(@q.month).to eql 9
|
79
|
+
expect(@q.day).to eql 23
|
80
|
+
end
|
81
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qreki
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masaki Ozawa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-06-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -75,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
75
75
|
version: '0'
|
76
76
|
requirements: []
|
77
77
|
rubyforge_project:
|
78
|
-
rubygems_version: 2.
|
78
|
+
rubygems_version: 2.2.2
|
79
79
|
signing_key:
|
80
80
|
specification_version: 4
|
81
81
|
summary: qreki
|