public
Fork of mojombo/chronic
Description: "Chronic is a pure Ruby natural language date parser." + improvements, corrections, speedups, and additions
Homepage: http://chronic.rubyforge.org
Clone URL: git://github.com/jf/chronic.git
Search Repo:
numerizer, time overflow
mojombo (author)
Sat Mar 31 19:56:18 -0700 2007
commit  044fbd787e3de2509dd69d386df78aa6c2acfddb
tree    02579c14a6db29ac8e5255e82d9d10d5c8aee48d
parent  fc507350c9dabd55415c4d6b93e8c376f8c9b90f
...
 
 
 
 
 
1
2
3
...
1
2
3
4
5
6
7
8
0
@@ -1,3 +1,8 @@
0
+= 0.2.0 2007-03-20
0
+
0
+* fixed time overflow issue
0
+* implemented numerizer, allowing the use of number words (e.g. five weeks ago) (thanks shalev!)
0
+
0
 = 0.1.6 2006-01-15
0
 
0
 * added 'weekend' support (eventualbuddha)
...
26
27
28
29
 
30
31
32
 
33
34
35
...
37
38
39
 
40
41
42
...
26
27
28
 
29
30
31
32
33
34
35
36
...
38
39
40
41
42
43
44
0
@@ -26,10 +26,11 @@
0
 lib/chronic/repeaters/repeater_year.rb
0
 lib/chronic/scalar.rb
0
 lib/chronic/separator.rb
0
-test/parse_numbers.rb
0
+lib/numerizer/numerizer.rb
0
 test/suite.rb
0
 test/test_Chronic.rb
0
 test/test_Handler.rb
0
+test/test_Numerizer.rb
0
 test/test_RepeaterDayName.rb
0
 test/test_RepeaterFortnight.rb
0
 test/test_RepeaterHour.rb
0
@@ -37,6 +38,7 @@
0
 test/test_RepeaterMonthName.rb
0
 test/test_RepeaterTime.rb
0
 test/test_RepeaterWeek.rb
0
+test/test_RepeaterWeekend.rb
0
 test/test_RepeaterYear.rb
0
 test/test_Span.rb
0
 test/test_Token.rb
...
7
8
9
 
 
10
11
12
...
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
...
7
8
9
10
11
12
13
14
...
17
18
19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0
@@ -7,6 +7,8 @@
0
 Hoe.new('chronic', Chronic::VERSION) do |p|
0
   p.rubyforge_name = 'chronic'
0
   p.summary = 'A natural language date parser'
0
+ p.author = 'Tom Preston-Werner'
0
+ p.email = 'tom@rubyisawesome.com'
0
   p.description = p.paragraphs_of('README.txt', 2).join("\n\n")
0
   p.url = p.paragraphs_of('README.txt', 0).first.split(/\n/)[1..-1]
0
   p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
0
@@ -15,28 +17,4 @@
0
 end
0
 
0
 # vim: syntax=Ruby
0
-
0
-__END__
0
-
0
-require 'rubygems'
0
-
0
-SPEC = Gem::Specification.new do |s|
0
- s.name = 'chronic'
0
- s.version = '0.1.5'
0
- s.author = 'Tom Preston-Werner'
0
- s.email = 'tom@rubyisawesome.com'
0
- s.homepage = 'http://chronic.rubyforge.org'
0
- s.platform = Gem::Platform::RUBY
0
- s.summary = "A natural language date parser"
0
- candidates = Dir["{lib,test}/**/*"]
0
- s.files = candidates.delete_if do |item|
0
- item.include?('.svn')
0
- end
0
- s.require_path = "lib"
0
- s.autorequire = "chronic"
0
- s.test_file = "test/suite.rb"
0
- s.has_rdoc = true
0
- s.extra_rdoc_files = ['README']
0
- s.rdoc_options << '--main' << 'README'
0
-end
...
7
8
9
 
 
10
11
12
13
...
33
34
35
 
 
36
37
 
38
39
40
...
44
45
46
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
...
7
8
9
10
11
12
13
14
15
...
35
36
37
38
39
40
 
41
42
43
44
...
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
0
@@ -7,6 +7,8 @@
0
 #
0
 #=============================================================================
0
 
0
+$:.unshift File.dirname(__FILE__) # For use/testing when no gem is installed
0
+
0
 require 'chronic/chronic'
0
 require 'chronic/handlers'
0
 
