jpdate 0.2.1 → 0.2.2

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/jcal +7 -10
  3. data/lib/jpdate/version.rb +1 -1
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 345f8a5a0b7e7099e8ed209ce2ae3e1c8407bced2a832eb833ced3c2a1366456
4
- data.tar.gz: 0ab8d6ccc65bb541fb7c625743408eb62bd9f290d94a2fac29bc4097bec1a831
3
+ metadata.gz: 573d09d7c3f6c9bc501fa9e8e9031f3827efc3556056960628af0d44231b83ce
4
+ data.tar.gz: 33116adb481bbe670f4c19436621f2c864646261cbb112817213fc1dfcc79921
5
5
  SHA512:
6
- metadata.gz: eaf67f084c9f54c0f9fd363c869208046896beca305e1592b54c192a26665c78f942c514659c960063b5f244cf19e800d071eddf722c4844d10e39d372362e17
7
- data.tar.gz: a4bafe024c2baf13fa977038f238681bc96b7daa97508a3d5b732b3b72573a5d8de303ec8d903de564fb051299f39b6f4b7e984a300e19d3d4de52012b564248
6
+ metadata.gz: ce83f54a80cb9dc1a6c1d94a04dfa576bb3f4c7578013575e1cdf15256f7aedc79a72867568a2a3f1364e1abcd6b5114010c0a39055be6519b50d91654d62814
7
+ data.tar.gz: f4d5fe3c15d05c9dd415b5b4bbf1c034e3ed62fc04f74986db2d6ee906f6780b23618e04fb17d8c7e4fd3408329f51fc5aa1c2599eab1ec4827e45165f839fe1
data/bin/jcal CHANGED
@@ -31,6 +31,7 @@ module Jcal
31
31
  module_function
32
32
 
33
33
  def render_matrix(y, m)
34
+ m = 12 if m == 0
34
35
  title = (sprintf("#{JPDate::Era.name_year(y, m).join('/')} %4d年 %2d月", y, m)).center_ja(16 * 7)
35
36
  week_names = WEEK_JA.map {|s| s.rjust_ja(16)}
36
37
  week_names[0] = "\e[31m#{week_names[0]}\e[0m"
@@ -81,13 +82,9 @@ module Jcal
81
82
  end
82
83
 
83
84
  def matrix(base_year, start_month, end_month=start_month)
84
- base_year -= 1 if start_month <= 0
85
- start_month, end_month = *[start_month, end_month].map {|i| i %= 12; i == 0 ? 12 : i}
86
- if start_month <= end_month
87
- (start_month..end_month).each {|i| render_matrix(base_year , i)}
88
- else
89
- (start_month..12 ).each {|i| render_matrix(base_year , i)}
90
- ( 1..end_month).each {|i| render_matrix(base_year + 1, i)}
85
+ end_month += 12 if start_month > end_month
86
+ (start_month..end_month).each do |i|
87
+ render_matrix(base_year + (i / 12.0).ceil - 1, i % 12)
91
88
  end
92
89
  end
93
90
 
@@ -104,8 +101,8 @@ options = {}
104
101
  OptionParser.new do |opt|
105
102
  opt.banner = 'Usage: jcal [options] [yyyy|mm] [yyyy|mm] [yyyy|mm]'
106
103
  opt.separator('')
107
- opt.on('-y[NUM]', 'List NUM years.(0-10)') {|v| options[:years] = v.to_i}
108
- opt.on('-m[NUM]', 'Show NUM months.(0-12)') {|v| options[:months] = v.to_i}
104
+ opt.on('-y[NUM]', 'Show NUM years.(0-10)') {|v| options[:years] = v.to_i}
105
+ opt.on('-m[NUM]', 'Show NUM months.') {|v| options[:months] = v.to_i}
109
106
  opt.on('-e' , 'List with the name of Japanese era.') {|v| options[:era] = v}
110
107
  opt.separator('')
111
108
  opt.on('Example:',
@@ -119,6 +116,7 @@ OptionParser.new do |opt|
119
116
  ' jcal -m # Show monthly calendar from last month to next month.',
120
117
  ' jcal -m6 2010 1 # Show monthly calendar from Jan.2010 to Jun.2010.',
121
118
  ' jcal 2010 2 8 # Show monthly calendar from Feb.2010 to Aug.2010.',
119
+ ' jcal --version=JPDate # Show version of JPDate.',
122
120
  )
123
121
  begin
124
122
  opt.parse!(ARGV)
@@ -141,7 +139,6 @@ m = [m[0] , m[0] + options[:months] - 1] if options.key?(:months) && option
141
139
  (y[0] = options[:years]; options[:years] = 0) if options.key?(:years) && options[:years] >= 1900 # -y西暦なら、西暦と解釈
142
140
  m = [1, 12] if options.key?(:years) && options[:years] <= 1 # -y指定期間が1年以下は、12カ月分表示
143
141
  options[:years] ||= (y[1] - y[0]).abs + 1 if y.size == 2 && (options.empty? || options[:era]) # 西暦2個・月0個・オプションなしは、-yに期間を追加
144
-
145
142
  if options.key?(:years) && options[:years] >= 2
146
143
  Jcal::list(y.min, options[:years], options[:era])
147
144
  else
@@ -5,5 +5,5 @@
5
5
  require 'date'
6
6
 
7
7
  class JPDate < Date
8
- VERSION = "0.2.1"
8
+ VERSION = "0.2.2"
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jpdate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - zariganitosh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-21 00:00:00.000000000 Z
11
+ date: 2018-11-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler