diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2019-01-05 14:55:25 -0800 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2019-01-05 14:55:25 -0800 |
| commit | 8e65fed76ab3ea2c1d7cee92c9272f939b231506 (patch) | |
| tree | a7bbe43f3a7dde63bd8ac20ff0a1f1b05e600155 | |
| parent | 1256fb6666f1934e67ce4ae226ef3cac4598274b (diff) | |
Added support for noon/midnight, fixed bug in 12:XX calculations.
| -rwxr-xr-x | nowopen | 12 | ||||
| -rw-r--r-- | places.peg | 2 |
2 files changed, 10 insertions, 4 deletions
@@ -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 @@ -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-]+ |
