kronic 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/HISTORY +4 -0
- data/lib/js/kronic.js +7 -1
- data/spec/kronic_spec.rb +6 -0
- metadata +3 -3
data/Gemfile.lock
CHANGED
data/HISTORY
CHANGED
data/lib/js/kronic.js
CHANGED
@@ -88,10 +88,16 @@ var Kronic = (function() {
|
|
88
88
|
else
|
89
89
|
year = today.getYear() + 1900;
|
90
90
|
|
91
|
-
if (!(day && month && year))
|
91
|
+
if (!(day && month !== null && year))
|
92
92
|
return null;
|
93
93
|
|
94
94
|
var result = new Date(year, month, day);
|
95
|
+
|
96
|
+
// Date constructor will happily accept invalid dates
|
97
|
+
// so we're checking that day existed in the given month
|
98
|
+
if (result.getMonth() != month || result.getDate() != day)
|
99
|
+
return null;
|
100
|
+
|
95
101
|
if (result > today && !rawYear)
|
96
102
|
result = new Date(year - 1, month, day);
|
97
103
|
return result;
|
data/spec/kronic_spec.rb
CHANGED
@@ -66,6 +66,12 @@ describe Kronic do
|
|
66
66
|
it_should_parse('September 4', date(:sep_4))
|
67
67
|
it_should_parse('2008-09-04', Date.new(2008, 9, 4))
|
68
68
|
it_should_parse('2008-9-4', Date.new(2008, 9, 4))
|
69
|
+
it_should_parse('1 Jan 2010', Date.new(2010, 1, 1))
|
70
|
+
it_should_parse('31 Dec 2010', Date.new(2010, 12, 31))
|
71
|
+
|
72
|
+
it_should_parse('0 Jan 2010', nil)
|
73
|
+
it_should_parse('32 Dec 2010', nil)
|
74
|
+
it_should_parse('366 Jan 2010', nil)
|
69
75
|
it_should_parse('bogus', nil)
|
70
76
|
it_should_parse('14', nil)
|
71
77
|
it_should_parse('14 bogus in', nil)
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 1.1.
|
8
|
+
- 1
|
9
|
+
version: 1.1.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Xavier Shay
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-10-
|
17
|
+
date: 2010-10-30 00:00:00 +11:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|