PrimitiveTimestamp.class.php

Go to the documentation of this file.
00001 <?php
00002 /***************************************************************************
00003  *   Copyright (C) 2006-2007 by Konstantin V. Arkhipov                     *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU Lesser General Public License as        *
00007  *   published by the Free Software Foundation; either version 3 of the    *
00008  *   License, or (at your option) any later version.                       *
00009  *                                                                         *
00010  ***************************************************************************/
00011 /* $Id: PrimitiveTimestamp.class.php 4687 2007-12-09 18:57:18Z voxus $ */
00012 
00016     final class PrimitiveTimestamp extends PrimitiveDate
00017     {
00018         const HOURS     = 'hrs';
00019         const MINUTES   = 'min';
00020         const SECONDS   = 'sec';
00021         
00022         public function importMarried($scope)
00023         {
00024             if (
00025                 BasePrimitive::import($scope)
00026                 && isset(
00027                     $scope[$this->name][self::DAY],
00028                     $scope[$this->name][self::MONTH],
00029                     $scope[$this->name][self::YEAR]
00030                 )
00031                 && is_array($scope[$this->name])
00032             ) {
00033                 if ($this->isEmpty($scope))
00034                     return !$this->isRequired();
00035                 
00036                 $hours = $minutes = $seconds = 0;
00037                 
00038                 if (isset($scope[$this->name][self::HOURS]))
00039                     $hours = (int) $scope[$this->name][self::HOURS];
00040                 
00041                 if (isset($scope[$this->name][self::MINUTES]))
00042                     $minutes = (int) $scope[$this->name][self::MINUTES];
00043                 
00044                 if (isset($scope[$this->name][self::SECONDS]))
00045                     $seconds = (int) $scope[$this->name][self::SECONDS];
00046                 
00047                 $year = (int) $scope[$this->name][self::YEAR];
00048                 $month = (int) $scope[$this->name][self::MONTH];
00049                 $day = (int) $scope[$this->name][self::DAY];
00050                 
00051                 if (!checkdate($month, $day, $year))
00052                     return false;
00053                 
00054                 try {
00055                     $stamp = new Timestamp(
00056                         $year.'-'.$month.'-'.$day.' '
00057                         .$hours.':'.$minutes.':'.$seconds
00058                     );
00059                 } catch (WrongArgumentException $e) {
00060                     // fsck wrong stamps
00061                     return false;
00062                 }
00063                 
00064                 if ($this->checkRanges($stamp)) {
00065                     $this->value = $stamp;
00066                     return true;
00067                 }
00068             }
00069             
00070             return false;
00071         }
00072         
00073         protected function getObjectName()
00074         {
00075             return 'Timestamp';
00076         }
00077     }
00078 ?>

Generated on Sun Dec 9 21:56:23 2007 for onPHP by  doxygen 1.5.4