euromark 13 年之前
父节点
当前提交
fd669e1d28
共有 3 个文件被更改,包括 15 次插入34 次删除
  1. 4 4
      Controller/Component/CommonComponent.php
  2. 1 1
      Lib/Utility/TimeLib.php
  3. 10 29
      View/Helper/DatetimeHelper.php

+ 4 - 4
Controller/Component/CommonComponent.php

@@ -861,13 +861,13 @@ class CommonComponent extends Component {
 	 * @param int $year
 	 * @param int $year
 	 * @param int $month
 	 * @param int $month
 	 * @static
 	 * @static
-	 * TODO: move to DateLib etc
+	 * TODO: move to TimeLib etc
 	 * 2009-12-26 ms
 	 * 2009-12-26 ms
 	 */
 	 */
 	public function daysInMonth($year, $month) {
 	public function daysInMonth($year, $month) {
-		trigger_error('deprecated - use Tools.DatetimeLib instead');
-		App::uses('DatetimeLib', 'Tools.Utility');
-		return DatetimeLib::daysInMonth($year, $month);
+		trigger_error('deprecated - use Tools.TimeLib instead');
+		App::uses('TimeLib', 'Tools.Utility');
+		return TimeLib::daysInMonth($year, $month);
 	}
 	}
 
 
 
 

+ 1 - 1
Lib/Utility/TimeLib.php

@@ -1147,7 +1147,7 @@ class TimeLib extends CakeTime {
 	/**
 	/**
 	 * @param string $searchString to parse
 	 * @param string $searchString to parse
 	 * @param string $fieldname (Model.field)
 	 * @param string $fieldname (Model.field)
-	 * @param array $options (see DatetimeLib::period)
+	 * @param array $options (see TimeLib::period)
 	 * @return string $query SQL Query
 	 * @return string $query SQL Query
 	 * 2011-11-18 ms
 	 * 2011-11-18 ms
 	 */
 	 */

+ 10 - 29
View/Helper/DatetimeHelper.php

@@ -1,6 +1,6 @@
 <?php
 <?php
 
 
-App::uses('DatetimeLib', 'Tools.Utility');
+//App::uses('TimeLib', 'Tools.Utility');
 App::uses('TimeHelper', 'View/Helper');
 App::uses('TimeHelper', 'View/Helper');
 
 
 /**
 /**
@@ -11,9 +11,10 @@ class DatetimeHelper extends TimeHelper {
 
 
 	public $helpers = array('Html');
 	public $helpers = array('Html');
 
 
-	public $Datetime;
+	//public $Time;
 
 
 	protected $userOffset = null;
 	protected $userOffset = null;
+
 	protected $daylightSavings = false;
 	protected $daylightSavings = false;
 
 
 	public function __construct($View = null, $settings = array()) {
 	public function __construct($View = null, $settings = array()) {
@@ -27,20 +28,8 @@ class DatetimeHelper extends TimeHelper {
 		if (!empty($i18n['daylight_savings'])) {
 		if (!empty($i18n['daylight_savings'])) {
 			$this->daylightSavings = (bool)$i18n['daylight_savings'];
 			$this->daylightSavings = (bool)$i18n['daylight_savings'];
 		}
 		}
-		//$this->Datetime = new DatetimeLib();
 	}
 	}
 
 
-	/*
-	public function __call($method, $params) {
-
-		if (!method_exists($this, 'call__')) {
-			//trigger_error(__('Magic method handler call__ not defined in %s', get_class($this)), E_USER_ERROR);
-		}
-		return call_user_func_array(array($this->Datetime, $method), $params);
-	}
-	*/
-
-
 	/**
 	/**
 	 * EXPERIMENTAL!!!
 	 * EXPERIMENTAL!!!
 	 * @param
 	 * @param
@@ -58,7 +47,6 @@ class DatetimeHelper extends TimeHelper {
 		return $offset + ($is_dst ? 3600 : 0);
 		return $offset + ($is_dst ? 3600 : 0);
 	}
 	}
 
 
-
 	/**
 	/**
 	 * @param string date (from db)
 	 * @param string date (from db)
 	 * @return int $age on success, mixed $default otherwise
 	 * @return int $age on success, mixed $default otherwise
@@ -75,9 +63,6 @@ class DatetimeHelper extends TimeHelper {
 			return $default;
 			return $default;
 	}
 	}
 
 
-
-
-
 	/**
 	/**
 	 * Like localDate(), only with additional markup <span> and class="today", if today, etc
 	 * Like localDate(), only with additional markup <span> and class="today", if today, etc
 	 * 2009-11-22 ms
 	 * 2009-11-22 ms
@@ -88,8 +73,6 @@ class DatetimeHelper extends TimeHelper {
 		return $date;
 		return $date;
 	}
 	}
 
 
-
-
 	/**
 	/**
 	 * Like niceDate(), only with additional markup <span> and class="today", if today, etc
 	 * Like niceDate(), only with additional markup <span> and class="today", if today, etc
 	 * 2009-11-22 ms
 	 * 2009-11-22 ms
@@ -100,8 +83,6 @@ class DatetimeHelper extends TimeHelper {
 		return $date;
 		return $date;
 	}
 	}
 
 
-
-
 	/**
 	/**
 	 * returns red/specialGreen/green date depending on the current day
 	 * returns red/specialGreen/green date depending on the current day
 	 * @param date in DB Format (xxxx-xx-xx)
 	 * @param date in DB Format (xxxx-xx-xx)
@@ -125,7 +106,7 @@ class DatetimeHelper extends TimeHelper {
 
 
 			$y = $this->isThisYear($date) ? '' : ' Y';
 			$y = $this->isThisYear($date) ? '' : ' Y';
 
 
-			$format = (!empty($options['format'])?$options['format']:FORMAT_NICE_YMD);
+			$format = (!empty($options['format']) ? $options['format'] : FORMAT_NICE_YMD);
 
 
 			# Hack
 			# Hack
 			# //TODO: get this to work with datetime - somehow cleaner
 			# //TODO: get this to work with datetime - somehow cleaner
@@ -137,13 +118,13 @@ class DatetimeHelper extends TimeHelper {
 
 
 			if ($this->isToday($date)) {
 			if ($this->isToday($date)) {
 				$when = 0;
 				$when = 0;
-				$niceDate = __('Today').$timeAttachment;
+				$niceDate = __('Today') . $timeAttachment;
 			} elseif ($this->isTomorrow($date)) {
 			} elseif ($this->isTomorrow($date)) {
 				$when = 1;
 				$when = 1;
-				$niceDate = __('Tomorrow').$timeAttachment;
+				$niceDate = __('Tomorrow') . $timeAttachment;
 			} elseif ($this->wasYesterday($date)) {
 			} elseif ($this->wasYesterday($date)) {
 				$when = -1;
 				$when = -1;
-				$niceDate = __('Yesterday').$timeAttachment;
+				$niceDate = __('Yesterday') . $timeAttachment;
 			} else {
 			} else {
 				# before or after?
 				# before or after?
 				if ($this->isNotTodayAndInTheFuture($date)) {
 				if ($this->isNotTodayAndInTheFuture($date)) {
@@ -151,7 +132,7 @@ class DatetimeHelper extends TimeHelper {
 				} else {
 				} else {
 					$when = -1;
 					$when = -1;
 				}
 				}
-				$niceDate = $this->niceDate($date, $format).$timeAttachment; //date("M jS{$y}", $date);
+				$niceDate = $this->niceDate($date, $format) . $timeAttachment; //date("M jS{$y}", $date);
 			}
 			}
 
 
 			if (!empty($whenOverride) && $when == 0) {
 			if (!empty($whenOverride) && $when == 0) {
@@ -189,13 +170,13 @@ class DatetimeHelper extends TimeHelper {
 		}
 		}
 		$span = '<span'.$attr.'>';
 		$span = '<span'.$attr.'>';
 		$spanEnd = '</span>';
 		$spanEnd = '</span>';
-		return $span.$niceDate.$spanEnd;
+		return $span . $niceDate . $spanEnd;
 	}
 	}
 
 
 
 
 
 
 	/**
 	/**
-	 * @deprecated - use DatetimeLib::isInRange()
+	 * @deprecated - use TimeLib::isInRange()
 	 * for birthdays etc
 	 * for birthdays etc
 	 * @param date
 	 * @param date
 	 * @param string days with +-
 	 * @param string days with +-