wareki 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 25e6a9393b513cbd061933550558007a4aaed2d8
4
- data.tar.gz: 381b7cf7b1e169d6c6f46775eb06d9a3306c5937
3
+ metadata.gz: 580a31cae7a0a20059c2e914c08a0fd5793fa715
4
+ data.tar.gz: 0d965affe4eb6a63e64b2c7fc3dd3f0038fe87e4
5
5
  SHA512:
6
- metadata.gz: 3f2d1c15b3b9ab624c4413b05a57645d350855365f0d1dc9e3c7f119d2670c649955124e40bd7963867da21a85cc130cec3837aff1f96fd78f1d67fa03943bd7
7
- data.tar.gz: a42f7a5f4e3c6819e3497fd0b612b3c70d8282b3ef860296f15a0cd4e84b6ebe4005d9b4e3a7fb8b182cc95de50159abf769601ec39404500f61d9d1230ed1e9
6
+ metadata.gz: 4118d6b51ee6f34dde41d0009a57e695bf4c2e5070e64a014b87f2b5747eb8ef798ea89bab59cdbdc078a8fe7d7d605197d862e45bd089e817fe8d768204e596
7
+ data.tar.gz: b9206e669bdd95e22fabe2cf8f4c200c69e04abbc07d56bced3802456745b8ac1da4c909f0c87ab3f39d75dd98ae57f1fcbea2530aafe5808bc8f27980701e99
data/ChangeLog ADDED
@@ -0,0 +1,21 @@
1
+ 2017-02-04 Tatsuki Sugiura <sugi@nemui.org>
2
+
3
+ * Version 0.1.3
4
+ * Fix last day of era/year handling issue (#2)
5
+ * Fix kansuji converter for large numbers
6
+ (This is NOT affected with ordinal date numbers)
7
+
8
+ 2015-09-03 Tatsuki Sugiura <sugi@nemui.org>
9
+
10
+ * Version 0.1.2
11
+ * Fix file permissions (#1)
12
+
13
+ 2015-08-23 Tatsuki Sugiura <sugi@nemui.org>
14
+
15
+ * Version 0.1.1
16
+ * Fix gemspec: dependency of ruby version
17
+
18
+ 2015-08-23 Tatsuki Sugiura <sugi@nemui.org>
19
+
20
+ * Version 0.1.0.
21
+ * First release
data/README.rdoc CHANGED
@@ -1,5 +1,9 @@
1
1
  = ruby 和暦ライブラリ
2
2
 
3
+ {<img src="https://badge.fury.io/rb/wareki.svg" alt="Gem Version" />}[https://badge.fury.io/rb/wareki]
4
+ {<img src="https://travis-ci.org/sugi/wareki.svg?branch=master" alt="Build Status" />}[https://travis-ci.org/sugi/wareki]
5
+ {<img src="https://coveralls.io/repos/sugi/wareki/badge.svg?branch=master&service=github" alt="Coverage Status" />}[https://coveralls.io/github/sugi/wareki?branch=master]
6
+
3
7
  == 概要
4
8
 
5
9
  日本の和暦をサポートするライブラリです。
@@ -96,6 +100,14 @@ Gemfile に以下のようにするか、
96
100
  * 旧暦: {suikawiki - 旧暦}[http://wiki.suikawiki.org/n/%E6%97%A7%E6%9A%A6#section-%E5%AF%BE%E7%85%A7%E8%A1%A8%E3%81%A8%E5%A4%89%E6%8F%9B%E3%83%84%E3%83%BC%E3%83%AB] にある「日本暦日原典」第4版準拠の先発グレゴリオ暦対照表
97
101
  * 元号: {Wikipedia - 元号一覧_(日本)}[https://ja.wikipedia.org/wiki/%E5%85%83%E5%8F%B7%E4%B8%80%E8%A6%A7_%28%E6%97%A5%E6%9C%AC%29] のユリウス歴とグレゴリオ暦表記の物を利用しています
98
102
 
103
+ == ライセンス
104
+
105
+ {The BSD 2-Clause License}[https://opensource.org/licenses/BSD-2-Clause]
106
+
107
+ == 作者
108
+
109
+ Tatsuki Sugiura <sugi@nemui.org>
110
+
99
111
  == TODO
100
112
  * 北朝モード
101
113
  * Wareki::Date で各種計算のサポート
data/lib/wareki/common.rb CHANGED
@@ -7,7 +7,7 @@ module Wareki
7
7
  GREGORIAN_START_YEAR = 1873
8
8
  IMPERIAL_START = 1480041 # Date.new(-660, 2, 11, Date::GREGORIAN).jd
9
9
  IMPERIAL_START_YEAR = -660
10
- DATE_INFINITY = ::Date.new(2**(0.size * 8 -2) -1, 12, 31) # Use max Fixnum as year.
10
+ DATE_INFINITY = ::Date.new(280000000, 12, 31) # Use 280000000 for jruby limitation...
11
11
  YEAR_BY_NUM = Hash[*YEAR_DEFS.map{|y| [y.year, y]}.flatten].freeze
12
12
  ERA_BY_NAME = Hash[*(ERA_NORTH_DEFS + ERA_DEFS).map {|g| [g.name, g]}.flatten]
13
13
  ERA_BY_NAME['皇紀'] = ERA_BY_NAME['神武天皇即位紀元'] = Era.new('皇紀', -660, 1480041, DATE_INFINITY.jd)
data/lib/wareki/date.rb CHANGED
@@ -172,7 +172,7 @@ module Wareki
172
172
  when :s; month
173
173
  when :S; Utils.i_to_zen(month)
174
174
  when :Sk; Utils.i_to_kan(month)
175
- when :SK; ALT_MONTH_NAME[month-1]
175
+ when :SK; Utils.alt_month_name(month)
176
176
  when :l; leap_month? ? "'" : ""
177
177
  when :L; leap_month? ? "’" : ""
178
178
  when :Lk; leap_month? ? "閏" : ""
data/lib/wareki/utils.rb CHANGED
@@ -1,8 +1,10 @@
1
+ # coding: utf-8
1
2
  module Wareki
2
3
  module Utils
3
4
  module_function
4
5
  def kan_to_i(str)
5
- ret = 0
6
+ ret3 = 0
7
+ ret4 = 0
6
8
  curnum = nil
7
9
  str == "零" and return 0
8
10
  str.to_s.each_char do |c|
@@ -17,31 +19,36 @@ module Wareki
17
19
  when "〇", "0", "0"
18
20
  curnum and curnum *= 10
19
21
  when "卄", "廿"
20
- ret += 20
22
+ ret3 += 20
21
23
  curnum = nil
22
24
  when "卅", "丗"
23
- ret += 30
25
+ ret3 += 30
24
26
  curnum = nil
25
27
  when "卌"
26
- ret += 40
28
+ ret3 += 40
27
29
  curnum = nil
28
30
  when "皕"
29
- ret += 200
31
+ ret3 += 200
30
32
  curnum = nil
31
- when "", "", "", "", "", "兆"
33
+ when "", "", "", "", ""
32
34
  if curnum
33
- ret += curnum * 10 ** (["十", "百", "千", "万", "億", "兆"].index(c)+1)
34
- else
35
- ret += 10 ** (["十", "百", "千", "万", "億", "兆"].index(c)+1)
35
+ ret3 += curnum
36
+ curnum = nil
36
37
  end
38
+ ret3 = 1 if ret3 == 0
39
+ ret4 += ret3 * 10 ** ((["万", "億", "兆", "京", "垓"].index(c)+1)*4)
40
+ ret3 = 0
41
+ when "十", "百", "千"
42
+ curnum ||= 1
43
+ ret3 += curnum * 10 ** (["十", "百", "千"].index(c)+1)
37
44
  curnum = nil
38
45
  end
39
46
  end
40
47
  if curnum
41
- ret += curnum
48
+ ret3 += curnum
42
49
  curnum = nil
43
50
  end
44
- ret
51
+ ret4 + ret3
45
52
  end
46
53
 
47
54
  def i_to_kan(num, opts = {})
@@ -160,14 +167,17 @@ module Wareki
160
167
 
161
168
  def find_year(d)
162
169
  jd = _to_jd(d)
163
- YEAR_DEFS.bsearch{|y| y.end > jd }
170
+ YEAR_DEFS.bsearch{|y| y.end >= jd }
164
171
  end
165
172
 
166
173
  def find_era(d)
167
174
  jd = _to_jd(d)
168
- e = ERA_DEFS.bsearch{|e| e.end > jd }
169
- e.start > jd and return nil
170
- e
175
+ ERA_DEFS.reverse_each { |e|
176
+ e.start > jd and next
177
+ e.end < jd and next
178
+ return e
179
+ }
180
+ return nil
171
181
  end
172
182
  end
173
183
  end
@@ -1,3 +1,3 @@
1
1
  module Wareki
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wareki
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tatsuki Sugiura
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-02 00:00:00.000000000 Z
11
+ date: 2017-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -60,6 +60,7 @@ executables: []
60
60
  extensions: []
61
61
  extra_rdoc_files: []
62
62
  files:
63
+ - ChangeLog
63
64
  - LICENSE
64
65
  - README.rdoc
65
66
  - lib/wareki.rb
@@ -90,7 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
90
91
  version: '0'
91
92
  requirements: []
92
93
  rubyforge_project:
93
- rubygems_version: 2.2.2
94
+ rubygems_version: 2.4.5.1
94
95
  signing_key:
95
96
  specification_version: 4
96
97
  summary: Pure ruby library of Wareki (Japanese calendar date)