chronic_between 0.2.20 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 8e782325343267b23052adc75dde54165a8961a9
4
- data.tar.gz: aa6118e0926baea1beb55a8cab889a93b1826487
2
+ SHA256:
3
+ metadata.gz: 7e2865012a80e1f1b4a3fcaf61ff9fe58dbc4e78a5a3d0d7b3f11fbfe77c9fc5
4
+ data.tar.gz: 24917faa9f82dd24a0bb77d69ad634a848fd2ab7f591543683c267b07a37cff2
5
5
  SHA512:
6
- metadata.gz: de9153ee83dabd245c10a5f65a0b078bf9618f43bc1b06648a44339b7d9657a5f071af362d7c923d1a6db16ae04d0128d20113826e37c7cfe4526a36ab845889
7
- data.tar.gz: 162ddac873e84971150116ce6ce92c6b9de41a72c1adafd33ceb7dafa4a8a2409591ad6f96b48d04830fe2f83f756bc23ad3ff9425fa4ca0e18535883c851900
6
+ metadata.gz: 8ae97ebee98bd804fb629e19cb43f43b89454524e3c352ad164358c734743f319588d4e29f9f075f633644e3a6278681843956e8e6489246c61b1946493e0f34
7
+ data.tar.gz: 84b766228dbeace64509714a112e470c70b68c139265f3165f0121970ab2be9804324e3ca8a7c2008cb95c364059a6019c3fd77369a176a90808fe85159eb1bf
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -12,13 +12,14 @@ class ChronicBetween
12
12
  def initialize(x)
13
13
 
14
14
  @times = x.is_a?(String) ? x.split(/[,;&]/).map(&:strip) : x
15
- @routes = {}; @params = {}
15
+ super()
16
16
  end
17
17
 
18
18
  def within?(raw_date)
19
19
 
20
20
  date = raw_date.respond_to?(:to_datetime) ? raw_date.to_datetime : raw_date
21
21
  @timezone = date.strftime("%z")
22
+ @params[:timezone] = @timezone
22
23
  @year = date.year
23
24
  dates = []
24
25
 
@@ -88,43 +89,27 @@ class ChronicBetween
88
89
  end
89
90
 
90
91
  # e.g. 3:45-5:15
91
- get %r{^(\d[\w:]*)-(\d[\w:]*)(?=\s*(daily|every day)?)} do
92
+ get %r{^(\d[\w:]*)\s*(?:-|to|and)\s*(\d[\w:]*)(?=\s*(daily|every day)?)} do
92
93
  t1, t2 = params[:captures]
93
94
  time_range(date, t1, t2)
94
95
  end
95
96
 
96
- # e.g. 3:45 to 5:15
97
- get %r{^(\d[\w:]*)\s+to\s+(\d[\w:]*)(?=\s*(daily|every day)?)} do
98
- t1, t2 = params[:captures]
99
- time_range(date, t1, t2)
100
- end
101
97
 
102
98
  # e.g. Mon 3:45-5:15
103
- get %r{^(\w+)\s+(\d[\w:]*)-(\d[\w:]*)$} do
99
+ get %r{^(\w+)\s+(\d[\w:]*)\s*(?:-|to|and)\s*(\d[\w:]*)$} do
104
100
  d1, t1, t2 = params[:captures]
105
101
  cdatetime_range(date, d1, t1, t2)
106
102
  end
107
-
108
- # e.g. Mon 3:45 to 5:15
109
- get %r{^(\w+)\s+(\d[\w:]*)\s+to\s+(\d[\w:]*)$} do
110
- d1, t1, t2 = params[:captures]
111
- cdatetime_range(date, d1, t1, t2)
112
- end
113
-
103
+
114
104
  # e.g. 3:45-5:15 Mon
115
- get %r{^(\d[\w:]*)-(\d[\w:]*)\s+(\w+)$} do
105
+ get %r{^(\d[\w:]*)\s*(?:-|to|and)\s*(\d[\w:]*)\s+(\w+)$} do
116
106
  t1, t2, d1 = params[:captures]
117
107
  cdatetime_range(date, d1, t1, t2)
118
108
  end
119
109
 
120
- # e.g. 3:45 to 5:15 Mon
121
- get %r{^(\d[\w:]*)\s+to\s+(\d[\w:]*)\s+(\w+)$} do
122
- t1, t2, d1 = params[:captures]
123
- cdatetime_range(date, d1, t1, t2)
124
- end
125
110
 
126
111
  # e.g. Mon-Wed
127
- get %r{^(\w+)-(\w+)$} do
112
+ get %r{^(\w+)\s*(?:-|to|and)\s*(\w+)$} do
128
113
  d1, d2 = params[:captures]
129
114
  cdate2, n_days = latest_date_and_ndays(date, d1, d2)
130
115
 
@@ -133,17 +118,17 @@ class ChronicBetween
133
118
  end
134
119
 
135
120
  # e.g. after 6pm
136
- get %r{^after\s+(\d[\w:]*)$} do
121
+ get /^after\s+(\d[\w:]*)$/i do
137
122
  t1 = params[:captures].first
138
- date1 = DateTime.parse(date.strftime("%d-%b-%y ") + t1)
123
+ date1 = DateTime.parse(date.strftime("%d-%b-%y ") + t1 + ' ' + params[:timezone])
139
124
  date2 = DateTime.parse((date + 1).strftime("%d-%b-%y ") + '00:00')
140
125
  [date1, date2]
141
126
  end
142
127
 
143
128
  # e.g. before 9pm
