eZTime Class Reference
[Locale system]

Locale aware time handler. More...

List of all members.


Public Methods

 eZTime ($time=false)
isValid ()
 setLocale (&$locale)
locale ()
timeZone ()
 setHour ($hour)
 setMinute ($min)
 setSecond ($sec)
 setHMS ($hour,$min=0,$sec=0)
hour ()
minute ()
second ()
timeStamp ()
 adjustTime ($hour,$min=0,$sec=0)
create ($hour=-1,$min=-1,$sec=-1)
duplicate ()
 isGreaterThan (&$time,$equal=false)
 isEqualTo (&$time)
toString ($short=false)

Public Attributes

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

 Time
 The current time as a clamped timestamp.


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 locale().

You can also change the time directly with second() for the respective values.

When creating new times you're advised to use the static duplicate() function.

Time checking is done with the 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:

include_once( 'lib/ezlocale/classes/ezlocale.php' );
include_once( 'lib/ezlocale/classes/eztime.php' );

$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:
eZLocale

Definition at line eztime.php.


Constructor & Destructor Documentation

eZTime::eZTime   time = false
 

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

Definition at line eztime.php.

References Time.

Referenced by duplicate().


Member Function Documentation

eZTime::adjustTime   hour,
  min = 0,
  sec = 0
 

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

Definition at line eztime.php.

References Time.

& eZTime::create   hour = -1,
  min = -1,
  sec = -1
 

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.

Definition at line eztime.php.

References hour().

& eZTime::duplicate  
 

Creates an exact copy of this object and returns a reference to it.

Definition at line eztime.php.

References eZTime().

& eZTime::hour  
 

Returns the hour element.

Definition at line eztime.php.

Referenced by setHour().

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.

Definition at line eztime.php.

References Time.

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.

Definition at line eztime.php.

References Time.

& eZTime::isValid  
 

Returns:
true if the date has valid data.

Definition at line eztime.php.

& eZTime::locale  
 

Returns a reference to the current locale.

Definition at line eztime.php.

References Locale.

Referenced by setLocale().

& eZTime::minute  
 

Returns the minute element.

Definition at line eztime.php.

& eZTime::second  
 

Returns the second element.

Definition at line eztime.php.

eZTime::setHMS   hour,
  min = 0,
  sec = 0
 

Sets all hour, minute and second elements.

Definition at line eztime.php.

References Time.

eZTime::setHour   hour
 

Sets the hour leaving the other elements untouched.

Definition at line eztime.php.

References Time.

eZTime::setLocale &$    locale
 

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

Definition at line eztime.php.

References locale().

eZTime::setMinute   min
 

Sets the minute leaving the other elements untouched.

Definition at line eztime.php.

References Time.

eZTime::setSecond   sec
 

Sets the second leaving the other elements untouched.

Definition at line eztime.php.

References Time.

& eZTime::timeStamp  
 

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.

Note:
The value is returned as a reference and should not be modified.

Definition at line eztime.php.

References Time.

& eZTime::timeZone  
 

Returns the current time zone.

Definition at line eztime.php.

& 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.

Definition at line eztime.php.

References Locale.


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

Exponential