lunar_blessing 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 12e6f6c9d02a03f317b9daf2e0657d7b43f6e9ae
4
+ data.tar.gz: ae498737940495c8c392b700f47441412af803a3
5
+ SHA512:
6
+ metadata.gz: a05acaee383d4730b36ef7a09bef1a61eb4c6b0f19d6b5110aa1cfd3b15d6b4b61213c2736c0512cd9a2837f21e60596b001193f8f17f7b8ae28aea7ec9d2863
7
+ data.tar.gz: fd721cd42903eafcf090d26b0a95f395e15ca9853be135d68ebf360c39d2ea6d5a4034a6d5c3e9a173eb6fcf10615c5b3b1875a0545f6f094f4af804fe8da767
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.gem
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.1
5
+ before_install: gem install bundler -v 1.12.5
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at poshboytl@gmail.com. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in lunar_blessing.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Terry Tai
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,50 @@
1
+ # LunarBlessing
2
+
3
+ ![](https://i.ytimg.com/vi/LRztF05kE4s/hqdefault.jpg)
4
+
5
+ LunarBlessing is created for converting Chinese Lunar Calendar date to Solar Calendar date.
6
+ It supports years from 1900 to 2099.
7
+
8
+ Now LunarBlessing is not supporting convert Solar date to Lunar date, but it's already in todo list.
9
+ We will add this feature when we need it. So if you wanna contribute, that would be awesome.
10
+
11
+ ## Name
12
+ This gem name is inspried by a DOTA HERO called Luna, she has a abilitie called Lunar Blessing.
13
+
14
+ ## Installation
15
+
16
+ Add this line to your application's Gemfile:
17
+
18
+ ```ruby
19
+ gem 'lunar_blessing', github: 'mycolorway/lunar_blessing'
20
+ ```
21
+
22
+ And then execute:
23
+
24
+ $ bundle
25
+
26
+ Now this gem is not published to rubygems.org yet, so install with git or local is neccessary.
27
+
28
+ ## Usage
29
+
30
+ ```ruby
31
+ lunar_date = LunarBlessing::Date.new(year: 2015, month: 12, day: 28)
32
+ lunar_date.to_solar #=> '2016-02-06'
33
+ lunar_date.to_s #=> '腊月廿八'
34
+ lunar_date.to_s(with_year: true) #=> '二〇一六年腊月廿八'
35
+ ```
36
+
37
+ ## Requirement
38
+ This gem only support Ruby version >= 2.1, because we use 'keyword arguments' feature.
39
+ If you want to remove it and support other ruby versions, a PR is welcome.
40
+
41
+ ## License
42
+
43
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
44
+
45
+
46
+ ## TODO
47
+
48
+ - [x] Add to_s for LunarBlessing:Date
49
+ - [ ] Convert solar date to lunar date
50
+ - [x] Write document
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "lunar_blessing"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,243 @@
1
+ module LunarBlessing
2
+ module DatesMaping
3
+ DATES_MAPPING = [
4
+ [8, "0131", "0301", "0331", "0429", "0528", "0627", "0726", "0825", "0924", "1023", "1122", "1222", "1320"], #1900
5
+ [0, "0219", "0320", "0419", "0518", "0616", "0716", "0814", "0913", "1012", "1111", "1211", "1310"], #1901
6
+ [0, "0208", "0310", "0408", "0508", "0606", "0705", "0804", "0902", "1002", "1031", "1130", "1230"], #1902
7
+ [5, "0129", "0227", "0329", "0427", "0527", "0625", "0724", "0823", "0921", "1020", "1119", "1219", "1317"], #1903
8
+ [0, "0216", "0317", "0416", "0515", "0614", "0713", "0811", "0910", "1009", "1107", "1207", "1306"], #1904
9
+ [0, "0204", "0306", "0405", "0504", "0603", "0703", "0801", "0830", "0929", "1028", "1127", "1226"], #1905
10
+ [4, "0125", "0223", "0325", "0424", "0523", "0622", "0721", "0820", "0918", "1018", "1116", "1216", "1314"], #1906
11
+ [0, "0213", "0314", "0413", "0512", "0611", "0710", "0809", "0908", "1007", "1106", "1205", "1304"], #1907
12
+ [0, "0202", "0303", "0401", "0430", "0530", "0629", "0728", "0827", "0925", "1025", "1124", "1223"], #1908
13
+ [2, "0122", "0220", "0322", "0420", "0519", "0618", "0717", "0816", "0914", "1014", "1113", "1213", "1311"], #1909
14
+ [0, "0210", "0311", "0410", "0509", "0607", "0707", "0805", "0904", "1003", "1102", "1202", "1301"], #1910
15
+ [6, "0130", "0301", "0330", "0429", "0528", "0626", "0726", "0824", "0922", "1022", "1121", "1220", "1319"], #1911
16
+ [0, "0218", "0319", "0417", "0517", "0615", "0714", "0813", "0911", "1010", "1109", "1209", "1307"], #1912
17
+ [0, "0206", "0308", "0407", "0506", "0605", "0704", "0802", "0901", "0930", "1029", "1128", "1227"], #1913
18
+ [5, "0126", "0225", "0327", "0425", "0525", "0623", "0723", "0821", "0920", "1019", "1117", "1217", "1315"], #1914
19
+ [0, "0214", "0316", "0414", "0514", "0613", "0712", "0811", "0909", "1009", "1107", "1207", "1305"], #1915
20
+ [0, "0203", "0304", "0403", "0502", "0601", "0630", "0730", "0829", "0927", "1027", "1125", "1225"], #1916
21
+ [2, "0123", "0222", "0323", "0421", "0521", "0619", "0719", "0818", "0916", "1016", "1115", "1214", "1313"], #1917
22
+ [0, "0211", "0313", "0411", "0510", "0609", "0708", "0807", "0905", "1005", "1104", "1203", "1302"], #1918
23
+ [7, "0201", "0302", "0401", "0430", "0529", "0628", "0727", "0825", "0924", "1024", "1122", "1222", "1321"], #1919
24
+ [0, "0220", "0320", "0419", "0518", "0616", "0716", "0814", "0912", "1012", "1110", "1210", "1309"], #1920
25
+ [0, "0208", "0310", "0408", "0508", "0606", "0705", "0804", "0902", "1001", "1031", "1129", "1229"], #1921
26
+ [5, "0128", "0227", "0328", "0427", "0527", "0625", "0724", "0823", "0921", "1020", "1119", "1218", "1317"], #1922
27
+ [0, "0216", "0317", "0416", "0516", "0614", "0714", "0812", "0911", "1010", "1108", "1208", "1306"], #1923
28
+ [0, "0205", "0305", "0404", "0504", "0602", "0702", "0801", "0830", "0929", "1028", "1127", "1226"], #1924
29
+ [4, "0124", "0223", "0324", "0423", "0522", "0621", "0721", "0819", "0918", "1018", "1116", "1216", "1314"], #1925
30
+ [0, "0213", "0314", "0412", "0512", "0610", "0710", "0808", "0907", "1007", "1105", "1205", "1304"], #1926
31
+ [0, "0202", "0304", "0402", "0501", "0531", "0629", "0729", "0827", "0926", "1025", "1124", "1224"], #1927
32
+ [2, "0123", "0221", "0322", "0420", "0519", "0618", "0717", "0815", "0914", "1013", "1112", "1212", "1311"], #1928
33
+ [0, "0210", "0311", "0410", "0509", "0607", "0707", "0805", "0903", "1003", "1101", "1201", "1231"], #1929
34
+ [6, "0130", "0228", "0330", "0429", "0528", "0626", "0726", "0824", "0922", "1022", "1120", "1220", "1319"], #1930
35
+ [0, "0217", "0319", "0418", "0517", "0616", "0715", "0814", "0912", "1011", "1110", "1209", "1308"], #1931
36
+ [0, "0206", "0307", "0406", "0506", "0604", "0704", "0802", "0901", "0930", "1029", "1128", "1227"], #1932
37
+ [5, "0126", "0224", "0326", "0425", "0524", "0623", "0722", "0821", "0920", "1019", "1118", "1217", "1315"], #1933
38
+ [0, "0214", "0315", "0414", "0513", "0612", "0712", "0810", "0909", "1008", "1107", "1207", "1305"], #1934
39
+ [0, "0204", "0305", "0403", "0503", "0601", "0701", "0730", "0829", "0928", "1027", "1126", "1226"], #1935
40
+ [3, "0124", "0223", "0323", "0421", "0521", "0619", "0718", "0817", "0916", "1015", "1114", "1214", "1313"], #1936
41
+ [0, "0211", "0313", "0411", "0510", "0609", "0708", "0806", "0905", "1004", "1103", "1203", "1302"], #1937
42
+ [7, "0131", "0302", "0401", "0430", "0529", "0628", "0727", "0825", "0924", "1023", "1122", "1222", "1320"], #1938
43
+ [0, "0219", "0321", "0420", "0519", "0617", "0717", "0815", "0913", "1013", "1111", "1211", "1309"], #1939
44
+ [0, "0208", "0309", "0408", "0507", "0606", "0705", "0804", "0902", "1001", "1031", "1129", "1229"], #1940
45
+ [6, "0127", "0226", "0328", "0426", "0526", "0625", "0724", "0823", "0921", "1020", "1119", "1218", "1317"], #1941
46
+ [0, "0215", "0317", "0415", "0515", "0614", "0713", "0812", "0910", "1010", "1108", "1208", "1306"], #1942
47
+ [0, "0205", "0306", "0405", "0504", "0603", "0702", "0801", "0831", "0929", "1029", "1127", "1227"], #1943
48
+ [4, "0125", "0224", "0324", "0423", "0522", "0621", "0720", "0819", "0917", "1017", "1116", "1215", "1314"], #1944
49
+ [0, "0213", "0314", "0412", "0512", "0610", "0709", "0808", "0906", "1006", "1105", "1205", "1303"], #1945
50
+ [0, "0202", "0304", "0402", "0501", "0531", "0629", "0728", "0827", "0925", "1025", "1124", "1223"], #1946
51
+ [2, "0122", "0221", "0323", "0421", "0520", "0619", "0718", "0816", "0915", "1014", "1113", "1212", "1311"], #1947
52
+ [0, "0210", "0311", "0409", "0509", "0607", "0707", "0805", "0903", "1003", "1101", "1201", "1230"], #1948
53
+ [7, "0129", "0228", "0329", "0428", "0528", "0626", "0726", "0824", "0922", "1022", "1120", "1220", "1318"], #1949
54
+ [0, "0217", "0318", "0417", "0517", "0615", "0715", "0814", "0912", "1011", "1110", "1209", "1308"], #1950
55
+ [0, "0206", "0308", "0406", "0506", "0605", "0704", "0803", "0901", "1001", "1030", "1129", "1228"], #1951
56
+ [5, "0127", "0225", "0326", "0424", "0524", "0622", "0722", "0820", "0919", "1019", "1117", "1217", "1315"], #1952
57
+ [0, "0214", "0315", "0414", "0513", "0611", "0711", "0810", "0908", "1008", "1107", "1206", "1305"], #1953
58
+ [0, "0203", "0305", "0403", "0503", "0601", "0630", "0730", "0828", "0927", "1027", "1126", "1225"], #1954
59
+ [3, "0124", "0222", "0324", "0422", "0522", "0620", "0719", "0818", "0916", "1016", "1114", "1214", "1313"], #1955
60
+ [0, "0212", "0312", "0411", "0510", "0609", "0708", "0806", "0905", "1004", "1103", "1203", "1301"], #1956
61
+ [8, "0131", "0302", "0331", "0430", "0529", "0628", "0727", "0825", "0924", "1023", "1122", "1221", "1320"], #1957
62
+ [0, "0218", "0320", "0419", "0519", "0617", "0717", "0815", "0913", "1013", "1111", "1211", "1309"], #1958
63
+ [0, "0208", "0309", "0408", "0508", "0606", "0706", "0804", "0903", "1002", "1101", "1130", "1230"], #1959
64
+ [6, "0128", "0227", "0327", "0426", "0525", "0624", "0724", "0822", "0921", "1020", "1119", "1218", "1317"], #1960
65
+ [0, "0215", "0317", "0415", "0515", "0613", "0713", "0811", "0910", "1010", "1108", "1208", "1306"], #1961
66
+ [0, "0205", "0306", "0405", "0504", "0602", "0702", "0731", "0830", "0929", "1028", "1127", "1227"], #1962
67
+ [4, "0125", "0224", "0325", "0424", "0523", "0621", "0721", "0819", "0918", "1017", "1116", "1216", "1315"], #1963
68
+ [0, "0213", "0314", "0412", "0512", "0610", "0709", "0808", "0906", "1006", "1104", "1204", "1303"], #1964
69
+ [0, "0202", "0303", "0402", "0501", "0531", "0629", "0728", "0827", "0925", "1024", "1123", "1223"], #1965
70
+ [3, "0121", "0220", "0322", "0421", "0520", "0619", "0718", "0816", "0915", "1014", "1112", "1212", "1311"], #1966
71
+ [0, "0209", "0311", "0410", "0509", "0608", "0708", "0806", "0904", "1004", "1102", "1202", "1231"], #1967
72
+ [7, "0130", "0228", "0329", "0427", "0527", "0626", "0725", "0824", "0922", "1022", "1120", "1220", "1318"], #1968
73
+ [0, "0217", "0318", "0417", "0516", "0615", "0714", "0813", "0912", "1011", "1110", "1209", "1308"], #1969
74
+ [0, "0206", "0308", "0406", "0505", "0604", "0703", "0802", "0901", "0930", "1030", "1129", "1228"], #1970
75
+ [5, "0127", "0225", "0327", "0425", "0524", "0623", "0722", "0821", "0919", "1019", "1118", "1218", "1316"], #1971
76
+ [0, "0215", "0315", "0414", "0513", "0611", "0711", "0809", "0908", "1007", "1106", "1206", "1304"], #1972
77
+ [0, "0203", "0305", "0403", "0503", "0601", "0630", "0730", "0828", "0926", "1026", "1125", "1224"], #1973
78
+ [4, "0123", "0222", "0324", "0422", "0522", "0620", "0719", "0818", "0916", "1015", "1114", "1214", "1312"], #1974
79
+ [0, "0211", "0313", "0412", "0511", "0610", "0709", "0807", "0906", "1005", "1103", "1203", "1301"], #1975
80
+ [8, "0131", "0301", "0331", "0429", "0529", "0627", "0727", "0825", "0924", "1023", "1121", "1221", "1319"], #1976
81
+ [0, "0218", "0320", "0418", "0518", "0617", "0716", "0815", "0913", "1013", "1111", "1211", "1309"], #1977
82
+ [0, "0207", "0309", "0407", "0507", "0606", "0705", "0804", "0902", "1002", "1101", "1130", "1230"], #1978
83
+ [6, "0128", "0227", "0328", "0426", "0526", "0624", "0724", "0823", "0921", "1021", "1120", "1219", "1318"], #1979
84
+ [0, "0216", "0317", "0415", "0514", "0613", "0712", "0811", "0909", "1009", "1108", "1207", "1306"], #1980
85
+ [0, "0205", "0306", "0405", "0504", "0602", "0702", "0731", "0829", "0928", "1028", "1126", "1226"], #1981
86
+ [4, "0125", "0224", "0325", "0424", "0523", "0621", "0721", "0819", "0917", "1017", "1115", "1215", "1314"], #1982
87
+ [0, "0213", "0315", "0413", "0513", "0611", "0710", "0809", "0907", "1006", "1105", "1204", "1303"], #1983
88
+ [10, "0202", "0303", "0401", "0501", "0531", "0629", "0728", "0827", "0925", "1024", "1123", "1222", "1321"], #1984
89
+ [0, "0220", "0321", "0420", "0520", "0618", "0718", "0816", "0915", "1014", "1112", "1212", "1310"], #1985
90
+ [0, "0209", "0310", "0409", "0509", "0607", "0707", "0806", "0904", "1004", "1102", "1202", "1231"], #1986
91
+ [6, "0129", "0228", "0329", "0428", "0527", "0626", "0726", "0824", "0923", "1023", "1121", "1221", "1319"], #1987
92
+ [0, "0217", "0318", "0416", "0516", "0614", "0714", "0812", "0911", "1011", "1109", "1209", "1308"], #1988
93
+ [0, "0206", "0308", "0406", "0505", "0604", "0703", "0802", "0831", "0930", "1029", "1128", "1228"], #1989
94
+ [5, "0127", "0225", "0327", "0425", "0524", "0623", "0722", "0820", "0919", "1018", "1117", "1217", "1316"], #1990
95
+ [0, "0215", "0316", "0415", "0514", "0612", "0712", "0810", "0908", "1008", "1106", "1206", "1305"], #1991
96
+ [0, "0204", "0304", "0403", "0503", "0601", "0630", "0730", "0828", "0926", "1026", "1124", "1224"], #1992
97
+ [3, "0123", "0221", "0323", "0422", "0521", "0620", "0719", "0818", "0916", "1015", "1114", "1213", "1312"], #1993
98
+ [0, "0210", "0312", "0411", "0511", "0609", "0709", "0807", "0906", "1005", "1103", "1203", "1301"], #1994
99
+ [8, "0131", "0301", "0331", "0430", "0529", "0628", "0727", "0826", "0925", "1024", "1122", "1222", "1320"], #1995
100
+ [0, "0219", "0319", "0418", "0517", "0616", "0715", "0814", "0912", "1012", "1111", "1211", "1309"], #1996
101
+ [0, "0207", "0309", "0407", "0507", "0605", "0705", "0803", "0902", "1002", "1031", "1130", "1230"], #1997
102
+ [5, "0128", "0227", "0328", "0426", "0526", "0624", "0723", "0822", "0921", "1020", "1119", "1219", "1317"], #1998
103
+ [0, "0216", "0318", "0416", "0515", "0614", "0713", "0811", "0910", "1009", "1108", "1208", "1307"], #1999
104
+ [0, "0205", "0306", "0405", "0504", "0602", "0702", "0731", "0829", "0928", "1027", "1126", "1226"], #2000
105
+ [4, "0124", "0223", "0325", "0423", "0523", "0621", "0721", "0819", "0917", "1017", "1115", "1215", "1313"], #2001
106
+ [0, "0212", "0314", "0413", "0512", "0611", "0710", "0809", "0907", "1006", "1105", "1204", "1303"], #2002
107
+ [0, "0201", "0303", "0402", "0501", "0531", "0630", "0729", "0828", "0926", "1025", "1124", "1223"], #2003
108
+ [2, "0122", "0220", "0321", "0419", "0519", "0618", "0717", "0816", "0914", "1014", "1112", "1212", "1310"], #2004
109
+ [0, "0209", "0310", "0409", "0508", "0607", "0706", "0805", "0904", "1003", "1102", "1201", "1231"], #2005
110
+ [7, "0129", "0228", "0329", "0428", "0527", "0626", "0725", "0824", "0922", "1022", "1121", "1220", "1319"], #2006
111
+ [0, "0218", "0319", "0417", "0517", "0615", "0714", "0813", "0911", "1011", "1110", "1210", "1308"], #2007
112
+ [0, "0207", "0308", "0406", "0505", "0604", "0703", "0801", "0831", "0929", "1029", "1128", "1227"], #2008
113
+ [5, "0126", "0225", "0327", "0425", "0524", "0623", "0722", "0820", "0919", "1018", "1117", "1216", "1315"], #2009
114
+ [0, "0214", "0316", "0414", "0514", "0612", "0712", "0810", "0908", "1008", "1106", "1206", "1304"], #2010
115
+ [0, "0203", "0305", "0403", "0503", "0602", "0701", "0731", "0829", "0927", "1027", "1125", "1225"], #2011
116
+ [4, "0123", "0222", "0322", "0421", "0521", "0619", "0719", "0817", "0916", "1015", "1114", "1213", "1312"], #2012
117
+ [0, "0210", "0312", "0410", "0510", "0608", "0708", "0807", "0905", "1005", "1103", "1203", "1301"], #2013
118
+ [9, "0131", "0301", "0331", "0429", "0529", "0627", "0727", "0825", "0924", "1024", "1122", "1222", "1320"], #2014
119
+ [0, "0219", "0320", "0419", "0518", "0616", "0716", "0814", "0913", "1013", "1112", "1211", "1310"], #2015
120
+ [0, "0208", "0309", "0407", "0507", "0605", "0704", "0803", "0901", "1001", "1031", "1129", "1229"], #2016
121
+ [6, "0128", "0226", "0328", "0426", "0526", "0624", "0723", "0822", "0920", "1020", "1118", "1218", "1317"], #2017
122
+ [0, "0216", "0317", "0416", "0515", "0614", "0713", "0811", "0910", "1009", "1108", "1207", "1306"], #2018
123
+ [0, "0205", "0307", "0405", "0505", "0603", "0703", "0801", "0830", "0929", "1028", "1126", "1226"], #2019
124
+ [4, "0125", "0223", "0324", "0423", "0523", "0621", "0721", "0819", "0917", "1017", "1115", "1215", "1313"], #2020
125
+ [0, "0212", "0313", "0412", "0512", "0610", "0710", "0808", "0907", "1006", "1105", "1204", "1303"], #2021
126
+ [0, "0201", "0303", "0401", "0501", "0530", "0629", "0729", "0827", "0926", "1025", "1124", "1223"], #2022
127
+ [2, "0122", "0220", "0322", "0420", "0519", "0618", "0718", "0816", "0915", "1015", "1113", "1213", "1311"], #2023
128
+ [0, "0210", "0310", "0409", "0508", "0606", "0706", "0804", "0903", "1003", "1101", "1201", "1231"], #2024
129
+ [6, "0129", "0228", "0329", "0428", "0527", "0625", "0725", "0823", "0922", "1021", "1120", "1220", "1319"], #2025
130
+ [0, "0217", "0319", "0417", "0517", "0615", "0714", "0813", "0911", "1010", "1109", "1209", "1308"], #2026
131
+ [0, "0206", "0308", "0407", "0506", "0605", "0704", "0802", "0901", "0930", "1029", "1128", "1228"], #2027
132
+ [5, "0126", "0225", "0326", "0425", "0524", "0623", "0722", "0820", "0919", "1018", "1116", "1216", "1315"], #2028
133
+ [0, "0213", "0315", "0414", "0513", "0612", "0711", "0810", "0908", "1008", "1106", "1205", "1304"], #2029
134
+ [0, "0203", "0304", "0403", "0502", "0601", "0701", "0730", "0829", "0927", "1027", "1125", "1225"], #2030
135
+ [3, "0123", "0221", "0323", "0422", "0521", "0620", "0719", "0818", "0917", "1016", "1115", "1214", "1313"], #2031
136
+ [0, "0211", "0312", "0410", "0509", "0608", "0707", "0806", "0905", "1004", "1103", "1203", "1301"], #2032
137
+ [7, "0131", "0301", "0331", "0429", "0528", "0627", "0726", "0825", "0923", "1023", "1122", "1222", "1320"], #2033
138
+ [0, "0219", "0320", "0419", "0518", "0616", "0716", "0814", "0913", "1012", "1111", "1211", "1309"], #2034
139
+ [0, "0208", "0310", "0408", "0508", "0606", "0705", "0804", "0902", "1001", "1031", "1130", "1229"], #2035
140
+ [6, "0128", "0227", "0328", "0426", "0526", "0624", "0723", "0822", "0920", "1019", "1118", "1217", "1316"], #2036
141
+ [0, "0215", "0317", "0416", "0515", "0614", "0713", "0811", "0910", "1009", "1107", "1207", "1305"], #2037
142
+ [0, "0204", "0306", "0405", "0504", "0603", "0702", "0801", "0830", "0929", "1028", "1126", "1226"], #2038
143
+ [5, "0124", "0223", "0325", "0423", "0523", "0622", "0721", "0820", "0918", "1018", "1116", "1216", "1314"], #2039
144
+ [0, "0212", "0313", "0411", "0511", "0610", "0709", "0808", "0906", "1006", "1105", "1204", "1303"], #2040
145
+ [0, "0201", "0302", "0401", "0430", "0530", "0628", "0728", "0827", "0925", "1025", "1124", "1223"], #2041
146
+ [2, "0122", "0220", "0322", "0420", "0519", "0618", "0717", "0816", "0914", "1014", "1113", "1212", "1311"], #2042
147
+ [0, "0210", "0311", "0410", "0509", "0607", "0707", "0805", "0903", "1003", "1102", "1201", "1231"], #2043
148
+ [7, "0130", "0229", "0329", "0428", "0527", "0625", "0725", "0823", "0921", "1021", "1119", "1219", "1318"], #2044
149
+ [0, "0217", "0319", "0417", "0517", "0615", "0714", "0813", "0911", "1010", "1109", "1208", "1307"], #2045
150
+ [0, "0206", "0308", "0406", "0506", "0604", "0704", "0802", "0901", "0930", "1029", "1128", "1227"], #2046
151
+ [5, "0126", "0225", "0326", "0425", "0525", "0623", "0723", "0821", "0920", "1019", "1117", "1217", "1315"], #2047
152
+ [0, "0214", "0314", "0413", "0513", "0611", "0711", "0810", "0908", "1008", "1106", "1205", "1304"], #2048
153
+ [0, "0202", "0304", "0402", "0502", "0531", "0630", "0730", "0828", "0927", "1027", "1125", "1225"], #2049
154
+ [3, "0123", "0221", "0323", "0421", "0521", "0619", "0719", "0817", "0916", "1016", "1114", "1214", "1313"], #2050
155
+ [0, "0211", "0313", "0411", "0510", "0609", "0708", "0806", "0905", "1005", "1103", "1203", "1302"], #2051
156
+ [8, "0201", "0301", "0331", "0429", "0528", "0627", "0726", "0824", "0923", "1022", "1121", "1221", "1320"], #2052
157
+ [0, "0219", "0320", "0419", "0518", "0616", "0716", "0814", "0912", "1012", "1110", "1210", "1309"], #2053
158
+ [0, "0208", "0309", "0408", "0508", "0606", "0705", "0804", "0902", "1001", "1031", "1129", "1229"], #2054
159
+ [6, "0128", "0226", "0328", "0427", "0526", "0625", "0724", "0823", "0921", "1020", "1119", "1218", "1317"], #2055
160
+ [0, "0215", "0316", "0415", "0515", "0613", "0713", "0811", "0910", "1009", "1107", "1207", "1305"], #2056
161
+ [0, "0204", "0305", "0404", "0504", "0602", "0702", "0731", "0830", "0929", "1028", "1126", "1226"], #2057
162
+ [4, "0124", "0223", "0324", "0423", "0522", "0621", "0720", "0819", "0918", "1017", "1116", "1216", "1314"], #2058
163
+ [0, "0212", "0314", "0412", "0512", "0610", "0710", "0808", "0907", "1006", "1105", "1205", "1304"], #2059
164
+ [0, "0202", "0303", "0401", "0501", "0530", "0628", "0727", "0826", "0924", "1024", "1123", "1223"], #2060
165
+ [3, "0121", "0220", "0322", "0420", "0519", "0618", "0717", "0815", "0914", "1013", "1112", "1212", "1311"], #2061
166
+ [0, "0209", "0311", "0410", "0509", "0607", "0707", "0805", "0903", "1003", "1101", "1201", "1231"], #2062
167
+ [7, "0129", "0228", "0330", "0428", "0528", "0626", "0726", "0824", "0922", "1022", "1120", "1220", "1318"], #2063
168
+ [0, "0217", "0318", "0417", "0516", "0615", "0714", "0813", "0911", "1010", "1109", "1208", "1307"], #2064
169
+ [0, "0205", "0307", "0406", "0505", "0604", "0704", "0802", "0901", "0930", "1029", "1128", "1227"], #2065
170
+ [5, "0126", "0224", "0326", "0424", "0524", "0623", "0722", "0821", "0919", "1019", "1117", "1217", "1315"], #2066
171
+ [0, "0214", "0315", "0414", "0513", "0612", "0711", "0810", "0909", "1008", "1107", "1206", "1305"], #2067
172
+ [0, "0203", "0304", "0402", "0502", "0531", "0629", "0729", "0828", "0926", "1026", "1125", "1224"], #2068
173
+ [4, "0123", "0221", "0323", "0421", "0521", "0619", "0718", "0817", "0915", "1015", "1114", "1214", "1312"], #2069
174
+ [0, "0211", "0312", "0411", "0510", "0609", "0708", "0806", "0905", "1004", "1103", "1203", "1301"], #2070
175
+ [8, "0131", "0302", "0331", "0430", "0529", "0628", "0727", "0825", "0924", "1023", "1122", "1221", "1320"], #2071
176
+ [0, "0219", "0320", "0418", "0518", "0616", "0716", "0814", "0912", "1012", "1110", "1210", "1308"], #2072
177
+ [0, "0207", "0309", "0407", "0507", "0605", "0704", "0803", "0901", "0930", "1030", "1128", "1228"], #2073
178
+ [6, "0126", "0225", "0326", "0425", "0525", "0623", "0723", "0821", "0920", "1019", "1118", "1217", "1316"], #2074
179
+ [0, "0214", "0316", "0414", "0514", "0612", "0712", "0811", "0909", "1009", "1107", "1207", "1305"], #2075
180
+ [0, "0204", "0304", "0403", "0502", "0601", "0630", "0730", "0828", "0927", "1027", "1125", "1225"], #2076
181
+ [0, "0123", "0222", "0323", "0422", "0521", "0620", "0719", "0818", "0917", "1017", "1115", "1215"], #2077
182
+ [0, "0113", "0212", "0313", "0412", "0511", "0609", "0709", "0807", "0906", "1006", "1104", "1204"], #2078
183
+ [0, "0103", "0201", "0303", "0401", "0501", "0530", "0628", "0728", "0826", "0925", "1024", "1123"], #2079
184
+ [3, "1223", "0122", "0220", "0321", "0419", "0519", "0617", "0716", "0815", "0913", "1012", "1111", "1211"], #2080
185
+ [0, "0110", "0208", "0310", "0409", "0508", "0607", "0706", "0804", "0903", "1002", "1031", "1130"], #2081
186
+ [7, "1230", "0128", "0227", "0329", "0428", "0527", "0625", "0725", "0823", "0922", "1021", "1119", "1219"], #2082
187
+ [0, "0118", "0216", "0318", "0417", "0516", "0615", "0714", "0813", "0911", "1011", "1109", "1209"], #2083
188
+ [0, "0107", "0206", "0306", "0405", "0504", "0603", "0703", "0801", "0831", "0929", "1029", "1127"], #2084
189
+ [5, "1227", "0125", "0224", "0325", "0423", "0523", "0622", "0721", "0820", "0919", "1018", "1117", "1216"], #2085
190
+ [0, "0115", "0213", "0315", "0413", "0512", "0611", "0710", "0809", "0908", "1007", "1106", "1206"], #2086
191
+ [0, "0104", "0203", "0304", "0403", "0502", "0531", "0630", "0729", "0828", "0926", "1026", "1125"], #2087
192
+ [4, "1225", "0123", "0222", "0322", "0421", "0520", "0618", "0718", "0816", "0914", "1014", "1113", "1213"], #2088
193
+ [0, "0111", "0210", "0312", "0410", "0510", "0608", "0707", "0806", "0904", "1003", "1102", "1202"], #2089
194
+ [8, "1231", "0130", "0301", "0331", "0429", "0529", "0627", "0726", "0825", "0923", "1022", "1121", "1221"], #2090
195
+ [0, "0119", "0218", "0320", "0418", "0518", "0616", "0716", "0814", "0913", "1012", "1110", "1210"], #2091
196
+ [0, "0108", "0207", "0308", "0406", "0506", "0605", "0704", "0803", "0901", "1001", "1030", "1129"], #2092
197
+ [6, "1228", "0126", "0225", "0327", "0425", "0525", "0623", "0723", "0822", "0920", "1020", "1118", "1218"], #2093
198
+ [0, "0116", "0214", "0316", "0414", "0514", "0612", "0712", "0811", "0909", "1009", "1108", "1207"], #2094
199
+ [0, "0106", "0204", "0306", "0404", "0503", "0602", "0701", "0731", "0829", "0928", "1028", "1127"], #2095
200
+ [4, "1226", "0125", "0223", "0324", "0422", "0521", "0620", "0719", "0817", "0916", "1016", "1115", "1214"], #2096
201
+ [0, "0113", "0212", "0313", "0412", "0511", "0609", "0709", "0807", "0905", "1005", "1104", "1203"], #2097
202
+ [0, "0102", "0201", "0303", "0401", "0501", "0530", "0628", "0727", "0826", "0924", "1024", "1122"], #2098
203
+ [2, "1222", "0121", "0220", "0321", "0420", "0520", "0618", "0717", "0816", "0914", "1013", "1112", "1211"] #2099
204
+ ]
205
+
206
+ YEAR_MAPPING = { 1 => '一', 2 => '二', 3 => '三', 4 => '四', 5 => '五', 6 =>'六', 7 =>'七', 8 => '八', 9 => '九', 0 => '〇' }
207
+ MONTH_MAPPING = { 1 => '正月', 2 => '二月', 3 =>'三月', 4 => '四月', 5 => '五月',
208
+ 6 =>'六月', 7 => '七月', 8 => '八月', 9 => '九月', 10 => '十月', 11 => '冬月', 12 => '腊月'}
209
+ DAY_MAPPING = {
210
+ 1 => '初一',
211
+ 2 => '初二',
212
+ 3 => '初三',
213
+ 4 => '初四',
214
+ 5 => '初五',
215
+ 6 => '初六',
216
+ 7 => '初七',
217
+ 8 => '初八',
218
+ 9 => '初九',
219
+ 10 => '初十',
220
+ 11 => '十一',
221
+ 12 => '十二',
222
+ 13 => '十三',
223
+ 14 => '十四',
224
+ 15 => '十五',
225
+ 16 => '十六',
226
+ 17 => '十七',
227
+ 18 => '十八',
228
+ 19 => '十九',
229
+ 20 => '二十',
230
+ 21 => '廿一',
231
+ 22 => '廿二',
232
+ 23 => '廿三',
233
+ 24 => '廿四',
234
+ 25 => '廿五',
235
+ 26 => '廿六',
236
+ 27 => '廿七',
237
+ 28 => '廿八',
238
+ 29 => '廿九',
239
+ 30 => '三十'
240
+ }
241
+
242
+ end
243
+ end
@@ -0,0 +1,3 @@
1
+ module LunarBlessing
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,105 @@
1
+ require "lunar_blessing/version"
2
+ require "lunar_blessing/dates_maping"
3
+ require 'date'
4
+
5
+ module LunarBlessing
6
+ class Date
7
+ include DatesMaping
8
+
9
+ MIN_YEAR = 1900
10
+ MAX_YEAR = 2099
11
+
12
+ attr_reader :year, :month, :day, :leap
13
+
14
+ def initialize(year:, month:, day:, leap: false)
15
+ raise OutOfRange.new(year) if year < MIN_YEAR || year > MAX_YEAR
16
+
17
+ @year = year
18
+ @month = month
19
+ @day = day
20
+ @leap = leap
21
+ @leap_month = DATES_MAPPING[offset][0].to_i
22
+
23
+ reset_month_by_leap
24
+ init_solar_date
25
+
26
+ if @month > 12 || @solar_month > 12
27
+ @solar_year += 1
28
+ @solar_month -= 12
29
+ end
30
+
31
+ end
32
+
33
+ def to_solar
34
+ solar_date.to_s
35
+ end
36
+
37
+ def to_s(with_year: false)
38
+ mm = MONTH_MAPPING[month.to_i]
39
+ dd = DAY_MAPPING[day.to_i]
40
+
41
+ "#{with_year ? chinese_year : ''}#{mm}#{dd}"
42
+ end
43
+
44
+ private
45
+
46
+ def chinese_year
47
+ yy = []
48
+ year.to_s.each_char do |y|
49
+ yy << YEAR_MAPPING[y.to_i]
50
+ end
51
+ yy << '年'
52
+ yy = yy.join
53
+
54
+ end
55
+
56
+ def solar_date
57
+ ::Date.new(solar_year, solar_month, solar_day) + (day - 1)
58
+ end
59
+
60
+ def offset
61
+ @offset ||= year - MIN_YEAR
62
+ end
63
+
64
+ def solar_string
65
+ @solar_string ||= DATES_MAPPING[offset][month]
66
+ end
67
+
68
+ def solar_month
69
+ @solar_month ||= solar_string[0..1].to_i
70
+ end
71
+
72
+ def solar_day
73
+ @solar_day ||= solar_string[-2..-1].to_i
74
+ end
75
+
76
+ def solar_year
77
+ @solar_year ||= year
78
+ end
79
+
80
+ def reset_month_by_leap
81
+ if leap || (@leap_month > 0 && month > @leap_month)
82
+ @month += 1
83
+ end
84
+ end
85
+
86
+ def init_solar_date
87
+ solar_year
88
+ solar_month
89
+ solar_day
90
+ end
91
+
92
+
93
+ end
94
+
95
+ class OutOfRange < StandardError
96
+ attr_reader :year
97
+ def initialize(year)
98
+ @year = year
99
+ end
100
+
101
+ def message
102
+ "The #{year} year you provided is out of range. This gem only support 1900 - 2099."
103
+ end
104
+ end
105
+ end
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'lunar_blessing/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "lunar_blessing"
8
+ spec.version = LunarBlessing::VERSION
9
+ spec.authors = ["Terry Tai"]
10
+ spec.email = ["poshboytl@gmail.com"]
11
+
12
+ spec.summary = %q{Lunar calendar, Solar calendar convertor}
13
+ spec.description = %q{Lunar calendar, Solar calendar convertor}
14
+ spec.homepage = "https://github.com/mycolorway/lunar_blessing"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.12"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "rspec", "~> 3.0"
25
+ end
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lunar_blessing
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Terry Tai
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-08-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.12'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.12'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ description: Lunar calendar, Solar calendar convertor
56
+ email:
57
+ - poshboytl@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".rspec"
64
+ - ".travis.yml"
65
+ - CODE_OF_CONDUCT.md
66
+ - Gemfile
67
+ - LICENSE.txt
68
+ - README.md
69
+ - Rakefile
70
+ - bin/console
71
+ - bin/setup
72
+ - lib/lunar_blessing.rb
73
+ - lib/lunar_blessing/dates_maping.rb
74
+ - lib/lunar_blessing/version.rb
75
+ - lunar_blessing.gemspec
76
+ homepage: https://github.com/mycolorway/lunar_blessing
77
+ licenses:
78
+ - MIT
79
+ metadata: {}
80
+ post_install_message:
81
+ rdoc_options: []
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ requirements: []
95
+ rubyforge_project:
96
+ rubygems_version: 2.6.11
97
+ signing_key:
98
+ specification_version: 4
99
+ summary: Lunar calendar, Solar calendar convertor
100
+ test_files: []