144
- get %r{^before\s+(\d[\w:]*)$} do
129
+ get /^before\s+(\d[\w:]*)$/i do
145
130
  t1 = params[:captures].first
146
- date2 = DateTime.parse(date.strftime("%d-%b-%y ") + t1)
131
+ date2 = DateTime.parse(date.strftime("%d-%b-%y ") + t1 + ' ' + params[:timezone])
147
132
  date1 = DateTime.parse(date.strftime("%d-%b-%y") + ' 00:00')
148
133
  [date1, date2]
149
134
  end
@@ -174,7 +159,8 @@ class ChronicBetween
174
159
  day = params[:captures].first
175
160
  cdate1 = Chronic.parse(day, :now => Time.local(@year))
176
161
  date1 = DateTime.parse(cdate1.strftime("%d-%b-%y") + ' 00:00')
177
- [date1, date1 + 1]
162
+ date2 = DateTime.parse(cdate1.strftime("%d-%b-%y") + ' 23:59:59')
163
+ [date1, date2]
178
164
  end
179
165
 
180
166
  end
@@ -215,4 +201,4 @@ class ChronicBetween
215
201
 
216
202
  alias datetime_range time_range
217
203
 
218
- end
204
+ end
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.20
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -10,57 +10,75 @@ bindir: bin
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
- MIIDRDCCAiygAwIBAgIBADANBgkqhkiG9w0BAQUFADBIMRIwEAYDVQQDDAlnZW1t
14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
28
+ BgkqhkiG9w0BAQsFAAOCAYEAYB9IpIiU4GuRdfRAhm312QppI9QVUhaKdHB+Vaz+
29
+ Lkjm2T+twfrsSysLFzuNQ2DFK82VL7l8MP9rybUPpUgY0EbNbLmzBJQeHjUQJAyb
30
+ 4YSXeAXgsGXi3KXZRKwr76hIsuy+1/lX5SMyfGFrRxeZZbj4kBX2J7ro78zFUCFx
31
+ 755lm8NO/33fxzhoQ1KyooiJE+hWCFfUmKfxdDmj6ufWnTz39O2vTHxLV9ErmyiP
32
+ uVWUHcbLoUUwD9lDzC8sfgywpVK+wMTX3KoIbxWDbLV7T0YYwXPipNNao6YVjg3c
33
+ 6YAndyTrY7nytVYX0phechPNprMvacxKtHvyWPTOY3JxgfW/drVSQfBeQH2Urezn
34
+ qYLkS0jCgesFuRz6AbSvvufxl8sJUwRwoyEy6BGP/iY6TxWq6g7VyuNdHlMwAiZ6
35
+ Ne+ahcHAtwCL3/OPMC7V9VQfw400l8Gx8gnhXY+vg37QXrdjt1Aq6cSlHhdnQJkr
36
+ +UWA0LSKYjup6Y8u3MMD7/Lf
31
37
  -----END CERTIFICATE-----
32
- date: 2013-09-25 00:00:00.000000000 Z
38
+ date: 2020-08-18 00:00:00.000000000 Z
33
39
  dependencies:
34
40
  - !ruby/object:Gem::Dependency
35
41
  name: chronic
36
42
  requirement: !ruby/object:Gem::Requirement
37
43
  requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '0.10'
38
47
  - - ">="
39
48
  - !ruby/object:Gem::Version
40
- version: '0'
49
+ version: 0.10.2
41
50
  type: :runtime
42
51
  prerelease: false
43
52
  version_requirements: !ruby/object:Gem::Requirement
44
53
  requirements:
54
+ - - "~>"
55
+ - !ruby/object:Gem::Version
56
+ version: '0.10'
45
57
  - - ">="
46
58
  - !ruby/object:Gem::Version
47
- version: '0'
59
+ version: 0.10.2
48
60
  - !ruby/object:Gem::Dependency
49
61
  name: app-routes
50
62
  requirement: !ruby/object:Gem::Requirement
51
63
  requirements:
64
+ - - "~>"
65
+ - !ruby/object:Gem::Version
66
+ version: '0.1'
52
67
  - - ">="
53
68
  - !ruby/object:Gem::Version
54
- version: '0'
69
+ version: 0.1.19
55
70
  type: :runtime
56
71
  prerelease: false
57
72
  version_requirements: !ruby/object:Gem::Requirement
58
73
  requirements:
74
+ - - "~>"
75
+ - !ruby/object:Gem::Version
76
+ version: '0.1'
59
77
  - - ">="
60
78
  - !ruby/object:Gem::Version
61
- version: '0'
79
+ version: 0.1.19
62
80
  description:
63
- email: james@r0bertson.co.uk
81
+ email: james@jamesrobertson.eu
64
82
  executables: []
65
83
  extensions: []
66
84
  extra_rdoc_files: []
@@ -78,15 +96,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
78
96
  requirements:
79
97
  - - ">="
80
98
  - !ruby/object:Gem::Version
81
- version: '0'
99
+ version: 2.1.2
82
100
  required_rubygems_version: !ruby/object:Gem::Requirement
83
101
  requirements:
84
102
  - - ">="
85
103
  - !ruby/object:Gem::Version
86
104
  version: '0'
87
105
  requirements: []
88
- rubyforge_project:
89
- rubygems_version: 2.0.0.rc.2
106
+ rubygems_version: 3.0.3
90
107
  signing_key:
91
108
  specification_version: 4
92
109
  summary: chronic_between
metadata.gz.sig CHANGED
Binary file