return $fullMonthNames;
}
+ /**
+ * @param $string
+ *
+ * @return int
+ */
static function unixTime($string) {
if (empty($string)) {
return 0;
* %P - uppercase ante/post meridiem ('AM', 'PM')
* %Y - year as a decimal number including the century ('2005')
*
- * @param $dateString
+ * @param string $dateString
* @param string $format the output format
* @param array $dateParts an array with the desired date parts
*
/**
* converts the date/datetime from ISO format to MySQL format
+ * Note that until CRM-14986/ 4.4.7 this was required whenever the pattern $dao->find(TRUE): $dao->save(); was
+ * used to update an object with a date field was used. The DAO now checks for a '-' in date field strings
+ * & runs this function if the - appears - meaning it is likely redundant in the form & BAO layers
*
* @param string $iso date/datetime in ISO format
*
return FALSE;
}
+ /**
+ * @param $date
+ *
+ * @return bool
+ */
static function isDate(&$date) {
if (CRM_Utils_System::isNull($date)) {
return FALSE;
return TRUE;
}
+ /**
+ * @param null $timeStamp
+ *
+ * @return bool|string
+ */
static function currentDBDate($timeStamp = NULL) {
return $timeStamp ? date('YmdHis', $timeStamp) : date('YmdHis');
}
+ /**
+ * @param $date
+ * @param null $now
+ *
+ * @return bool
+ */
static function overdue($date, $now = NULL) {
$mysqlDate = self::isoToMysql($date);
if (!$now) {
unset($to);
break;
+ case 'greater_previous':
+ $from['d'] = 31;
+ $from['M'] = 12;
+ $from['Y'] = $now['year'] - 1;
+ unset($to);
+ break;
+
case 'ending':
$to['d'] = $now['mday'];
$to['M'] = $now['mon'];
$difference = 2;
$quarter = ceil($now['mon'] / 3);
$quarter = $quarter - $difference;
+ $subtractYear = 0;
if ($quarter <= 0) {
$subtractYear = 1;
$quarter += 4;
case 'earlier':
$quarter = ceil($now['mon'] / 3) - 1;
+ $subtractYear = 0;
if ($quarter <= 0) {
$subtractYear = 1;
$quarter += 4;
unset($to);
break;
+ case 'greater_previous':
+ $quarter = ceil($now['mon'] / 3) - 1;
+ $subtractYear = 0;
+ if ($quarter <= 0) {
+ $subtractYear = 1;
+ $quarter += 4;
+ }
+ $from['M'] = 3 * $quarter;
+ $from['Y'] = $from['Y'] = $now['year'] - $subtractYear;
+ $from['d'] = date('t', mktime(0, 0, 0, $from['M'], 1, $from['Y']));
+ unset($to);
+ break;
+
case 'ending':
$to['d'] = $now['mday'];
$to['M'] = $now['mon'];
unset($to);
break;
+ case 'greater_previous':
+ //from end of past month
+ if ($now['mon'] == 1) {
+ $from['M'] = 12;
+ $from['Y'] = $now['year'] - 1;
+ }
+ else {
+ $from['M'] = $now['mon'] - 1;
+ $from['Y'] = $now['year'];
+ }
+
+ $from['d'] = date('t', mktime(0, 0, 0, $from['M'], 1, $from['Y']));
+ unset($to);
+ break;
+
case 'ending':
$to['d'] = $now['mday'];
$to['M'] = $now['mon'];
unset($to);
break;
+ case 'greater_previous':
+ $from['d'] = $now['mday'];
+ $from['M'] = $now['mon'];
+ $from['Y'] = $now['year'];
+ $from = self::intervalAdd('day', -1 * ($now['wday']) - 1, $from);
+ unset($to);
+ break;
+
case 'ending':
$to['d'] = $now['mday'];
$to['M'] = $now['mon'];
}
+ /**
+ * @param $date
+ * @param $dateType
+ *
+ * @return null|string
+ */
static function formatDate($date, $dateType) {
$formattedDate = NULL;
if (empty($date)) {