lib/fugit/nat.rb in fugit-1.3.7 vs lib/fugit/nat.rb in fugit-1.3.8
- old
+ new
@@ -270,12 +270,16 @@
end
def simple_hour(i)
seq(:simple_hour, i, :shour, :am_pm, '?')
end
+ def dig_hour_b(i); rex(nil, i, /(2[0-4]|[01][0-9]|[0-9]):[0-5]\d/); end
+ def dig_hour_a(i); rex(nil, i, /(2[0-4]|[01][0-9])[0-5]\d/); end
+ def dig_hour(i); alt(nil, i, :dig_hour_a, :dig_hour_b); end
+ #
def digital_hour(i)
- rex(:digital_hour, i, /(2[0-4]|[01][0-9]):?[0-5]\d/)
+ seq(:digital_hour, i, :dig_hour, :am_pm, '?')
end
def at_point(i)
alt(nil, i,
:digital_hour, :simple_hour, :named_hour, :numeral_hour,
@@ -475,11 +479,13 @@
v = vs[0].to_i
v += 12 if vs[1] == 'pm'
[ v, 0 ]
end
def rewrite_digital_hour(t)
- m = t.string.match(/(\d\d?):?(\d\d)/)
- [ m[1].to_i, m[2].to_i ]
+ m = t.string.match(/(\d\d?):?(\d\d)(\s+pm)?/i)
+ hou = m[1].to_i; hou += 12 if m[3] && hou < 12
+ min = m[2].to_i
+ [ hou, min ]
end
def rewrite_weekday(t)
WEEKDAYS.index(t.strim.downcase[0, 3])