calendar_china 0.1.0 → 1.0.0
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +28 -5
- data/lib/calendar_china.rb +15 -2
- data/lib/calendar_china/version.rb +1 -1
- data/lib/data/2015.json +145 -0
- data/lib/data/2016.json +160 -0
- data/lib/data/2017.json +155 -0
- data/lib/data/2018.json +155 -0
- data/lib/helpers/date_helper.rb +4 -4
- metadata +5 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e51679d9d8c820cb85946f5fd0224cc5d576fdd349872f4294596fb111ffeef8
|
4
|
+
data.tar.gz: 8d08eb79716230d1be81f968939f901b4208ee73fa6c2f99e9c3ccf2160252f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59d3ac60984a3034a8f9a96f43865abf174fef864f6522cb38ab2cf8b66c53baf7d7659aad9102296cebb695e5a5afd0bd3bf2c4e37e2d1e1962acea8814d28b
|
7
|
+
data.tar.gz: be7fab0d966b3aa68e904a4c3fb2cb56294cbdda20a7fcb3f70239b10044436ed148d5d7bafe300f5324b3b0c5925462c2d90b034b6a9b2cf52c7fc585c416c3
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
# CalendarChina
|
2
2
|
|
3
|
-
|
3
|
+
Due to the extremely weird holidays in China, we have to customize the calendar.
|
4
4
|
|
5
|
-
|
5
|
+
NOTE: need to update these lib/data/{xxxx}.json on time.
|
6
|
+
|
7
|
+
These datasource are retrieved from the [holiday-cn](https://github.com/NateScarlet/holiday-cn), and thanks to NateScarlet
|
6
8
|
|
7
9
|
## Installation
|
8
10
|
|
@@ -12,6 +14,12 @@ Add this line to your application's Gemfile:
|
|
12
14
|
gem 'calendar_china'
|
13
15
|
```
|
14
16
|
|
17
|
+
Or use github
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
gem 'calendar_china', github: 'JohnnyTing/calendar_china'
|
21
|
+
```
|
22
|
+
|
15
23
|
And then execute:
|
16
24
|
|
17
25
|
$ bundle install
|
@@ -22,7 +30,22 @@ Or install it yourself as:
|
|
22
30
|
|
23
31
|
## Usage
|
24
32
|
|
25
|
-
|
33
|
+
By default, initialize current year and date. you also can specify the fields. Below is an example:
|
34
|
+
```ruby
|
35
|
+
ccd = CalendarChina::Date.new("2020", "2020-01-01")
|
36
|
+
|
37
|
+
# return true
|
38
|
+
ccd.is_holiday?
|
39
|
+
|
40
|
+
# return true
|
41
|
+
ccd.is_rest?
|
42
|
+
|
43
|
+
# return false
|
44
|
+
ccd.is_workday?
|
45
|
+
|
46
|
+
# return hash: {:date=>"2020-01-02", :days=>0}, date field is next workday lasted, days field is via these days arrives next workday
|
47
|
+
ccd.next_workday
|
48
|
+
```
|
26
49
|
|
27
50
|
## Development
|
28
51
|
|
@@ -32,7 +55,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
32
55
|
|
33
56
|
## Contributing
|
34
57
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
58
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/JohnnyTing/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/JohnnyTing/calendar_china/blob/master/CODE_OF_CONDUCT.md).
|
36
59
|
|
37
60
|
|
38
61
|
## License
|
@@ -41,4 +64,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
41
64
|
|
42
65
|
## Code of Conduct
|
43
66
|
|
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/
|
67
|
+
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/JohnnyTing/calendar_china/blob/master/CODE_OF_CONDUCT.md).
|
data/lib/calendar_china.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'calendar_china/version'
|
2
2
|
require 'calendar_china/methods'
|
3
3
|
require 'active_support/all'
|
4
4
|
require 'json'
|
@@ -6,14 +6,27 @@ require_relative 'helpers/date_helper'
|
|
6
6
|
|
7
7
|
module CalendarChina
|
8
8
|
class Error < StandardError; end
|
9
|
+
|
10
|
+
# China's Calendar. For more details, see the calendar_china/methods.rb
|
11
|
+
#
|
12
|
+
# NOTE: need to update the lib/data/{xxxx}.json on time.
|
13
|
+
# retrieve these json file from https://github.com/NateScarlet/holiday-cn, and thanks to NateScarlet
|
9
14
|
class Date
|
10
15
|
include CalendarChina::Methods
|
11
16
|
include DateHelper
|
12
17
|
|
13
18
|
attr_accessor :china_year, :china_date
|
19
|
+
|
20
|
+
# By default, initialize current year and date.
|
21
|
+
# you also can specify the fields. Below is some examples for usage:
|
22
|
+
# ccd = CalendarChina::Date.new("2020", "2020-01-01")
|
23
|
+
# ccd.is_holiday? => true
|
24
|
+
# ccd.is_rest? => true
|
25
|
+
# ccd.is_workday? => false
|
26
|
+
# ccd.next_workday => {:date=>"2020-01-02", :days=>0}
|
14
27
|
def initialize(year = current_year, date = current_date)
|
15
28
|
@china_year = year
|
16
|
-
@china_date =
|
29
|
+
@china_date = adjust_date(date)
|
17
30
|
end
|
18
31
|
end
|
19
32
|
end
|
data/lib/data/2015.json
ADDED
@@ -0,0 +1,145 @@
|
|
1
|
+
{
|
2
|
+
"$schema": "https://raw.githubusercontent.com/NateScarlet/holiday-cn/master/schema.json",
|
3
|
+
"$id": "https://raw.githubusercontent.com/NateScarlet/holiday-cn/master/2015.json",
|
4
|
+
"year": 2015,
|
5
|
+
"papers": [
|
6
|
+
"http://www.gov.cn/zhengce/content/2014-12/16/content_9302.htm"
|
7
|
+
],
|
8
|
+
"days": [
|
9
|
+
{
|
10
|
+
"name": "元旦",
|
11
|
+
"date": "2015-01-01",
|
12
|
+
"isOffDay": true
|
13
|
+
},
|
14
|
+
{
|
15
|
+
"name": "元旦",
|
16
|
+
"date": "2015-01-02",
|
17
|
+
"isOffDay": true
|
18
|
+
},
|
19
|
+
{
|
20
|
+
"name": "元旦",
|
21
|
+
"date": "2015-01-03",
|
22
|
+
"isOffDay": true
|
23
|
+
},
|
24
|
+
{
|
25
|
+
"name": "元旦",
|
26
|
+
"date": "2015-01-04",
|
27
|
+
"isOffDay": false
|
28
|
+
},
|
29
|
+
{
|
30
|
+
"name": "春节",
|
31
|
+
"date": "2015-02-15",
|
32
|
+
"isOffDay": false
|
33
|
+
},
|
34
|
+
{
|
35
|
+
"name": "春节",
|
36
|
+
"date": "2015-02-18",
|
37
|
+
"isOffDay": true
|
38
|
+
},
|
39
|
+
{
|
40
|
+
"name": "春节",
|
41
|
+
"date": "2015-02-19",
|
42
|
+
"isOffDay": true
|
43
|
+
},
|
44
|
+
{
|
45
|
+
"name": "春节",
|
46
|
+
"date": "2015-02-20",
|
47
|
+
"isOffDay": true
|
48
|
+
},
|
49
|
+
{
|
50
|
+
"name": "春节",
|
51
|
+
"date": "2015-02-21",
|
52
|
+
"isOffDay": true
|
53
|
+
},
|
54
|
+
{
|
55
|
+
"name": "春节",
|
56
|
+
"date": "2015-02-22",
|
57
|
+
"isOffDay": true
|
58
|
+
},
|
59
|
+
{
|
60
|
+
"name": "春节",
|
61
|
+
"date": "2015-02-23",
|
62
|
+
"isOffDay": true
|
63
|
+
},
|
64
|
+
{
|
65
|
+
"name": "春节",
|
66
|
+
"date": "2015-02-24",
|
67
|
+
"isOffDay": true
|
68
|
+
},
|
69
|
+
{
|
70
|
+
"name": "春节",
|
71
|
+
"date": "2015-02-28",
|
72
|
+
"isOffDay": false
|
73
|
+
},
|
74
|
+
{
|
75
|
+
"name": "清明节",
|
76
|
+
"date": "2015-04-05",
|
77
|
+
"isOffDay": true
|
78
|
+
},
|
79
|
+
{
|
80
|
+
"name": "清明节",
|
81
|
+
"date": "2015-04-06",
|
82
|
+
"isOffDay": true
|
83
|
+
},
|
84
|
+
{
|
85
|
+
"name": "劳动节",
|
86
|
+
"date": "2015-05-01",
|
87
|
+
"isOffDay": true
|
88
|
+
},
|
89
|
+
{
|
90
|
+
"name": "端午节",
|
91
|
+
"date": "2015-06-20",
|
92
|
+
"isOffDay": true
|
93
|
+
},
|
94
|
+
{
|
95
|
+
"name": "端午节",
|
96
|
+
"date": "2015-06-22",
|
97
|
+
"isOffDay": true
|
98
|
+
},
|
99
|
+
{
|
100
|
+
"name": "中秋节",
|
101
|
+
"date": "2015-09-27",
|
102
|
+
"isOffDay": true
|
103
|
+
},
|
104
|
+
{
|
105
|
+
"name": "国庆节",
|
106
|
+
"date": "2015-10-01",
|
107
|
+
"isOffDay": true
|
108
|
+
},
|
109
|
+
{
|
110
|
+
"name": "国庆节",
|
111
|
+
"date": "2015-10-02",
|
112
|
+
"isOffDay": true
|
113
|
+
},
|
114
|
+
{
|
115
|
+
"name": "国庆节",
|
116
|
+
"date": "2015-10-03",
|
117
|
+
"isOffDay": true
|
118
|
+
},
|
119
|
+
{
|
120
|
+
"name": "国庆节",
|
121
|
+
"date": "2015-10-04",
|
122
|
+
"isOffDay": true
|
123
|
+
},
|
124
|
+
{
|
125
|
+
"name": "国庆节",
|
126
|
+
"date": "2015-10-05",
|
127
|
+
"isOffDay": true
|
128
|
+
},
|
129
|
+
{
|
130
|
+
"name": "国庆节",
|
131
|
+
"date": "2015-10-06",
|
132
|
+
"isOffDay": true
|
133
|
+
},
|
134
|
+
{
|
135
|
+
"name": "国庆节",
|
136
|
+
"date": "2015-10-07",
|
137
|
+
"isOffDay": true
|
138
|
+
},
|
139
|
+
{
|
140
|
+
"name": "国庆节",
|
141
|
+
"date": "2015-10-10",
|
142
|
+
"isOffDay": false
|
143
|
+
}
|
144
|
+
]
|
145
|
+
}
|
data/lib/data/2016.json
ADDED
@@ -0,0 +1,160 @@
|
|
1
|
+
{
|
2
|
+
"$schema": "https://raw.githubusercontent.com/NateScarlet/holiday-cn/master/schema.json",
|
3
|
+
"$id": "https://raw.githubusercontent.com/NateScarlet/holiday-cn/master/2016.json",
|
4
|
+
"year": 2016,
|
5
|
+
"papers": [
|
6
|
+
"http://www.gov.cn/zhengce/content/2015-12/10/content_10394.htm"
|
7
|
+
],
|
8
|
+
"days": [
|
9
|
+
{
|
10
|
+
"name": "元旦",
|
11
|
+
"date": "2016-01-01",
|
12
|
+
"isOffDay": true
|
13
|
+
},
|
14
|
+
{
|
15
|
+
"name": "春节",
|
16
|
+
"date": "2016-02-06",
|
17
|
+
"isOffDay": false
|
18
|
+
},
|
19
|
+
{
|
20
|
+
"name": "春节",
|
21
|
+
"date": "2016-02-07",
|
22
|
+
"isOffDay": true
|
23
|
+
},
|
24
|
+
{
|
25
|
+
"name": "春节",
|
26
|
+
"date": "2016-02-08",
|
27
|
+
"isOffDay": true
|
28
|
+
},
|
29
|
+
{
|
30
|
+
"name": "春节",
|
31
|
+
"date": "2016-02-09",
|
32
|
+
"isOffDay": true
|
33
|
+
},
|
34
|
+
{
|
35
|
+
"name": "春节",
|
36
|
+
"date": "2016-02-10",
|
37
|
+
"isOffDay": true
|
38
|
+
},
|
39
|
+
{
|
40
|
+
"name": "春节",
|
41
|
+
"date": "2016-02-11",
|
42
|
+
"isOffDay": true
|
43
|
+
},
|
44
|
+
{
|
45
|
+
"name": "春节",
|
46
|
+
"date": "2016-02-12",
|
47
|
+
"isOffDay": true
|
48
|
+
},
|
49
|
+
{
|
50
|
+
"name": "春节",
|
51
|
+
"date": "2016-02-13",
|
52
|
+
"isOffDay": true
|
53
|
+
},
|
54
|
+
{
|
55
|
+
"name": "春节",
|
56
|
+
"date": "2016-02-14",
|
57
|
+
"isOffDay": false
|
58
|
+
},
|
59
|
+
{
|
60
|
+
"name": "清明节",
|
61
|
+
"date": "2016-04-04",
|
62
|
+
"isOffDay": true
|
63
|
+
},
|
64
|
+
{
|
65
|
+
"name": "劳动节",
|
66
|
+
"date": "2016-05-01",
|
67
|
+
"isOffDay": true
|
68
|
+
},
|
69
|
+
{
|
70
|
+
"name": "劳动节",
|
71
|
+
"date": "2016-05-02",
|
72
|
+
"isOffDay": true
|
73
|
+
},
|
74
|
+
{
|
75
|
+
"name": "端午节",
|
76
|
+
"date": "2016-06-09",
|
77
|
+
"isOffDay": true
|
78
|
+
},
|
79
|
+
{
|
80
|
+
"name": "端午节",
|
81
|
+
"date": "2016-06-10",
|
82
|
+
"isOffDay": true
|
83
|
+
},
|
84
|
+
{
|
85
|
+
"name": "端午节",
|
86
|
+
"date": "2016-06-11",
|
87
|
+
"isOffDay": true
|
88
|
+
},
|
89
|
+
{
|
90
|
+
"name": "端午节",
|
91
|
+
"date": "2016-06-12",
|
92
|
+
"isOffDay": false
|
93
|
+
},
|
94
|
+
{
|
95
|
+
"name": "中秋节",
|
96
|
+
"date": "2016-09-15",
|
97
|
+
"isOffDay": true
|
98
|
+
},
|
99
|
+
{
|
100
|
+
"name": "中秋节",
|
101
|
+
"date": "2016-09-16",
|
102
|
+
"isOffDay": true
|
103
|
+
},
|
104
|
+
{
|
105
|
+
"name": "中秋节",
|
106
|
+
"date": "2016-09-17",
|
107
|
+
"isOffDay": true
|
108
|
+
},
|
109
|
+
{
|
110
|
+
"name": "中秋节",
|
111
|
+
"date": "2016-09-18",
|
112
|
+
"isOffDay": false
|
113
|
+
},
|
114
|
+
{
|
115
|
+
"name": "国庆节",
|
116
|
+
"date": "2016-10-01",
|
117
|
+
"isOffDay": true
|
118
|
+
},
|
119
|
+
{
|
120
|
+
"name": "国庆节",
|
121
|
+
"date": "2016-10-02",
|
122
|
+
"isOffDay": true
|
123
|
+
},
|
124
|
+
{
|
125
|
+
"name": "国庆节",
|
126
|
+
"date": "2016-10-03",
|
127
|
+
"isOffDay": true
|
128
|
+
},
|
129
|
+
{
|
130
|
+
"name": "国庆节",
|
131
|
+
"date": "2016-10-04",
|
132
|
+
"isOffDay": true
|
133
|
+
},
|
134
|
+
{
|
135
|
+
"name": "国庆节",
|
136
|
+
"date": "2016-10-05",
|
137
|
+
"isOffDay": true
|
138
|
+
},
|
139
|
+
{
|
140
|
+
"name": "国庆节",
|
141
|
+
"date": "2016-10-06",
|
142
|
+
"isOffDay": true
|
143
|
+
},
|
144
|
+
{
|
145
|
+
"name": "国庆节",
|
146
|
+
"date": "2016-10-07",
|
147
|
+
"isOffDay": true
|
148
|
+
},
|
149
|
+
{
|
150
|
+
"name": "国庆节",
|
151
|
+
"date": "2016-10-08",
|
152
|
+
"isOffDay": false
|
153
|
+
},
|
154
|
+
{
|
155
|
+
"name": "国庆节",
|
156
|
+
"date": "2016-10-09",
|
157
|
+
"isOffDay": false
|
158
|
+
}
|
159
|
+
]
|
160
|
+
}
|
data/lib/data/2017.json
ADDED
@@ -0,0 +1,155 @@
|
|
1
|
+
{
|
2
|
+
"$schema": "https://raw.githubusercontent.com/NateScarlet/holiday-cn/master/schema.json",
|
3
|
+
"$id": "https://raw.githubusercontent.com/NateScarlet/holiday-cn/master/2017.json",
|
4
|
+
"year": 2017,
|
5
|
+
"papers": [
|
6
|
+
"http://www.gov.cn/zhengce/content/2016-12/01/content_5141603.htm"
|
7
|
+
],
|
8
|
+
"days": [
|
9
|
+
{
|
10
|
+
"name": "元旦",
|
11
|
+
"date": "2017-01-01",
|
12
|
+
"isOffDay": true
|
13
|
+
},
|
14
|
+
{
|
15
|
+
"name": "元旦",
|
16
|
+
"date": "2017-01-02",
|
17
|
+
"isOffDay": true
|
18
|
+
},
|
19
|
+
{
|
20
|
+
"name": "春节",
|
21
|
+
"date": "2017-01-22",
|
22
|
+
"isOffDay": false
|
23
|
+
},
|
24
|
+
{
|
25
|
+
"name": "春节",
|
26
|
+
"date": "2017-01-27",
|
27
|
+
"isOffDay": true
|
28
|
+
},
|
29
|
+
{
|
30
|
+
"name": "春节",
|
31
|
+
"date": "2017-01-28",
|
32
|
+
"isOffDay": true
|
33
|
+
},
|
34
|
+
{
|
35
|
+
"name": "春节",
|
36
|
+
"date": "2017-01-29",
|
37
|
+
"isOffDay": true
|
38
|
+
},
|
39
|
+
{
|
40
|
+
"name": "春节",
|
41
|
+
"date": "2017-01-30",
|
42
|
+
"isOffDay": true
|
43
|
+
},
|
44
|
+
{
|
45
|
+
"name": "春节",
|
46
|
+
"date": "2017-01-31",
|
47
|
+
"isOffDay": true
|
48
|
+
},
|
49
|
+
{
|
50
|
+
"name": "春节",
|
51
|
+
"date": "2017-02-01",
|
52
|
+
"isOffDay": true
|
53
|
+
},
|
54
|
+
{
|
55
|
+
"name": "春节",
|
56
|
+
"date": "2017-02-02",
|
57
|
+
"isOffDay": true
|
58
|
+
},
|
59
|
+
{
|
60
|
+
"name": "春节",
|
61
|
+
"date": "2017-02-04",
|
62
|
+
"isOffDay": false
|
63
|
+
},
|
64
|
+
{
|
65
|
+
"name": "清明节",
|
66
|
+
"date": "2017-04-01",
|
67
|
+
"isOffDay": false
|
68
|
+
},
|
69
|
+
{
|
70
|
+
"name": "清明节",
|
71
|
+
"date": "2017-04-02",
|
72
|
+
"isOffDay": true
|
73
|
+
},
|
74
|
+
{
|
75
|
+
"name": "清明节",
|
76
|
+
"date": "2017-04-03",
|
77
|
+
"isOffDay": true
|
78
|
+
},
|
79
|
+
{
|
80
|
+
"name": "清明节",
|
81
|
+
"date": "2017-04-04",
|
82
|
+
"isOffDay": true
|
83
|
+
},
|
84
|
+
{
|
85
|
+
"name": "劳动节",
|
86
|
+
"date": "2017-05-01",
|
87
|
+
"isOffDay": true
|
88
|
+
},
|
89
|
+
{
|
90
|
+
"name": "端午节",
|
91
|
+
"date": "2017-05-27",
|
92
|
+
"isOffDay": false
|
93
|
+
},
|
94
|
+
{
|
95
|
+
"name": "端午节",
|
96
|
+
"date": "2017-05-28",
|
97
|
+
"isOffDay": true
|
98
|
+
},
|
99
|
+
{
|
100
|
+
"name": "端午节",
|
101
|
+
"date": "2017-05-29",
|
102
|
+
"isOffDay": true
|
103
|
+
},
|
104
|
+
{
|
105
|
+
"name": "端午节",
|
106
|
+
"date": "2017-05-30",
|
107
|
+
"isOffDay": true
|
108
|
+
},
|
109
|
+
{
|
110
|
+
"name": "中秋节、国庆节",
|
111
|
+
"date": "2017-09-30",
|
112
|
+
"isOffDay": false
|
113
|
+
},
|
114
|
+
{
|
115
|
+
"name": "中秋节、国庆节",
|
116
|
+
"date": "2017-10-01",
|
117
|
+
"isOffDay": true
|
118
|
+
},
|
119
|
+
{
|
120
|
+
"name": "中秋节、国庆节",
|
121
|
+
"date": "2017-10-02",
|
122
|
+
"isOffDay": true
|
123
|
+
},
|
124
|
+
{
|
125
|
+
"name": "中秋节、国庆节",
|
126
|
+
"date": "2017-10-03",
|
127
|
+
"isOffDay": true
|
128
|
+
},
|
129
|
+
{
|
130
|
+
"name": "中秋节、国庆节",
|
131
|
+
"date": "2017-10-04",
|
132
|
+
"isOffDay": true
|
133
|
+
},
|
134
|
+
{
|
135
|
+
"name": "中秋节、国庆节",
|
136
|
+
"date": "2017-10-05",
|
137
|
+
"isOffDay": true
|
138
|
+
},
|
139
|
+
{
|
140
|
+
"name": "中秋节、国庆节",
|
141
|
+
"date": "2017-10-06",
|
142
|
+
"isOffDay": true
|
143
|
+
},
|
144
|
+
{
|
145
|
+
"name": "中秋节、国庆节",
|
146
|
+
"date": "2017-10-07",
|
147
|
+
"isOffDay": true
|
148
|
+
},
|
149
|
+
{
|
150
|
+
"name": "中秋节、国庆节",
|
151
|
+
"date": "2017-10-08",
|
152
|
+
"isOffDay": true
|
153
|
+
}
|
154
|
+
]
|
155
|
+
}
|
data/lib/data/2018.json
ADDED
@@ -0,0 +1,155 @@
|
|
1
|
+
{
|
2
|
+
"$schema": "https://raw.githubusercontent.com/NateScarlet/holiday-cn/master/schema.json",
|
3
|
+
"$id": "https://raw.githubusercontent.com/NateScarlet/holiday-cn/master/2018.json",
|
4
|
+
"year": 2018,
|
5
|
+
"papers": [
|
6
|
+
"http://www.gov.cn/zhengce/content/2017-11/30/content_5243579.htm"
|
7
|
+
],
|
8
|
+
"days": [
|
9
|
+
{
|
10
|
+
"name": "元旦",
|
11
|
+
"date": "2018-01-01",
|
12
|
+
"isOffDay": true
|
13
|
+
},
|
14
|
+
{
|
15
|
+
"name": "春节",
|
16
|
+
"date": "2018-02-11",
|
17
|
+
"isOffDay": false
|
18
|
+
},
|
19
|
+
{
|
20
|
+
"name": "春节",
|
21
|
+
"date": "2018-02-15",
|
22
|
+
"isOffDay": true
|
23
|
+
},
|
24
|
+
{
|
25
|
+
"name": "春节",
|
26
|
+
"date": "2018-02-16",
|
27
|
+
"isOffDay": true
|
28
|
+
},
|
29
|
+
{
|
30
|
+
"name": "春节",
|
31
|
+
"date": "2018-02-17",
|
32
|
+
"isOffDay": true
|
33
|
+
},
|
34
|
+
{
|
35
|
+
"name": "春节",
|
36
|
+
"date": "2018-02-18",
|
37
|
+
"isOffDay": true
|
38
|
+
},
|
39
|
+
{
|
40
|
+
"name": "春节",
|
41
|
+
"date": "2018-02-19",
|
42
|
+
"isOffDay": true
|
43
|
+
},
|
44
|
+
{
|
45
|
+
"name": "春节",
|
46
|
+
"date": "2018-02-20",
|
47
|
+
"isOffDay": true
|
48
|
+
},
|
49
|
+
{
|
50
|
+
"name": "春节",
|
51
|
+
"date": "2018-02-21",
|
52
|
+
"isOffDay": true
|
53
|
+
},
|
54
|
+
{
|
55
|
+
"name": "春节",
|
56
|
+
"date": "2018-02-24",
|
57
|
+
"isOffDay": false
|
58
|
+
},
|
59
|
+
{
|
60
|
+
"name": "清明节",
|
61
|
+
"date": "2018-04-05",
|
62
|
+
"isOffDay": true
|
63
|
+
},
|
64
|
+
{
|
65
|
+
"name": "清明节",
|
66
|
+
"date": "2018-04-06",
|
67
|
+
"isOffDay": true
|
68
|
+
},
|
69
|
+
{
|
70
|
+
"name": "清明节",
|
71
|
+
"date": "2018-04-07",
|
72
|
+
"isOffDay": true
|
73
|
+
},
|
74
|
+
{
|
75
|
+
"name": "清明节",
|
76
|
+
"date": "2018-04-08",
|
77
|
+
"isOffDay": false
|
78
|
+
},
|
79
|
+
{
|
80
|
+
"name": "劳动节",
|
81
|
+
"date": "2018-04-28",
|
82
|
+
"isOffDay": false
|
83
|
+
},
|
84
|
+
{
|
85
|
+
"name": "劳动节",
|
86
|
+
"date": "2018-04-29",
|
87
|
+
"isOffDay": true
|
88
|
+
},
|
89
|
+
{
|
90
|
+
"name": "劳动节",
|
91
|
+
"date": "2018-04-30",
|
92
|
+
"isOffDay": true
|
93
|
+
},
|
94
|
+
{
|
95
|
+
"name": "劳动节",
|
96
|
+
"date": "2018-05-01",
|
97
|
+
"isOffDay": true
|
98
|
+
},
|
99
|
+
{
|
100
|
+
"name": "端午节",
|
101
|
+
"date": "2018-06-18",
|
102
|
+
"isOffDay": true
|
103
|
+
},
|
104
|
+
{
|
105
|
+
"name": "中秋节",
|
106
|
+
"date": "2018-09-24",
|
107
|
+
"isOffDay": true
|
108
|
+
},
|
109
|
+
{
|
110
|
+
"name": "国庆节",
|
111
|
+
"date": "2018-09-29",
|
112
|
+
"isOffDay": false
|
113
|
+
},
|
114
|
+
{
|
115
|
+
"name": "国庆节",
|
116
|
+
"date": "2018-09-30",
|
117
|
+
"isOffDay": false
|
118
|
+
},
|
119
|
+
{
|
120
|
+
"name": "国庆节",
|
121
|
+
"date": "2018-10-01",
|
122
|
+
"isOffDay": true
|
123
|
+
},
|
124
|
+
{
|
125
|
+
"name": "国庆节",
|
126
|
+
"date": "2018-10-02",
|
127
|
+
"isOffDay": true
|
128
|
+
},
|
129
|
+
{
|
130
|
+
"name": "国庆节",
|
131
|
+
"date": "2018-10-03",
|
132
|
+
"isOffDay": true
|
133
|
+
},
|
134
|
+
{
|
135
|
+
"name": "国庆节",
|
136
|
+
"date": "2018-10-04",
|
137
|
+
"isOffDay": true
|
138
|
+
},
|
139
|
+
{
|
140
|
+
"name": "国庆节",
|
141
|
+
"date": "2018-10-05",
|
142
|
+
"isOffDay": true
|
143
|
+
},
|
144
|
+
{
|
145
|
+
"name": "国庆节",
|
146
|
+
"date": "2018-10-06",
|
147
|
+
"isOffDay": true
|
148
|
+
},
|
149
|
+
{
|
150
|
+
"name": "国庆节",
|
151
|
+
"date": "2018-10-07",
|
152
|
+
"isOffDay": true
|
153
|
+
}
|
154
|
+
]
|
155
|
+
}
|
data/lib/helpers/date_helper.rb
CHANGED
@@ -3,14 +3,14 @@ module DateHelper
|
|
3
3
|
::Date.current.year
|
4
4
|
end
|
5
5
|
|
6
|
-
def
|
6
|
+
def adjust_date(date)
|
7
7
|
case date
|
8
8
|
when String
|
9
9
|
date
|
10
10
|
when ::Date, DateTime
|
11
|
-
date
|
11
|
+
format_date(date)
|
12
12
|
when Integer
|
13
|
-
Time.at(date)
|
13
|
+
format_date(Time.at(date))
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
@@ -19,6 +19,6 @@ module DateHelper
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def current_date
|
22
|
-
::Date.current
|
22
|
+
format_date(::Date.current)
|
23
23
|
end
|
24
24
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: calendar_china
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- JohnnyTing
|
@@ -52,6 +52,10 @@ files:
|
|
52
52
|
- lib/calendar_china.rb
|
53
53
|
- lib/calendar_china/methods.rb
|
54
54
|
- lib/calendar_china/version.rb
|
55
|
+
- lib/data/2015.json
|
56
|
+
- lib/data/2016.json
|
57
|
+
- lib/data/2017.json
|
58
|
+
- lib/data/2018.json
|
55
59
|
- lib/data/2019.json
|
56
60
|
- lib/data/2020.json
|
57
61
|
- lib/helpers/date_helper.rb
|