calendar_sniper 1.1.2 → 1.1.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 46126c0af90cff973cbb7e9393ef8232c9d43a39
4
- data.tar.gz: ecd1295c52212d5584aa0686a410e1dbc35685e4
3
+ metadata.gz: 620db522bc24dac549356ead4886806f513ec873
4
+ data.tar.gz: ab877c11ec5f74df80004f8351360f3c5e5f7e47
5
5
  SHA512:
6
- metadata.gz: 7c1a1f57a175d340410d2faabdbbd7032d7360ecc1dbdb12263f2e1723fc4f02ed8d29ff0e583a2c713615f984a46f8d216432ff6620f70d6cab04870e3153e2
7
- data.tar.gz: 39d6f6a4a8b5e68157fbef67fd460bb015a2c872f1ef74e9d41e49a1b136ab39b6a8c4c704655e74e1089e7004181028e64268f096552712d04395c0d4ac1261
6
+ metadata.gz: b6362d151b7242c9ecbe24b6d169c77d23dfe5bf7e1a08d534c605acd1a1021c6133cce655aafb68834023f452909290d63052b13ed6d8ba5f73a8598bcbdd8d
7
+ data.tar.gz: 5f28470515faa64047cc812cbb34ae7711e26cd3410657ec103e04b0789ca4296753db537759f642169b53aa29c38ab1f70dde94b55eac5adb5b149ac10d8fca
@@ -1,5 +1,8 @@
1
1
  require "calendar_sniper/version"
2
2
  require 'active_support'
3
+ require 'active_support/core_ext/date'
4
+ require 'active_support/core_ext/date_time'
5
+ require 'active_support/core_ext/time'
3
6
 
4
7
  module CalendarSniper
5
8
  extend ActiveSupport::Concern
@@ -36,7 +39,7 @@ module CalendarSniper
36
39
 
37
40
  def coalesce_date(from_date_or_string, by_direction)
38
41
  if from_date_or_string.is_a?(String)
39
- date_from_string = DateTime.strptime(from_date_or_string, date_format_for_string(from_date_or_string))
42
+ date_from_string = Time.strptime(from_date_or_string, date_format_for_string(from_date_or_string))
40
43
  set_time_for_direction(date_from_string, by_direction)
41
44
  else
42
45
  set_time_for_direction(from_date_or_string, by_direction)
@@ -1,3 +1,3 @@
1
1
  module CalendarSniper
2
- VERSION = "1.1.2"
2
+ VERSION = "1.1.3"
3
3
  end
data/spec/parsing_spec.rb CHANGED
@@ -15,7 +15,23 @@ describe CalendarSniper::ClassMethods do
15
15
  [ '%Y-%m-%d %l:%M:%S%z', '2013-01-01 2:50:00-0400']
16
16
  ].each do |format, example|
17
17
  it "can parse #{example} as #{format}" do
18
- expect(TestSniper.send(:coalesce_date, example, '=')).to eq(DateTime.strptime(example, format))
18
+ expect(TestSniper.send(:coalesce_date, example, '=')).to eq(Time.strptime(example, format))
19
+ end
20
+ end
21
+
22
+ it 'Uses the default time zone for greater than' do
23
+ Time.use_zone('Eastern Time (US & Canada)') do
24
+ dt = TestSniper.send(:coalesce_date, '1/01/2013', :>)
25
+ expect(dt.zone).to eq('EST')
26
+ expect(dt.strftime('%Y-%m-%d %H:%M:%S%z')).to eq('2013-01-01 00:00:00-0500')
27
+ end
28
+ end
29
+
30
+ it 'Uses the default time zone for less than' do
31
+ Time.use_zone('Eastern Time (US & Canada)') do
32
+ dt = TestSniper.send(:coalesce_date, '1/01/2013', :<)
33
+ expect(dt.zone).to eq('EST')
34
+ expect(dt.strftime('%Y-%m-%d %H:%M:%S%z')).to eq('2013-01-01 23:59:59-0500')
19
35
  end
20
36
  end
21
37
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: calendar_sniper
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris MacNaughton