chronic_between 0.2.21 → 0.5.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: f3d968ce9b2f81737fb89d9d5d1724e4d86d2bcd
4
- data.tar.gz: ad2fb0eee29e9de621c73a2e5d7709d8417c7278
2
+ SHA256:
3
+ metadata.gz: cd466f4f19e9f874988e0329cf2a23e65dae616e89a43cc6adc96fbb226c7f4a
4
+ data.tar.gz: a73e8db3600949810dcc188a1b93f38dea023a4b1af71149e507462dad63d860
5
5
  SHA512:
6
- metadata.gz: 962205a48171d76ec5bcf0a07a22bdf21972de0d2e1b45b5c4b5cedcdb76edc1962de6ad019a63e7d5bc843e289678dcd9082b2567d936965fdf3ba252cda9a7
7
- data.tar.gz: efbcd8fd96296877cbd93d0fd95f55cb61208d46535828c64846bd3c36bd4ac91bb317bb7b05e47d3ab3265549b3c49ec27a52da3579f5c22744244cb14c2bc4
6
+ metadata.gz: dcff7e1534de947ebecf54b4f99bd4ae256e58010e25ddc403329af1369c72c79d9637d516f02a7572912bc84d643feee078d830bf7b32ccba33b21696181ab5
7
+ data.tar.gz: 0e84a667249e165e9a59a82b12bead1d1e08e8c3e216988fc4f0a9122fbcb09f27db1244e6fd0d534ab039c4cf5b0bb4936262c48e15f8bb46fc14a4ec0edffb
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -9,8 +9,9 @@ require 'app-routes'
9
9
  class ChronicBetween
10
10
  include AppRoutes
11
11
 
12
- def initialize(x)
12
+ def initialize(x, debug: false)
13
13
 
14
+ @debug = debug
14
15
  @times = x.is_a?(String) ? x.split(/[,;&]/).map(&:strip) : x
15
16
  super()
16
17
  end
@@ -19,6 +20,7 @@ class ChronicBetween
19
20
 
20
21
  date = raw_date.respond_to?(:to_datetime) ? raw_date.to_datetime : raw_date
21
22
  @timezone = date.strftime("%z")
23
+ @params[:timezone] = @timezone
22
24
  @year = date.year
23
25
  dates = []
24
26
 
@@ -88,43 +90,27 @@ class ChronicBetween
88
90
  end
89
91
 
90
92
  # e.g. 3:45-5:15
91
- get %r{^(\d[\w:]*)-(\d[\w:]*)(?=\s*(daily|every day)?)} do
93
+ get %r{^(\d[\w:]*)\s*(?:-|to|and)\s*(\d[\w:]*)(?=\s*(daily|every day)?)} do
92
94
  t1, t2 = params[:captures]
93
95
  time_range(date, t1, t2)
94
96
  end
95
97
 
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
98
 
102
99
  # e.g. Mon 3:45-5:15
103
- get %r{^(\w+)\s+(\d[\w:]*)-(\d[\w:]*)$} do
100
+ get %r{^(\w+)\s+(\d[\w:]*)\s*(?:-|to|and)\s*(\d[\w:]*)$} do
104
101
  d1, t1, t2 = params[:captures]
105
102
  cdatetime_range(date, d1, t1, t2)
106
103
  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
-
104
+
114
105
  # e.g. 3:45-5:15 Mon
115
- get %r{^(\d[\w:]*)-(\d[\w:]*)\s+(\w+)$} do
106
+ get %r{^(\d[\w:]*)\s*(?:-|to|and)\s*(\d[\w:]*)\s+(\w+)$} do
116
107
  t1, t2, d1 = params[:captures]
117
108
  cdatetime_range(date, d1, t1, t2)
118
109
  end
119
110
 
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
111
 
126
112
  # e.g. Mon-Wed
