era_ja 0.1.0 → 0.1.1

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.
data/.gitignore CHANGED
@@ -16,3 +16,4 @@ test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
18
  vendor/bundle
19
+ .DS_Store
data/lib/era_ja.rb CHANGED
@@ -15,17 +15,18 @@ module EraJa
15
15
  # @return [String]
16
16
  def to_era(format = "%o%E.%m.%d")
17
17
  format.sub!(/%o/i) { |m| m + ' ' }
18
+ format.sub!(/%E/) { |m| m + ' ' }
18
19
  @era_format = format[/%o/i]
19
20
  if self.to_time < ::Time.mktime(1868,9,8)
20
21
  raise "#to_era is expeted later in 1968,9,8"
21
22
  elsif self.to_time < ::Time.mktime(1912,7,30)
22
- strftime(format).sub(/%E/, format_year(year - 1867)).sub(/%o /i) { format_era('M') }
23
+ strftime(format).sub(/%E /, format_year(year - 1867)).sub(/%o /i) { format_era('M') }
23
24
  elsif self.to_time < ::Time.mktime(1926,12,25)
24
- strftime(format).sub(/%E/, format_year(year - 1911)).sub(/%o /i) { format_era('T') }
25
+ strftime(format).sub(/%E /, format_year(year - 1911)).sub(/%o /i) { format_era('T') }
25
26
  elsif self.to_time < ::Time.mktime(1989,1,8)
26
- strftime(format).sub(/%E/, format_year(year - 1925)).sub(/%o /i) { format_era('S') }
27
+ strftime(format).sub(/%E /, format_year(year - 1925)).sub(/%o /i) { format_era('S') }
27
28
  else
28
- strftime(format).sub(/%E/, format_year(year - 1988)).sub(/%o /i) { format_era('H') }
29
+ strftime(format).sub(/%E /, format_year(year - 1988)).sub(/%o /i) { format_era('H') }
29
30
  end
30
31
  end
31
32
 
@@ -1,3 +1,3 @@
1
1
  module EraJa
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/spec/spec_helper.rb CHANGED
@@ -21,6 +21,18 @@ shared_examples "should equal '24.04.29'" do
21
21
  end
22
22
  end
23
23
 
24
+ shared_examples "should equal '2404'" do
25
+ context "with '%E%m'" do
26
+ it { subject.to_era("%E%m").should eq "2404" }
27
+ end
28
+ end
29
+
30
+ shared_examples "should equal '平成240429'" do
31
+ context "with '%O%E%m%d'" do
32
+ it { subject.to_era("%O%E%m%d").should eq '平成240429' }
33
+ end
34
+ end
35
+
24
36
  shared_examples "should equal 'H01.01.08'" do
25
37
  it { subject.to_era.should eq "H01.01.08" }
26
38
  end
@@ -66,6 +78,8 @@ shared_examples "2012,4,29" do
66
78
  include_examples "should equal 'H24.04.29'"
67
79
  include_examples "should equal '平成24年04月29日'"
68
80
  include_examples "should equal '24.04.29'"
81
+ include_examples "should equal '2404'"
82
+ include_examples "should equal '平成240429'"
69
83
  end
70
84
 
71
85
  shared_examples "1989,1,8" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: era_ja
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-09 00:00:00.000000000 Z
12
+ date: 2012-07-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -113,7 +113,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
113
113
  version: '0'
114
114
  segments:
115
115
  - 0
116
- hash: -4408163875494566668
116
+ hash: -2746383159837241495
117
117
  required_rubygems_version: !ruby/object:Gem::Requirement
118
118
  none: false
119
119
  requirements:
@@ -122,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
122
122
  version: '0'
123
123
  segments:
124
124
  - 0
125
- hash: -4408163875494566668
125
+ hash: -2746383159837241495
126
126
  requirements: []
127
127
  rubyforge_project:
128
128
  rubygems_version: 1.8.24