0
0
@@ -33,8 +35,10 @@
0
 require 'chronic/ordinal'
0
 require 'chronic/separator'
0
 
0
+require 'numerizer/numerizer'
0
+
0
 module Chronic
0
- VERSION = "0.1.6"
0
+ VERSION = "0.2.0"
0
   
0
   def self.debug; false; end
0
 end
0
@@ -44,5 +48,51 @@
0
 def p(val)
0
   p_orig val
0
   puts
0
+end
0
+
0
+class Time
0
+ def self.construct(year, month = 1, day = 1, hour = 0, minute = 0, second = 0)
0
+ if second >= 60
0
+ minute += second / 60
0
+ second = second % 60
0
+ end
0
+
0
+ if minute >= 60
0
+ hour += minute / 60
0
+ minute = minute % 60
0
+ end
0
+
0
+ if hour >= 24
0
+ day += hour / 24
0
+ hour = hour % 24
0
+ end
0
+
0
+ # determine if there is a day overflow. this is complicated by our crappy calendar
0
+ # system (non-constant number of days per month)
0
+ day <= 56 || raise("day must be no more than 56 (makes month resolution easier)")
0
+ if day > 28
0
+ # no month ever has fewer than 28 days, so only do this if necessary
0
+ leap_year = (year % 4 == 0) && !(year % 100 == 0)
0
+ leap_year_month_days = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
0
+ common_year_month_days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
0
+ days_this_month = leap_year ? leap_year_month_days[month - 1] : common_year_month_days[month - 1]
0
+ if day > days_this_month
0
+ month += day / days_this_month
0
+ day = day % days_this_month
0
+ end
0
+ end
0
+
0
+ if month > 12
0
+ if month % 12 == 0
0
+ year += (month - 12) / 12
0
+ month = 12
0
+ else
0
+ year += month / 12
0
+ month = month % 12
0
+ end
0
+ end
0
+
0
+ Time.local(year, month, day, hour, minute, second)
0
+ end
0
 end
...
101
102
103
 
104
105
106
107
...
118
119
120
121
122
123
124
125
126
127
128
129
 
130
131
132
...
101
102
103
104
105
106
107
108
...
119
120
121
 
 
 
122
123
124
125
126
 
127
128
129
130
0
@@ -101,6 +101,7 @@
0
     # ordinals (third => 3rd)
0
     def pre_normalize(text) #:nodoc:
0
       normalized_text = text.to_s.downcase