127
- get %r{^(\w+)-(\w+)$} do
113
+ get %r{^(\w+)\s*(?:-|to|and)\s*(\w+)$} do
128
114
  d1, d2 = params[:captures]
129
115
  cdate2, n_days = latest_date_and_ndays(date, d1, d2)
130
116
 
@@ -133,17 +119,17 @@ class ChronicBetween
133
119
  end
134
120
 
135
121
  # e.g. after 6pm
136
- get %r{^after\s+(\d[\w:]*)$} do
122
+ get /^after\s+(\d[\w:]*)$/i do
137
123
  t1 = params[:captures].first
138
- date1 = DateTime.parse(date.strftime("%d-%b-%y ") + t1)
124
+ date1 = DateTime.parse(date.strftime("%d-%b-%y ") + t1 + ' ' + params[:timezone])
139
125
  date2 = DateTime.parse((date + 1).strftime("%d-%b-%y ") + '00:00')
140
126
  [date1, date2]
141
127
  end
142
128
 
143
129
  # e.g. before 9pm
144
- get %r{^before\s+(\d[\w:]*)$} do
130
+ get /^before\s+(\d[\w:]*)$/i do
145
131
  t1 = params[:captures].first
146
- date2 = DateTime.parse(date.strftime("%d-%b-%y ") + t1)
132
+ date2 = DateTime.parse(date.strftime("%d-%b-%y ") + t1 + ' ' + params[:timezone])
147
133
  date1 = DateTime.parse(date.strftime("%d-%b-%y") + ' 00:00')
148
134
  [date1, date2]
149
135
  end
@@ -161,12 +147,15 @@ class ChronicBetween
161
147
 
162
148
  # e.g. April 5th - April 9th
163
149
  get %r{^(.*)\s+-\s+(.*)$} do
150
+
151
+ puts 'route 600' if @debug
164
152
  d1, d2 = params[:captures]
165
153
  cdate1, cdate2 = [d1,d2].map {|d| Chronic.parse(d, :now => Time.local(@year))}
166
154
  n_days = ((cdate2 - cdate1) / 86400).to_i
167
155
 
168
156
  date1 = DateTime.parse(cdate1.strftime("%d-%b-%y") + ' 00:00')
169
- [date1, date1 + n_days + 1]
157
+ date2 = DateTime.parse(cdate1.strftime("%d-%b-%y") + ' 23:59:59')
158
+ [date1, date2 + n_days]
170
159
  end
171
160
 
172
161
  # e.g. April 5th
@@ -174,12 +163,14 @@ class ChronicBetween
174
163
  day = params[:captures].first
175
164
  cdate1 = Chronic.parse(day, :now => Time.local(@year))
176
165
  date1 = DateTime.parse(cdate1.strftime("%d-%b-%y") + ' 00:00')
177
- [date1, date1 + 1]
166
+ date2 = DateTime.parse(cdate1.strftime("%d-%b-%y") + ' 23:59:59')
167
+ [date1, date2]
178
168
  end
179
169
 
180
170
  end
181
171
 
182
172
  def build(times)
173
+
183
174
  times.inject([]) do |result, x|
184
175
  r = run_route(x.strip)
185
176
  r.first.is_a?(Array) ? result + r : result << r
@@ -215,4 +206,4 @@ class ChronicBetween
215
206
 
216
207
  alias datetime_range time_range
217
208
 
