chronic 0.10.0 → 0.10.1

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: ce57c7b6e3bd50e021abd796f6cdbb4cad313dbc
4
- data.tar.gz: 2ea7a98ce486caf4bbcf394903ee150a920ad888
3
+ metadata.gz: f263bcd5514b460b4cb10a43df35c8892bfd6833
4
+ data.tar.gz: 3a6cff0f27219456cec1b66f77278be4ed73624c
5
5
  SHA512:
6
- metadata.gz: 0737803ebaad62093afbdb8cabece3ec65f0921c174e1a0dc4869fa7c48c539e82bd01834d8ecf3b763e7692016cfc6bbe7893d5650a2ca8cfcd9df98e554012
7
- data.tar.gz: c508780a3ea66dbce11b4351ed546483e30adb6cfa27c5f86dc466132f07447d0e5f13165990d7053d6015277f05464dfc5018f365b40e82e775f3bc7e5e6ba0
6
+ metadata.gz: 6185e7082e304721164dd59a375a6ccecfa2b549a52323a5b438c4703494af2f1a111cd144499f732259392cea9cb33c5fb6251012cb0e1cab5db19449b56125
7
+ data.tar.gz: 1a29549c56f3be9af3ee80131642c340a2efcd801158088ec8ddd631471cd5a01dc8961be4e181e69d705227c5e311875c36b6bd7cee45c9b61b68a6f6e06bea
data/HISTORY.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 0.10.1 / 2013-08-27
2
+
3
+ * Support `ActiveSupport::TimeZone` (#209, #208)
4
+
1
5
  # 0.10.0 / 2013-08-25
2
6
 
3
7
  * Chronic will parse subseconds correctly
@@ -19,4 +19,5 @@ Gem::Specification.new do |s|
19
19
  s.add_development_dependency 'rake'
20
20
  s.add_development_dependency 'simplecov'
21
21
  s.add_development_dependency 'minitest', '~> 5.0'
22
+ s.add_development_dependency 'activesupport'
22
23
  end
@@ -53,7 +53,7 @@ require 'chronic/repeaters/repeater_time'
53
53
  # Chronic.parse('monday', :context => :past)
54
54
  # #=> Mon Aug 21 12:00:00 PDT 2006
55
55
  module Chronic
56
- VERSION = "0.10.0"
56
+ VERSION = "0.10.1"
57
57
 
58
58
  class << self
59
59
 
@@ -137,8 +137,14 @@ module Chronic
137
137
  month = month % 12
138
138
  end
139
139
  end
140
- offset = Time::normalize_offset(offset) if Chronic.time_class.is_a?(DateTime)
141
- Chronic.time_class.new(year, month, day, hour, minute, second, offset)
140
+ if Chronic.time_class.name == "Date"
141
+ Chronic.time_class.new(year, month, day)
142
+ elsif not Chronic.time_class.respond_to?(:new)
143
+ Chronic.time_class.local(year, month, day, hour, minute, second)
144
+ else
145
+ offset = Time::normalize_offset(offset) if Chronic.time_class.name == "DateTime"
146
+ Chronic.time_class.new(year, month, day, hour, minute, second, offset)
147
+ end
142
148
  end
143
149
 
144
150
  end
@@ -129,4 +129,55 @@ class TestChronic < TestCase
129
129
  assert_equal Time.local(2005, 12), Chronic.construct(2000, 72)
130
130
  end
131
131
 
132
+ def test_time
133
+ org = Chronic.time_class
134
+ begin
135
+ Chronic.time_class = ::Time
136
+ assert_equal ::Time.new(2013, 8, 27, 20, 30, 40, '+05:30'), Chronic.construct(2013, 8, 27, 20, 30, 40, '+05:30')
137
+ assert_equal ::Time.new(2013, 8, 27, 20, 30, 40, '-08:00'), Chronic.construct(2013, 8, 27, 20, 30, 40, -28800)
138
+ ensure
139
+ Chronic.time_class = org
140
+ end
141
+ end
142
+
143
+ def test_date
144
+ org = Chronic.time_class
145
+ begin
146
+ Chronic.time_class = ::Date
147
+ assert_equal Date.new(2013, 8, 27), Chronic.construct(2013, 8, 27)
148
+ ensure
149
+ Chronic.time_class = org
150
+ end
151
+ end
152
+
153
+ def test_datetime
154
+ org = Chronic.time_class
155
+ begin
156
+ Chronic.time_class = ::DateTime
157
+ assert_equal DateTime.new(2013, 8, 27, 20, 30, 40, '+05:30'), Chronic.construct(2013, 8, 27, 20, 30, 40, '+05:30')
158
+ assert_equal DateTime.new(2013, 8, 27, 20, 30, 40, '-08:00'), Chronic.construct(2013, 8, 27, 20, 30, 40, -28800)
159
+ ensure
160
+ Chronic.time_class = org
161
+ end
162
+ end
163
+
164
+ def test_activesupport
165
+ =begin
166
+ # ActiveSupport needs MiniTest '~> 4.2' which conflicts with '~> 5.0'
167
+ require 'active_support/time'
168
+ org = Chronic.time_class
169
+ org_zone = ::Time.zone
170
+ begin
171
+ ::Time.zone = "Tokyo"
172
+ Chronic.time_class = ::Time.zone
173
+ assert_equal Time.new(2013, 8, 27, 20, 30, 40, '+09:00'), Chronic.construct(2013, 8, 27, 20, 30, 40)
174
+ ::Time.zone = "Indiana (East)"
175
+ Chronic.time_class = ::Time.zone
176
+ assert_equal Time.new(2013, 8, 27, 20, 30, 40, -14400), Chronic.construct(2013, 8, 27, 20, 30, 40)
177
+ ensure
178
+ Chronic.time_class = org
179
+ ::Time.zone = org_zone
180
+ end
181
+ =end
182
+ end
132
183
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chronic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Preston-Werner
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-25 00:00:00.000000000 Z
12
+ date: 2013-08-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -53,6 +53,20 @@ dependencies:
53
53
  - - ~>
54
54
  - !ruby/object:Gem::Version
55
55
  version: '5.0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: activesupport
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
56
70
  description: Chronic is a natural language date/time parser written in pure Ruby.
57
71
  email:
58
72
  - tom@mojombo.com