todoist_date_time 0.2.1 → 0.2.2
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/VERSION +1 -1
- data/lib/todoist_date_time.rb +11 -2
- data/spec/todoist_date_time_spec.rb +6 -1
- data/todoist_date_time.gemspec +2 -2
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.2
|
data/lib/todoist_date_time.rb
CHANGED
@@ -99,10 +99,19 @@ module TodoistDateTime
|
|
99
99
|
parts[0] = Date::MONTHNAMES.find{ |month| month =~ Regexp.new("^" + parts[0], Regexp::IGNORECASE) unless month.nil? }
|
100
100
|
end
|
101
101
|
|
102
|
-
|
102
|
+
parts[2] = Date.today.year unless parts.count == 3
|
103
|
+
parts.map!{|elem| elem.to_s}
|
103
104
|
|
105
|
+
if parts[0].to_i > 12
|
106
|
+
date_string = parts[0] + "." + parts[1]
|
107
|
+
else
|
108
|
+
date_string = parts[1] + "." + parts[0]
|
109
|
+
end
|
110
|
+
date_string += "." + parts[2]
|
111
|
+
|
112
|
+
DateTime.parse(date_string)
|
104
113
|
else
|
105
|
-
begin
|
114
|
+
begin
|
106
115
|
DateTime.parse(date_string)
|
107
116
|
rescue
|
108
117
|
raise InvalidInput.new(datetime_string)
|
@@ -96,12 +96,17 @@ describe "TodoistDateTime" do
|
|
96
96
|
month.chars.to_a.each_with_index do |char, char_idx| # build dayname char by char and test each one
|
97
97
|
month = @monthnames.find{ |month| month =~ Regexp.new("^" + month[0..char_idx], Regexp::IGNORECASE) unless month.nil? }
|
98
98
|
expected_date = @today
|
99
|
-
expected_date += 1.month until expected_date.month == @monthnames.index(month)
|
99
|
+
expected_date += 1.month until expected_date.month == @monthnames.index(month)
|
100
100
|
(month[0..char_idx] + "/" + expected_date.day.to_s + "/" + expected_date.year.to_s).to_tddatetime.should == expected_date
|
101
101
|
end
|
102
102
|
end
|
103
103
|
end
|
104
104
|
|
105
|
+
it "should parse '27/5', '27/5 2009' as 27.01. in YYYY or 2009" do
|
106
|
+
"27/5".to_tddatetime.should == DateTime.parse("27.05.#{Date.today.year}")
|
107
|
+
"27/5/2009".to_tddatetime.should == DateTime.parse("27.05.2009")
|
108
|
+
end
|
109
|
+
|
105
110
|
it "should parse 'april/1', 'april/1/2009', '4/1', 4/1/2009', '1/april', '1/april/2009' as 01.04 in YYYY or 2009" do
|
106
111
|
@date_parts_separators.each do |date_separator|
|
107
112
|
@monthnames.each_index do |month_idx|
|
data/todoist_date_time.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{todoist_date_time}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Kazuhiro Hiramatsu"]
|
12
|
-
s.date = %q{2010-02-
|
12
|
+
s.date = %q{2010-02-10}
|
13
13
|
s.description = %q{Add into String class method which converts string value written in Todoist (http://todoist.com) datetime syntax into valid DateTime instance}
|
14
14
|
s.email = %q{kaz_u@wp.pl}
|
15
15
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: todoist_date_time
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kazuhiro Hiramatsu
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-02-
|
12
|
+
date: 2010-02-10 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|