eZ Publish  [4.2]
eZDate Class Reference

Locale aware date handler. More...

List of all members.

Public Member Functions

 adjustDate ($month, $day=0, $year=0)
 attribute ($name)
 attributes ()
 day ()
 duplicate ()
 eZDate ($date=false)
 hasAttribute ($name)
 isEqualTo ($date)
 isGreaterThan ($date, $equal=false)
 isValid ()
 locale ()
 month ()
 setDay ($day)
 setLocale ($locale)
 setMDY ($month, $day=0, $year=0)
 setMonth ($month)
 setTimeStamp ($stamp)
 setYear ($year)
 timeStamp ()
 toString ($short=false)
 year ()

Static Public Member Functions

static create ($month, $day=0, $year=0)

Public Attributes

 $Date
 The current date as a timestamp without hour, minute or second values.
 $IsValid
 $Locale
 Locale object, is just a reference to minimize memory usage.

Detailed Description

Locale aware date handler.

eZDate handles date values in months, days and years. The time stored as a timestamp with 0 hours, 0 minutes and 0 seconds.

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

Change the date directly with setYear(), setMonth(), setDay() and setMDY(). You can also adjust the date relative to it's current value by using adjustDate(). Use timeStamp() to get the current timestamp value or year(), month() and day() for the respective values.

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

Date 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:

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

$us_locale = eZLocale::instance( 'us' );

$date1 = new eZDate();
$date2 = eZDate::create();
$date2->setLocale( $us_locale );
$date2->adjustDate( 1, 2, 3 );
$date3 = $date1->duplicate();

print( $date1->toString() );
print( $date2->toString( true ) );
print( $date1->isEqualTo( $date3 ) ? 'true' : 'false' ); // Prints 'true'
See also:
eZTime, eZDateTime, eZLocale

Definition at line 79 of file ezdate.php.


Member Function Documentation

eZDate::adjustDate ( month,
day = 0,
year = 0 
)

Adjusts the date relative to it's current value. This is useful for adding/subtracting years, months or days to an existing date.

Definition at line 242 of file ezdate.php.

eZDate::attribute ( name)

Definition at line 115 of file ezdate.php.

eZDate::attributes ( )

Definition at line 101 of file ezdate.php.

Referenced by hasAttribute().

static eZDate::create ( month,
day = 0,
year = 0 
) [static]

Creates a new eZDate object with the date values $month, $day and $year and returns a reference to it. Any value can be ommitted or set to 0 to use the current date value.

Definition at line 296 of file ezdate.php.

eZDate::day ( )

Returns the day element.

Definition at line 218 of file ezdate.php.

Referenced by attribute().

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

Definition at line 312 of file ezdate.php.

eZDate::eZDate ( date = false)

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

Definition at line 85 of file ezdate.php.

Referenced by create().

eZDate::hasAttribute ( name)

Definition at line 110 of file ezdate.php.

eZDate::isEqualTo ( date)

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

Definition at line 277 of file ezdate.php.

eZDate::isGreaterThan ( date,
equal = false 
)

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

Definition at line 254 of file ezdate.php.

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

Definition at line 135 of file ezdate.php.

Referenced by attribute().

eZDate::locale ( )

Returns the current locale.

Definition at line 151 of file ezdate.php.

eZDate::month ( )

Returns the month element.

Definition at line 210 of file ezdate.php.

Referenced by attribute().

eZDate::setDay ( day)

Sets the day leaving the other elements untouched.

Definition at line 193 of file ezdate.php.

eZDate::setLocale ( locale)

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

Definition at line 143 of file ezdate.php.

eZDate::setMDY ( month,
day = 0,
year = 0 
)

Sets the year, month and day elements. If $day or $year is omitted or set 0 they will get a value taken from the current time.

Definition at line 227 of file ezdate.php.

eZDate::setMonth ( month)

Sets the month leaving the other elements untouched.

Definition at line 184 of file ezdate.php.

eZDate::setTimeStamp ( stamp)

Definition at line 166 of file ezdate.php.

eZDate::setYear ( year)

Sets the year leaving the other elements untouched.

Definition at line 175 of file ezdate.php.

eZDate::timeStamp ( )

Returns the timestamp value, this is the number of seconds since the epoch with hours, minutes and seconds set to 0.

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

Definition at line 161 of file ezdate.php.

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

eZDate::toString ( short = false)

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

Definition at line 322 of file ezdate.php.

eZDate::year ( )

Returns the year element.

Definition at line 202 of file ezdate.php.

Referenced by attribute().


Member Data Documentation

eZDate::$Date

The current date as a timestamp without hour, minute or second values.

Definition at line 335 of file ezdate.php.

eZDate::$IsValid

Definition at line 336 of file ezdate.php.

eZDate::$Locale

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

Definition at line 333 of file ezdate.php.


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