calendar_china 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c09d2aa913863fdac341affb1cb53d0d3e84528540bb9261b4f863e6f66581b3
4
+ data.tar.gz: 89b3ae6494b08dd991f510214aa6cba3fc22a11145660a86bc3ba6969ece8acb
5
+ SHA512:
6
+ metadata.gz: b3a6d72984d4737763d266f6983e2a8504df2aee64cdf92d88a60e8dd36b2f8efca707dd56dc625f973291e5c8e8f67b2f7088ce42bf7a27699920972b49f1ca
7
+ data.tar.gz: 8e88c3f0c0443023fca9901f2c5e3be487ae38a77fc9e329db401ff6d48a9531b1f12e5e40a9b101e23956b5b811e26b60221ec0860f5c3138b7bd842b57a614
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+ .idea
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.6.6
6
+ before_install: gem install bundler -v 2.1.4
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at JohnnyTing2DingXu@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [https://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: https://contributor-covenant.org
74
+ [version]: https://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in calendar_china.gemspec
4
+ gemspec
5
+
6
+ gem "rake", "~> 12.0"
7
+ gem "rspec", "~> 3.0"
@@ -0,0 +1,49 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ calendar_china (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ activesupport (6.0.2.2)
10
+ concurrent-ruby (~> 1.0, >= 1.0.2)
11
+ i18n (>= 0.7, < 2)
12
+ minitest (~> 5.1)
13
+ tzinfo (~> 1.1)
14
+ zeitwerk (~> 2.2)
15
+ concurrent-ruby (1.1.6)
16
+ diff-lcs (1.3)
17
+ i18n (1.8.2)
18
+ concurrent-ruby (~> 1.0)
19
+ minitest (5.14.0)
20
+ rake (12.3.3)
21
+ rspec (3.9.0)
22
+ rspec-core (~> 3.9.0)
23
+ rspec-expectations (~> 3.9.0)
24
+ rspec-mocks (~> 3.9.0)
25
+ rspec-core (3.9.1)
26
+ rspec-support (~> 3.9.1)
27
+ rspec-expectations (3.9.1)
28
+ diff-lcs (>= 1.2.0, < 2.0)
29
+ rspec-support (~> 3.9.0)
30
+ rspec-mocks (3.9.1)
31
+ diff-lcs (>= 1.2.0, < 2.0)
32
+ rspec-support (~> 3.9.0)
33
+ rspec-support (3.9.2)
34
+ thread_safe (0.3.6)
35
+ tzinfo (1.2.7)
36
+ thread_safe (~> 0.1)
37
+ zeitwerk (2.3.0)
38
+
39
+ PLATFORMS
40
+ ruby
41
+
42
+ DEPENDENCIES
43
+ activesupport (~> 6.0.2, >= 6.0.2.2)
44
+ calendar_china!
45
+ rake (~> 12.0)
46
+ rspec (~> 3.0)
47
+
48
+ BUNDLED WITH
49
+ 2.1.4
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 JohnnyTing
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.
@@ -0,0 +1,44 @@
1
+ # CalendarChina
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/calendar_china`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'calendar_china'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install calendar_china
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/calendar_china. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/calendar_china/blob/master/CODE_OF_CONDUCT.md).
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
41
+
42
+ ## Code of Conduct
43
+
44
+ Everyone interacting in the CalendarChina project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/calendar_china/blob/master/CODE_OF_CONDUCT.md).
@@ -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
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "calendar_china"
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(__FILE__)
@@ -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,29 @@
1
+ require_relative 'lib/calendar_china/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "calendar_china"
5
+ spec.version = CalendarChina::VERSION
6
+ spec.authors = ["JohnnyTing"]
7
+ spec.email = ["JohnnyTing2DingXu@gmail.com"]
8
+
9
+ spec.summary = %q{China's Calendar.}
10
+ spec.description = %q{China's Calendar.}
11
+ spec.homepage = "https://github.com/JohnnyTing/calendar_china"
12
+ spec.license = "MIT"
13
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
14
+
15
+ spec.metadata["homepage_uri"] = spec.homepage
16
+ spec.metadata["source_code_uri"] = "https://github.com/JohnnyTing/calendar_china"
17
+ spec.metadata["changelog_uri"] = "https://github.com/JohnnyTing/calendar_china"
18
+
19
+ # Specify which files should be added to the gem when it is released.
20
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
21
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
22
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
23
+ end
24
+ spec.bindir = "exe"
25
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
+ spec.require_paths = ["lib"]
27
+
28
+ spec.add_development_dependency "activesupport", '~> 6.0.2', '>= 6.0.2.2'
29
+ end
@@ -0,0 +1,19 @@
1
+ require "calendar_china/version"
2
+ require 'calendar_china/methods'
3
+ require 'active_support/all'
4
+ require 'json'
5
+ require_relative 'helpers/date_helper'
6
+
7
+ module CalendarChina
8
+ class Error < StandardError; end
9
+ class Date
10
+ include CalendarChina::Methods
11
+ include DateHelper
12
+
13
+ attr_accessor :china_year, :china_date
14
+ def initialize(year = current_year, date = current_date)
15
+ @china_year = year
16
+ @china_date = right_date(date)
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,57 @@
1
+ module CalendarChina
2
+ module Methods
3
+ def is_holiday?(date = china_date)
4
+ holidays.include?(date)
5
+ end
6
+
7
+ def is_workday?(date = china_date)
8
+ special_work_days.include?(date) || !(is_holiday?(date) || date.to_date.on_weekend?)
9
+ end
10
+
11
+ def is_rest?(date = china_date)
12
+ !is_workday?(date)
13
+ end
14
+
15
+ def next_workday(date = china_date)
16
+ result = {}
17
+ st = date.to_date.deep_dup
18
+ current_date = date.to_date
19
+ loop do
20
+ next_date = current_date.next
21
+ date_str = format_date(next_date)
22
+ if is_workday?(date_str)
23
+ days = (next_date - st).to_i
24
+ result[:date] = date_str
25
+ result[:days] = days - 1
26
+ break
27
+ else
28
+ current_date = next_date
29
+ end
30
+ end
31
+ result
32
+ end
33
+
34
+ private
35
+
36
+ def metadata
37
+ return @metadata if @metadata
38
+
39
+ path = File.expand_path("../../data/#{china_year}.json", __FILE__)
40
+ @metadata = JSON.parse(File.read(path))['days']
41
+ @metadata
42
+ end
43
+
44
+ def holidays
45
+ @holidays ||= metadata.map do |data|
46
+ data['date'] if data['isOffDay']
47
+ end.compact
48
+ end
49
+
50
+ def special_work_days
51
+ @special_work_days ||= metadata.map do |data|
52
+ data['date'] unless data['isOffDay']
53
+ end.compact
54
+ end
55
+
56
+ end
57
+ end
@@ -0,0 +1,3 @@
1
+ module CalendarChina
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,166 @@
1
+ {
2
+ "$schema": "https://raw.githubusercontent.com/NateScarlet/holiday-cn/master/schema.json",
3
+ "$id": "https://raw.githubusercontent.com/NateScarlet/holiday-cn/master/2019.json",
4
+ "year": 2019,
5
+ "papers": [
6
+ "http://www.gov.cn/zhengce/content/2019-03/22/content_5375877.htm",
7
+ "http://www.gov.cn/zhengce/content/2018-12/06/content_5346276.htm"
8
+ ],
9
+ "days": [
10
+ {
11
+ "name": "元旦",
12
+ "date": "2018-12-29",
13
+ "isOffDay": false
14
+ },
15
+ {
16
+ "name": "元旦",
17
+ "date": "2018-12-30",
18
+ "isOffDay": true
19
+ },
20
+ {
21
+ "name": "元旦",
22
+ "date": "2018-12-31",
23
+ "isOffDay": true
24
+ },
25
+ {
26
+ "name": "元旦",
27
+ "date": "2019-01-01",
28
+ "isOffDay": true
29
+ },
30
+ {
31
+ "name": "春节",
32
+ "date": "2019-02-02",
33
+ "isOffDay": false
34
+ },
35
+ {
36
+ "name": "春节",
37
+ "date": "2019-02-03",
38
+ "isOffDay": false
39
+ },
40
+ {
41
+ "name": "春节",
42
+ "date": "2019-02-04",
43
+ "isOffDay": true
44
+ },
45
+ {
46
+ "name": "春节",
47
+ "date": "2019-02-05",
48
+ "isOffDay": true
49
+ },
50
+ {
51
+ "name": "春节",
52
+ "date": "2019-02-06",
53
+ "isOffDay": true
54
+ },
55
+ {
56
+ "name": "春节",
57
+ "date": "2019-02-07",
58
+ "isOffDay": true
59
+ },
60
+ {
61
+ "name": "春节",
62
+ "date": "2019-02-08",
63
+ "isOffDay": true
64
+ },
65
+ {
66
+ "name": "春节",
67
+ "date": "2019-02-09",
68
+ "isOffDay": true
69
+ },
70
+ {
71
+ "name": "春节",
72
+ "date": "2019-02-10",
73
+ "isOffDay": true
74
+ },
75
+ {
76
+ "name": "清明节",
77
+ "date": "2019-04-05",
78
+ "isOffDay": true
79
+ },
80
+ {
81
+ "name": "劳动节",
82
+ "date": "2019-04-28",
83
+ "isOffDay": false
84
+ },
85
+ {
86
+ "name": "劳动节",
87
+ "date": "2019-05-01",
88
+ "isOffDay": true
89
+ },
90
+ {
91
+ "name": "劳动节",
92
+ "date": "2019-05-02",
93
+ "isOffDay": true
94
+ },
95
+ {
96
+ "name": "劳动节",
97
+ "date": "2019-05-03",
98
+ "isOffDay": true
99
+ },
100
+ {
101
+ "name": "劳动节",
102
+ "date": "2019-05-04",
103
+ "isOffDay": true
104
+ },
105
+ {
106
+ "name": "劳动节",
107
+ "date": "2019-05-05",
108
+ "isOffDay": false
109
+ },
110
+ {
111
+ "name": "端午节",
112
+ "date": "2019-06-07",
113
+ "isOffDay": true
114
+ },
115
+ {
116
+ "name": "中秋节",
117
+ "date": "2019-09-13",
118
+ "isOffDay": true
119
+ },
120
+ {
121
+ "name": "国庆节",
122
+ "date": "2019-09-29",
123
+ "isOffDay": false
124
+ },
125
+ {
126
+ "name": "国庆节",
127
+ "date": "2019-10-01",
128
+ "isOffDay": true
129
+ },
130
+ {
131
+ "name": "国庆节",
132
+ "date": "2019-10-02",
133
+ "isOffDay": true
134
+ },
135
+ {
136
+ "name": "国庆节",
137
+ "date": "2019-10-03",
138
+ "isOffDay": true
139
+ },
140
+ {
141
+ "name": "国庆节",
142
+ "date": "2019-10-04",
143
+ "isOffDay": true
144
+ },
145
+ {
146
+ "name": "国庆节",
147
+ "date": "2019-10-05",
148
+ "isOffDay": true
149
+ },
150
+ {
151
+ "name": "国庆节",
152
+ "date": "2019-10-06",
153
+ "isOffDay": true
154
+ },
155
+ {
156
+ "name": "国庆节",
157
+ "date": "2019-10-07",
158
+ "isOffDay": true
159
+ },
160
+ {
161
+ "name": "国庆节",
162
+ "date": "2019-10-12",
163
+ "isOffDay": false
164
+ }
165
+ ]
166
+ }
@@ -0,0 +1,191 @@
1
+ {
2
+ "$schema": "https://raw.githubusercontent.com/NateScarlet/holiday-cn/master/schema.json",
3
+ "$id": "https://raw.githubusercontent.com/NateScarlet/holiday-cn/master/2020.json",
4
+ "year": 2020,
5
+ "papers": [
6
+ "http://www.gov.cn/zhengce/content/2019-11/21/content_5454164.htm",
7
+ "http://www.gov.cn/zhengce/content/2020-01/27/content_5472352.htm"
8
+ ],
9
+ "days": [
10
+ {
11
+ "name": "元旦",
12
+ "date": "2020-01-01",
13
+ "isOffDay": true
14
+ },
15
+ {
16
+ "name": "春节",
17
+ "date": "2020-01-19",
18
+ "isOffDay": false
19
+ },
20
+ {
21
+ "name": "春节",
22
+ "date": "2020-01-24",
23
+ "isOffDay": true
24
+ },
25
+ {
26
+ "name": "春节",
27
+ "date": "2020-01-25",
28
+ "isOffDay": true
29
+ },
30
+ {
31
+ "name": "春节",
32
+ "date": "2020-01-26",
33
+ "isOffDay": true
34
+ },
35
+ {
36
+ "name": "春节",
37
+ "date": "2020-01-27",
38
+ "isOffDay": true
39
+ },
40
+ {
41
+ "name": "春节",
42
+ "date": "2020-01-28",
43
+ "isOffDay": true
44
+ },
45
+ {
46
+ "name": "春节",
47
+ "date": "2020-01-29",
48
+ "isOffDay": true
49
+ },
50
+ {
51
+ "name": "春节",
52
+ "date": "2020-01-30",
53
+ "isOffDay": true
54
+ },
55
+ {
56
+ "name": "春节",
57
+ "date": "2020-02-01",
58
+ "isOffDay": true
59
+ },
60
+ {
61
+ "name": "春节",
62
+ "date": "2020-02-02",
63
+ "isOffDay": true
64
+ },
65
+ {
66
+ "name": "春节",
67
+ "date": "2020-02-03",
68
+ "isOffDay": false
69
+ },
70
+ {
71
+ "name": "清明节",
72
+ "date": "2020-04-04",
73
+ "isOffDay": true
74
+ },
75
+ {
76
+ "name": "清明节",
77
+ "date": "2020-04-05",
78
+ "isOffDay": true
79
+ },
80
+ {
81
+ "name": "清明节",
82
+ "date": "2020-04-06",
83
+ "isOffDay": true
84
+ },
85
+ {
86
+ "name": "劳动节",
87
+ "date": "2020-04-26",
88
+ "isOffDay": false
89
+ },
90
+ {
91
+ "name": "劳动节",
92
+ "date": "2020-05-01",
93
+ "isOffDay": true
94
+ },
95
+ {
96
+ "name": "劳动节",
97
+ "date": "2020-05-02",
98
+ "isOffDay": true
99
+ },
100
+ {
101
+ "name": "劳动节",
102
+ "date": "2020-05-03",
103
+ "isOffDay": true
104
+ },
105
+ {
106
+ "name": "劳动节",
107
+ "date": "2020-05-04",
108
+ "isOffDay": true
109
+ },
110
+ {
111
+ "name": "劳动节",
112
+ "date": "2020-05-05",
113
+ "isOffDay": true
114
+ },
115
+ {
116
+ "name": "劳动节",
117
+ "date": "2020-05-09",
118
+ "isOffDay": false
119
+ },
120
+ {
121
+ "name": "端午节",
122
+ "date": "2020-06-25",
123
+ "isOffDay": true
124
+ },
125
+ {
126
+ "name": "端午节",
127
+ "date": "2020-06-26",
128
+ "isOffDay": true
129
+ },
130
+ {
131
+ "name": "端午节",
132
+ "date": "2020-06-27",
133
+ "isOffDay": true
134
+ },
135
+ {
136
+ "name": "端午节",
137
+ "date": "2020-06-28",
138
+ "isOffDay": false
139
+ },
140
+ {
141
+ "name": "国庆节、中秋节",
142
+ "date": "2020-09-27",
143
+ "isOffDay": false
144
+ },
145
+ {
146
+ "name": "国庆节、中秋节",
147
+ "date": "2020-10-01",
148
+ "isOffDay": true
149
+ },
150
+ {
151
+ "name": "国庆节、中秋节",
152
+ "date": "2020-10-02",
153
+ "isOffDay": true
154
+ },
155
+ {
156
+ "name": "国庆节、中秋节",
157
+ "date": "2020-10-03",
158
+ "isOffDay": true
159
+ },
160
+ {
161
+ "name": "国庆节、中秋节",
162
+ "date": "2020-10-04",
163
+ "isOffDay": true
164
+ },
165
+ {
166
+ "name": "国庆节、中秋节",
167
+ "date": "2020-10-05",
168
+ "isOffDay": true
169
+ },
170
+ {
171
+ "name": "国庆节、中秋节",
172
+ "date": "2020-10-06",
173
+ "isOffDay": true
174
+ },
175
+ {
176
+ "name": "国庆节、中秋节",
177
+ "date": "2020-10-07",
178
+ "isOffDay": true
179
+ },
180
+ {
181
+ "name": "国庆节、中秋节",
182
+ "date": "2020-10-08",
183
+ "isOffDay": true
184
+ },
185
+ {
186
+ "name": "国庆节、中秋节",
187
+ "date": "2020-10-10",
188
+ "isOffDay": false
189
+ }
190
+ ]
191
+ }
@@ -0,0 +1,24 @@
1
+ module DateHelper
2
+ def current_year
3
+ ::Date.current.year
4
+ end
5
+
6
+ def right_date(date)
7
+ case date
8
+ when String
9
+ date
10
+ when ::Date, DateTime
11
+ date.strftime('%F')
12
+ when Integer
13
+ Time.at(date).strftime('%F')
14
+ end
15
+ end
16
+
17
+ def format_date(date)
18
+ date.strftime('%F')
19
+ end
20
+
21
+ def current_date
22
+ ::Date.current.strftime('%F')
23
+ end
24
+ end
metadata ADDED
@@ -0,0 +1,84 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: calendar_china
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - JohnnyTing
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-04-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 6.0.2
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 6.0.2.2
23
+ type: :development
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: 6.0.2
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 6.0.2.2
33
+ description: China's Calendar.
34
+ email:
35
+ - JohnnyTing2DingXu@gmail.com
36
+ executables: []
37
+ extensions: []
38
+ extra_rdoc_files: []
39
+ files:
40
+ - ".gitignore"
41
+ - ".rspec"
42
+ - ".travis.yml"
43
+ - CODE_OF_CONDUCT.md
44
+ - Gemfile
45
+ - Gemfile.lock
46
+ - LICENSE.txt
47
+ - README.md
48
+ - Rakefile
49
+ - bin/console
50
+ - bin/setup
51
+ - calendar_china.gemspec
52
+ - lib/calendar_china.rb
53
+ - lib/calendar_china/methods.rb
54
+ - lib/calendar_china/version.rb
55
+ - lib/data/2019.json
56
+ - lib/data/2020.json
57
+ - lib/helpers/date_helper.rb
58
+ homepage: https://github.com/JohnnyTing/calendar_china
59
+ licenses:
60
+ - MIT
61
+ metadata:
62
+ homepage_uri: https://github.com/JohnnyTing/calendar_china
63
+ source_code_uri: https://github.com/JohnnyTing/calendar_china
64
+ changelog_uri: https://github.com/JohnnyTing/calendar_china
65
+ post_install_message:
66
+ rdoc_options: []
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: 2.3.0
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ requirements: []
80
+ rubygems_version: 3.0.3
81
+ signing_key:
82
+ specification_version: 4
83
+ summary: China's Calendar.
84
+ test_files: []