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
|
# File 'lib/datte/date_parser.rb', line 9
def parse
ABSOLUTE_DATES.each do |matcher|
if md = @body.match(matcher)
@date.update_date(md)
break
end
end
ABSOLUTE_TIMES.each do |matcher|
if md = @body.match(matcher)
@date.update_time(md)
p @date
break
end
end
NOUNS.each do |matcher_s, method|
matcher = Regexp.new(matcher_s.to_s)
if md = @body.match(matcher)
eval(method)
break
end
end
AFTERS.each do |matcher|
if md = @body.match(matcher)
@date.after(md)
break
end
end
WEEKS.each do |matcher_s, week|
matcher = Regexp.new(matcher_s.to_s)
if @body.match(matcher)
WDAYS.each do |wday_matcher_s, wday|
wday_matcher = Regexp.new(wday_matcher_s.to_s)
if @body.match(wday_matcher)
now_wday = DateTime.now.wday
day = 7 * (week || 1) + wday - now_wday
@date.after({day: day})
end
end
end
end
return @date.to_datetime
end
|