retail_calendar 1.0.2 → 1.1.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 +63 -3
- data/lib/retail_calendar/finder.rb +30 -0
- data/lib/retail_calendar/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca733d61f3c24273b3e501b1bffdd72aa0fd71d5
|
4
|
+
data.tar.gz: 360a51716c8f86ebf5e67a735d0a83c6de377196
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b9190b7403a5a464c76aed51343bdeb61c8bc6e671ec1b477ad9cfb3ea4dd58318bdff3131b476392ea008363788f30ef12387b48058e67b1f1562df11febe21
|
7
|
+
data.tar.gz: 2881df23558f2eeffaad593cb353fb1ef0f7b5cda25e13c438f489c4024dc646c7f37eaf10f0385bdd3c5df0e214be6f2c68e355594287c4c18096e3e067a80d
|
data/README.md
CHANGED
@@ -33,7 +33,7 @@ Or install it yourself as:
|
|
33
33
|
|
34
34
|
Instantiate RetailCalendar::Finder object to get start and end dates for weeks/periods(months)/quarters/seasons/years
|
35
35
|
|
36
|
-
```
|
36
|
+
```ruby
|
37
37
|
> cal = RetailCalendar::Finder.new
|
38
38
|
=> #<RetailCalendar::Finder:0x00000102125a40 @offset="+0000">
|
39
39
|
```
|
@@ -47,7 +47,7 @@ Instantiate with time zone
|
|
47
47
|
|
48
48
|
### Functions
|
49
49
|
|
50
|
-
```
|
50
|
+
```ruby
|
51
51
|
> res = cal.week(2014, 1, 1)
|
52
52
|
=> #<Dish::Plate:0x0000010214e6c0
|
53
53
|
@_original_hash=
|
@@ -83,11 +83,71 @@ Instantiate with time zone
|
|
83
83
|
@_original_hash=
|
84
84
|
{"start_date"=>Sun, 02 Feb 2014 00:00:00 +0000,
|
85
85
|
"end_date"=>Sat, 31 Jan 2015 00:00:00 +0000}>
|
86
|
+
|
87
|
+
> res = cal.this_week
|
88
|
+
=> #<Dish::Plate:0x000001024bc230
|
89
|
+
@_original_hash=
|
90
|
+
{"start_date"=>Sun, 01 Jun 2014 00:00:00 +0000,
|
91
|
+
"end_date"=>Sat, 07 Jun 2014 00:00:00 +0000}>
|
92
|
+
|
93
|
+
> res = cal.this_period
|
94
|
+
=> #<Dish::Plate:0x000001011b0678
|
95
|
+
@_original_hash=
|
96
|
+
{"start_date"=>Sun, 01 Jun 2014 00:00:00 +0000,
|
97
|
+
"end_date"=>Sat, 05 Jul 2014 00:00:00 +0000}>
|
98
|
+
|
99
|
+
> res = cal.this_quarter
|
100
|
+
=> #<Dish::Plate:0x000001012a3b20
|
101
|
+
@_original_hash=
|
102
|
+
{"start_date"=>Sun, 04 May 2014 00:00:00 +0000,
|
103
|
+
"end_date"=>Sat, 02 Aug 2014 00:00:00 +0000}>
|
104
|
+
|
105
|
+
> res = cal.this_season
|
106
|
+
=> #<Dish::Plate:0x00000101313790
|
107
|
+
@_original_hash=
|
108
|
+
{"start_date"=>Sun, 02 Feb 2014 00:00:00 +0000,
|
109
|
+
"end_date"=>Sat, 02 Aug 2014 00:00:00 +0000}>
|
110
|
+
|
111
|
+
> res = cal.this_year
|
112
|
+
=> #<Dish::Plate:0x00000101378c30
|
113
|
+
@_original_hash=
|
114
|
+
{"start_date"=>Sun, 02 Feb 2014 00:00:00 +0000,
|
115
|
+
"end_date"=>Sat, 31 Jan 2015 00:00:00 +0000}>
|
116
|
+
|
117
|
+
> res = cal.last_week
|
118
|
+
=> #<Dish::Plate:0x000001013ebdc0
|
119
|
+
@_original_hash=
|
120
|
+
{"start_date"=>Sun, 25 May 2014 00:00:00 +0000,
|
121
|
+
"end_date"=>Sat, 31 May 2014 00:00:00 +0000}>
|
122
|
+
|
123
|
+
> res = cal.last_period
|
124
|
+
=> #<Dish::Plate:0x0000010142a020
|
125
|
+
@_original_hash=
|
126
|
+
{"start_date"=>Sun, 04 May 2014 00:00:00 +0000,
|
127
|
+
"end_date"=>Sat, 31 May 2014 00:00:00 +0000}>
|
128
|
+
|
129
|
+
> res = cal.last_quarter
|
130
|
+
=> #<Dish::Plate:0x00000101483440
|
131
|
+
@_original_hash=
|
132
|
+
{"start_date"=>Sun, 02 Feb 2014 00:00:00 +0000,
|
133
|
+
"end_date"=>Sat, 03 May 2014 00:00:00 +0000}>
|
134
|
+
|
135
|
+
> res = cal.last_season
|
136
|
+
=> #<Dish::Plate:0x000001014db3c0
|
137
|
+
@_original_hash=
|
138
|
+
{"start_date"=>Sun, 04 Aug 2013 00:00:00 +0000,
|
139
|
+
"end_date"=>Sat, 01 Feb 2014 00:00:00 +0000}>
|
140
|
+
|
141
|
+
> res = cal.last_year
|
142
|
+
=> #<Dish::Plate:0x00000101529a20
|
143
|
+
@_original_hash=
|
144
|
+
{"start_date"=>Sun, 03 Feb 2013 00:00:00 +0000,
|
145
|
+
"end_date"=>Sat, 01 Feb 2014 00:00:00 +0000}>
|
86
146
|
```
|
87
147
|
|
88
148
|
Handles Retail Leap years
|
89
149
|
|
90
|
-
```
|
150
|
+
```ruby
|
91
151
|
> res = cal.year(2006)
|
92
152
|
=> #<Dish::Plate:0x00000101979558
|
93
153
|
@_original_hash=
|
@@ -75,6 +75,11 @@ module RetailCalendar
|
|
75
75
|
year(previous_year)
|
76
76
|
end
|
77
77
|
|
78
|
+
def this_year
|
79
|
+
previous_year = DateTime.now.change(:offset => @offset).year
|
80
|
+
year(previous_year)
|
81
|
+
end
|
82
|
+
|
78
83
|
def last_season
|
79
84
|
current_year = DateTime.now.change(:offset => @offset).year
|
80
85
|
current_season = get_current_season
|
@@ -88,6 +93,12 @@ module RetailCalendar
|
|
88
93
|
season(previous_year, previous_season)
|
89
94
|
end
|
90
95
|
|
96
|
+
def this_season
|
97
|
+
current_year = DateTime.now.change(:offset => @offset).year
|
98
|
+
current_season = get_current_season
|
99
|
+
season(current_year, current_season)
|
100
|
+
end
|
101
|
+
|
91
102
|
def last_quarter
|
92
103
|
current_year = DateTime.now.change(:offset => @offset).year
|
93
104
|
current_quarter = get_current_quarter
|
@@ -101,6 +112,12 @@ module RetailCalendar
|
|
101
112
|
quarter(previous_year, previous_quarter)
|
102
113
|
end
|
103
114
|
|
115
|
+
def this_quarter
|
116
|
+
current_year = DateTime.now.change(:offset => @offset).year
|
117
|
+
current_quarter = get_current_quarter
|
118
|
+
quarter(current_year, current_quarter)
|
119
|
+
end
|
120
|
+
|
104
121
|
def last_period
|
105
122
|
current_year = DateTime.now.change(:offset => @offset).year
|
106
123
|
current_period = get_current_period
|
@@ -114,6 +131,12 @@ module RetailCalendar
|
|
114
131
|
period(previous_year, previous_period)
|
115
132
|
end
|
116
133
|
|
134
|
+
def this_period
|
135
|
+
current_year = DateTime.now.change(:offset => @offset).year
|
136
|
+
current_period = get_current_period
|
137
|
+
period(current_year, current_period)
|
138
|
+
end
|
139
|
+
|
117
140
|
def last_week
|
118
141
|
start_date = DateTime.now.change(:offset => @offset) - 1.week
|
119
142
|
start_date = start_date.beginning_of_week(start_day = :sunday)
|
@@ -121,6 +144,13 @@ module RetailCalendar
|
|
121
144
|
create_return_object(start_date,end_date)
|
122
145
|
end
|
123
146
|
|
147
|
+
def this_week
|
148
|
+
start_date = DateTime.now.change(:offset => @offset)
|
149
|
+
start_date = start_date.beginning_of_week(start_day = :sunday)
|
150
|
+
end_date = start_date + 1.week - 1
|
151
|
+
create_return_object(start_date,end_date)
|
152
|
+
end
|
153
|
+
|
124
154
|
private
|
125
155
|
|
126
156
|
def get_current_season
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: retail_calendar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aditya Raghuwanshi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-06-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|