berlindb / core

All of the required core code
MIT License
252 stars 27 forks source link

Date Query: abstract start_of_week inside of build_mysql_week() #80

Closed JJJ closed 3 years ago

JJJ commented 3 years ago

In 87fa6d5, Berlin brought 2 WordPress core functions into Queries\Date public methods.

Now, inside of build_mysql_week(), there is a get_option( 'start_of_week' ) call that Sugar Calendar would benefit from being able to more easily override.

The purpose of this get_option() call is to ensure that WEEK() MySQL statements on specific columns use the correct the "offset" or INTERVAL and DAY as needed. Sugar Calendar uses its own sc_start_of_week setting, which does fallback to start_of_week already, so it's not possible to filter it the other direction without creating an infinite loop situation.

JJJ commented 3 years ago

The second parameter in build_mysql_week() already accepts $start_of_week, so my thought is that Queries\Date could add start_of_week as a first-order query argument, akin to column, compare, and relation.

PR imminent.