TimeObject.object
上传用户:xiao730204
上传日期:2007-01-04
资源大小:141k
文件大小:2k
源码类别:

WEB邮件程序

开发平台:

PHP

  1. <?php
  2. class TimeObject extends BaseObject {
  3.    var $time;
  4.    var $hour;
  5.    var $min;
  6.    var $sec;
  7.    var $am_pm;
  8.    var $month;
  9.    var $day;
  10.    var $year;
  11.    Function TimeObject() {
  12.       $this->BaseObject( 'TimeObject' );
  13.       $this->time       = 0;
  14.       $this->hour       = 0;
  15.       $this->min        = 0;
  16.       $this->sec        = 0;
  17.       $this->am_pm      = 0;
  18.       $this->month      = 0;
  19.       $this->day        = 0;
  20.       $this->year       = 0;
  21.       $this->GetLocalTime();
  22.       $this->FormatTime();
  23.    }
  24.    Function GetLocalTime() {
  25.       $this->time       = time();
  26.    }
  27.    Function FormatTime() {
  28.       $this->hour       = date( 'h', $this->time );
  29.       $this->min        = date( 'i', $this->time );
  30.       $this->sec        = date( 's', $this->time );
  31.       $this->am_pm      = date( 'A', $this->time );
  32.       $this->month      = date( 'm', $this->time );
  33.       $this->day        = date( 'd', $this->time );
  34.       $this->year       = date( 'Y', $this->time );
  35.    }
  36.    Function Modify( 
  37.       $hour          = 0, 
  38.       $min           = 0, 
  39.       $sec           = 0,
  40.       $mon           = 0,
  41.       $day           = 0,
  42.       $year          = 0
  43.    ) {
  44.       if ( $hour != 0 ) {  $this->hour    += $hour;   }
  45.       if ( $min  != 0 ) {  $this->min     += $min;    }
  46.       if ( $sec  != 0 ) {  $this->sec     += $sec;    }
  47.       if ( $mon  != 0 ) {  $this->month   += $mon;    }
  48.       if ( $day  != 0 ) {  $this->day     += $day;    }
  49.       if ( $year != 0 ) {  $this->year    += $year;   }
  50.       $this->time = mktime( 
  51.          $this->hour,
  52.          $this->min,
  53.          $this->sec,
  54.          $this->month,
  55.          $this->day,
  56.          $this->year
  57.       );
  58.    }
  59.    /* 
  60.    This is a fix for php3's broken serialize that exhibits the
  61.    need to strip functions off of object references
  62.    */
  63.    Function Copy( $broken_object ) {
  64.       $this->hour          = $broken_object->hour;
  65.       $this->min           = $broken_object->min;
  66.       $this->sec           = $broken_object->sec;
  67.       $this->month         = $broken_object->month;
  68.       $this->day           = $broken_object->day;
  69.       $this->year          = $broken_object->year;
  70.       $this->time          = $broken_object->time;
  71.       $this->Modify();
  72.    }
  73. }
  74. ?>