I am building a directory of businesses and want to not only publish a list of business hours, but also to publish if a business is currently open for business.
In a matrix, I have 7 rows with row_1 representing Sunday row_7 for Saturday. So I have two questions.
Is there a flaw in the conditional that tells whether a business is currently open? It seems to work right now, but not very tested.
{!-- Hours of Operation --}
{exp:stash:set name="hours-of-operation"}
The Current time is: {current_time format="%g:%i%a"}<br/>
{hours_of_operation}
{if row_count=="1"}Sunday{/if}
{if row_count=="2"}Monday{/if}
{if row_count=="3"}Tuesday{/if}
{if row_count=="4"}Wednesday{/if}
{if row_count=="5"}Thursday{/if}
{if row_count=="6"}Friday{/if}
{if row_count=="7"}Saturday{/if}
{open_time format="%g:%i%a"} - {close_time format="%g:%i%a"}<br/>
{/hours_of_operation}
{/exp:stash:set}
{!-- Hours of Operation --}
{!-- Are we open? --}
{exp:stash:set name="are-we-open"}
{exp:mx_calc expression='{current_time format="%w"}+1'}
{!-- matrix --}
{hours_of_operation}
{if row_count=="{calc_result}"}
Today is: {current_time format="%l"}<br/>
<strong>
{if '{open_time format="%H%i"}' <= '{current_time format="%H%i"}' && '{close_time format="%H%i"}' <= '{current_time format="%H%i"}'}
We are currently open!{if:else}We are currently closed.
{/if}
</strong><br/>
Today's Hours are:<br/> <strong>{open_time format="%g:%i%a"} - {close_time format="%g:%i%a"}</strong><br/>
{/if}
{/hours_of_operation}
{!-- matrix --}
{/exp:mx_calc}
{/exp:stash:set}
{!-- Are we open? --}
Operations on Matrices Addition, subtraction and multiplication are the basic operations on the matrix. To add or subtract matrices, these must be of identical order and for multiplication, the number of columns in the first matrix equals the number of rows in the second matrix.
Multiplying a row by a non-zero constant. On this elementary row operations matrix process we have multiplied the non-zero constant 3 to the first row of the original matrix. Such operation is represented by 3 R 1 ↔ R 1 3R_{1} \leftrightarrow R_{1} 3R1↔R1.
Multiplying any row or column of a determinant by a number , multiplies the determinant by that number: This means that the common factor of a row (or column) can be taken outside the sign of a determinant. Let A and B be square matrices of the same order.
This looks good to me, the only thing I would change is add another column on the left of the matrix and call it day of week with a drop down to allow the client to select the day. then in your code you can get rid of all those conditionals and replace it with just {day_of_week}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With