chronic_between 0.2.16 → 0.2.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +1 -1
- data/lib/chronic_between.rb +8 -7
- data.tar.gz.sig +0 -0
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6dfb37c01093fbbf536e29073a9725e675a1a0f6
|
4
|
+
data.tar.gz: 63b9063fe483ea098d27163049a69c4304408a2e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f816539494c46ee60120445e9a28a4de321d6532f06c1b60a6d65365b70329c17427bbe43ae0873022a3c1eca04b831c0173f55a6842a4f84d54ef7b49b32aaf
|
7
|
+
data.tar.gz: a4f7b4a864b7134b806b827a662acdf0ae929ca3f98a4db72132f98f708daf27d6853ed0692731da0b6b53821e1df0754d427bcefc12b09bb190152c8480c01d
|
checksums.yaml.gz.sig
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
��}v���Cэ� �^�5��k:* ��TfH�n�v�V/Ȧ��:�K����s�d]dȟΏ�d.%�T�d��U�֞ߚ��m`K�����|q+�g��'�4m�cV���0�0q�@�P��*���D�`���H7��S۬�*�����7ʙ�~�ʌ\&�F�)$�U�����XIx�ni�:K����4:��`��. �p>�{9�?������&�5)Ks��e���\�vHRH+lES���@!?��8��
|
data/lib/chronic_between.rb
CHANGED
@@ -6,7 +6,6 @@ require 'chronic'
|
|
6
6
|
require 'date'
|
7
7
|
require 'app-routes'
|
8
8
|
|
9
|
-
|
10
9
|
class ChronicBetween
|
11
10
|
include AppRoutes
|
12
11
|
|
@@ -19,6 +18,8 @@ class ChronicBetween
|
|
19
18
|
def within?(raw_date)
|
20
19
|
|
21
20
|
date = raw_date.respond_to?(:to_datetime) ? raw_date.to_datetime : raw_date
|
21
|
+
@timezone = date.strftime("%z")
|
22
|
+
@year = date.year
|
22
23
|
dates = []
|
23
24
|
|
24
25
|
ranges(@params, date)
|
@@ -145,7 +146,7 @@ class ChronicBetween
|
|
145
146
|
# e.g. April 2nd - April 5th 12:00-14:00
|
146
147
|
get %r{^(.*)\s+-\s+(.*)\s+(\d[\w:]*)-(\d[\w:]*)$} do
|
147
148
|
d1, d2, t1, t2 = params[:captures]
|
148
|
-
cdate1, cdate2 = [d1,d2].map {|d| Chronic.parse(d)}
|
149
|
+
cdate1, cdate2 = [d1,d2].map {|d| Chronic.parse(d, :now => Time.local(@year))}
|
149
150
|
n_days = ((cdate2 - cdate1) / 86400).to_i
|
150
151
|
dates = 0.upto(n_days).map do |n|
|
151
152
|
x = cdate1.to_datetime + n
|
@@ -156,7 +157,7 @@ class ChronicBetween
|
|
156
157
|
# e.g. April 5th - April 9th
|
157
158
|
get %r{^(.*)\s+-\s+(.*)$} do
|
158
159
|
d1, d2 = params[:captures]
|
159
|
-
cdate1, cdate2 = [d1,d2].map {|d| Chronic.parse(d)}
|
160
|
+
cdate1, cdate2 = [d1,d2].map {|d| Chronic.parse(d, :now => Time.local(@year))}
|
160
161
|
n_days = ((cdate2 - cdate1) / 86400).to_i
|
161
162
|
|
162
163
|
date1 = DateTime.parse(cdate1.strftime("%d-%b-%y") + ' 00:00')
|
@@ -166,7 +167,7 @@ class ChronicBetween
|
|
166
167
|
# e.g. April 5th
|
167
168
|
get %r{^(.*)$} do
|
168
169
|
day = params[:captures].first
|
169
|
-
cdate1 = Chronic.parse(day)
|
170
|
+
cdate1 = Chronic.parse(day, :now => Time.local(@year))
|
170
171
|
date1 = DateTime.parse(cdate1.strftime("%d-%b-%y") + ' 00:00')
|
171
172
|
[date1, date1 + 1]
|
172
173
|
end
|
@@ -195,7 +196,7 @@ class ChronicBetween
|
|
195
196
|
end
|
196
197
|
|
197
198
|
def latest_date_and_ndays(date, d1, d2)
|
198
|
-
raw_date1 = Chronic.parse(d1, :context => :past)
|
199
|
+
raw_date1 = Chronic.parse(d1, :context => :past, :now => Time.local(@year))
|
199
200
|
raw_date2 = Chronic.parse(d2, :now => raw_date1)
|
200
201
|
cdate2 = Chronic.parse(d2, now: (date - 1))
|
201
202
|
n_days = ((raw_date2 - raw_date1) / 86400).to_i
|
@@ -203,8 +204,8 @@ class ChronicBetween
|
|
203
204
|
[cdate2, n_days]
|
204
205
|
end
|
205
206
|
|
206
|
-
def time_range(date, t1, t2)
|
207
|
-
[t1,t2].map {|t| DateTime.parse(date.strftime("%d-%b-%y ") + t)}
|
207
|
+
def time_range(date, t1, t2)
|
208
|
+
[t1,t2].map {|t| DateTime.parse(date.strftime("%d-%b-%y ") + t + @timezone )}
|
208
209
|
end
|
209
210
|
|
210
211
|
alias datetime_range time_range
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chronic_between
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -29,7 +29,7 @@ cert_chain:
|
|
29
29
|
aQjggWe+thx9aRnac+FunPZ7ltAgjkOreOsrc0fCXFmRlvDjbnCNBvpi4PhfHXzh
|
30
30
|
VK9OMDms3W3rq/ODn7ohj8ao4ZtQdcvF
|
31
31
|
-----END CERTIFICATE-----
|
32
|
-
date: 2013-05-
|
32
|
+
date: 2013-05-17 00:00:00.000000000 Z
|
33
33
|
dependencies:
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
35
|
name: chronic
|
metadata.gz.sig
CHANGED
Binary file
|