Hi
I have a case that I need to test using Today's date, or in fact the MONTH Today.
Looking at the Module Code, I discovered that in addition to documented Testing Cases, the Module will also test against DATE_UNIX_and DATE_STAMP, which is useful but not what I was looking for, so I made some changes to the code to enable the additional cases of:
DATE_MONTH
DATE_WEEKDAY
DATE_YEAR
Additional code was added at line 183:
'DATE_WEEKDAY => Current date in Full Weekday format (' . $this->dateFormatter->format($this->dateTime->getRequestTime()) . ')',
'DATE_MONTH => Current date in Full Month format (' . $this->dateFormatter->format($this->dateTime->getRequestTime()) . ')',
'DATE_YEAR => Current date in (yyyy) Year format (' . $this->dateFormatter->format($this->dateTime->getRequestTime()) . ')',and then at line 317:
// If we find a DATE_WEEKDAY date stamp replacement, replace that.
if (strpos($equalto, 'DATE_WEEKDAY') !== FALSE) {
$equalto = str_replace('DATE_WEEKDAY', $this->dateTime->getRequestTime(), $equalto);
$equalto = date('l',$equalto);
}
if (strpos($then, 'DATE_WEEKDAY') !== FALSE) {
$then = str_replace('DATE_WEEKDAY', $this->dateTime->getRequestTime(), $then);
$then = date('l',$then);
}
if (strpos($or, 'DATE_WEEKDAY') !== FALSE) {
$or = str_replace('DATE_WEEKDAY', $this->dateTime->getRequestTime(), $or);
$or = date('l',$or);
}
// If we find a DATE_MONTH date stamp replacement, replace that.
if (strpos($equalto, 'DATE_MONTH') !== FALSE) {
$equalto = str_replace('DATE_MONTH', $this->dateTime->getRequestTime(), $equalto);
$equalto = date('F',$equalto);
}
if (strpos($then, 'DATE_MONTH') !== FALSE) {
$then = str_replace('DATE_MONTH', $this->dateTime->getRequestTime(), $then);
$then = date('F',$then);
}
if (strpos($or, 'DATE_MONTH') !== FALSE) {
$or = str_replace('DATE_MONTH', $this->dateTime->getRequestTime(), $or);
$or = date('F',$or);
}
// If we find a DATE_YEAR date stamp replacement, replace that.
if (strpos($equalto, 'DATE_YEAR') !== FALSE) {
$equalto = str_replace('DATE_YEAR', $this->dateTime->getRequestTime(), $equalto);
$equalto = date('Y',$equalto);
}
if (strpos($then, 'DATE_YEAR') !== FALSE) {
$then = str_replace('DATE_YEAR', $this->dateTime->getRequestTime(), $then);
$then = date('Y',$then);
}
if (strpos($or, 'DATE_YEAR') !== FALSE) {
$or = str_replace('DATE_YEAR', $this->dateTime->getRequestTime(), $or);
$or = date('Y',$or);
}
This now allows me to test a date field that is formatted as a MONTH, WEEKDAY or YEAR, against today's date as a MONTH, or as the WEEKDAY, or full yyyy YEAR.
I believe that it would be a useful addition to the Module. It certainly sorted out my problem.
Needs review
1.4
Code
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
No activities found.