lib/datte/date_parser.rb in datte-0.5.1 vs lib/datte/date_parser.rb in datte-0.6.0
- old
+ new
@@ -35,9 +35,23 @@
@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
private