diff --git a/nowopen b/nowopen index 69b8bbc..f72ea8a 100755 --- a/nowopen +++ b/nowopen @@ -85,11 +85,15 @@ for i,place in ipairs(places) do end end local function t(time) - local hour = tonumber(time.hour) + local hour24 = tonumber(time.hour) local minute = tonumber(time.minute or 0) - if time.ampm == 'pm' then hour = hour + 12 end - local t = os.time{hour=hour, min=minute, year=today.year, month=today.month, day=today.day} - if t < now then t = t + 24*60*60 end + if hour24 == 12 then + if time.ampm == 'am' then hour24 = hour24 - 12 end + else + if time.ampm == 'pm' then hour24 = hour24 + 12 end + end + local t = os.time{hour=hour24, min=minute, year=today.year, month=today.month, day=today.day} + while t < now do t = t + 24*60*60 end return t end if today_times and today_times.open then diff --git a/places.peg b/places.peg index cf5a1fe..dbde5e7 100644 --- a/places.peg +++ b/places.peg @@ -16,6 +16,8 @@ days <- time <- {| {:hour: {[0-9]+} :} (":" {:minute: {[0-9]+} :})? {:ampm: { "am" / "pm"} :} + / ("noon" {:hour: {~''->'12'~} :} {:ampm: {~''->'pm'~} :}) + / ("midnight" {:hour: {~''->'12'~} :} {:ampm: {~''->'am'~} :}) |} tag <- word (" "+ word)* word <- [^%nl%tab (),:#0-9-]+