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 +4 -4
- data/README.md +19 -11
- data/lib/japanese_calendar/core_ext/time.rb +2 -0
- data/lib/japanese_calendar/version.rb +1 -1
- data/lib/japanese_calendar/weekday.rb +21 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d5904f38ba5b838626a46e31be45e2a73329a3d
|
4
|
+
data.tar.gz: 814f791883585675c6799577b5a4c3d1bf0a0b62
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
-
|
46
|
-
|
47
|
-
time.strftime("
|
48
|
-
time.strftime("%
|
49
|
-
time.strftime("
|
50
|
-
time.strftime("
|
51
|
-
time.strftime("%
|
52
|
-
time.strftime("
|
53
|
-
time.strftime("%
|
54
|
-
|
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
|
@@ -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.
|
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-
|
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
|