0
+ normalized_text = numericize_numbers(normalized_text)
0
       normalized_text.gsub!(/['"\.]/, '')
0
       normalized_text.gsub!(/([\/\-\,\@])/) { ' ' + $1 + ' ' }
0
       normalized_text.gsub!(/\btoday\b/, 'this day')
0
0
@@ -118,15 +119,12 @@
0
       normalized_text.gsub!(/\btonight\b/, 'this night')
0
       normalized_text.gsub!(/(?=\w)([ap]m|oclock)\b/, ' \1')
0
       normalized_text.gsub!(/\b(hence|after|from)\b/, 'future')
0
- normalized_text.gsub!(/\ba\b/, '1')
0
- normalized_text.gsub!(/\s+/, ' ')
0
- normalized_text = numericize_numbers(normalized_text)
0
       normalized_text = numericize_ordinals(normalized_text)
0
     end
0
   
0
     # Convert number words to numbers (three => 3)
0
     def numericize_numbers(text) #:nodoc:
0
- text
0
+ Numerizer.numerize(text)
0
     end
0
   
0
     # Convert ordinal words to numeric ordinals (third => 3rd)
...
214
215
216
217
218
219
220
221
222
223
224
225
226
227
 
 
 
 
 
 
 
 
 
 
 
 
 
228
229
230
...
214
215
216
 
 
 
 
 
 
 
 
 
 
 
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
0
@@ -214,17 +214,19 @@
0
     def handle_s_r_p(tokens, options) #:nodoc:
0
       repeater = tokens[1].get_tag(Repeater)
0
             
0
- span =
0
- case true
0
- when [RepeaterYear, RepeaterSeason, RepeaterSeasonName, RepeaterMonth, RepeaterMonthName, RepeaterFortnight, RepeaterWeek].include?(repeater.class)
0
- self.parse("this hour", :guess => false, :now => @now)
0
- when [RepeaterWeekend, RepeaterDay, RepeaterDayName, RepeaterDayPortion, RepeaterHour].include?(repeater.class)
0
- self.parse("this minute", :guess => false, :now => @now)
0
- when [RepeaterMinute, RepeaterSecond].include?(repeater.class)
0
- self.parse("this second", :guess => false, :now => @now)
0
- else
0
- raise(ChronicPain, "Invalid repeater: #{repeater.class}")
0
- end
0
+ # span =
0
+ # case true
0
+ # when [RepeaterYear, RepeaterSeason, RepeaterSeasonName, RepeaterMonth, RepeaterMonthName, RepeaterFortnight, RepeaterWeek].include?(repeater.class)
0
+ # self.parse("this hour", :guess => false, :now => @now)
0
+ # when [RepeaterWeekend, RepeaterDay, RepeaterDayName, RepeaterDayPortion, RepeaterHour].include?(repeater.class)
0
+ # self.parse("this minute", :guess => false, :now => @now)
0
+ # when [RepeaterMinute, RepeaterSecond].include?(repeater.class)
0
+ # self.parse("this second", :guess => false, :now => @now)
0
+ # else
0
+ # raise(ChronicPain, "Invalid repeater: #{repeater.class}")
0
+ # end
0
+
0
+ span = self.parse("this second", :guess => false, :now => @now)
0
       
0
       self.handle_srp(tokens, span, options)
0
     end
...
10
11
12
13
14
15
 
 
 
16
17
18
...
10
11
12
 
 
 
13
14
15
16
17
18
0
@@ -10,9 +10,9 @@
0
     end
0
   
0
     def self.scan_for_all(token)
0
- scanner = {/past/ => :past,
0
- /future/ => :future,
0
- /in/ => :future}
0
+ scanner = {/\bpast\b/ => :past,
0
+ /\bfuture\b/ => :future,
0
+ /\bin\b/ => :future}
0
       scanner.keys.each do |scanner_item|
0
         return self.new(scanner[scanner_item]) if scanner_item =~ token.word
0
       end
...
19
20
21
22
23
 
 
24
25
26
 
 
27
28
29
 
 
30
31
32
...
19
20
21
 
 
22
23
24
 
 
25
26
27
 
 
28
29
30
31
32
0
@@ -19,14 +19,14 @@
0
     
0
     case pointer
0
     when :future
0
- day_begin = Time.local(@now.year, @now.month, @now.day, @now.hour + 1)
0
- day_end = Time.local(@now.year, @now.month, @now.day) + DAY_SECONDS
0
+ day_begin = Time.construct(@now.year, @now.month, @now.day, @now.hour + 1)
0
+ day_end = Time.construct(@now.year, @now.month, @now.day) + DAY_SECONDS
0
     when :past
0
- day_begin = Time.local(@now.year, @now.month, @now.day)
0
- day_end = Time.local(@now.year, @now.month, @now.day, @now.hour)
0
+ day_begin = Time.construct(@now.year, @now.month, @now.day)
0
+ day_end = Time.construct(@now.year, @now.month, @now.day, @now.hour)
0
     when :none
0
- day_begin = Time.local(@now.year, @now.month, @now.day)
0
- day_end = Time.local(@now.year, @now.month, @now.day) + DAY_SECONDS
0
+ day_begin = Time.construct(@now.year, @now.month, @now.day)
0
+ day_end = Time.construct(@now.year, @now.month, @now.day) + DAY_SECONDS
0
     end
0
     
0
     Chronic::Span.new(day_begin, day_end)
...
7
8
9
10
 
11
12
13
...
7
8
9
 
10
11
12
13
0
@@ -7,7 +7,7 @@
0
     direction = pointer == :future ? 1 : -1
0
     
0
     if !@current_day_start
0
- @current_day_start = Time.local(@now.year, @now.month, @now.day)
0
+ @current_day_start = Time.construct(@now.year, @now.month, @now.day)
0
       @current_day_start += direction * DAY_SECONDS
0
 
0
       day_num = symbol_to_number(@type)
...
28
29
30
31
 
32
33
34
35
 
36
37
 
38
39
40
41
42
 
43
44
 
45
46
47
48
49
 
50
51
 
52
53
54
...
66
67
68
69
 
70
71
72
...
28
29
30
 
31
32
33
34
 
35
36
 
37
38
39
40
41
 
42
43
 
44
45
46
47
48
 
49
50
 
51
52
53
54
...
66
67
68
 
69
70
71
72
0
@@ -28,27 +28,27 @@
0
     full_day = 60 * 60 * 24
0
     
0
     if !@current_span
0
- now_seconds = @now - Time.local(@now.year, @now.month, @now.day)
0
+ now_seconds = @now - Time.construct(@now.year, @now.month, @now.day)
0
       if now_seconds < @range.begin
0
         case pointer
0
         when :future
0
- range_start = Time.local(@now.year, @now.month, @now.day) + @range.begin
0
+ range_start = Time.construct(@now.year, @now.month, @now.day) + @range.begin
0
         when :past
0
- range_start = Time.local(@now.year, @now.month, @now.day) - full_day + @range.begin
0
+ range_start = Time.construct(@now.year, @now.month, @now.day) - full_day + @range.begin
0
         end
0
       elsif now_seconds > @range.end
0
         case pointer
0
         when :future
0
- range_start = Time.local(@now.year, @now.month, @now.day) + full_day + @range.begin
0
+ range_start = Time.construct(@now.year, @now.month, @now.day) + full_day + @range.begin
0
         when :past
0
- range_start = Time.local(@now.year, @now.month, @now.day) + @range.begin
0
+ range_start = Time.construct(@now.year, @now.month, @now.day) + @range.begin
0
         end
0
       else
0
         case pointer
0
         when :future
0
- range_start = Time.local(@now.year, @now.month, @now.day) + full_day + @range.begin
0
+ range_start = Time.construct(@now.year, @now.month, @now.day) + full_day + @range.begin
0
         when :past
0
- range_start = Time.local(@now.year, @now.month, @now.day) - full_day + @range.begin
0
+ range_start = Time.construct(@now.year, @now.month, @now.day) - full_day + @range.begin
0
         end
0
       end
0
       
0
@@ -66,7 +66,7 @@
0
   def this(context = :future)
0
     super
0
     
0
- range_start = Time.local(@now.year, @now.month, @now.day) + @range.begin
0
+ range_start = Time.construct(@now.year, @now.month, @now.day) + @range.begin
0
     @current_span = Chronic::Span.new(range_start, range_start + (@range.end - @range.begin))
0
   end
0
   
...
33
34
35
36
 
37
38
39
...
41
42
43
44
 
45
46
47
...
33
34
35
 
36
37
38
39
...
41
42
43
 
44
45
46
47
0
@@ -33,7 +33,7 @@
0
     
0
     case pointer
0
     when :future
0
- this_fortnight_start = Time.local(@now.year, @now.month, @now.day, @now.hour) + Chronic::RepeaterHour::HOUR_SECONDS
0
+ this_fortnight_start = Time.construct(@now.year, @now.month, @now.day, @now.hour) + Chronic::RepeaterHour::HOUR_SECONDS
0
       sunday_repeater = Chronic::RepeaterDayName.new(:sunday)
0
       sunday_repeater.start = @now
0
       sunday_repeater.this(:future)
0
@@ -41,7 +41,7 @@
0
       this_fortnight_end = this_sunday_span.begin
0
       Chronic::Span.new(this_fortnight_start, this_fortnight_end)
0
     when :past
0
- this_fortnight_end = Time.local(@now.year, @now.month, @now.day, @now.hour)
0
+ this_fortnight_end = Time.construct(@now.year, @now.month, @now.day, @now.hour)
0
       sunday_repeater = Chronic::RepeaterDayName.new(:sunday)
0
       sunday_repeater.start = @now
0
       last_sunday_span = sunday_repeater.next(:past)
...
7
8
9
10
 
11
12
 
13
14
15
16
17
...
24
25
26
27
28
 
 
29
30
31
 
 
32
33
 
34
35
36
...
7
8
9
 
10
11
 
12
13
14
15
16
17
...
24
25
26
 
 
27
28
29
 
 
30
31
32
 
33
34
35
36
0
@@ -7,9 +7,9 @@
0
     if !@current_hour_start
0
       case pointer
0
       when :future
0
- @current_hour_start = Time.local(@now.year, @now.month, @now.day, @now.hour + 1)
0
+ @current_hour_start = Time.construct(@now.year, @now.month, @now.day, @now.hour + 1)
0
       when :past
0
- @current_hour_start = Time.local(@now.year, @now.month, @now.day, @now.hour - 1)
0
+ @current_hour_start = Time.construct(@now.year, @now.month, @now.day, @now.hour - 1)
0
       end
0
     else
0
       direction = pointer == :future ? 1 : -1
0
0
0
@@ -24,13 +24,13 @@
0
     
0
     case pointer
0
     when :future
0
- hour_start = Time.local(@now.year, @now.month, @now.day, @now.hour, @now.min + 1)
0
- hour_end = Time.local(@now.year, @now.month, @now.day, @now.hour + 1)
0
+ hour_start = Time.construct(@now.year, @now.month, @now.day, @now.hour, @now.min + 1)
0
+ hour_end = Time.construct(@now.year, @now.month, @now.day, @now.hour + 1)
0
     when :past
0
- hour_start = Time.local(@now.year, @now.month, @now.day, @now.hour)
0
- hour_end = Time.local(@now.year, @now.month, @now.day, @now.hour, @now.min)
0
+ hour_start = Time.construct(@now.year, @now.month, @now.day, @now.hour)
0
+ hour_end = Time.construct(@now.year, @now.month, @now.day, @now.hour, @now.min)
0
     when :none
0
- hour_start = Time.local(@now.year, @now.month, @now.day, @now.hour)
0
+ hour_start = Time.construct(@now.year, @now.month, @now.day, @now.hour)
0
       hour_end = hour_begin + HOUR_SECONDS
0
     end
0
     
...
15
16
17
18
 
19
20
 
21
22
23
24
 
 
25
26
27
...
15
16
17
 
18
19
 
20
21
22
 
 
23
24
25
26
27
0
@@ -15,13 +15,13 @@
0
     case pointer
0
     when :future
0
       minute_begin = @now
0
- minute_end = Time.local(@now.year, @now.month, @now.day, @now.hour, @now.min)
0
+ minute_end = Time.construct(@now.year, @now.month, @now.day, @now.hour, @now.min)
0
     when :past
0
- minute_begin = Time.local(@now.year, @now.month, @now.day, @now.hour, @now.min)
0
+ minute_begin = Time.construct(@now.year, @now.month, @now.day, @now.hour, @now.min)
0
       minute_end = @now
0
     when :none
0
- minute_begin = Time.local(@now.year, @now.month, @now.day, @now.hour, @now.min)
0
- minute_end = Time.local(@now.year, @now.month, @now.day, @now.hour, @now.min) + MINUTE_SECONDS
0
+ minute_begin = Time.construct(@now.year, @now.month, @now.day, @now.hour, @now.min)
0
+ minute_end = Time.construct(@now.year, @now.month, @now.day, @now.hour, @now.min) + MINUTE_SECONDS
0
     end
0
     
0
     Chronic::Span.new(minute_begin, minute_end)
...
6
7
8
9
 
10
11
 
12
13
14
 
15
16
17
18
19
...
19
20
21
22
23
 
 
24
25
26
 
 
27
28
29
 
 
30
31
32
...
48
49
50
51
 
52
53
54
...
6
7
8
 
9
10
 
11
12
13
 
14
15
16
17
18
19
...
19
20
21
 
 
22
23
24
 
 
25
26
27
 
 
28
29
30
31
32
...
48
49
50
 
51
52
53
54
0
@@ -6,12 +6,12 @@
0
     super
0
     
0
     if !@current_month_start
0
- @current_month_start = offset_by(Time.local(@now.year, @now.month), 1, pointer)
0
+ @current_month_start = offset_by(Time.construct(@now.year, @now.month), 1, pointer)
0
     else
0
- @current_month_start = offset_by(Time.local(@current_month_start.year, @current_month_start.month), 1, pointer)
0
+ @current_month_start = offset_by(Time.construct(@current_month_start.year, @current_month_start.month), 1, pointer)
0
     end
0
     
0
- Chronic::Span.new(@current_month_start, Time.local(@current_month_start.year, @current_month_start.month + 1))
0
+ Chronic::Span.new(@current_month_start, Time.construct(@current_month_start.year, @current_month_start.month + 1))
0
   end
0
   
0
   def this(pointer = :future)
0
0
0
@@ -19,14 +19,14 @@
0
     
0
     case pointer
0
     when :future
0
- month_start = Time.local(@now.year, @now.month, @now.day + 1)
0
- month_end = self.offset_by(Time.local(@now.year, @now.month), 1, :future)
0
+ month_start = Time.construct(@now.year, @now.month, @now.day + 1)
0
+ month_end = self.offset_by(Time.construct(@now.year, @now.month), 1, :future)
0
     when :past
0
- month_start = Time.local(@now.year, @now.month)
0
- month_end = Time.local(@now.year, @now.month, @now.day)
0
+ month_start = Time.construct(@now.year, @now.month)
0
+ month_end = Time.construct(@now.year, @now.month, @now.day)
0
     when :none
0
- month_start = Time.local(@now.year, @now.month)
0
- month_end = self.offset_by(Time.local(@now.year, @now.month), 1, :future)
0
+ month_start = Time.construct(@now.year, @now.month)
0
+ month_end = self.offset_by(Time.construct(@now.year, @now.month), 1, :future)
0
     end
0
     
0
     Chronic::Span.new(month_start, month_end)
0
@@ -48,7 +48,7 @@
0
       new_year += 1
0
       new_month -= YEAR_MONTHS
0
     end
0
- Time.local(new_year, new_month, time.day, time.hour, time.min, time.sec)
0
+ Time.construct(new_year, new_month, time.day, time.hour, time.min, time.sec)
0
   end
0
   
0
   def width
...
9
10
11
12
 
13
14
 
15
16
17
18
 
19
20
 
21
22
23
24
 
25
26
 
27
28
29
30
31
32
33
 
34
35
 
36
37
38
...
47
48
49
50
 
51
52
53
...
9
10
11
 
12
13
 
14
15
16
17
 
18
19
 
20
21
22
23
 
24
25
 
26
27
28
29
30
31
32
 
33
34
 
35
36
37
38
...
47
48
49
 
50
51
52
53
0
@@ -9,30 +9,30 @@
0
       case pointer
0
       when :future
0
         if @now.month < target_month
0
- @current_month_begin = Time.local(@now.year, target_month)
0
+ @current_month_begin = Time.construct(@now.year, target_month)
0
         else @now.month > target_month
0
- @current_month_begin = Time.local(@now.year + 1, target_month)
0
+ @current_month_begin = Time.construct(@now.year + 1, target_month)
0
         end
0
       when :none
0
         if @now.month <= target_month
0
- @current_month_begin = Time.local(@now.year, target_month)
0
+ @current_month_begin = Time.construct(@now.year, target_month)
0
         else @now.month > target_month
0
- @current_month_begin = Time.local(@now.year + 1, target_month)
0
+ @current_month_begin = Time.construct(@now.year + 1, target_month)
0
         end
0
       when :past
0
         if @now.month > target_month
0
- @current_month_begin = Time.local(@now.year, target_month)
0
+ @current_month_begin = Time.construct(@now.year, target_month)
0
         else @now.month < target_month
0
- @current_month_begin = Time.local(@now.year - 1, target_month)
0
+ @current_month_begin = Time.construct(@now.year - 1, target_month)
0
         end
0
       end
0
       @current_month_begin || raise("Current month should be set by now")
0
     else
0
       case pointer
0
       when :future
0
- @current_month_begin = Time.local(@current_month_begin.year + 1, @current_month_begin.month)
0
+ @current_month_begin = Time.construct(@current_month_begin.year + 1, @current_month_begin.month)
0
       when :past
0
- @current_month_begin = Time.local(@current_month_begin.year - 1, @current_month_begin.month)
0
+ @current_month_begin = Time.construct(@current_month_begin.year - 1, @current_month_begin.month)
0
       end
0
     end
0
     
0
@@ -47,7 +47,7 @@
0
       next_month_month = cur_month_month + 1
0
     end
0
       
0
- Chronic::Span.new(@current_month_begin, Time.local(next_month_year, next_month_month))
0
+ Chronic::Span.new(@current_month_begin, Time.construct(next_month_year, next_month_month))
0
   end
0
   
0
   def this(pointer = :future)
...
6
7
8
9
 
10
11
 
12
13
14
15
 
16
17
18
 
19
20
21
22
23
...
23
24
25
26
27
 
 
28
29
30
 
 
31
32
33
 
 
34
35
36
37
...
40
41
42
43
 
44
45
46
 
47
48
49
...
6
7
8
 
9
10
 
11
12
13
14
 
15
16
17
 
18
19
20
21
22
23
...
23
24
25
 
 
26
27
28
 
 
29
30
31
 
 
32
33
34
35
36
37
...
40
41
42
 
43
44
45
 
46
47
48
49
0
@@ -6,16 +6,16 @@
0
     if !@current_year_start
0
       case pointer
0
       when :future
0
- @current_year_start = Time.local(@now.year + 1)
0
+ @current_year_start = Time.construct(@now.year + 1)
0
       when :past
0
- @current_year_start = Time.local(@now.year - 1)
0
+ @current_year_start = Time.construct(@now.year - 1)
0
       end
0
     else
0
       diff = pointer == :future ? 1 : -1
0
- @current_year_start = Time.local(@current_year_start.year + diff)
0
+ @current_year_start = Time.construct(@current_year_start.year + diff)
0
     end
0
     
0
- Chronic::Span.new(@current_year_start, Time.local(@current_year_start.year + 1))
0
+ Chronic::Span.new(@current_year_start, Time.construct(@current_year_start.year + 1))
0
   end
0
   
0
   def this(pointer = :future)
0
0
0
@@ -23,14 +23,14 @@
0
     
0
     case pointer
0
     when :future
0
- this_year_start = Time.local(@now.year, @now.month, @now.day) + Chronic::RepeaterDay::DAY_SECONDS
0
- this_year_end = Time.local(@now.year + 1, 1, 1)
0
+ this_year_start = Time.construct(@now.year, @now.month, @now.day) + Chronic::RepeaterDay::DAY_SECONDS
0
+ this_year_end = Time.construct(@now.year + 1, 1, 1)
0
     when :past
0
- this_year_start = Time.local(@now.year, 1, 1)
0
- this_year_end = Time.local(@now.year, @now.month, @now.day)
0
+ this_year_start = Time.construct(@now.year, 1, 1)
0
+ this_year_end = Time.construct(@now.year, @now.month, @now.day)
0
     when :none
0
- this_year_start = Time.local(@now.year, 1, 1)
0
- this_year_end = Time.local(@now.year + 1, 1, 1)
0
+ this_year_start = Time.construct(@now.year, 1, 1)
0
+ this_year_end = Time.construct(@now.year + 1, 1, 1)
0
     end
0
     
0
     Chronic::Span.new(this_year_start, this_year_end)
0
0
@@ -40,10 +40,10 @@
0
     direction = pointer == :future ? 1 : -1
0
     
0
     sb = span.begin
0
- new_begin = Time.local(sb.year + (amount * direction), sb.month, sb.day, sb.hour, sb.min, sb.sec)
0
+ new_begin = Time.construct(sb.year + (amount * direction), sb.month, sb.day, sb.hour, sb.min, sb.sec)
0
     
0
     se = span.end
0
- new_end = Time.local(se.year + (amount * direction), se.month, se.day, se.hour, se.min, se.sec)
0
+ new_end = Time.construct(se.year + (amount * direction), se.month, se.day, se.hour, se.min, se.sec)
0
     
0
     Chronic::Span.new(new_begin, new_end)
0
   end
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
0
@@ -1 +1,104 @@
0
+require 'strscan'
0
+
0
+class Numerizer
0
+
0
+ DIRECT_NUMS = [
0
+ ['eleven', '11'],
0
+ ['twelve', '12'],
0
+ ['thirteen', '13'],
0
+ ['fourteen', '14'],
0
+ ['fifteen', '15'],
0
+ ['sixteen', '16'],
0
+ ['seventeen', '17'],
0
+ ['eighteen', '18'],
0
+ ['nineteen', '19'],
0
+ ['ninteen', '19'], # Common mis-spelling
0
+ ['zero', '0'],
0
+ ['one', '1'],
0
+ ['two', '2'],
0
+ ['three', '3'],
0
+ ['four(\W|$)', '4\1'], # The weird regex is so that it matches four but not fourty
0
+ ['five', '5'],
0
+ ['six(\W|$)', '6\1'],
0
+ ['seven(\W|$)', '7\1'],
0
+ ['eight(\W|$)', '8\1'],
0
+ ['nine(\W|$)', '9\1'],
0
+ ['ten', '10'],
0
+ ['\ba[\b^$]', '1'] # doesn't make sense for an 'a' at the end to be a 1
0
+ ]
0
+
0
+ TEN_PREFIXES = [ ['twenty', 20],
0
+ ['thirty', 30],
0
+ ['fourty', 40],
0
+ ['fifty', 50],
0
+ ['sixty', 60],
0
+ ['seventy', 70],
0
+ ['eighty', 80],
0<