00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
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
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 ?>