# HG changeset patch # User Matthew Wild # Date 1245621334 -3600 # Node ID f59a3859363e0dfde4c22f857f2f34c6dbcc9ca5 # Parent a127265f325760ae1b513c3d12578cbd42f5ae6c Match case-insensitively diff -r a127265f3257 -r f59a3859363e ndp.lua --- a/ndp.lua Sun Jun 21 22:54:45 2009 +0100 +++ b/ndp.lua Sun Jun 21 22:55:34 2009 +0100 @@ -110,19 +110,19 @@ function when(str, relative_to) local time = relative_to or os.time(); - local P = lpeg.P; + local P, Pi = lpeg.P, lpeg.Pi; local patterns = { - { P"tomorrow" / + { Pi"tomorrow" / function () time = time + seconds_in_a.day; end }; - { P"next week" / + { Pi"next week" / function () time = time + seconds_in_a.week; end }; - { P"next year" / + { Pi"next year" / function () time = adjust_time(time, "year", get_time_part(time, "year") + 1); end }; @@ -130,15 +130,15 @@ function (year) time = adjust_time(time, "year", tonumber(year)); end }; - { P"in "^0 * month_name / + { Pi"in "^0 * month_name / function (month_name) time = find_next_month_by_name(time, month_name:match("%S+$")); end }; - { P"on "^0 * day_name / + { Pi"on "^0 * day_name / function (day_name) time = find_next_day_by_name(time, day_name:match("%S+$")); end }; - { P"in "^0 * ( quantity * P" " * unit_of_time ) * (P"s"^-1) / + { Pi"in "^0 * ( quantity * P" " * unit_of_time ) * (P"s"^-1) / function (number_and_unit) local number, unit = number_and_unit:gsub("^in ", ""):match("^(.+)%s+(.-)s?$");