|
eZ Publish
[trunk]
|
Locale aware date handler. More...
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. | |
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:
$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'
Definition at line 57 of file ezdate.php.
| 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 220 of file ezdate.php.
| eZDate::attribute | ( | $ | name | ) |
Definition at line 93 of file ezdate.php.
Definition at line 79 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 274 of file ezdate.php.
| eZDate::day | ( | ) |
Definition at line 290 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 63 of file ezdate.php.
Referenced by create().
| eZDate::hasAttribute | ( | $ | name | ) |
Definition at line 88 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 255 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 232 of file ezdate.php.
| eZDate::isValid | ( | ) |
Definition at line 113 of file ezdate.php.
Referenced by attribute().
| eZDate::locale | ( | ) |
Returns the current locale.
Definition at line 129 of file ezdate.php.
| eZDate::month | ( | ) |
| eZDate::setDay | ( | $ | day | ) |
Sets the day leaving the other elements untouched.
Definition at line 171 of file ezdate.php.
| eZDate::setLocale | ( | $ | locale | ) |
Sets the locale to $locale which is used in text output.
Definition at line 121 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 205 of file ezdate.php.
| eZDate::setMonth | ( | $ | month | ) |
Sets the month leaving the other elements untouched.
Definition at line 162 of file ezdate.php.
| eZDate::setTimeStamp | ( | $ | stamp | ) |
Definition at line 144 of file ezdate.php.
| eZDate::setYear | ( | $ | year | ) |
Sets the year leaving the other elements untouched.
Definition at line 153 of file ezdate.php.
Returns the timestamp value, this is the number of seconds since the epoch with hours, minutes and seconds set to 0.
Definition at line 139 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 300 of file ezdate.php.
| eZDate::year | ( | ) |
| eZDate::$Date |
The current date as a timestamp without hour, minute or second values.
Definition at line 313 of file ezdate.php.
| eZDate::$IsValid |
Definition at line 314 of file ezdate.php.
| eZDate::$Locale |
Locale object, is just a reference to minimize memory usage.
Definition at line 311 of file ezdate.php.