kronos 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +14 -14
- data/VERSION +1 -1
- data/kronos.gemspec +4 -4
- data/lib/kronos.rb +2 -2
- data/spec/to_s_spec.rb +4 -4
- metadata +11 -4
data/README.md
CHANGED
@@ -61,13 +61,13 @@ Kronos handles date-related comparisons more intelligently.
|
|
61
61
|
|
62
62
|
Many Ruby date libraries make the assumption that you are specifying a point (i.e. a particular date), not an interval (such as an entire month or year). Kronos, on the other hand, lets you specify dates that are intervals:
|
63
63
|
|
64
|
-
|
65
|
-
|
66
|
-
|
64
|
+
k_1973 = Kronos.parse("1973")
|
65
|
+
k_1974 = Kronos.parse("1974")
|
66
|
+
k_march_1974 = Kronos.parse("March 1974")
|
67
67
|
|
68
68
|
With Kronos, you can compare date objects as follows:
|
69
69
|
|
70
|
-
|
70
|
+
k_1973 < k_1974 # => true
|
71
71
|
k_1973 < k_march_1974 # => true
|
72
72
|
|
73
73
|
### A Note about Kronos Comparison Operators
|
@@ -78,17 +78,17 @@ Here's an example. If you ask "Does the year 1974 come before March 1974?" a car
|
|
78
78
|
|
79
79
|
Because of this, Konos comparison operators (`<`, `==`, `>`) behave a little bit differently for Kronos objects than for, say, integers. Given any two integers m and n, you can be sure that one of the operators holds. For example:
|
80
80
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
81
|
+
m = 1
|
82
|
+
n = 2
|
83
|
+
m < n # => true
|
84
|
+
m == n # => false
|
85
|
+
m > n # => false
|
86
86
|
|
87
87
|
However, given two Kronos objects k1 and k2 you cannot guarantee that one of the operators will hold. For example:
|
88
88
|
|
89
89
|
k_1974 < k_march_1974 # => false
|
90
90
|
k_1973 == k_march_1974 # => false
|
91
|
-
|
91
|
+
k_1974 > k_march_1974 # => false
|
92
92
|
|
93
93
|
Since the two dates are unequal but overlap, Kronos will always return false.
|
94
94
|
|
@@ -96,8 +96,8 @@ Since the two dates are unequal but overlap, Kronos will always return false.
|
|
96
96
|
|
97
97
|
I plan to implement the `in?` method as follows:
|
98
98
|
|
99
|
-
|
100
|
-
|
99
|
+
k_march_1974.in?(k_1974) # => true
|
100
|
+
k_1974.in?(k_march_1974) # => false
|
101
101
|
|
102
102
|
## History
|
103
103
|
|
@@ -105,8 +105,8 @@ We import a lot of data from government Web sites as part of our work at the Sun
|
|
105
105
|
|
106
106
|
## Contributors
|
107
107
|
|
108
|
-
David James (djsun)
|
109
|
-
Eric Mill (klondike)
|
108
|
+
* David James (djsun)
|
109
|
+
* Eric Mill (klondike)
|
110
110
|
|
111
111
|
## Feedback
|
112
112
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.8
|
data/kronos.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{kronos}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.8"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["David James"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-10-17}
|
13
13
|
s.description = %q{Kronos provides flexible date parsing. Currently just a thin layer on top of ParseDate.}
|
14
14
|
s.email = %q{djames@sunlightfoundation.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -36,7 +36,7 @@ Gem::Specification.new do |s|
|
|
36
36
|
s.homepage = %q{http://github.com/djsun/kronos}
|
37
37
|
s.rdoc_options = ["--charset=UTF-8"]
|
38
38
|
s.require_paths = ["lib"]
|
39
|
-
s.rubygems_version = %q{1.3.
|
39
|
+
s.rubygems_version = %q{1.3.7}
|
40
40
|
s.summary = %q{Simple and flexible date parsing.}
|
41
41
|
s.test_files = [
|
42
42
|
"spec/compare_spec.rb",
|
@@ -51,7 +51,7 @@ Gem::Specification.new do |s|
|
|
51
51
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
52
52
|
s.specification_version = 3
|
53
53
|
|
54
|
-
if Gem::Version.new(Gem::
|
54
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
55
55
|
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
56
56
|
else
|
57
57
|
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
data/lib/kronos.rb
CHANGED
data/spec/to_s_spec.rb
CHANGED
@@ -18,16 +18,16 @@ describe "to_s" do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
describe "Feb. 2005" do
|
21
|
-
it "should be '2005
|
21
|
+
it "should be '2005-02'" do
|
22
22
|
k = new_kronos(2005, 2)
|
23
|
-
k.to_s.should == '2005
|
23
|
+
k.to_s.should == '2005-02'
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
27
|
describe "Feb. 9, 2005" do
|
28
|
-
it "should be '2005
|
28
|
+
it "should be '2005-02-09'" do
|
29
29
|
k = new_kronos(2005, 2, 9)
|
30
|
-
k.to_s.should == '2005
|
30
|
+
k.to_s.should == '2005-02-09'
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kronos
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 11
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 0
|
7
8
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
9
|
+
- 8
|
10
|
+
version: 0.1.8
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- David James
|
@@ -14,16 +15,18 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2010-
|
18
|
+
date: 2010-10-17 00:00:00 -04:00
|
18
19
|
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
22
|
name: rspec
|
22
23
|
prerelease: false
|
23
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
24
26
|
requirements:
|
25
27
|
- - ">="
|
26
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 13
|
27
30
|
segments:
|
28
31
|
- 1
|
29
32
|
- 2
|
@@ -66,23 +69,27 @@ rdoc_options:
|
|
66
69
|
require_paths:
|
67
70
|
- lib
|
68
71
|
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
69
73
|
requirements:
|
70
74
|
- - ">="
|
71
75
|
- !ruby/object:Gem::Version
|
76
|
+
hash: 3
|
72
77
|
segments:
|
73
78
|
- 0
|
74
79
|
version: "0"
|
75
80
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
76
82
|
requirements:
|
77
83
|
- - ">="
|
78
84
|
- !ruby/object:Gem::Version
|
85
|
+
hash: 3
|
79
86
|
segments:
|
80
87
|
- 0
|
81
88
|
version: "0"
|
82
89
|
requirements: []
|
83
90
|
|
84
91
|
rubyforge_project:
|
85
|
-
rubygems_version: 1.3.
|
92
|
+
rubygems_version: 1.3.7
|
86
93
|
signing_key:
|
87
94
|
specification_version: 3
|
88
95
|
summary: Simple and flexible date parsing.
|