218
- end
209
+ 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.21
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -10,59 +10,75 @@ bindir: bin
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
- MIIDljCCAn6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBIMRIwEAYDVQQDDAlnZW1t
14
- YXN0ZXIxHjAcBgoJkiaJk/IsZAEZFg5qYW1lc3JvYmVydHNvbjESMBAGCgmSJomT
15
- 8ixkARkWAmV1MB4XDTE0MDIyMjIyNDYyMFoXDTE1MDIyMjIyNDYyMFowSDESMBAG
16
- A1UEAwwJZ2VtbWFzdGVyMR4wHAYKCZImiZPyLGQBGRYOamFtZXNyb2JlcnRzb24x
17
- EjAQBgoJkiaJk/IsZAEZFgJldTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
18
- ggEBAO+p5KofHi+Ouh5y5nvDf+D6IybatY/ZMGPKRRYlfdK6p3yWe2HpGJfvsI10
19
- zwynkn77MNBwoubvZs6MktrDnD6pKndXyRL9mo7LNEFdy7JESnEqwnMCdenkvYaq
20
- aOz3V/p9k6p58qmJSWRci4md782oWikXkpZpOEXNIw7JktlnEwrzvBm9L/p4UjMc
21
- fnkRYOBPoPuAmf22zk8JUuT/BLcIcsdzbIxmr8bi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KtHvyWPTOY3JxgfW/drVSQfBeQH2Urezn
34
+ qYLkS0jCgesFuRz6AbSvvufxl8sJUwRwoyEy6BGP/iY6TxWq6g7VyuNdHlMwAiZ6
35
+ Ne+ahcHAtwCL3/OPMC7V9VQfw400l8Gx8gnhXY+vg37QXrdjt1Aq6cSlHhdnQJkr
36
+ +UWA0LSKYjup6Y8u3MMD7/Lf
33
37
  -----END CERTIFICATE-----
34
- date: 2014-02-22 00:00:00.000000000 Z
38
+ date: 2021-06-20 00:00:00.000000000 Z
35
39
  dependencies:
36
40
  - !ruby/object:Gem::Dependency
37
41
  name: chronic
38
42
  requirement: !ruby/object:Gem::Requirement
39
43
  requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '0.10'
40
47
  - - ">="
41
48
  - !ruby/object:Gem::Version
42
- version: '0'
49
+ version: 0.10.2
43
50
  type: :runtime
44
51
  prerelease: false
45
52
  version_requirements: !ruby/object:Gem::Requirement
46
53
  requirements:
54
+ - - "~>"
55
+ - !ruby/object:Gem::Version
56
+ version: '0.10'
47
57
  - - ">="
48
58
  - !ruby/object:Gem::Version
49
- version: '0'
59
+ version: 0.10.2
50
60
  - !ruby/object:Gem::Dependency
51
61
  name: app-routes
52
62
  requirement: !ruby/object:Gem::Requirement
53
63
  requirements:
64
+ - - "~>"
65
+ - !ruby/object:Gem::Version
66
+ version: '0.1'
54
67
  - - ">="
55
68
  - !ruby/object:Gem::Version
56
- version: '0'
69
+ version: 0.1.19
57
70
  type: :runtime
58
71
  prerelease: false
59
72
  version_requirements: !ruby/object:Gem::Requirement
60
73
  requirements:
74
+ - - "~>"
75
+ - !ruby/object:Gem::Version
76
+ version: '0.1'
61
77
  - - ">="
62
78
  - !ruby/object:Gem::Version
63
- version: '0'
79
+ version: 0.1.19
64
80
  description:
65
- email: james@r0bertson.co.uk
81
+ email: digital.robertson@gmail.com
66
82
  executables: []
67
83
  extensions: []
68
84
  extra_rdoc_files: []
@@ -80,15 +96,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
80
96
  requirements:
81
97
  - - ">="
82
98
  - !ruby/object:Gem::Version
83
- version: '0'
99
+ version: 2.1.2
84
100
  required_rubygems_version: !ruby/object:Gem::Requirement
85
101
  requirements:
86
102
  - - ">="
87
103
  - !ruby/object:Gem::Version
88
104
  version: '0'
89
105
  requirements: []
90
- rubyforge_project:
91
- rubygems_version: 2.1.11
106
+ rubygems_version: 3.1.2
92
107
  signing_key:
93
108
  specification_version: 4
94
109
  summary: chronic_between
metadata.gz.sig CHANGED
Binary file