Open mermshaus opened 8 years ago
Thanks for typing this up! It's great. Some thoughts...
hours_today
= real time. hours_this_week
= real time. hours_overview
≠ real time. If someone wanted an overview of hours, they could do it without the help of a script like this. Realize we could easily accommodate that need, but feels like a departure from the main purpose.yesterdayFlag
out of the render method.render
method. We could get rid of it entirely. I'd rather provide an example that uses a combination of is_open
and hours_today
to generate open/ closed messaging. That seems more flexible than the template system. The if open / else
logic should occur in index.php page instead of in the class.hours_today
still returns the current day’s hours and not yesterday’s. Agreed!hours_this_week
should exist. But it should take exceptions into consideration.hours_overview
could exist (same as hours_this_week
, without exceptions), but I don't think it's super important. I suppose the grouping feature is nice. That could validate it's existence.render
and provide example of same functionality using other existing methods.hours_this_week
consider exceptions.Here's what I'd like to see included in the API. Let me know what you think!
is_open()
- returns true if store is currently open / false if currently closed. Function is independent of days. Doesn't matter if a store is "open late". "Open late" simply equals "open" in this case. Honors exceptions.hours_today()
- returns array of the current day's hours. "Open late" hours from previous day are not included. After midnight, we move to the next day, even if currently "open late". Honors exceptions.hours_this_week()
- returns array of the current week's hours. Organized Monday-Sunday. Days are never combined if hours are same. Honors exceptions.hours_overview([groupSameDays = false])
- returns array of a typical week's hours. Organized Monday-Sunday. Days are optionally combined if hours are same. Does NOT honor exceptions.
Concepts
$hours
combined with$exceptions
(if applicable).Current public API methods
is_open
returnstrue
when the shop is OPEN.render
returns a string whose actual content is rather hard to describe. I skip that for now. The method works okay-ish, I guess.hours_today
returns the REAL HOURS for the current day. If the shop is OPEN LATE at the time of the method call, this method still returns the current day’s hours and not yesterday’s.If current day’s hours have an OPEN LATE part (e. g.
19:00-03:00
), it will be included in the return value (it won’t be cut at midnight). OPEN LATE hours from yesterday will never be included in the return value.This method’s focus is “informational.” If you have hours for a club, sat: 21:00-05:00, sun: closed, and you call this method at Sun, 1am, it will tell you that the club is closed on Sundays. It won’t tell you that you have got 4 hours left for a visit during the OPEN LATE time from Saturday.
I quote parts of my comment to f63b117:
hours_overview
(the predecessor of this method) was to allow the user to create a table of default$hours
without regards to$exceptions
. I think that we need a method to do this and that we need a more generic name for it.