aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2020-07-08 19:06:13 -0700
committerBruce Hill <bruce@bruce-hill.com>2020-07-08 19:06:13 -0700
commit84972581becdca49c017d0ba04dadc1500bcfd65 (patch)
tree51a2a77168b9b9ac488d5db8b43094fb5425487f
parent98f64ed00be9735fbc76340c2687184d1f72d124 (diff)
Bugfix for wraparound weekdays (e.g. wed-sun)
-rwxr-xr-xnowopen5
1 files changed, 3 insertions, 2 deletions
diff --git a/nowopen b/nowopen
index 5df7214..502703e 100755
--- a/nowopen
+++ b/nowopen
@@ -121,8 +121,9 @@ for i,place in ipairs(places) do
end
local today_times
for _,time in ipairs(place.times) do
- if get_weekday(time.from) <= today.wday
- and today.wday <= get_weekday(time.to or time.from) then
+ local from, to = get_weekday(time.from), get_weekday(time.to or time.from)
+ if (from <= to and from <= today.wday and today.wday <= to) -- no wraparound (e.g. mon-wed)
+ or (from > to and (today.wday >= from or today.wday <= to)) then -- wraparound (e.g. fri-tues)
today_times = time
end
end