japanese_calendar 0.2.0 → 0.3.0

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: 24d6b788116b03f3cda9eb3777c06fd528990b9e
4
- data.tar.gz: 7e51d4fa12dd788b786102db9a602ae5e76e8acc
3
+ metadata.gz: 0d5904f38ba5b838626a46e31be45e2a73329a3d
4
+ data.tar.gz: 814f791883585675c6799577b5a4c3d1bf0a0b62
5
5
  SHA512:
6
- metadata.gz: 3b778089d926467aae31b406e8f7ccef7512fd3e836078c398e6d609eed645a329fde41f41c8b5b5b5a512b1349f85f5d4d6d861b1396e683ebafb1b8bead51b
7
- data.tar.gz: 37381cf4c47ca1cbfe0fbb9a2d54effa435dcd01e71cffa3aa0b88094580795ee8984bcb760028f43decca3454d9443949a3ead6368810009d10cc7fe27f742b
6
+ metadata.gz: 853d9e4c2dd6a751f0e45ba58fb432f6e346b4ffbdfdd77f5996ae694e72e2f16a398ae2e85a0b6e8496e8de80e43c249f024136cdf2993f2df8209febda7167
7
+ data.tar.gz: 79dd32bb385d535d081a94400065cef92d7066d7e1d3097afc33473724e9b75d9db1c6580d2727e7717b2875ef10968176010a3a44fedbe19ed1e4e87bb1c0da
data/README.md CHANGED
@@ -38,20 +38,28 @@ Time.new(1926, 12, 24).era_year # => 15
38
38
  Time.new(1912, 7, 29).era_year # => 45
39
39
  ```
40
40
 
41
- To get a string representation of the Japanese era, use the `strftime` method:
41
+ To get a string representation of the Japanese calendar, use the `strftime` method:
42
42
 
43
43
  ```
44
44
  time = Time.new(1989, 1, 1)
45
- time.strftime("%K") # => "平成"
46
- time.strftime("%O") # => "Heisei"
47
- time.strftime("%^O") # => "HEISEI"
48
- time.strftime("%o") # => "H"
49
- time.strftime("%J") # => "01"
50
- time.strftime("%-J") # => "1"
51
- time.strftime("%_J") # => " 1"
52
- time.strftime("%K%-J年%-m月%-d日") # => "平成1年1月1日"
53
- time.strftime("%o%J.%m.%d") # => H01.01.01
54
- time.strftime("%b %-d %O %-J") # => Jan 1 Heisei 1
45
+
46
+ # Japanese era
47
+ time.strftime("%K") # => "平成"
48
+ time.strftime("%O") # => "Heisei"
49
+ time.strftime("%^O") # => "HEISEI"
50
+ time.strftime("%o") # => "H"
51
+ time.strftime("%J") # => "01"
52
+ time.strftime("%-J") # => "1"
53
+ time.strftime("%_J") # => " 1"
54
+
55
+ # Japanese weekday name
56
+ time.strftime("%Q") # => "日曜日"
57
+ time.strftime("%q") # => "日"
58
+
59
+ # More examples
60
+ time.strftime("%K%-J年%-m月%-d日(%q)") # => "平成1年1月1日(日)"
61
+ time.strftime("%o%J.%m.%d") # => H01.01.01
62
+ time.strftime("%B %-d, %-Y (%O %-J)") # => January 1, 1989 (Heisei 1)
55
63
  ```
56
64
 
57
65
  ## Development
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
  require "japanese_calendar/era"
3
+ require "japanese_calendar/weekday"
3
4
 
4
5
  class Time
5
6
  prepend JapaneseCalendar::Era
7
+ prepend JapaneseCalendar::Weekday
6
8
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module JapaneseCalendar
3
- VERSION = "0.2.0"
3
+ VERSION = "0.3.0"
4
4
  end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+ module JapaneseCalendar
3
+ module Weekday
4
+ NAMES = %w(日曜日 月曜日 火曜日 水曜日 木曜日 金曜日 土曜日).freeze
5
+
6
+ # Formats time according to the directives in the given format string.
7
+ #
8
+ # date_of_birth = Time.new(1978, 7, 19)
9
+ #
10
+ # date_of_birth.strftime("%Q") # => "水曜日"
11
+ # date_of_birth.strftime("%q") # => "水"
12
+ #
13
+ # date_of_birth.strftime("%-Y年%-m月%-d日(%q)") # => "1978年7月19日(水)"
14
+ def strftime(format)
15
+ string = format.dup
16
+ string.gsub!(/%Q/, NAMES[wday])
17
+ string.gsub!(/%q/, NAMES[wday][0])
18
+ super(string)
19
+ end
20
+ end
21
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: japanese_calendar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryo Yamamoto
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-12-23 00:00:00.000000000 Z
11
+ date: 2016-12-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -106,6 +106,7 @@ files:
106
106
  - lib/japanese_calendar/core_ext/time.rb
107
107
  - lib/japanese_calendar/era.rb
108
108
  - lib/japanese_calendar/version.rb
109
+ - lib/japanese_calendar/weekday.rb
109
110
  homepage: https://github.com/RyoYamamotoJP/japanese_calendar
110
111
  licenses:
111
112
  - MIT