Two thoughts.
Why not just set <arg id="start_date">today</arg>? Assuming events can “fall off” the schedule as they pass, as the filter suggests, and assuming the events shown are limited by group/tag, setting start_date to today would solve the lingering issue I think. After all events pass, or when today > end_date, then it should return nothing and continue on.
You can define custom xphp variables. For instance, I have this in a public module to allow for groups widgets (I think from before they were a widget option):
<?
if (strpos($buffer, '<xphp var="group_list_public"')!==false) {
$groups = $this->getGroupData();
$GLOBALS['group_list_public'] = $this->groupListTypesExclude($groups, ['Web Utility', 'Other'], 'alpha');
};
So, for the value of next year, you could include something like this:
<?
if (strpos($buffer, '<xphp var="server_next_year"')!==false) {
$GLOBALS['server_next_year'] = date('Y') + 1;
};
Or, potentially, you can use the custom variables to solve the first issue with something like this:
<?
if (strpos($buffer, '<xphp var="commencement_year_check_may"')!==false) {
$GLOBALS['commencement_year_check_may'] = date('n') <= 5 ? date('Y') : 1970;
};
if (strpos($buffer, '<xphp var="commencement_year_check_dec"')!==false) {
$GLOBALS['commencement_year_check_may'] = date('n') > 5 ? date('Y') : 1970;
};
if (strpos($buffer, '<xphp var="server_next_year"')!==false) {
$GLOBALS['next_year'] = date('Y') + 1;
};
Where we use the year 1970 in the end date to force the widget to return nothing.
So, perhaps something like this if you need to constrain to the month’s events specifically:
<arg id="filter" name="date_dt" action="greater_than">today</arg>
<!-- Show events between May 1-31 of this year -->
<arg id="start_date">05/01/<xphp var="server_date_year"/></arg>
<arg id="end_date">05/31/<xphp var="commencement_year_check_may"/></arg>
<!-- If none, show events between December 1-31 of this year -->
<arg id="fallback">
<arg id="start_date">12/01/<xphp var="server_date_year"/></arg>
<arg id="end_date">12/31/<xphp var="commencement_year_check_dec"/></arg>
</arg>
<!-- If still none, show events between May 1-31 of next year -->
<arg id="fallback">
<arg id="start_date">05/01/<xphp var="server_next_year"/></arg>
<arg id="end_date">05/31/<xphp var="server_next_year"/></arg>
</arg>
Or perhaps more simply if events are well-defined or filtered by tag/group:
<!-- Show events between May 1-31 of this year -->
<arg id="start_date">today</arg>
<arg id="end_date">05/31/<xphp var="commencement_year_check_may"/></arg>
<!-- If none, show events between December 1-31 of this year -->
<arg id="fallback">
<arg id="start_date">today</arg>
<arg id="end_date">12/31/<xphp var="commencement_year_check_dec"/></arg>
</arg>
<!-- If still none, show events between May 1-31 of next year -->
<arg id="fallback">
<arg id="start_date">05/01/<xphp var="server_next_year"/></arg>
<arg id="end_date">05/31/<xphp var="server_next_year"/></arg>
</arg>