TimeObject.object
上传用户:xiao730204
上传日期:2007-01-04
资源大小:141k
文件大小:2k
- <?php
- class TimeObject extends BaseObject {
- var $time;
- var $hour;
- var $min;
- var $sec;
- var $am_pm;
- var $month;
- var $day;
- var $year;
- Function TimeObject() {
- $this->BaseObject( 'TimeObject' );
- $this->time = 0;
- $this->hour = 0;
- $this->min = 0;
- $this->sec = 0;
- $this->am_pm = 0;
- $this->month = 0;
- $this->day = 0;
- $this->year = 0;
- $this->GetLocalTime();
- $this->FormatTime();
- }
- Function GetLocalTime() {
- $this->time = time();
- }
- Function FormatTime() {
- $this->hour = date( 'h', $this->time );
- $this->min = date( 'i', $this->time );
- $this->sec = date( 's', $this->time );
- $this->am_pm = date( 'A', $this->time );
- $this->month = date( 'm', $this->time );
- $this->day = date( 'd', $this->time );
- $this->year = date( 'Y', $this->time );
- }
- Function Modify(
- $hour = 0,
- $min = 0,
- $sec = 0,
- $mon = 0,
- $day = 0,
- $year = 0
- ) {
- if ( $hour != 0 ) { $this->hour += $hour; }
- if ( $min != 0 ) { $this->min += $min; }
- if ( $sec != 0 ) { $this->sec += $sec; }
- if ( $mon != 0 ) { $this->month += $mon; }
- if ( $day != 0 ) { $this->day += $day; }
- if ( $year != 0 ) { $this->year += $year; }
- $this->time = mktime(
- $this->hour,
- $this->min,
- $this->sec,
- $this->month,
- $this->day,
- $this->year
- );
- }
- /*
- This is a fix for php3's broken serialize that exhibits the
- need to strip functions off of object references
- */
- Function Copy( $broken_object ) {
- $this->hour = $broken_object->hour;
- $this->min = $broken_object->min;
- $this->sec = $broken_object->sec;
- $this->month = $broken_object->month;
- $this->day = $broken_object->day;
- $this->year = $broken_object->year;
- $this->time = $broken_object->time;
- $this->Modify();
- }
- }
- ?>