MINOR phpDoc to methods in Date, small tweaks to DayOfMonth method to be consistent with value checks

This commit is contained in:
Sean Harvey 2012-03-01 09:56:05 +13:00
parent f4a758e500
commit 8109a5e54d

View File

@ -33,7 +33,7 @@ class Date extends DBField {
$this->value = $value['Year'] . '-' . $value['Month'] . '-' . $value['Day']; $this->value = $value['Year'] . '-' . $value['Month'] . '-' . $value['Day'];
return; return;
} else { } else {
// return nothing (so ereg() doesn't fail on an empty array below) // return nothing (so checks below don't fail on an empty array)
return null; return null;
} }
} }
@ -93,14 +93,17 @@ class Date extends DBField {
} }
/** /**
* Returns the date of the month * Returns the day of the month.
* @param boolean $includeOrdinals Include ordinal suffix to day, e.g. "th" or "rd"
* @return string
*/ */
function DayOfMonth($includeOrdinal = false) { function DayOfMonth($includeOrdinal = false) {
if($this->value) {
$format = 'j'; $format = 'j';
if ($includeOrdinal) $format .= 'S'; if ($includeOrdinal) $format .= 'S';
if($this->value) return date($format, strtotime($this->value)); return date($format, strtotime($this->value));
}
} }
/** /**
* Returns the date in the format 24 December 2006 * Returns the date in the format 24 December 2006
@ -141,6 +144,9 @@ class Date extends DBField {
/* /*
* Return a string in the form "12 - 16 Sept" or "12 Aug - 16 Sept" * Return a string in the form "12 - 16 Sept" or "12 Aug - 16 Sept"
* @param Date $otherDateObj Another date object specifying the end of the range
* @param boolean $includeOrdinals Include ordinal suffix to day, e.g. "th" or "rd"
* @return string
*/ */
function RangeString($otherDateObj, $includeOrdinals = false) { function RangeString($otherDateObj, $includeOrdinals = false) {
$d1 = $this->DayOfMonth($includeOrdinals); $d1 = $this->DayOfMonth($includeOrdinals);