function _simpleads_ad_dates in SimpleAds 7.2
Check advertisement active dates.
1 call to _simpleads_ad_dates()
- simpleads_field_formatter_view in includes/
field.inc - Implements hook_field_formatter_view().
File
- includes/
helper.inc, line 66 - Helper functions.
Code
function _simpleads_ad_dates($date1, $date2, $entity_status = NULL) {
$result = "";
$current_timestamp = REQUEST_TIME;
$status = $entity_status ? t('Active') . ', ' : t('Inactive') . ', ';
$status = '<em>' . $status . '</em>';
if (empty($date1) || $date1 == $date2) {
$timestamp = strtotime($date1);
if ($timestamp > $current_timestamp) {
$result = t('!status starting on <b>!start-date</b>', array(
'!status' => $status,
'!start-date' => $date1,
));
}
else {
$result = t('!status Expired on <b>!start-date</b>', array(
'!status' => $status,
'!start-date' => $date1,
));
}
}
else {
$timestamp1 = strtotime($date1);
$timestamp2 = strtotime($date2);
if ($timestamp1 > $current_timestamp && $current_timestamp < $timestamp2) {
$result = t('!status starts on <b>!start-date</b> and expires on <b>!end-date</b>', array(
'!status' => $status,
'!start-date' => $date1,
'!end-date' => $date2,
));
}
elseif ($timestamp1 < $current_timestamp && $current_timestamp < $timestamp2) {
$result = t('!status started on <b>!start-date</b> and expires on <b>!end-date</b>', array(
'!status' => $status,
'!start-date' => $date1,
'!end-date' => $date2,
));
}
else {
$result = t('!status Expired on <b>!end-date</b>', array(
'!status' => $status,
'!start-date' => $date1,
'!end-date' => $date2,
));
}
}
return $result;
}