kronic 1.1.0 → 1.1.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.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- kronic (1.0.0)
4
+ kronic (1.1.1)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
data/HISTORY CHANGED
@@ -1,3 +1,7 @@
1
+ 1.1.1 - 30 October 2010
2
+ * Fix javascript parsing of dates in January
3
+ * Fix javascript parsing of overflowed dates such as "366 Jan 2010"
4
+
1
5
  1.1.0 - 28 October 2010
2
6
  * Remove dependency on strftime.js
3
7
 
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
- - 0
9
- version: 1.1.0
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-28 00:00:00 +11:00
17
+ date: 2010-10-30 00:00:00 +11:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency