Changeset 440
- Timestamp:
- 05/18/07 10:20:59 (2 years ago)
- Files:
-
- trunk/lib/jelix/utils/jDateTime.class.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/jelix/utils/jDateTime.class.php
r386 r440 5 5 * @author Gérald Croes, Laurent Jouanneau 6 6 * @contributor Laurent Jouanneau 7 * @contributor Loic Mathaud 7 8 * @copyright 2001-2005 CopixTeam 2005-2006 Laurent Jouanneau 9 * @copyright 2007 Loic Mathaud 8 10 * @link http://www.jelix.org 9 11 * @licence http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public Licence, see LICENCE file … … 246 248 /** 247 249 * add a duration to the date 248 * @param jDateTime $dt the duration value 249 */ 250 public function add($dt){ 251 250 * @param jDateTime/int $year the duration value or a year with 4 digits 251 * @param int $month month with 2 digits 252 * @param int $day day with 2 digits 253 * @param int $hour hour with 2 digits 254 * @param int $minute minute with 2 digits 255 * @param int $second second with 2 digits 256 */ 257 public function add($year, $month=0, $day=0, $hour=0, $minute=0, $second=0) { 258 if ($year instanceof jDateTime) { 259 $dt = $year; 260 } else { 261 $dt = new jDateTime($year, $month, $day, $hour, $minute, $second); 262 } 252 263 $t = mktime ( $this->hour + $dt->hour, $this->minute + $dt->minute, $this->second + $dt->second , 253 264 $this->month + $dt->month, $this->day + $dt->day, $this->year + $dt->year); … … 264 275 /** 265 276 * substract a duration to the date 266 * @param jDateTime $dt the duration value 267 */ 268 public function sub($dt){ 277 * @param jDateTime/int $year the duration value or a year with 4 digits 278 * @param int $month month with 2 digits 279 * @param int $day day with 2 digits 280 * @param int $hour hour with 2 digits 281 * @param int $minute minute with 2 digits 282 * @param int $second second with 2 digits 283 */ 284 public function sub($year, $month=0, $day=0, $hour=0, $minute=0, $second=0) { 285 if ($year instanceof jDateTime) { 286 $dt = $year; 287 } else { 288 $dt = new jDateTime($year, $month, $day, $hour, $minute, $second); 289 } 269 290 $t = mktime ( $this->hour - $dt->hour, $this->minute - $dt->minute, $this->second - $dt->second , 270 291 $this->month - $dt->month, $this->day - $dt->day, $this->year - $dt->year); … … 305 326 } 306 327 328 /** 329 * set date to current datetime 330 */ 331 public function now() { 332 $this->year = date('Y'); 333 $this->month = date('m'); 334 $this->day = date('d'); 335 $this->hour = date('H'); 336 $this->minute = date('i'); 337 $this->second = date('s'); 338 } 307 339 } 308 340
