Permalink
Browse files

MINOR phpDoc to methods in Date, small tweaks to DayOfMonth method to…

… be consistent with value checks
  • Loading branch information...
1 parent f4a758e commit 8109a5e54d5be92e6c1b4fa776841a414fee3e05 @halkyon halkyon committed Feb 29, 2012
Showing with 13 additions and 7 deletions.
  1. +13 −7 model/fieldtypes/Date.php
View
@@ -33,7 +33,7 @@ function setValue($value) {
$this->value = $value['Year'] . '-' . $value['Month'] . '-' . $value['Day'];
return;
} 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;
}
}
@@ -93,15 +93,18 @@ function ShortMonth() {
}
/**
- * 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) {
- $format = 'j';
- if ($includeOrdinal) $format .= 'S';
- if($this->value) return date($format, strtotime($this->value));
+ if($this->value) {
+ $format = 'j';
+ if ($includeOrdinal) $format .= 'S';
+ return date($format, strtotime($this->value));
+ }
}
-
/**
* Returns the date in the format 24 December 2006
*/
@@ -132,7 +135,7 @@ function Format($format) {
* strftime obeys the current LC_TIME/LC_ALL when printing lexical values
* like day- and month-names
*/
- function FormatI18N($formattingString) {
+ function FormatI18N($formattingString) {
if($this->value) {
$fecfrm = strftime($formattingString, strtotime($this->value));
return utf8_encode($fecfrm);
@@ -141,6 +144,9 @@ function FormatI18N($formattingString) {
/*
* 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) {
$d1 = $this->DayOfMonth($includeOrdinals);

0 comments on commit 8109a5e

Please sign in to comment.