eZPublish(LegacyStack)  5.1
eZTime Class Reference

Locale aware time handler. More...

Public Member Functions

 adjustTime ($hour, $minute=0, $second=0)
 
 attribute ($name)
 
 attributes ()
 
 duplicate ()
 
 eZTime ($timestamp=false)
 
 hasAttribute ($name)
 
 hour ()
 
 isEqualTo (&$time)
 
 isGreaterThan (&$time, $equal=false)
 
 isValid ()
 
locale ()
 
 minute ()
 
 second ()
 
 setHMS ($hour, $min=0, $sec=0)
 
 setHour ($hour)
 
 setLocale (&$locale)
 
 setMinute ($min)
 
 setSecond ($sec)
 
 setTimeOfDay ($timestamp)
 
 setTimeStamp ($timestamp)
 
 timeOfDay ()
 
 timeStamp ()
 
 toString ($short=false)
 

Static Public Member Functions

static create ($hour=-1, $minute=-1, $second=-1)
 
static secondsPerDay ()
 

Public Attributes

 $Locale
 Locale object, is just a reference to minimize memory usage. More...
 
 $Time
 The current time as a clamped timestamp. More...
 
const SECONDS_A_DAY = 86400
 
const SECONDS_A_MINUTE = 60
 
const SECONDS_AN_HOUR = 3600
 

Detailed Description

Locale aware time handler.

eZTime handles 24 hour time values in hours, minutes and seconds. The time stored as a timestamp clamped to a 24 hour day, ie 86400.

A new instance of eZTime will automaticly use the current locale and current time, if you however want a different locale use the setLocale() function. The current locale can be fetched with locale().

You can also change the time directly with setHour(), setMinute(), setSecond() and setHMS(). You can also adjust the time relative to it's current value by using adjustTime(). Use timeStamp() to get the current timestamp value or hour(), minute() and second() for the respective values.

When creating new times you're advised to use the static create() function which returns a new eZTime object. You can also create a copy with the duplicate() function.

Time checking is done with the isGreaterThan() and isEqualTo() functions.

Text output is done with toString() which can return a long string (default) or short string representation according to the current locale.

Example:

$us_locale = eZLocale::instance( 'us' );
$time1 = new eZTime();
$time2 = eZTime::create();
$time2->setLocale( $us_locale );
$time2->adjustTime( -8 );
$time3 = $time1->duplicate();
print( $time1->toString() );
print( $time2->toString( true ) );
print( $time1->isEqualTo( $time3 ) ? 'true' : 'false' ); // Prints 'true'
See Also
eZDate, eZDateTime, eZLocale

Member Function Documentation

eZTime::adjustTime (   $hour,
  $minute = 0,
  $second = 0 
)

Adjusts the time relative to it's current value. This is useful for adding/subtracting hours, minutes or seconds to an existing time.

eZTime::attribute (   $name)
eZTime::attributes ( )

Referenced by hasAttribute().

static eZTime::create (   $hour = -1,
  $minute = -1,
  $second = -1 
)
static

Creates a new eZTime object with the time values $hour, $min and $sec and returns a reference to it. Any value can be ommitted or set to -1 to use the current time value.

eZTime::duplicate ( )
Deprecated:
This function is deprecated in PHP5, use the PHP5 clone keyword instead Creates an exact copy of this object and returns it.
eZTime::eZTime (   $timestamp = false)

Creates a new time object with default locale, if $time is not supplied the current time is used.

Referenced by create().

eZTime::hasAttribute (   $name)
eZTime::hour ( )

Returns the hour element.

Referenced by attribute(), setMinute(), setSecond(), and timeStamp().

eZTime::isEqualTo ( $time)

Returns true if this object is equal to $time. $time can be specified as a timestamp value or as an eZTime object.

eZTime::isGreaterThan ( $time,
  $equal = false 
)

Returns true if this object has a time greater than $time. $time can be specified as a timestamp value or as an eZTime object. If $equal is true it returns true if they are equal as well.

eZTime::isValid ( )
Returns
true if the date has valid data.

Referenced by attribute().

& eZTime::locale ( )

Returns a reference to the current locale.

eZTime::minute ( )

Returns the minute element.

Referenced by attribute(), setHour(), setSecond(), and timeStamp().

eZTime::second ( )

Returns the second element.

Referenced by attribute(), setHour(), setMinute(), and timeStamp().

static eZTime::secondsPerDay ( )
static
Deprecated:
Use eZTime::SECONDS_A_DAY instead Get number of seconds per day
eZTime::setHMS (   $hour,
  $min = 0,
  $sec = 0 
)

Sets all hour, minute and second elements.

Referenced by eZTime().

eZTime::setHour (   $hour)

Sets the hour leaving the other elements untouched.

eZTime::setLocale ( $locale)

Sets the locale to $locale which is used in text output.

eZTime::setMinute (   $min)

Sets the minute leaving the other elements untouched.

eZTime::setSecond (   $sec)

Sets the second leaving the other elements untouched.

eZTime::setTimeOfDay (   $timestamp)

Referenced by adjustTime(), and eZTime().

eZTime::setTimeStamp (   $timestamp)

Referenced by eZTime().

eZTime::timeOfDay ( )

Returns the timestamp value, this is not the number of seconds since the epoch but a clamped value to the number of seconds in a day.

Referenced by attribute().

eZTime::timeStamp ( )

Referenced by attribute(), and toString().

eZTime::toString (   $short = false)

Creates a string representation of the time using the current locale and returns it. If $short is true a short representation is used.

Member Data Documentation

eZTime::$Locale

Locale object, is just a reference to minimize memory usage.

Referenced by locale().

eZTime::$Time

The current time as a clamped timestamp.

Referenced by isEqualTo(), isGreaterThan(), and timeOfDay().

const eZTime::SECONDS_A_DAY = 86400

Number of seconds in a day.

const eZTime::SECONDS_A_MINUTE = 60

Number of seconds in a minute.

const eZTime::SECONDS_AN_HOUR = 3600

Number of seconds in an hour.


The documentation for this class was generated from the following file: